R CMD INSTALL and hence install.packages()
+gave an internal error installing a package called
+description from a tarball on a case-insensitive file system.
+
+
+
match(x, t) (and hence x %in% t) failed
+when x was of length one, and either character and x
+and t only differed in their Encoding or when
+x and t where complex with NAs or NaNs.
+(PR#16885.)
+
+
+
unloadNamespace(ns) also works again when ns is a
+‘namespace’, as from getNamespace().
+
+
+
rgamma(1,Inf) or rgamma(1, 0,0) no longer give
+NaN but the correct limit.
+
+
+
length(baseenv()) is correct now.
+
+
+
pretty(d, ..) for date-time d rarely failed
+when "halfmonth" time steps were tried (PR#16923) and
+on ‘inaccurate’ platforms such as 32-bit windows or
+a configuration with --disable-long-double; see comment
+#15 of PR#16761.
+
+
+
In text.default(x, y, labels), the rarely(?) used
+default for labels is now correct also for the case of a
+2-column matrix x and missing y.
+
+
+
as.factor(c(a = 1L)) preserves names() again
+as in R < 3.1.0.
+
+
+
strtrim(""[0], 0[0]) now works.
+
+
+
Use of Ctrl-C to terminate a reverse incremental
+search started by Ctrl-R in the readline-based Unix
+terminal interface is now supported for readline >= 6.3
+(Ctrl-G always worked). (PR#16603)
+
+
+
diff(<difftime>) now keeps the "units"
+attribute, as subtraction already did, PR#16940.
+
+
+
+
+
+
+
CHANGES IN R 3.3.0
+
+
+
+
SIGNIFICANT USER-VISIBLE CHANGES
+
+
+
+
nchar(x, *)'s argument keepNA governing how
+the result for NAs in x is determined, gets a new
+default keepNA = NA which returns NA where
+x is NA, except for type = "width" which still
+returns 2, the formatting / printing width of NA.
+
+
+
All builds have support for https: URLs in the
+default methods for download.file(), url() and code
+making use of them.
+
+
Unfortunately that cannot guarantee that any particular
+https: URL can be accessed. For example, server and client
+have to successfully negotiate a cryptographic protocol (TLS/SSL,
+...) and the server's identity has to be verifiable via
+the available certificates. Different access methods may allow
+different protocols or use private certificate bundles: we
+encountered a https: CRAN mirror which could be accessed by
+one browser but not by another nor by download.file() on
+the same Linux machine.
+
+
+
+
+
+
+
NEW FEATURES
+
+
+
+
The print method for methods() gains a
+byclass argument.
+
+
+
New functions validEnc() and validUTF8() to
+give access to the validity checks for inputs used by
+grep() and friends.
+
+
+
Experimental new functionality for S3 method checking, notably
+isS3method().
+
+
Also, the names of the R ‘language elements’ are exported
+as character vector tools::langElts.
+
+
+
str(x) now displays "Time-Series" also for
+matrix (multivariate) time-series, i.e. when is.ts(x) is true.
+
+
+
(Windows only) The GUI menu item to install local packages
+now accepts ‘*.tar.gz’ files as well as ‘*.zip’ files
+(but defaults to the latter).
+
+
+
New programmeR's utility function chkDots().
+
+
+
D() now signals an error when given invalid input,
+rather than silently returning NA. (Request of John Nash.)
+
+
+
formula objects are slightly more “first class”:
+e.g., formula() or new("formula", y ~ x) are now
+valid. Similarly, for "table", "ordered" and
+"summary.table". Packages defining S4 classes with the above
+S3/S4 classes as slots should be reinstalled.
+
+
+
+
+
New function strrep() for repeating the elements of a
+character vector.
+
+
+
rapply() preserves attributes on the list when
+how = "replace".
+
+
+
New S3 generic function sigma() with methods for
+extracting the estimated standard deviation aka “residual
+standard deviation” from a fitted model.
+
+
+
news() now displays R and package news files within
+the HTML help system if it is available. If no news file is found,
+a visible NULL is returned to the console.
+
+
+
as.raster(x) now also accepts raw arrays
+x assuming values in 0:255.
+
+
+
Subscripting of matrix/array objects of type
+"expression" is now supported.
+
+
+
type.convert("i") now returns a factor instead of a
+complex value with zero real part and missing imaginary part.
+
+
+
Graphics devices cairo_pdf() and cairo_ps()
+now allow non-default values of the cairographics ‘fallback
+resolution’ to be set.
+
+
This now defaults to 300 on all platforms: that is the default
+documented by cairographics, but apparently was not used by all
+system installations.
+
+
+
file() gains an explicit method argument
+rather than implicitly using
+getOption("url.method", "default").
+
+
+
Thanks to a patch from Tomas Kalibera, x[x != 0] is
+now typically faster than x[which(x != 0)] (in the case
+where x has no NAs, the two are equivalent).
+
+
+
read.table() now always uses the names for a named
+colClasses argument (previously names were only used when
+colClasses was too short). (In part, wish of PR#16478.)
+
+
+
(Windows only) download.file() with default
+method = "auto" and a ftps:// URL chooses
+"libcurl" if that is available.
+
+
+
The out-of-the box Bioconductor mirror has been changed to
+one using https://: use chooseBioCmirror() to choose
+a http:// mirror if required.
+
+
+
The data frame and formula methods for aggregate()
+gain a drop argument.
+
+
+
available.packages() gains a repos argument.
+
+
+
The undocumented switching of methods for url() on
+https: and ftps: URLs is confined to
+method = "default" (and documented).
+
+
+
smoothScatter() gains a ret.selection argument.
+
+
+
qr() no longer has a ... argument to pass
+additional arguments to methods.
+
+
+
[ has a method for class "table".
+
+
+
It is now possible (again) to replayPlot() a
+display list snapshot that was created by recordPlot()
+in a different R session.
+
+
It is still not a good idea to use snapshots as a persistent
+storage format for R plots, but it is now not completely silly to
+use a snapshot as a format for transferring an R plot between two
+R sessions.
+
+
The underlying changes mean that packages providing graphics
+devices (e.g., Cairo, RSvgDevice,
+cairoDevice, tikzDevice) will need to be
+reinstalled.
+
+
Code for restoring snapshots was contributed by Jeroen Ooms
+and JJ Allaire.
+
tools::undoc(dir = D) and codoc(dir = D) now
+also work when D is a directory whose normalizePath()ed
+version does not end in the package name, e.g. from a symlink.
+
+
+
abbreviate() has more support for multi-byte
+character sets – it no longer removes bytes within characters and
+knows about Latin vowels with accents. It is still only
+really suitable for (most) European languages, and still warns on
+non-ASCII input.
+
+
abbreviate(use.classes = FALSE) is now implemented, and
+that is more suitable for non-European languages.
+
+
+
match(x, table) is faster (sometimes by an order of
+magnitude) when x is of length one and incomparables
+is unchanged, thanks to Peter Haverty (PR#16491).
+
+
+
More consistent, partly not back-compatible behavior of
+NA and NaN coercion to complex numbers, operations
+less often resulting in complex NA (NA_complex_).
+
+
+
lengths() considers methods for length and
+[[ on x, so it should work automatically on any
+objects for which appropriate methods on those generics are
+defined.
+
+
+
The logic for selecting the default screen device on OS X
+has been simplified: it is now quartz() if that is
+available even if environment variable DISPLAY has been set
+by the user.
+
+
The choice can easily be overridden via environment
+variable R_INTERACTIVE_DEVICE.
+
+
+
On Unix-like platforms which support the getline C
+library function, system(*,intern = TRUE) no longer
+truncates (output) lines longer than 8192 characters, thanks to
+Karl Millar. (PR#16544)
+
regmatches(invert = NA) can now be used to extract
+both non-matched and matched substrings.
+
+
+
data.frame() gains argument fix.empty.names;
+as.data.frame.list() gets new cut.names,
+col.names and fix.empty.names.
+
+
+
plot(x ~ x, *) now warns that it is the same as
+plot(x ~ 1, *).
+
+
+
recordPlot() has new arguments load and
+attach to allow package names to be stored as part of a
+recorded plot. replayPlot() has new argument
+reloadPkgs to load/attach any package names that were
+stored as part of a recorded plot.
+
+
+
S4 dispatch works within calls to .Internal(). This
+means explicit S4 generics are no longer needed for
+unlist() and as.vector().
+
+
+
Only font family names starting with "Hershey" (and
+not "Her" as before) are given special treatment by the
+graphics engine.
+
+
+
S4 values are automatically coerced to vector (via
+as.vector) when subassigned into atomic vectors.
+
+
+
findInterval() gets a left.open option.
+
+
+
The version of LAPACK included in the sources has been
+updated to 3.6.0, including those ‘deprecated’ routines
+which were previously included. Ca 40 double-complex
+routines have been added at the request of a package maintainer.
+
+
As before, the details of what is included are in
+‘src/modules/lapack/README’ and this now gives information on
+earlier additions.
+
+
+
tapply() has been made considerably more efficient
+without changing functionality, thanks to proposals from Peter
+Haverty and Suharto Anggono. (PR#16640)
+
+
+
match.arg(arg) (the one-argument case) is faster; so
+is sort.int(). (PR#16640)
+
+
+
The format method for object_size objects now
+also accepts “binary” units such as "KiB" and e.g.,
+"Tb". (Partly from PR#16649.)
+
+
+
Profiling now records calls of the form foo::bar and
+some similar cases directly rather than as calls to
+<Anonymous>. Contributed by Winston Chang.
+
+
+
New string utilities startsWith(x, prefix) and
+endsWith(x, suffix). Also provide speedups for some
+grepl("^...",*) uses (related to proposals in PR#16490).
+
+
+
Reference class finalizers run at exit, as well as on
+garbage collection.
+
+
+
Avoid parallel dependency on stats for port
+choice and random number seeds. (PR#16668)
+
+
+
The radix sort algorithm and implementation from
+data.table (forder) replaces the previous radix
+(counting) sort and adds a new method for order().
+Contributed by Matt Dowle and Arun Srinivasan, the new algorithm
+supports logical, integer (even with large values), real, and
+character vectors. It outperforms all other methods, but there
+are some caveats (see ?sort).
+
+
+
The order() function gains a method argument
+for choosing between "shell" and "radix".
+
+
+
New function grouping() returns a permutation that
+stably rearranges data so that identical values are adjacent. The
+return value includes extra partitioning information on the
+groups. The implementation came included with the new radix sort.
+
+
+
rhyper(nn, m, n, k) no longer returns NA when
+one of the three parameters exceeds the maximal integer.
+
+
+
switch() now warns when no alternatives are provided.
+
+
+
parallel::detectCores() now has default logical
+ = TRUE on all platforms – as this was the default on Windows,
+this change only affects Sparc Solaris.
+
+
Option logical = FALSE is now supported on Linux and recent
+versions of OS X (for the latter, thanks to a suggestion of Kyaw
+Sint).
+
+
+
hist() for "Date" or "POSIXt" objects
+would sometimes give misleading labels on the breaks, as they
+were set to the day before the start of the period being
+displayed. The display format has been changed, and the shift of the
+start day has been made conditional on right = TRUE (the
+default). (PR#16679)
+
+
+
R now uses a new version of the logo (donated to the R
+Foundation by RStudio). It is defined in ‘.svg’ format, so
+will resize without unnecessary degradation when displayed on
+HTML pages—there is also a vector PDF version. Thanks to
+Dirk Eddelbuettel for producing the corresponding X11 icon.
+
+
+
New function .traceback() returns the stack trace
+which traceback() prints.
+
+
+
lengths() dispatches internally.
+
+
+
dotchart() gains a pt.cex argument to control
+the size of points separately from the size of plot labels.
+Thanks to Michael Friendly and Milan Bouchet-Valat for ideas
+and patches.
+
+
+
as.roman(ch) now correctly deals with more diverse
+character vectors ch; also arithmetic with the resulting
+roman numbers works in more cases. (PR#16779)
+
+
+
prcomp() gains a new option rank. allowing to
+directly aim for less than min(n,p) PC's. The
+summary() and its print() method have been amended,
+notably for this case.
+
+
+
gzcon() gains a new option text, which marks
+the connection as text-oriented (so e.g. pushBack()
+works). It is still always opened in binary mode.
+
+
+
The import() namespace directive now accepts an
+argument except which names symbols to exclude from the
+imports. The except expression should evaluate to a
+character vector (after substituting symbols for strings). See
+Writing R Extensions.
+
+
+
New convenience function Rcmd() in package
+tools for invoking R CMD tools from within R.
+
+
+
New functions makevars_user() and
+makevars_site() in package tools to determine the
+location of the user and site specific ‘Makevars’ files for
+customizing package compilation.
+
+
+
+
+
+
+
UTILITIES
+
+
+
+
R CMD check has a new option
+--ignore-vignettes for use with non-Sweave vignettes
+whose VignetteBuilder package is not available.
+
+
+
R CMD check now by default checks code usage
+(viacodetools) with only the base package
+attached. Functions from default packages other than base
+which are used in the package code but not imported are reported
+as undefined globals, with a suggested addition to the
+NAMESPACE file.
+
+
+
R CMD check --as-cran now also checks DOIs in
+package ‘CITATION’ and Rd files.
+
+
+
R CMD Rdconv and R CMD Rd2pdf each have
+a new option --RdMacros=pkglist which allows Rd macros
+to be specified before processing.
+
+
+
+
+
+
+
DEPRECATED AND DEFUNCT
+
+
+
+
The previously included versions of zlib,
+bzip2, xz and PCRE have been removed, so suitable
+external (usually system) versions are required (see the
+‘R Installation and Administration’ manual).
+
+
+
The unexported and undocumented Windows-only devices
+cairo_bmp(), cairo_png() and cairo_tiff()
+have been removed. (These devices should be used as
+e.g. bmp(type = "cairo").)
+
+
+
(Windows only) Function setInternet2() has no effect
+and will be removed in due course. The choice between methods
+"internal" and "wininet" is now made by the
+method arguments of url() and download.file()
+and their defaults can be set via options. The
+out-of-the-box default remains "wininet" (as it has been
+since R 3.2.2).
+
+
+
[<- with an S4 value into a list currently embeds the
+S4 object into its own list such that the end result is roughly
+equivalent to using [[<-. That behavior is deprecated. In
+the future, the S4 value will be coerced to a list with
+as.list().
+
+
+
Package tools' functions
+package.dependencies(), pkgDepends(), etc are
+deprecated now, mostly in favor of package_dependencies()
+which is both more flexible and efficient.
+
+
+
+
+
+
+
INSTALLATION and INCLUDED SOFTWARE
+
+
+
+
Support for very old versions of valgrind
+(e.g., 3.3.0) has been removed.
+
+
+
The included libtool script (generated by
+configure) has been updated to version 2.4.6 (from 2.2.6a).
+
+
+
libcurl version 7.28.0 or later with support for the
+https protocol is required for installation (except on
+Windows).
+
+
+
BSD networking is now required (except on Windows) and so
+capabilities("http/ftp") is always true.
+
+
+
configure uses pkg-config for PNG, TIFF
+and JPEG where this is available. This should work better with
+multiple installs and with those using static libraries.
+
+
+
The minimum supported version of OS X is 10.6 (‘Snow
+Leopard’): even that has been unsupported by Apple since 2012.
+
+
+
The configure default on OS X is
+--disable-R-framework: enable this if you intend to
+install under ‘/Library/Frameworks’ and use with R.app.
+
+
+
The minimum preferred version of PCRE has since R 3.0.0
+been 8.32 (released in Nov 2012). Versions 8.10 to 8.31 are now
+deprecated (with warnings from configure), but will
+still be accepted until R 3.4.0.
+
+
+
configure looks for C functions __cospi,
+__sinpi and __tanpi and uses these if cospi
+etc are not found. (OS X is the main instance.)
+
+
+
(Windows) R is now built using gcc
+4.9.3. This build will require recompilation of at least those packages
+that include C++ code, and possibly others. A build of R-devel using
+the older toolchain will be temporarily available for comparison
+purposes.
+
+
During the transition, the environment variable
+R_COMPILED_BY has been defined to indicate which toolchain
+was used to compile R (and hence, which should be used to compile
+code in packages). The COMPILED_BY variable described below
+will be a permanent replacement for this.
+
+
+
(Windows) A make and R CMD config variable
+named COMPILED_BY has been added. This indicates
+which toolchain was used to compile R (and hence, which should be
+used to compile code in packages).
+
+
+
+
+
+
+
PACKAGE INSTALLATION
+
+
+
+
The make macro AWK which used to be made
+available to files such as ‘src/Makefile’ is no longer set.
+
+
+
+
+
+
+
C-LEVEL FACILITIES
+
+
+
+
The API call logspace_sum introduced in R 3.2.0 is
+now remapped as an entry point to Rf_logspace_sum, and its
+first argument has gained a const qualifier. (PR#16470)
+
+
Code using it will need to be reinstalled.
+
+
Similarly, entry point log1pexp also defined in
+‘Rmath.h’ is remapped there to Rf_log1pexp
+
+
+
R_GE_version has been increased to 11.
+
+
+
New API call R_orderVector1, a faster
+one-argument version of R_orderVector.
+
+
+
When R headers such as ‘R.h’ and ‘Rmath.h’ are
+called from C++ code in packages they include the C++ versions of
+system headers such as ‘<cmath>’ rather than the legacy
+headers such as ‘<math.h>’. (Headers ‘Rinternals.h’ and
+‘Rinterface.h’ already did, and inclusion of system headers
+can still be circumvented by defining NO_C_HEADERS,
+including as from this version for those two headers.)
+
+
The manual has long said that R headers should not be
+included within an extern "C" block, and almost all the
+packages affected by this change were doing so.
+
+
+
Including header ‘S.h’ from C++ code would fail on some
+platforms, and so gives a compilation error on all.
+
+
+
The deprecated header ‘Rdefines.h’ is now compatible
+with defining R_NO_REMAP.
+
+
+
The connections API now includes a function
+R_GetConnection() which allows packages implementing
+connections to convert R connection objects to
+Rconnection handles used in the API. Code which previously
+used the low-level R-internal getConnection() entry point
+should switch to the official API.
+
+
+
+
+
+
+
BUG FIXES
+
+
+
+
C-level asChar(x) is fixed for when x is not a
+vector, and it returns "TRUE"/"FALSE" instead of
+"T"/"F" for logical vectors.
+
+
+
The first arguments of .colSums() etc (with an
+initial dot) are now named x rather than X (matching
+colSums()): thus error messages are corrected.
+
+
+
A coef() method for class "maov" has been
+added to allow vcov() to work with multivariate
+results. (PR#16380)
+
+
+
method = "libcurl" connections signal errors rather
+than retrieving HTTP error pages (where the ISP reports the
+error).
+
+
+
xpdrows.data.frame() was not checking for unique
+row names; in particular, this affected assignment to non-existing
+rows via numerical indexing. (PR#16570)
+
+
+
tail.matrix() did not work for zero rows matrices,
+and could produce row “labels” such as "[1e+05,]".
+
+
+
Data frames with a column named "stringsAsFactors"
+now format and print correctly. (PR#16580)
+
+
+
cor() is now guaranteed to return a value with
+absolute value less than or equal to 1. (PR#16638)
+
+
+
Array subsetting now keeps names(dim(.)).
+
+
+
Blocking socket connection selection recovers more
+gracefully on signal interrupts.
+
+
+
The data.frame method of rbind() construction
+row.names works better in borderline integer cases, but
+may change the names assigned. (PR#16666)
+
tar() now works with the default files = NULL.
+(PR#16716)
+
+
+
Jumps to outer contexts, for example in error recovery, now
+make intermediate jumps to contexts where on.exit() actions
+are established instead of trying to run all on.exit()
+actions before jumping to the final target. This unwinds the stack
+gradually, releases resources held on the stack, and significantly
+reduces the chance of a segfault when running out of C stack
+space. Error handlers established using
+withCallingHandlers() and options("error")
+specifications are ignored when handling a C stack overflow error
+as attempting one of these would trigger a cascade of C stack
+overflow errors. (These changes resolve PR#16753.)
+
+
+
The spacing could be wrong when printing a complex array.
+(Report and patch by Lukas Stadler.)
+
+
+
pretty(d, n, min.n, *) for date-time objects d
+works again in border cases with large min.n, returns a
+labels attribute also for small-range dates and in such cases
+its returned length is closer to the desired n. (PR#16761)
+Additionally, it finally does cover the range of d, as it
+always claimed.
+
+
+
tsp(x) <- NULL did not handle correctly objects
+inheriting from both "ts" and "mts". (PR#16769)
+
+
+
install.packages() could give false errors when
+options("pkgType") was "binary". (Reported by
+Jose Claudio Faria.)
+
+
+
A bug fix in R 3.0.2 fixed problems with locator()
+in X11, but introduced problems in Windows. Now both should be
+fixed. (PR#15700)
+
+
+
download.file() with method = "wininet"
+incorrectly warned of download file length difference when
+reported length was unknown. (PR#16805)
+
+
+
diag(NULL, 1) crashed because of missed type
+checking. (PR#16853)
+
+
+
+
+
+
+
CHANGES IN R 3.2.4 patched
+
+
+
+
BUG FIXES
+
+
+
+
format.POSIXlt() behaved incorrectly in R 3.2.4.
+E.g. the output of
+format(as.POSIXlt(paste0(1940:2000,"-01-01"), tz = "CET"),
+ usetz = TRUE) ended in two "CEST" time formats.
+
+
+
+
+
+
+
CHANGES IN R 3.2.4
+
+
+
+
NEW FEATURES
+
+
+
+
install.packages() and related functions now give a
+more informative warning when an attempt is made to install a base
+package.
+
+
+
summary(x) now prints with less rounding when
+x contains infinite values. (Request of PR#16620.)
+
+
+
provideDimnames() gets an optional unique argument.
+
+
+
shQuote() gains type = "cmd2" for quoting
+in cmd.exe in Windows. (Response to PR#16636.)
+
+
+
The data.frame method of rbind() gains an
+optional argument stringsAsFactors (instead of only
+depending on getOption("stringsAsFactors")).
+
+
+
smooth(x, *) now also works for long vectors.
+
+
+
tools::texi2dvi() has a workaround for problems with
+the texi2dvi script supplied by texinfo 6.1.
+
+
It extracts more error messages from the LaTeX logs when in
+emulation mode.
+
+
+
+
+
+
+
UTILITIES
+
+
+
+
R CMD check will leave a log file
+‘build_vignettes.log’ from the re-building of vignettes in
+the ‘.Rcheck’ directory if there is a problem, and always if
+environment variable _R_CHECK_ALWAYS_LOG_VIGNETTE_OUTPUT_ is
+set to a true value.
+
+
+
+
+
+
+
DEPRECATED AND DEFUNCT
+
+
+
+
Use of SUPPORT_OPENMP from header ‘Rconfig.h’ is
+deprecated in favour of the standard OpenMP define _OPENMP.
+
+
(This has been the recommendation in the manual for a while now.)
+
+
+
The make macro AWK which is long unused by
+R itself but recorded in file ‘etc/Makeconf’ is deprecated
+and will be removed in R 3.3.0.
+
+
+
The C header file ‘S.h’ is no longer documented: its
+use should be replaced by ‘R.h’.
+
+
+
+
+
+
+
BUG FIXES
+
+
+
+
kmeans(x, centers = <1-row>) now works. (PR#16623)
+
+
+
Vectorize() now checks for clashes in argument names.
+(PR#16577)
+
+
+
file.copy(overwrite = FALSE) would signal a successful
+copy when none had taken place. (PR#16576)
+
+
+
ngettext() now uses the same default domain as
+gettext(). (PR#14605)
+
+
+
array(.., dimnames = *) now warns about
+non-list dimnames and, from R 3.3.0, will signal the same
+error for invalid dimnames as matrix() has always done.
+
+
+
addmargins() now adds dimnames for the extended
+margins in all cases, as always documented.
+
+
+
heatmap() evaluated its add.expr argument
+in the wrong environment. (PR#16583)
+
+
+
require() etc now give the correct entry of
+lib.loc in the warning about an old version of a package
+masking a newer required one.
+
+
+
The internal deparser did not add parentheses when
+necessary, e.g. before [] or [[]]. (Reported by
+Lukas Stadler; additional fixes included as well).
+
+
+
as.data.frame.vector(*, row.names=*) no longer
+produces ‘corrupted’ data frames from row names of incorrect
+length, but rather warns about them. This will become an error.
+
+
+
url connections with method = "libcurl" are
+destroyed properly. (PR#16681)
+
+
+
withCallingHandler() now (again) handles warnings
+even during S4 generic's argument evaluation. (PR#16111)
+
+
+
deparse(..., control = "quoteExpressions")
+incorrectly quoted empty expressions. (PR#16686)
+
saveRDS(*, compress = "gzip") now works as
+documented. (PR#16653)
+
+
+
(Windows only) The Rgui front end did not
+always initialize the console properly, and could cause
+R to crash. (PR#16698)
+
+
+
dummy.coef.lm() now works in more cases, thanks to a
+proposal by Werner Stahel (PR#16665). In addition, it now works
+for multivariate linear models ("mlm", manova)
+thanks to a proposal by Daniel Wollschlaeger.
+
+
+
The as.hclust() method for "dendrogram"s
+failed often when there were ties in the heights.
+
+
+
reorder() and midcache.dendrogram() now are
+non-recursive and hence applicable to somewhat deeply nested
+dendrograms, thanks to a proposal by Suharto Anggono in PR#16424.
+
+
+
cor.test() now calculates very small p values
+more accurately (affecting the result only in extreme not
+statistically relevant cases). (PR#16704)
+
+
+
smooth(*, do.ends=TRUE) did not always work correctly
+in R versions between 3.0.0 and 3.2.3.
+
+
+
pretty(D) for date-time objects D now also
+works well if range(D) is (much) smaller than a second. In
+the case of only one unique value in D, the pretty range
+now is more symmetric around that value than previously.
+
+Similarly, pretty(dt) no longer returns a length 5 vector
+with duplicated entries for Date objects dt which
+span only a few days.
+
+
+
The figures in help pages such as ?points were
+accidentally damaged, and did not appear in R 3.2.3.
+(PR#16708)
+
+
+
available.packages() sometimes deleted the wrong
+file when cleaning up temporary files. (PR#16712)
+
+
+
The X11() device sometimes froze on Red Hat
+Enterprise Linux 6. It now waits for MapNotify events
+instead of Expose events, thanks to Siteshwar
+Vashisht. (PR#16497)
+
+
+
[dpqr]nbinom(*, size=Inf, mu=.) now works as limit
+case, for ‘dpq’ as the Poisson. (PR#16727)
+pnbinom() no longer loops infinitely in border cases.
+
+
+
approxfun(*, method="constant") and hence ecdf()
+which calls the former now correctly “predict” NaN
+values as NaN.
+
+
+
summary.data.frame() now displays NAs in
+Date columns in all cases. (PR#16709)
+
+
+
+
+
+
+
CHANGES IN R 3.2.3
@@ -259,7 +1304,7 @@
-
CHANGES IN R 3.2.2
+
CHANGES IN R 3.2.2
@@ -476,7 +1521,7 @@
-
CHANGES IN R 3.2.1
+
CHANGES IN R 3.2.1
@@ -638,7 +1683,7 @@
-
CHANGES IN R 3.2.0
+
CHANGES IN R 3.2.0
@@ -1411,7 +2456,7 @@
-
CHANGES IN R 3.1.3
+
CHANGES IN R 3.1.3
@@ -1690,7 +2735,7 @@
-
CHANGES IN R 3.1.2
+
CHANGES IN R 3.1.2
@@ -1946,7 +2991,7 @@
sub() and gsub() did not handle regular
expressions like "\s{2,}" properly if the text
-contained NA or non-ascii elements in a UTF-8
+contained NA or non-ASCII elements in a UTF-8
locale. Part of this was due to a bug in the TRE library.
(PR#16009)
@@ -1991,7 +3036,7 @@
-
CHANGES IN R 3.1.1
+
CHANGES IN R 3.1.1
@@ -2317,7 +3362,7 @@
-
CHANGES IN R 3.1.0
+
CHANGES IN R 3.1.0
@@ -3106,7 +4151,7 @@
-
CHANGES IN R 3.0.3
+
CHANGES IN R 3.0.3
@@ -3482,7 +4527,7 @@
-
CHANGES IN R 3.0.2
+
CHANGES IN R 3.0.2
@@ -4154,7 +5199,7 @@
-
CHANGES IN R 3.0.1
+
CHANGES IN R 3.0.1
@@ -4385,7 +5430,7 @@
-
CHANGES IN R 3.0.0
+
CHANGES IN R 3.0.0
diff -Nru r-base-3.2.3/doc/html/Notes r-base-3.3.1/doc/html/Notes
--- r-base-3.2.3/doc/html/Notes 1970-01-01 00:00:00.000000000 +0000
+++ r-base-3.3.1/doc/html/Notes 2016-03-16 23:04:41.000000000 +0000
@@ -0,0 +1,18 @@
+The 'new' R logo was added in early 2016.
+
+Rlogo.svg is the master copy, and is copyighted. See its text comment
+and doc/COPYRIGHTS for its licence.
+
+Rlogo.pdf is a conversion to scalable PDF, done by rsvg-convert.
+
+logo.jpg is an update to the new logo of a 100x76 file: it is no
+longer used within R (but is used by some packages).
+
+favicon.ico contains 16x16 and 32x32 PNG files (with transparent
+backgrounds and anti-aliasing) converted from Rlogo.svg in Photoshop,
+and bundled by
+
+icotool -c -o favicon.ico icon_16x16.png icon_32x32.png
+
+on Linux. These are 32-bit full-colour PNGs (and smaller than the
+previous version with a palette).
diff -Nru r-base-3.2.3/doc/html/packages-head-utf8.html r-base-3.3.1/doc/html/packages-head-utf8.html
--- r-base-3.2.3/doc/html/packages-head-utf8.html 2015-03-18 23:04:14.000000000 +0000
+++ r-base-3.3.1/doc/html/packages-head-utf8.html 2016-03-16 23:04:42.000000000 +0000
@@ -3,7 +3,7 @@
-
diff -Nru r-base-3.2.3/doc/manual/Makefile.in r-base-3.3.1/doc/manual/Makefile.in
--- r-base-3.2.3/doc/manual/Makefile.in 2015-08-25 22:19:14.000000000 +0000
+++ r-base-3.3.1/doc/manual/Makefile.in 2016-03-16 23:04:43.000000000 +0000
@@ -39,10 +39,12 @@
TEXI2HTML = $(MAKEINFO) $(MAKEINFO_HTML_OPTS)
TEXI2TEXT = $(MAKEINFO) $(MAKEINFO_TEXT_OPTS)
## some broken versions of texi2dvi need C collation.
-TEXI2DVI0 = @TEXI2DVI@
TEXI2DVI = LC_COLLATE=C @TEXI2DVI@ --texinfo="@set UseExternalXrefs "
TEXI2PDF = $(TEXI2DVI) --pdf
PDFLATEX = @PDFLATEX@
+## These are used to check if there is a non-empty path to the
+## texi2dvi script, and as it uses pdftex if that was detected.
+TEXI2DVI0 = @TEXI2DVI@
PDFTEX = @PDFTEX@
BATCHPDFLATEX = $(PDFLATEX) -interaction=nonstopmode
@@ -101,14 +103,14 @@
$(MAKEINFO) --enable-encoding -D UseExternalXrefs -I$(srcdir) $<
.texi.pdf:
- @if test -z "$(PDFTEX)"; then \
- $(ECHO) "ERROR: 'pdftex' needed but missing on your system."; \
- exit 1; \
- fi
@if test -z "$(TEXI2DVI0)"; then \
$(ECHO) "ERROR: 'texi2dvi' needed but missing on your system."; \
exit 1; \
fi
+ @if test -z "$(PDFTEX)"; then \
+ $(ECHO) "ERROR: 'pdftex' needed but missing on your system."; \
+ exit 1; \
+ fi
TEXINPUTS="$(srcdir):$$TEXINPUTS" $(TEXI2PDF) $<
## It seems ebook-convert converts the directory,
@@ -391,8 +393,8 @@
*-pkg.tex refman.i?? refman.tex fullrefman.i?? fullrefman.tex \
version.tex version.texi
-@rm -f stamp-*
+ -@rm -f *.epub *.mobi rw-FAQ rw-FAQ.html
distclean: clean
- -@rm -f *.epub *.mobi rw-FAQ rw-FAQ.html rw-FAQ.pdf
-@rm -f Makefile
maintainer-clean: distclean
@@ -467,7 +469,6 @@
rw-FAQ.pdf: rw-FAQ.texi $(top_srcdir)/VERSION
@$(SED) $(SEDVER) $< > tmp.texi
- @$(TEXI2DVI) --pdf tmp.texi
- @$(TEXI2DVI) --pdf tmp.texi
+ @$(TEXI2PDF) tmp.texi
@mv tmp.pdf $@
@rm tmp.*
diff -Nru r-base-3.2.3/doc/manual/R-admin.texi r-base-3.3.1/doc/manual/R-admin.texi
--- r-base-3.2.3/doc/manual/R-admin.texi 2015-12-08 23:15:09.000000000 +0000
+++ r-base-3.3.1/doc/manual/R-admin.texi 2016-06-14 22:15:06.000000000 +0000
@@ -848,8 +848,8 @@
Sub-architectures are also used on Windows, but by selecting executables
within the appropriate @file{bin} directory,
@file{@var{R_HOME}/bin/i386} or @file{@var{R_HOME}/bin/x64}. For
-backwards compatibility with @R{} < 2.12.0, there are executables
-@file{@var{R_HOME}/bin/R.exe} or @file{@var{R_HOME}/bin/Rscript.exe}:
+backwards compatibility there are executables
+@file{@var{R_HOME}/bin/R.exe} and @file{@var{R_HOME}/bin/Rscript.exe}:
these will run an executable from one of the subdirectories, which one
being taken first from the
@enindex R_ARCH
@@ -866,13 +866,13 @@
@node Multilib, , Sub-architectures, Sub-architectures
@subsection Multilib
-On Linux@footnote{mainly on RedHat and Fedora, whose layout is described
-here.}, there is an alternative mechanism for mixing 32-bit and 64-bit
-libraries known as @emph{multilib}. If a Linux distribution supports
-multilib, then parallel builds of @R{} may be installed in the
-sub-directories @file{lib} (32-bit) and @file{lib64} (64-bit). The
-build to be run may then be selected using the @command{setarch}
-command. For example, a 32-bit build may be run by
+For some Linux distributions@footnote{mainly on RedHat and Fedora, whose
+layout is described here.}, there is an alternative mechanism for mixing
+32-bit and 64-bit libraries known as @emph{multilib}. If the Linux
+distribution supports multilib, then parallel builds of @R{} may be
+installed in the sub-directories @file{lib} (32-bit) and @file{lib64}
+(64-bit). The build to be run may then be selected using the
+@command{setarch} command. For example, a 32-bit build may be run by
@example
setarch i686 R
@@ -889,8 +889,8 @@
version of @R{} installed (since this tells the package installation
code the architecture needed).
-At present there is a potential problem with packages using Java, as
-the post-install for a @cputype{i686} RPM on @cputype{x86_64} Linux
+There is a potential problem with packages using Java, as the
+post-install for a @cputype{i686} RPM on @cputype{x86_64} Linux
reconfigures Java and will find the @cputype{x86_64} Java. If you know
where a 32-bit Java is installed you may be able to run (as root)
@@ -919,10 +919,9 @@
One that may be useful when working on @R{} itself is the option
@option{--disable-byte-compiled-packages}, which ensures that the base
-and recommended packages are lazyloaded but not byte-compiled.
-(Alternatively the (make or environment) variable
-@env{R_NO_BASE_COMPILE} can be set to a non-empty value for the duration
-of the build.)
+and recommended packages are not byte-compiled. (Alternatively the
+(make or environment) variable @env{R_NO_BASE_COMPILE} can be set to a
+non-empty value for the duration of the build.)
Option @option{--with-internal-tzcode} makes use of @R{}'s own code and
copy of the Olson database for managing timezones. This will be
@@ -945,9 +944,9 @@
By default @command{configure} searches for suitable
options@footnote{for example, @option{-fopenmp}, @option{-xopenmp} or
-@option{-qopenmp}. This includes for 2015 versions of @command{clang}
-and the Intel C compiler.} for OpenMP support for the C, C++98, FORTRAN
-77 and Fortran compilers.
+@option{-qopenmp}. This includes for @command{clang} 3.7.x and the
+Intel C compiler.} for OpenMP support for the C, C++98, FORTRAN 77 and
+Fortran compilers.
Only the C result is currently used for @R{} itself, and only if
@code{MAIN_LD}/@code{DYLIB_LD} were not specified. This can be
@@ -970,15 +969,16 @@
@noindent
Setting to an empty value will disable OpenMP for that compiler (and
configuring with @option{--disable-openmp} will disable all detection of
-OpenMP). Note that the @command{configure} detection test is to compile
-and link a standalone OpenMP program, which is not the same as compiling
-a shared object and loading it into the C program of @R{}'s executable.
-Note that overridden values are not tested.
+OpenMP). The @command{configure} detection test is to compile and link
+a standalone OpenMP program, which is not the same as compiling a shared
+object and loading it into the C program of @R{}'s executable. Note
+that overridden values are not tested.
@node Testing a Unix-alike Installation, , Other Options, Installing R under Unix-alikes
@section Testing an Installation
-Full testing is possible only if the test files have been installed with
+Full post-installation testing is possible only if the test files have
+been installed with
@example
make install-tests
@@ -1046,11 +1046,6 @@
testInstalledBasic("internet")
@end example
-@noindent
-(On Windows that runs the tests using whichever of internal or WinInet
-internet functions has been selected for that session: to test both run
-this twice selecting both options using @code{setInternet2}.)
-
These tests work best if @command{diff} (in @file{Rtools*.exe} for
Windows users) is in the path.
@@ -1080,7 +1075,9 @@
@cputype{ix86} and @cputype{x86_64} @acronym{CPU}s.
Your file system must allow long file names (as is likely except
-perhaps for some network-mounted systems).
+perhaps for some network-mounted systems). If it doesn't also support
+conversion to short name equivalents (a.k.a. DOS 8.3 names), then R
+@emph{must} be installed in a path that does not contain spaces.
Installation is @emph{via} the installer
@file{@value{RWVERSION}-win.exe}. Just double-click on the icon and
@@ -1207,15 +1204,16 @@
The binary distributions of external software. Download
@example
-https://www.stats.ox.ac.uk/pub/Rtools/goodies/multilib/local320.zip
+https://www.stats.ox.ac.uk/pub/Rtools/goodies/multilib/local323.zip
@end example
@noindent
-create an empty directory, say @file{c:/R/extsoft}, and unpack it in
+(or a more recent version if appropriate), create an empty directory,
+say @file{c:/R/extsoft}, and unpack it in
that directory by e.g.@:
@example
-unzip local320.zip -d c:/R/extsoft
+unzip local323.zip -d c:/R/extsoft
@end example
@item
@@ -1238,13 +1236,13 @@
@end itemize
The following additional item is normally installed by
-@file{Rtools31.exe}. If instead you choose to do a completely manual
+@file{Rtools*.exe}. If instead you choose to do a completely manual
build you will also need
@itemize
@item
-The Tcl/Tk support files are contained in @file{Rtools31.exe} and
+The Tcl/Tk support files are contained in @file{Rtools*.exe} and
available as @file{.zip} files from
@uref{https://www.stats.ox.ac.uk/pub/Rtools}. Please make sure you
install the right version: there is a 32-bit version and a 64-bit
@@ -1650,19 +1648,10 @@
The front page of a @acronym{CRAN} site has a link `Download R for OS
X'. Click on that, then download the file @file{R-@value{VERSIONno}.pkg}
and install it. This runs on OS X 10.9 and later (Mavericks, Yosemite,
-El Capitan@footnote{for @R{} 3.2.1 and earlier, the installer will
-attempt unsuccessfully to install @command{R} and @command{Rscript} in
-@file{/usr/bin}.}, @dots{}).
-
-There may be@footnote{There was for R 3.2.1 but not for R 3.2.2.} a
-separate installer package @file{R-@value{VERSIONno}-snowleopard.pkg},
-which runs on OS X 10.6 and later (Snow Leopard, Lion, Mountain Lion,
-Mavericks, Yosemite, @dots{}); it is a 64-bit (@cputype{x86_64}) build
-which should run on all Macs from mid-2008 on.
+El Capitan, @dots{}).
Installers for R-patched and R-devel are usually available from
-@uref{https://r.research.att.com}, including a
-@file{R-3-2-branch-snowleopard-signed.pkg} build for R-patched.
+@uref{https://r.research.att.com}.
For some older versions of the OS you can in principle (it is little
tested) install @R{} from the sources.
@@ -1720,15 +1709,16 @@
can be viewed from @Rapp{}'s `Help' menu.
-You can run command-line @R{} from a Terminal@footnote{The installer as
-from @R{} 3.2.2 puts links to @command{R} and @command{Rscript} in
-@file{/usr/bin} (Mavericks, Yosemite) or @file{/usr/local/bin} (El
-Capitan and later). If these are missing, you can run directly the
-versions in @file{/Library/Frameworks/R.framework/Resources/}.} so these
-can be typed as commands like any other Unix-alike: see the next chapter
-of this manual. There are some small differences which may surprise
-users of @R{} on other platforms, notably the default location of the
-personal library directory (under @file{~/Library/R},
+You can run command-line @R{} and @command{Rscript} from a
+Terminal@footnote{The installer as puts links to @command{R} and
+@command{Rscript} in @file{/usr/bin} (Mavericks, Yosemite) or
+@file{/usr/local/bin} (El Capitan and later). If these are missing, you
+can run directly the versions in
+@file{/Library/Frameworks/R.framework/Resources/}.} so these can be
+typed as commands like any other Unix-alike: see the next chapter of
+this manual. There are some small differences which may surprise users
+of @R{} on other platforms, notably the default location of the personal
+library directory (under @file{~/Library/R},
e.g. @file{~/Library/R/3.3/library}), and that warnings, messages and
other output to @file{stderr} are highlighted in bold.
@@ -1737,11 +1727,10 @@
preferences are stored, so if it fails when launched for the very first
time, try it again (the first attempt will store some preferences).
-Users of @Rapp{} under Mavericks and later need to be aware of the `App
-Nap' feature
+Users of @Rapp{} need to be aware of the `App Nap' feature
(@uref{https://developer.apple.com/library/mac/releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_9.html})
which can cause @R{} tasks to appear to run very slowly when not
-producing output in the console. Here are three ways to avoid it:
+producing output in the console. Here are ways to avoid it:
@itemize
@item
@@ -1749,12 +1738,6 @@
indicator at the top right corner is visible).
@item
-Call @samp{Get Info} on the application (e.g.@: from Finder). This may
-have two tick boxes in the `General' panel: click the one named `Prevent
-App Nap' if it is not already ticked. (This only available for builds
-made prior to Mavericks.)
-
-@item
In a Terminal, run
@example
defaults write org.R-project.R NSAppSleepDisabled -bool YES
@@ -1782,7 +1765,7 @@
@file{/usr/local/bin} should also be removed.
If you want to get rid of @R{} more completely using a Terminal, simply
-run (use @file{/usr/local/bin} on El Capitan):
+run (use @file{/usr/local/bin} as from El Capitan):
@example
sudo rm -rf /Library/Frameworks/R.framework /Applications/R.app \
@@ -1810,6 +1793,18 @@
@noindent
These are paths relative to @file{/}, the root of the file system.
+@c Maybe too dangerous for naive users.
+@c file.remove removes empty directories on Unix.
+@c The second could be uninstalled by an @R{} script like
+
+@c @example
+@c lis <- system2("pkgutil", "--files org.r-project.x86_64.texinfo", stdout = TRUE)
+@c setwd("/")
+@c file.remove(rev(lis))
+@c @end example
+
+@c @noindent
+@c run as the owner of @file{/usr/local}.
@node Multiple versions, , Uninstalling under OS X, Installing R under OS X
@section Multiple versions
@@ -1824,7 +1819,7 @@
A version of @R{} can be run directly from the command-line as e.g.@:
@example
-/Library/Frameworks/R.framework/Versions/3.2/Resources/bin/R
+/Library/Frameworks/R.framework/Versions/3.3/Resources/bin/R
@end example
@noindent
@@ -1988,6 +1983,7 @@
* Customizing package compilation::
* Multiple sub-architectures::
* Byte-compilation::
+* External software::
@end menu
@@ -2065,7 +2061,7 @@
@code{install.packages} can look in several repositories, specified as a
character vector by the argument @code{repos}: these can include a
-@acronym{CRAN} mirror, Bioconductor, Omegahat, R-forge, rforge.net,
+@acronym{CRAN} mirror, Bioconductor, R-forge, rforge.net,
local archives, local files, @dots{}). Function
@code{setRepositories()} can select amongst those repositories that the
@R{} installation is aware of.
@@ -2109,14 +2105,16 @@
the path: it should work to have both 32- and 64-bit Gtk+ @file{bin}
directories in the path on a 64-bit version of @R{}.
-@command{R CMD INSTALL} works in Windows to install source packages. No
-additional tools are needed if the package does not contain compiled
-code, and @code{install.packages(type="source")} will work for such
-packages (and for those with compiled code if the tools (see @ref{The
-Windows toolset}) are in the path). We have seen occasional permission
-problems after unpacking source packages on some systems: these have
-been circumvented by setting the environment variable
-@env{R_INSTALL_TAR} to @samp{tar.exe}.
+@command{R CMD INSTALL} works in Windows to install source packages.
+No additional tools are needed if the package does not contain
+compiled code, and @code{install.packages(type="source")} will work
+for such packages (and for those with compiled code if the tools (see
+@ref{The Windows toolset}) are on the path, and the variables
+@code{BINPREF} and @code{BINPREF64} are set properly; see the
+discussion below). We have seen occasional permission problems after
+unpacking source packages on some systems: these have been
+circumvented by setting the environment variable @env{R_INSTALL_TAR}
+to @samp{tar.exe}.
@enindex R_INSTALL_TAR
If you have only a source package that is known to work with current
@@ -2148,16 +2146,24 @@
@enindex LOCAL_SOFT
-There is provision to make use of a system-wide library of installed
-external software by setting the @command{make} variable
-@code{LOCAL_SOFT}, to give an equivalent of @file{/usr/local} on a
-Unix-alike. This can be set in @file{src/gnuwin/MkRules.local} when
-@R{} is built from sources (see the comments in
-@file{src/gnuwin/MkRules.dist}), or in file@footnote{or by adding it in
-a file such as @file{etc/i386/Makevars.site}, which does not exist by
-default.} @file{etc/i386/Makeconf} or @file{etc/x64/Makeconf} for an
-installed version of @R{}. The version used by @acronym{CRAN} can be
-installed as described in @ref{Building from source}.
+@enindex BINPREF
+@enindex BINPREF64
+Packages with compiled code may need to have paths to the compilers
+set explicitly, and there is provision to make use of a system-wide
+library of installed external software. The compiler paths are set
+using the @command{make} variables @code{BINPREF} (and in some cases
+@code{BINPREF64}). The library location is set using @command{make}
+variable @code{LOCAL_SOFT}, to give an equivalent of @file{/usr/local}
+on a Unix-alike. All of these can be set in
+@file{src/gnuwin32/MkRules.local} when @R{} is built from sources (see
+the comments in @file{src/gnuwin32/MkRules.dist}), or in
+file@footnote{or by adding it in a file such as
+@file{etc/i386/Makevars.site}, which does not exist by default.}
+@file{etc/i386/Makeconf} or @file{etc/x64/Makeconf} for an installed
+version of @R{}. In the latter case only @code{BINPREF} is used, with
+the 64 bit path used in @file{etc/x64/Makeconf}. The version used by
+@acronym{CRAN} can be installed as described in @ref{Building from
+source}.
@node OS X packages, Customizing package compilation, Windows packages, Installing packages
@@ -2182,11 +2188,7 @@
to do so for those with, if @command{make} is available.
Note that most binary packages including compiled code are tied to a
-particular series (e.g.@: @R{} 3.2.x or 3.1.x) of @R{}.
-
-You should not attempt to mix-and-match binary packages built for the
-`Snow Leopard' and `Mavericks' @acronym{CRAN} distributions: doing so is
-likely to lead to crashes or failures to load.
+particular series (e.g.@: @R{} 3.2.x or 3.3.x) of @R{}.
Installing source packages which do not contain compiled code should
work with no additional tools. For others you will need the
@@ -2195,7 +2197,7 @@
Package @CRANpkg{rJava} and those which depend on it need a Java runtime
installed and several packages need X11 installed, including those using
-Tk. For Mountain Lion and later see @ref{OS X} and @ref{Java (OS X)}.
+Tk. See @ref{OS X} and @ref{Java (OS X)}.
Tcl/Tk extensions @code{BWidget} and @code{Tktable} are part of the
Tcl/Tk contained in the @R{} installer. These are required by a number
@@ -2211,13 +2213,14 @@
The default compilers specified in
@file{/Library/Frameworks/R.framework/Resources/etc/Makeconf} depend on
the version of OS X under which @R{} was installed, and are appropriate
-to the latest version of the command-line tools for that version
-of OS X. The settings can be changed, either by editing that file or in
-a file such as @file{~/.R/Makevars} (see the next section). Entries
-which may need to be changed include @samp{CC}, @samp{CXX}, @samp{FC},
-@samp{F77}, @samp{FLIBS} and the corresponding flags, and perhaps
-@samp{CXXCPP}, @samp{DYLIB_LD}, @samp{MAIN_LD}, @samp{SHLIB_CXXLD},
-@samp{SHLIB_FCLD} and @samp{SHLIB_LD}.
+for the latest version of the `Command Line Tools' for that version of
+OS X and the recommended version of Fortran (see @ref{OS X}). The
+settings can be changed, either by editing that file or in a file such
+as @file{~/.R/Makevars} (see the next section). Entries which may need
+to be changed include @samp{CC}, @samp{CXX}, @samp{FC}, @samp{F77},
+@samp{FLIBS} and the corresponding flags, and perhaps @samp{CXXCPP},
+@samp{DYLIB_LD}, @samp{MAIN_LD}, @samp{SHLIB_CXXLD}, @samp{SHLIB_FCLD}
+and @samp{SHLIB_LD}.
So for example you could select @command{clang} for both C and C++ with
extensive checking by having in @file{~/.R/Makevars}
@@ -2228,12 +2231,6 @@
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
@end example
-@noindent
-and for a version of @command{gfortran-4.2} we needed
-@example
-FLIBS=-lgfortran
-@end example
-
@node Customizing package compilation, Multiple sub-architectures, OS X packages, Installing packages
@subsection Customizing package compilation
@@ -2331,7 +2328,7 @@
--merge-multiarch} to build and merge the two architectures, starting
with a source tarball.
-@node Byte-compilation, , Multiple sub-architectures, Installing packages
+@node Byte-compilation, External software, Multiple sub-architectures, Installing packages
@subsection Byte-compilation
The base and recommended packages are byte-compiled by default. Other
@@ -2340,8 +2337,7 @@
@code{install.packages(type = "source", INSTALL_opts =
"--byte-compile")}.
-Not all contributed packages work correctly when byte-compiled (for
-example because they interfere with the sealing of namespaces). For
+Not all contributed packages work correctly when byte-compiled. For
most packages (especially those which make extensive use of compiled
code) the speed-up is small. Unless a package is used frequently the
time spent in byte-compilation can outweigh the time saved in execution:
@@ -2351,6 +2347,65 @@
Byte-compilation can be controlled on a per-package basis by the
@samp{ByteCompile} field in the @file{DESCRIPTION} file.
+@node External software, , Byte-compilation, Installing packages
+@subsection External software
+
+Some @R{} packages contain compiled code which links to external
+software libraries. Unless the external library is statically linked
+(which is done as much as possible for binary packages on Windows and OS
+X), the libraries have to be found when the package is loaded and not
+just when it is installed. How this should be done depends on the OS
+(and in some cases the version).
+
+For Unix-alikes except OS X the primary mechanism is the @code{ld.so}
+cache controlled by @command{ldconfig}: external dynamic libraries
+recorded in that cache will be found. Standard library locations will
+be covered by the cache, and well-designed software will add its
+locations (as for example @pkg{openmpi} does on Fedora). The secondary
+mechanism is to consult the environment variable @env{LD_LIBRARY_PATH}.
+Now the @R{} script controls that variable, and sets it to the
+concatenation of @env{R_LD_LIBRARY_PATH}, @env{R_JAVA_LD_LIBRARY_PATH}
+and the environment value of @env{LD_LIBRARY_PATH}. The first two have
+defaults which are normally set when @R{} is installed (but can be
+overridden in the environment) so @env{LD_LIBRARY_PATH} is the best
+choice for a user to set.
+
+On OS X the primary mechanism is to embed the absolute path to dependent
+dynamic libraries into an object when it is compiled. Few @R{} packages
+arrange to do so, but it can be edited@footnote{They need to have been
+created using @option{-headerpad_max_install_names}, which is the
+default for an @R{} package.} @emph{via} @command{install_name_tool} ---
+that only deals with direct dependencies and those would also need to be
+compiled to include the absolute paths of their dependencies. If the
+choice of absolute path is to be deferred to load time, how they are
+resolved is described in @command{man dyld}: the role of
+@env{LD_LIBRARY_PATH} is replaced on OS X by @env{DYLD_LIBRARY_PATH} and
+latterly @env{DYLD_FALLBACK_LIBRARY_PATH}. Running @command{R CMD otool
+-L} on the package shared object will show where (if anywhere) its
+dependencies are resolved. @env{DYLD_FALLBACK_LIBRARY_PATH} is preferred
+(and it is that which is manipulated by the @R{} script), but as from
+10.11 (`El Capitan') the default behaviour had been changed for security
+reasons to discard these environment variables when invoking a shell
+script (and @file{R} is a shell script). That makes the only portable
+option to set @env{R_LD_LIBRARY_PATH} in the environment, something like
+
+@example
+export R_LD_LIBRARY_PATH="`R RHOME`/lib:/opt/local/lib"
+@end example
+
+The precise rules for where Windows looks for DLLs are complex and
+depend on the version of Windows. But for present purposes the main
+solution is to put the directories containing the DLLs the package
+links to (and any those DLLs link to) on the @env{PATH}. 64-bit
+versions of Windows will ignore 32-bit DLLs from 64-bit @R{} and
+@emph{vice versa}.
+
+The danger with any of the methods which involve setting environment
+variables is of inadvertently masking a system library. This is less
+for @env{DYLD_FALLBACK_LIBRARY_PATH} and for @emph{appending} to
+@env{PATH} on Windows (as it should already contain the system library
+paths).
+
@node Updating packages, Removing packages, Installing packages, Add-on packages
@section Updating packages
@findex update.packages
@@ -2404,8 +2459,7 @@
lib = file.path("path", "to", "library"))
@end example
-Finally, in most installations one can just remove the package directory
-from the library.
+Finally, one can just remove the package directory from the library.
@node Setting up a package repository, Checking installed source packages, Removing packages, Add-on packages
@@ -2415,11 +2469,12 @@
Utilities such as @code{install.packages} can be pointed at any
@acronym{CRAN}-style repository, and @R{} users may want to set up their
own. The `base' of a repository is a URL such as
-@uref{http://www.omegahat.org/R/}: this must be an URL scheme that
-@code{download.packages} supports (which also includes @samp{ftp://} and
-@samp{file://} and on most systems @samp{https://}). Under that base
-URL there should be directory trees for one or more of the following
-types of package distributions:
+@uref{http://www.stats.ox.ac.uk/pub/RWin}: this must be an URL scheme
+that @code{download.packages} supports (which also includes
+@samp{ftp://} and @samp{file://} and (from @R{} 3.3.0 and perhaps
+earlier) @samp{https://}). Under that base URL there should be
+directory trees for one or more of the following types of package
+distributions:
@itemize
@item
@@ -2439,12 +2494,6 @@
@file{bin/macosx/mavericks/contrib/@var{3.y}} for the CRAN build for
`Mavericks' (and later) for @R{} versions @var{3.y.z}, containing
@file{.tgz} files.
-
-@item
-@code{"mac.binary"}: located at
-@file{bin/macosx/contrib/@var{3.y}} for a CRAN build for
-`Snow Leopard' (and later) for @R{} versions @var{3.y.z}, containing
-@file{.tgz} files.
@end itemize
Each terminal directory must also contain a @file{PACKAGES} file. This
@@ -2797,7 +2846,7 @@
@item
Only 64-bit builds support `long vectors', those with @math{2^{31}} or
-more elements (each of which needs 16GB of storage for a numeric
+more elements (which needs at least 16GB of storage for each numeric
vector).
@item
@@ -2819,9 +2868,9 @@
@cputype{x86_64} @emph{vs} @cputype{ix86}, the 64-bit CPU has features
(such as SSE2 instructions) which are guaranteed to be present but are
optional on the 32-bit CPU, and also has more general-purpose registers.
-This means that on chips like a desktop Intel Core 2 Duo the vanilla
-64-bit version of @R{} has been around 10% faster on both Linux and OS
-X. (Laptop CPUs are usually relatively slower in 64-bit mode.)
+This means that on chips like a desktop Intel i7 the vanilla 64-bit
+version of @R{} has been around 10% faster on both Linux and OS X.
+(Laptop CPUs are usually relatively slower in 64-bit mode.)
@end itemize
So, for speed you may want to use a 32-bit build (especially on a
@@ -2851,7 +2900,7 @@
Unix-alike if that is separate from the sources).
@file{Rmath.h} contains @samp{R_VERSION_STRING}, which is a character
-string containing the current @R{} version, for example @code{"3.2.0"}.
+string containing the current @R{} version, for example @code{"3.3.0"}.
There is full access to @R{}'s handling of @code{NaN}, @code{Inf} and
@code{-Inf} via special versions of the macros and functions
@@ -2942,7 +2991,7 @@
not be able to run it unless you add the directory containing
@enindex LD_LIBRARY_PATH
@file{libRmath.so} to the @env{LD_LIBRARY_PATH} environment variable
-(@file{libRmath.dylib}, @env{DYLD_LIBRARY_PATH} on OS X).
+(@file{libRmath.dylib}, @env{DYLD_FALLBACK_LIBRARY_PATH} on OS X).
The targets
@@ -3003,7 +3052,7 @@
make -f Makefile.win shared implib
@end example
-To use the routines in your own C or C++ programs using MinGW, include
+To use the routines in your own C or C++ programs using MinGW-w64, include
@example
#define MATHLIB_STANDALONE
@@ -3017,7 +3066,7 @@
able to force static or dynamic linking @emph{via}
@example
--Wl,-Bstatic -lRmath -Wl,dynamic
+-Wl,-Bstatic -lRmath -Wl,Bdynamic
-Wl,-Bdynamic -lRmath
@end example
@@ -3028,7 +3077,7 @@
linked).
It is possible to link to @file{Rmath.dll} using other compilers, either
-directly or via an import library: if you make a MinGW import library as
+directly or via an import library: if you make a MinGW-w64 import library as
above, you will create a file @file{Rmath.def} which can be used
(possibly after editing) to create an import library for other systems
such as Visual C++.
@@ -3043,7 +3092,7 @@
@noindent
to ensure that the constants like @code{NA_REAL} are linked correctly.
-(Auto-import will probably work with MinGW, but it is better to be
+(Auto-import will probably work with MinGW-w64, but it is better to be
sure. This is likely to also work with VC++, Borland and similar
compilers.)
@@ -3083,25 +3132,24 @@
@option{-std=gnu99}@footnote{@option{-std=c99} excludes POSIX
functionality, but @file{config.h} will turn on all @acronym{GNU}
extensions to include the POSIX functionality. The default mode for GCC
-5 is @option{-std=gnu11}.}. If the compiler is detected as
-@command{gcc}@tie{}@code{4.x}, @option{-std=gnu99} will be appended to
-@code{CC} unless it conflicts with a setting of @code{CFLAGS}. (Note
-that options essential to run the compiler even for linking, such as
-those to set the architecture, should be specified as part of @code{CC}
-rather than in @code{CFLAGS}.)
+5.1 and later is @option{-std=gnu11}.}. (Note that options essential to
+run the compiler even for linking, such as those to set the
+architecture, should be specified as part of @code{CC} rather than in
+@code{CFLAGS}.)
Unless you do not want to view graphs on-screen (or use OS X) you need
@samp{X11} installed, including its headers and client libraries. For
-recent Fedora distributions it means (at least) RPMs @samp{libX11},
-@samp{libX11-devel}, @samp{libXt} and @samp{libXt-devel}. On Debian we
-recommend the meta-package @samp{xorg-dev}. If you really do not want
-these you will need to explicitly configure @R{} without X11, using
-@option{--with-x=no}.
+recent Fedora/RedHat distributions it means (at least) RPMs
+@samp{libX11}, @samp{libX11-devel}, @samp{libXt} and @samp{libXt-devel}.
+On Debian/Ubuntu we recommend the meta-package @samp{xorg-dev}. If you
+really do not want these you will need to explicitly configure @R{}
+without X11, using @option{--with-x=no}.
The command-line editing (and command completion) depends on the
-@acronym{GNU} @code{readline} library: version 4.2 or later is needed
-for all the features to be enabled. Otherwise you will need to
-configure with @option{--with-readline=no} (or equivalent).
+@acronym{GNU} @code{readline} library (including its headers): version
+4.2 or later is needed for all the features to be enabled. Otherwise
+you will need to configure with @option{--with-readline=no} (or
+equivalent).
A suitably comprehensive @code{iconv} function is essential. The @R{}
usage requires @code{iconv} to be able to translate between
@@ -3126,6 +3174,41 @@
@code{setenv}.} are essential, and others@footnote{such as
@code{realpath}, @code{symlink}.} will be used if available.
+@c PCRE[1] 8.32 is from Nov 2012
+@c zlib 1.2.5 is from July 2010, bzip2 1.0.6 from Sept 2010
+@c xz 5.0.3 is from May 2011
+@c libcurl 7.28.0 was released in Oct 2012
+Installations of @code{zlib} (version 1.2.5 or later), @code{libbz2}
+(version 1.0.6 or later: called @pkg{bzip2-libs}/@pkg{bzip2-devel} or
+@pkg{libbz2-1.0}/@pkg{libbz2-dev} by some Linux distributions),
+@code{liblzma}@footnote{most often distributed as part of @code{xz}:
+possible names in Linux distributions include
+@code{xz-devel}/@code{xz-libs} and @code{liblzma-dev}.} version 5.0.3 or
+later are required.
+
+PCRE@footnote{sometimes known as PCRE1, and not PCRE2 which started at
+version 10.0.} (version 8.32 or later, although versions 8.10--8.31 will
+be accepted with a deprecation warning) is required (or just its library
+and headers if packaged separately). PCRE must be built with UTF-8
+support (not the default, and checked by @command{configure}) and
+support for Unicode properties is assumed by some @R{} packages. JIT
+support is desirable for the best performance: support for this and
+Unicode properties can be checked at run-time by calling
+@code{pcre_config()}. If building PCRE for use with @R{} a suitable
+@command{configure} command might be
+@example
+/configure --enable-utf --enable-unicode-properties --enable-jit --disable-cpp
+@end example
+@noindent
+The @option{--enable-jit} flag is supported for most common CPUs.
+
+Library @code{libcurl} (version 7.28.0 or later) is required.
+Information on @code{libcurl} is found from the @command{curl-config}
+script: if that is missing or needs to be overridden@footnote{for
+example to specify static linking with a build which has both shared and
+static libraries.} there are macros to do so described in file
+@file{config.site}.
+
A @command{tar} program is needed to unpack the sources and packages
(including the recommended packages). A version@footnote{Such as
@acronym{GNU} @command{tar} 1.15 or later, @command{bsdtar} (from
@@ -3153,10 +3236,18 @@
in re-distributions) as well as
@command{texi2dvi}.@footnote{@command{texi2dvi} is normally a shell
script. Some versions (including that from @pkg{texinfo} 5.2 and 6.0)
-need to be run under @command{bash} rather than a Bourne shell.}
+need to be run under @command{bash} rather than a Bourne shell,
+especially on Solaris. Some of the issues which have been observed with
+broken versions of @command{texi2dvi} can be circumvented by setting the
+environment variable @env{R_TEXI2DVICMD} to the value @code{emulation}.}
Further, the versions of @command{texi2dvi} and @file{texinfo.tex} need
to be compatible: we have seen problems with older @TeX{} distributions.
+@cindex Subversion
+If you want to build from the @R{} Subversion repository then
+@command{texi2any} is highly recommended as it is used to create files
+which are in the tarball but not stored in the Subversion repository.
+
@cindex Vignettes
The PDF documentation (including @file{doc/NEWS.pdf}) and building
vignettes needs @command{pdftex} and @command{pdflatex}. We require
@@ -3171,19 +3262,13 @@
may need to change @R{}'s defaults: @pxref{Making the manuals}). Note
that package @pkg{hyperref} (currently) requires packages
@pkg{kvoptions}, @pkg{ltxcmds} and @pkg{refcount}. For distributions
-based on TeXLive the simplest approach may be to install collections
+based on TeX Live the simplest approach may be to install collections
@pkg{collection-latex}, @pkg{collection-fontsrecommended},
@pkg{collection-latexrecommended}, @pkg{collection-fontsextra} and
@pkg{collection-latexextra} (assuming they are not installed by
default): Fedora uses names like @pkg{texlive-collection-fontsextra} and
Debian/Ubuntu like @pkg{texlive-fonts-extra}.
-
-@cindex Subversion
-If you want to build from the @R{} Subversion repository then
-@command{texi2any} is highly recommended as it is used to create files
-in the tarball but not under Subversion.
-
@enindex PATH
The essential programs should be in your @env{PATH} at the time
@command{configure} is run: this will capture the full paths.
@@ -3250,23 +3335,6 @@
into @code{libtiff} such as @code{lzma}, @code{jbig} and @code{jpeg12},
and these may need also to be present.
-@c PCRE[1] 8.10 is from June 2010, 8.32 from Nov 2012
-If you have them installed (including the appropriate headers and of
-suitable versions), system versions of @code{zlib} (version 1.2.5 or
-later),, @code{libbz2} (version 1.0.6 or later: called
-@pkg{bzip2-libs}/@pkg{bzip2-devel} or @pkg{libbz2-1.0}/@pkg{libbz2-dev}
-by some Linux distributions) and PCRE (version 8.10 or later, preferably
-8.32 or later@footnote{sometimes known as PCRE1, and not PCRE2, which
-started at version 10.0. PCRE must be built with UTF-8 support (not the
-default, and checked by @command{configure}) and support for Unicode
-properties is assumed by some @R{} packages. JIT support is desirable
-for the best performance: support for this and Unicode properties can be
-checked at run-time by calling @code{pcre_config()}.}): will be used,
-otherwise versions in the @R{} sources will be compiled in. The
-external versions can be avoided by configure options
-@option{--without-system-zlib}, @option{--without-system-bzlib} and
-@option{--without-system-pcre}.
-
Option @option{--with-system-tre} is also available: it needs a recent
version of TRE. (The current sources are in the @command{git} repository
at @url{https://github.com/laurikari/tre/}, but at the time of writing
@@ -3306,17 +3374,6 @@
very old or broken version of ICU be found this can be suppressed by
@option{--without-ICU}.
-@c 7.28.0 was released in Oct 2012.
-If @code{libcurl} version 7.28.0 or later is available (including its
-development files), it will be linked in to support
-@code{curlGetHeaders} and the @code{"libcurl"} methods of
-@code{download.file} and @code{url}. This is recommended as it gives
-access to @samp{https://} and @samp{ftps://} URLs. Information on
-@code{libcurl} is found from the @command{curl-config} script: if that
-is missing or needs to be overridden@footnote{for example to specify
-static linking with a build which has both shared and static libraries.}
-there are macros described in file @file{config.site}.
-
The @code{bitmap} and @code{dev2bitmap} devices and function
@code{embedFonts()} use ghostscript
(@uref{http://www.ghostscript.com/}). This should either be in your
@@ -3355,7 +3412,7 @@
versions of Tcl/Tk installed, specifying the paths to the correct config
files may be necessary to avoid confusion between them.
-Versions of Tcl/Tk up to 8.5.18 and 8.6.4 have been tested (including
+Versions of Tcl/Tk up to 8.5.19 and 8.6.4 have been tested (including
most versions of 8.4.x, but not recently).
Note that the @file{tk.h} header includes@footnote{This is true even for
@@ -3382,16 +3439,17 @@
@cputype{x86_64} Linux is
@example
-JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51-4.b16.fc21.x86_64/jre
+JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.71-1.b15.fc22.x86_64/jre
R_JAVA_LD_LIBRARY_PATH=$@{JAVA_HOME@}/lib/amd64/server
@end example
-Note that this unfortunately depends on the exact version of the JRE/JDK
+Unfortunately this depends on the exact version of the JRE/JDK
installed, and so may need updating if the Java installation is updated.
This can be done by running @code{R CMD javareconf} which updates
-settings in both @file{etc/Makeconf} and
+settings in both @file{@var{R_HOME}/etc/Makeconf} and
@file{@var{R_HOME}/etc/ldpaths}. See @code{R CMD javareconf --help} for
-details.
+details: note that this needs to be done by the account owning the @R{}
+installation.
Another way of overriding those settings is to set the environment variable
@enindex R_JAVA_LD_LIBRARY_PATH
@@ -3404,7 +3462,7 @@
@end example
It may be possible to avoid this by specifying an invariant link as the
-path. For example, on that system any of
+path when configuring. For example, on that system any of
@example
JAVA_HOME=/usr/lib/jvm/java
@@ -3491,9 +3549,9 @@
Some enhanced @acronym{BLAS}es are compiler-system-specific
(@code{sunperf} on Solaris@footnote{Using the Oracle Solaris Studio
@command{cc} and @command{f95} compilers}, @code{libessl} on IBM,
-@code{Accelerate} on OS X). The correct incantation for
-these is usually found @emph{via} @option{--with-blas} with no value on
-the appropriate platforms.
+@code{Accelerate} on OS X). The correct incantation for these is often
+found @emph{via} @option{--with-blas} with no value on the appropriate
+platforms.
Some of the external @acronym{BLAS}es are multi-threaded. One issue is
that @R{} profiling (which uses the @code{SIGPROF} signal) may cause
@@ -3922,7 +3980,9 @@
by option @option{--with-system-valgrind-headers}: they will be used if
present (on Linux they may be in a separate package such as
@pkg{valgrind-devel}). Note though that there is no guarantee that the
-code in @R{} will be compatible with future @command{valgrind} headers.
+code in @R{} will be compatible with very old@footnote{We believe that
+versions 3.4.0 to 3.10.1 are compatible.} or future @command{valgrind}
+headers.
If you need to re-configure @R{} with different options you may need to run
@code{make clean} or even @code{make distclean} before doing so.
@@ -4337,6 +4397,7 @@
* Solaris::
* AIX::
* FreeBSD::
+* OpenBSD::
* Cygwin::
* New platforms::
@end menu
@@ -4655,15 +4716,11 @@
@section OS X
@cindex OS X
-To build @R{} you need to have installed Apple's `Command Line Tools'
-(on some versions installing Xcode suffices). You also need
-@code{readline} (or to configure using @option{--without-readline}), and
-a Fortran compiler. Those and other binary components are available
-from @uref{https://r.research.att.com/libs}.
+The instructions here are for @cputype{x86_64} builds on 10.9
+(Mavericks) or later. In principle@footnote{It will be necessary to
+install later versions of software such as @code{libcurl}.} @R{} can be
+built for 10.6 to 10.8 but these has not been tested recently.
-An X sub-system is required unless configuring using
-@option{--without-x}: see @uref{https://xquartz.macosforge.org/}. (Note
-that XQuartz will likely need to be re-installed after an OS upgrade.)
To build @R{} you need Apple's `Command Line Tools': these can be
(re-)installed by @command{xcode-select --install}. (If you have a
fresh OS installation, running e.g.@: @command{make} in a terminal will
@@ -4671,10 +4728,16 @@
Xcode, this provides the command-line tools. The tools will need to be
reinstalled when OS X is upgraded, as upgrading partially removes them.)
-The instructions here are for @cputype{x86_64} builds on 10.6 (Snow
-Leopard) or later. In principle @R{} can be built for 10.4.x, 10.5.x
-and for PowerPC or 32-bit Intel Macs but these has not been tested
-recently.
+You need @code{readline}@footnote{Apple provides a partial emulation of
+GNU readline 4.2 based on the NetBSD @code{editline} library. That is
+not recommended but for the time being @R{}'s installation scripts will
+make use of it.} and a Fortran compiler. Those and other binary
+components are available from @uref{https://r.research.att.com/libs}:
+you are likely to need @code{pcre} and @code{xz} (recent OS X provides
+libraries but not headers for these).
+
+An X sub-system is required unless configuring using
+@option{--without-x}: see @uref{https://xquartz.macosforge.org/}.
To use the @code{quartz()} graphics device you need to configure with
@option{--with-aqua} (which is the default): @code{quartz()} then
@@ -4688,11 +4751,10 @@
Use @option{--without-aqua} if you want a standard Unix-alike build:
apart from disabling @code{quartz()} and the ability to use the build
with @Rapp{}, it also changes the default location of the personal
-library (see @code{?.libPaths}). Also use
-@option{--disable-R-framework} to install in the standard layout.
+library (see @code{?.libPaths}).
-Various compilers can be used. The current @acronym{CRAN} `Mavericks'
-distribution of @R{} is built using
+Various compilers can be used. The current @acronym{CRAN} distribution
+of @R{} is built using
@example
CC=clang
@@ -4713,47 +4775,7 @@
@uref{https://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2}.@footnote{This
is a tarball which needs to be unpacked in the Terminal by e.g.@:
@command{sudo tar -zxf gfortran-4.8.2-darwin13.tar.bz2 -C /}. It does
-not run on Core 2 Duo Macs.} Apple's builds of @command{clang}
-currently have no OpenMP support.
-
-The @acronym{CRAN} `Snow Leopard' distribution of @R{} was built using
-
-@itemize
-@item @command{gcc}
-from an Xcode distribution prior to version 5. This is a version of gcc
-4.2.1 with an LLVM backend.
-
-@item @command{gfortran}
-from
-@uref{http://cran.r-project.org/bin/macosx/tools/gfortran-4.2.3.pkg}.
-Note that this installs into @file{/usr/local/bin}, so make sure that is
-on your path. Other compilers from
-@uref{http://r.research.att.com/tools/} can also be used.
-
-@item @command{clang}
-from the Xcode distribution, to compile the Objective-C parts of the
-@code{quartz()} device.
-@end itemize
-
-To use these, have in @file{config.site} something like
-
-@example
-CC="llvm-gcc-4.2"
-CXX="llvm-g++-4.2"
-F77="gfortran-4.2 -arch x86_64"
-FC=$F77
-OBJC="clang"
-@end example
-
-@noindent
-Full names help to ensure that the intended compilers are used. In
-particular @command{gcc} is a copy of @command{llvm-gcc-4.2} for Xcode <
-5 but of @command{clang} in Xcode 5. The recommended Fortran compiler
-defaults to 32-bit, so @code{-arch x86_64} is needed. (For a 32-bit
-build, use @code{-arch i386} for all compiler commands.)
-
-The OpenMP support in this version of @command{gcc} is problematic, so
-the @acronym{CRAN} build is configured with @option{--disable-openmp}.
+not run on Core 2 Duo Macs.}
Other builds of @command{gfortran} are available: see
@uref{https://gcc.gnu.org/wiki/GFortranBinaries} and
@@ -4770,16 +4792,10 @@
Pre-compiled versions of many of the @ref{Useful libraries and programs}
are available from @uref{https://r.research.att.com/libs/}. You will
-most likely want at least @code{pcre}, @code{xz}, @code{jpeg}
-and @code{readline} (and perhaps @code{tiff}).
-@code{pkg-config} is not provided by Apple and useful for many packages:
-it will also be used if present when configuring the @code{X11()}
-device.
-
-Recent versions of OS X ship with @code{zlib} version 1.2.8 and
-@code{bzlib} version 1.0.6, sufficient for the default
-@command{configure} checks. Mavericks has a recent enough version of
-@code{libcurl}: Snow Leopard does not.
+most likely want at least @code{jpeg} and @code{tiff}.
+@code{pkg-config} is not provided by Apple and used for many packages:
+it will also be used if present when configuring the @code{X11()} and
+bitmap devices.
Support for @code{cairo} (without @code{Pango}) can be enabled in two
ways: both need @code{pkg-config} available. XQuartz ships @code{cairo}
@@ -4806,20 +4822,19 @@
@noindent
to provide potentially higher-performance versions of the @acronym{BLAS}
-and LAPACK routines. (Use of @code{Accelerate} with
-@option{--with-lapack} does not work on Snow Leopard: it may work there
-without.)@footnote{It is reported that for some non-Apple toolchains
-@code{CPPFLAGS} needed to contain @code{-D__ACCELERATE__}.}
+and LAPACK routines.@footnote{It is reported that for some non-Apple
+toolchains @code{CPPFLAGS} needed to contain @code{-D__ACCELERATE__}.}
Looking at the top of
@file{/Library/Frameworks/R.framework/Resources/etc/Makeconf}
will show the compilers and configuration options used for the
-@acronym{CRAN} binary package for @R{}: at the time of writing
+@acronym{CRAN} binary package for @R{}: at the time of writing the
+non-default options
@example
---enable-memory-profiling
+--enable-memory-profiling --enable-R-framework
@end example
@noindent
-was used for `Mavericks'.
+were used.
Configure option @option{--with-internal-tzcode} is the default on OS X,
as the system implementation of time zones does not work correctly for
@@ -4845,10 +4860,8 @@
and may need to re-install XQuartz and Java (this has been needed for
some upgrades but not others).
- @menu
-* Mavericks and later::
-* Lion and Mountain Lion::
-* Snow Leopard::
+
+@menu
* El Capitan::
* Tcl/Tk headers and libraries::
* Java (OS X)::
@@ -4856,113 +4869,9 @@
* Building R.app::
@end menu
-@node Mavericks and later, Lion and Mountain Lion, OS X, OS X
-@subsection Mavericks and later
-
-For these versions Apple makes available compilers based on
-@command{clang}, and C++ headers and runtime are from LLVM's
-@samp{libc++} project, as part of the `Command Line Tools' (sometimes
-called `Command Line Developer Tools') and of Xcode (you only need one
-or the other).
-
-These tools can be (re-)installed by @command{xcode-select --install}.
-(If you have a fresh installation of Mavericks or later, running e.g.@:
-@command{make} in a terminal will offer the installation of the
-command-line tools, or perhaps use the versions from Xcode. However,
-after an OS update, you are advised to re-install them.)
-
-To use the compilers from the command-line tools with the recommended
-Fortran compiler, have in @file{config.site} something like
-
-@example
-CC=clang
-CXX=clang++
-F77=gfortran-4.8
-FC=$F77
-OBJC=clang
-@end example
-
-More recent and complete distributions of @command{clang} are usually
-available from @uref{http://llvm.org/releases/}. In particular, these
-include support for the `Address Sanitizer' (not included by Apple until
-Xcode 7) and for OpenMP in versions 3.7.0 and later.
-
-
-See the comments under Mountain Lion about X11 and GTK.
-
-If you upgrade the OS you should re-install any of XQuartz, the `Command
-Line Tools' and Java which you have installed. (Upgrading may partially
-remove previous versions which can be confusing.)
-
-There are some warnings using the recommended @command{gfortran} build
-under Yosemite.
-
-
-@node Lion and Mountain Lion, Snow Leopard, Mavericks and later, OS X
-@subsection Lion and Mountain Lion
-
-`Command-line Tools for Xcode' used to be part of the Apple Developer
-Tools (`Xcode') but for these versions needs to be installed separately.
-They can be downloaded from
-@uref{http://developer.apple.com/devcenter/mac/} (you will need to
-register there: that allows you to download older versions available for
-your OS) or from within some versions of Xcode you can install the
-command-line tools from the @samp{Downloads} pane in the
-@samp{Preferences}.
-
-The X11 system used with Mountain Lion is XQuartz (see above): Lion
-included an X11 system.
-
-To build the graphics devices depending on cairographics, the XQuartz
-path for @command{pkg-config} files needs to be known to
-@command{pkg-config} when @command{configure} is run: this usually means
-adding it to the @env{PKG_CONFIG_PATH} environment variable, e.g.
-
-@example
-export PKG_CONFIG_PATH= \
- /opt/X11/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
-@end example
-
-@noindent
-or putting
-@example
-PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
-@end example
-
-@noindent
-in @file{config.site}.
-
-For some pre-compiled software, for example the GTK framework,
-@file{/opt/X11/include} may need to be added to the include paths.
-
-If you install the command-line tools for Xcode 4.6.3 you will get the
-compilers used for the CRAN binary distribution: those for Xcode 5 can
-be installed afterwards.
-
-
-@node Snow Leopard, El Capitan, Lion and Mountain Lion, OS X
-@subsection Snow Leopard
-
-A quirk on Snow Leopard is that the X11 libraries are not in the default
-linking path, so something like @samp{LIBS=-L/usr/X11/lib} may be
-required in @file{config.site}, or you can use the @command{configure}
-options @option{--x-includes=/usr/X11/include
---x-libraries=/usr/X11/lib} .
-
-The @acronym{CRAN} binaries were built using Xcode 4.2, a version
-available only to subscribing developers. It is believed that 3.2.6 (the
-last public free version for Snow Leopard) will work.
-
-@node El Capitan, Tcl/Tk headers and libraries, Snow Leopard, OS X
+@node El Capitan, Tcl/Tk headers and libraries, OS X, OS X
@subsection El Capitan
-@c Claimed that XQuartz does not install out-of-the-box:
-@c http://forums.macrumors.com/threads/os-x-el-capitan-working-not-working-apps.1890772/
-
-El Capitan was released at the end of September 2015, and experience to
-date is with systems which have been updated from Yosemite or earlier.
-Upgraded systems need the Command Line Tools reinstalled.
-
There are problems resulting from the new-to-El-Capitan restriction that
only Apple is allowed to install software under @file{/usr}: this
affects @emph{inter alia} @code{MacTeX} and @code{XQuartz}. For
@@ -4982,15 +4891,6 @@
although the linked versions under @file{/usr/X11} will be found (if the
link is present).
-@c It may be necessary for a clean installation for @code{XQuartz} to
-@c replace @file{/usr/X11} by @file{/opt/X11} in file
-@c @file{/usr/local/lib/tkConfig.sh}, and to use
-@c @command{install_name_tool} to adjust
-@c @file{/usr/local/lib/libtk8.6.dylib} to link to libraries under
-@c @file{/opt/X11} rather than @file{/usr/X11}. Updated installations seem
-@c to preserve @file{/usr/X11}, but there are packages assuming
-@c @file{/usr/X11R6}, a link that no longer exists.
-
@node Tcl/Tk headers and libraries, Java (OS X), El Capitan, OS X
@subsection Tcl/Tk headers and libraries
@@ -5007,17 +4907,16 @@
--with-tcl-config=/usr/local/lib/tclConfig.sh
--with-tk-config=/usr/local/lib/tkConfig.sh
@end example
-Note that this requires a fully-updated X11 installation (XQuartz for
-Mountain Lion and later).
+Note that this requires a matching XQuartz installation.
There is also a native (`Aqua') version of Tcl/Tk which produces widgets
in the native OS X style: this will not work with @Rapp{} because of
conflicts over the OS X menu, but for those only using command-line @R{}
this provides a much more intuitive interface to Tk for experienced Mac
users. Most versions of OS X come with Aqua Tcl/Tk libraries, but these
-are not recent versions of Tcl/Tk (8.5.9 in Mountain Lion and later).
-It is better to install Tcl/Tk 8.6.x from the sources or a binary
-distribution from
+are not at all recent versions of Tcl/Tk (8.5.9 in El Capitan, which is
+not even the latest patched version in that series). It is better to
+install Tcl/Tk 8.6.x from the sources or a binary distribution from
@uref{https://www.activestate.com/activetcl/downloads}. Configure @R{}
with
@example
@@ -5042,10 +4941,9 @@
The situation with Java support on OS X is messy.@footnote{For more
details see @uref{http://www.macstrategy.com/article.php?3}.}
-Snow Leopard and Lion shipped with a Java 6 runtime (JRE). Mountain
-Lion and later do not come with an installed JRE, and an OS X upgrade
-removes one if already installed: it is intended to be installed at
-first use. Check if a JRE is installed by running @command{java
+OS X no longer comes with an installed Java runtime (JRE), and an OS X
+upgrade removes one if already installed: it is intended to be installed
+at first use. Check if a JRE is installed by running @command{java
-version} in a @command{Terminal} window: if Java is not installed this
should prompt you to install it. You can also install directly the
latest Java from Oracle (currently from
@@ -5079,7 +4977,7 @@
@noindent
The Oracle JDK can be specified explicitly by something like
@example
-JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home
+JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk/Contents/Home
JAVA_CPPFLAGS="-I/$@{JAVA_HOME@}/include -I/$@{JAVA_HOME@}/include/darwin"
JAVA_LD_LIBRARY_PATH="$@{JAVA_HOME@}/jre/lib/server"
JAVA_LIBS="-L/$@{JAVA_HOME@}/jre/lib/server -ljvm"
@@ -5094,14 +4992,14 @@
@subsection Frameworks
The @acronym{CRAN} build of @R{} is installed as a framework, which is
-selected by the default option
+selected by the option
@example
./configure --enable-R-framework
@end example
(This is intended to be used with an Apple toolchain: other compilers may
-not support frameworks correctly.)
+not support frameworks correctly. It was the default prior to @R{} 3.3.0.)
It is only needed if you want to build @R{} for use with the @Rapp{}
console, and implies @option{--enable-R-shlib} to build @R{} as a
@@ -5109,7 +5007,8 @@
as a framework called @file{R.framework}. The default installation path
for @file{R.framework} is @file{/Library/Frameworks} but this can be
changed at configure time by specifying the flag
-@option{--enable-R-framework[=@var{DIR}]} or at install time as
+@option{--enable-R-framework[=@var{DIR}]} (or @option{--prefix}) or at
+install time @emph{via}
@example
make prefix=/where/you/want/R.framework/to/go install
@@ -5174,9 +5073,7 @@
A large selection of Open Source software can be installed from
@uref{https://www.opencsw.org}, by default installed under
@file{/opt/csw}. Solaris 10 ships with @code{bzlib} version 1.0.6
-(sufficient for the default @option{--with-system-bzlib}) but
-@code{zlib} version 1.2.3 (too old for @option{--with-system-zlib}):
-OpenCSW has 1.2.8.
+(sufficient) but @code{zlib} version 1.2.3 (too old): OpenCSW has 1.2.8.
You will need @acronym{GNU} @code{libiconv} and @code{readline}: the
Solaris version of @code{iconv} is not sufficiently powerful.
@@ -5420,7 +5317,7 @@
@end example
@noindent
-(@code{-L/opt/csw/lib} is needed since TeXLive was built using
+(@code{-L/opt/csw/lib} is needed since TeX Live was built using
32-bit @code{gcc}, and we need @file{/opt/csw/lib} in
@code{R_LD_LIBRARY_PATH}.)
@@ -5585,7 +5482,7 @@
environment can be found in the ``R on AIX'' project on R-Forge
(@uref{https://R-Forge.R-project.org/@/projects/@/aix/}).
-@node FreeBSD, Cygwin, AIX, Platform notes
+@node FreeBSD, OpenBSD, AIX, Platform notes
@section FreeBSD
@cindex FreeBSD
@@ -5595,17 +5492,10 @@
@R{} 3.0.2 at the time of writing. Davor Cubranic reported some success
on x86_64 FreeBSD 10.2 for @R{} 3.2.2.
-It appears that versions of FreeBSD using @command{clang} as the compiler
-(the default as from 10.0) need
-@example
-MAIN_LDFLAGS=-Wl,--export-dynamic
-@end example
-@noindent
-for @R{} releases up to 3.2.2.
-
Use of ICU for collation and the @command{configure} option
@option{--with-internal-tzcode} are desirable workarounds.
+@node OpenBSD, Cygwin, FreeBSD, Platform notes
@section OpenBSD
@cindex OpenBSD
@@ -5614,60 +5504,14 @@
(and patches applied) are at
@uref{http://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/math/R/}.
-@node Cygwin, New platforms, FreeBSD, Platform notes
+@node Cygwin, New platforms, OpenBSD, Platform notes
@section Cygwin
-The Cygwin emulation layer on Windows can be treated as a Unix-alike OS.
-This is unsupported, but experiments have been conducted and a few
-workarounds added. Cygwin has not been tested for @R{} 3.0.0 or later.
-
-The 64-bit version is completely unsupported. The 32-bit version has
-never worked well enough to pass @R{}'s @command{make check}.
-
-@R{} requires C99 complex type support, which is available as from
-Cygwin 1.7.8 (March 2011). However, the (then) implementation of
-@code{cacos} gave incorrect results, so we undefine @code{HAVE_CACOS}
-in @file{src/main/complex.c} on that platform. It has been reported
-that some C99 long double mathematical functions are missing, so
-configuring with @option{--disable-long-double} was required.
-
-Only building as a shared library can possibly work,@footnote{Windows
-DLLs need to have all links resolved at build time and so cannot resolve
-against @file{R.bin}.} so use e.g.@:
-
-@example
-./configure --disable-nls --enable-R-shlib FLIBS=-lgfortran
-make
-@end example
-
-@noindent
-Enabling NLS does work if required, although adding
-@option{--with-included-gettext} is preferable. You will see many
-warnings about the use of auto-import. Setting @samp{FLIBS} explicitly
-seems needed currently as the auto-detection gives an incorrect value.
-
-You will need the @pkg{tetex-extra} Cygwin package to build
-@file{NEWS.pdf} and the vignettes.
-
-Note that this gives you a command-line application using @code{readline}
-for command editing. The @samp{X11} graphics device will work if a
-suitable X server is running, and the standard Unix-alike ways of
-installing source packages work. There was a bug in the
-@file{/usr/lib/tkConfig.sh} script in the version we looked at, which
-needs to have
-
-@example
-TK_LIB_SPEC='-ltk84'
-@end example
-
-The overhead of using shell scripts makes this noticeably slower than a
-native build of @R{} on Windows.
-
-Even when @R{} could be built, not all the tests passed: there were
-incorrect results from wide-character regular expressions code and from
-sourcing CR-delimited files.
+The 32-bit version has never worked well enough to pass @R{}'s
+@command{make check}, and residual support from earlier experiments was
+removed in @R{} 3.3.0.
-Do not use Cygwin's BLAS library: it is known to give incorrect results.
+The 64-bit version is completely unsupported.
@node New platforms, , Cygwin, Platform notes
@section New platforms
@@ -5754,10 +5598,10 @@
the @R{} mailing lists unless you have followed all the prescriptions.}
We have collected most of the necessary tools (unfortunately not all,
-due to license or size limitations) into an executable installer
-named@footnote{for @R{} 3.0.0 and later.} @file{Rtools31.exe},
-available from @uref{https://CRAN.R-project.org/@/bin/@/windows/@/Rtools/}. You
-should download and run it, choosing the default ``Package authoring
+due to license or size limitations) into an executable installer named
+@file{Rtools*.exe}, available from
+@uref{https://CRAN.R-project.org/@/bin/@/windows/@/Rtools/}. You should
+download and run it, choosing the default ``Package authoring
installation'' to build add-on packages, or the ``full installation'' if
you intend to build @R{}.
@@ -5846,7 +5690,7 @@
The @file{Rtools*.exe} installer does @emph{not} include any version of
@LaTeX{}.
-It is also possible to use the TeXLive distribution from
+It is also possible to use the TeX Live distribution from
@uref{https://www.tug.org/texlive/}.
@enindex R_RD4PDF
@@ -5930,7 +5774,7 @@
Technically you need more than just a compiler so the set of tools is
referred to as a `toolchain'.
-The preferred toolchain is part of @code{Rtools31.exe}: this uses a beta
+The preferred toolchain is part of @code{Rtools*.exe}: this uses a beta
version of @command{gcc 4.6.3} and version 2.0.1 of the MinGW-w64
project's runtime.
@@ -5973,7 +5817,7 @@
There is a version of the @command{file} command that identifies the
type of files, and is used by @command{Rcmd check} if available. The
-binary distribution is included in @file{Rtools31.exe}.
+binary distribution is included in @file{Rtools*.exe}.
The file @file{xzutils.zip} contains the program @command{xz} which can
be used to (de)compress files with that form of compression.
diff -Nru r-base-3.2.3/doc/manual/R-data.texi r-base-3.3.1/doc/manual/R-data.texi
--- r-base-3.2.3/doc/manual/R-data.texi 2015-07-31 22:15:15.000000000 +0000
+++ r-base-3.3.1/doc/manual/R-data.texi 2016-03-16 23:04:43.000000000 +0000
@@ -138,13 +138,13 @@
There are packages to allow functionality developed in languages such as
@code{Java}, @code{perl} and @code{python} to be directly integrated
with @R{} code, making the use of facilities in these languages even
-more appropriate. (See the @CRANpkg{rJava} package from @acronym{CRAN} and
-the @pkg{SJava}, @pkg{RSPerl} and @pkg{RSPython} packages from the
-Omegahat project, @uref{http://www.omegahat.org}.)
+more appropriate. (See the @CRANpkg{rJava} package from @acronym{CRAN}
+and the @pkg{SJava}, @pkg{RSPerl} and @pkg{RSPython} packages from the
+Omegahat project, @uref{http://www.omegahat.net}.)
@cindex Unix tools
-@cindex AWK
+@cindex awk
@cindex perl
It is also worth remembering that @R{} like @Sl{} comes from the Unix
tradition of small re-usable tools, and it can be rewarding to use tools
@@ -184,10 +184,11 @@
possible, and @ref{Importing from other statistical systems} discusses
what facilities are available to access such files directly from @R{}.
For Excel spreadsheets, the available methods are summarized in
-@ref{Reading Excel spreadsheets}. For ODS spreadsheets from Open
-Office, see the Omegahat package@footnote{Currently not available from
-that repository but as a source package for download from
-@url{http://www.omegahat.org/ROpenOffice/}.} @pkg{ROpenOffice}.
+@ref{Reading Excel spreadsheets}.
+@c For ODS spreadsheets from Open
+@c Office, see the Omegahat package@footnote{Currently not available from
+@c that repository but as a source package for download from
+@c @url{http://www.omegahat.net/ROpenOffice/}.} @pkg{ROpenOffice}.
In a few cases, data have been stored in a binary form for compactness
and speed of access. One application of this that we have seen several
@@ -435,12 +436,12 @@
although it does not require it.
The @CRANpkg{XML} package provides general facilities for reading and
-writing @acronym{XML} documents within @R{}. A description of the
-facilities of the @CRANpkg{XML} package is outside the scope of this
-document: see the package's Web page at
-@uref{http://www.omegahat.org/RSXML} for details and examples. Package
-@CRANpkg{StatDataML} on @acronym{CRAN} is one example building on
-@CRANpkg{XML}.
+writing @acronym{XML} documents within @R{}.
+@c A description of the facilities of the @CRANpkg{XML} package is outside
+@c the scope of this document: see the package's Web page at
+@c @uref{http://www.omegahat.net/RSXML} for details and examples.
+Package @CRANpkg{StatDataML} on @acronym{CRAN} is one example building
+on @CRANpkg{XML}.
NB: @CRANpkg{XML} is available as a binary package for Windows, normally
from the `CRAN extras' repository (which is selected by default on
diff -Nru r-base-3.2.3/doc/manual/R-defs.texi r-base-3.3.1/doc/manual/R-defs.texi
--- r-base-3.2.3/doc/manual/R-defs.texi 2015-08-25 22:19:14.000000000 +0000
+++ r-base-3.3.1/doc/manual/R-defs.texi 2016-02-14 23:15:05.000000000 +0000
@@ -44,7 +44,7 @@
@c -- edit these here alone -- in order keep consistency
@macro Rcopyright{year}
-Copyright @copyright{} \year\--2015 R Core Team
+Copyright @copyright{} \year\--2016 R Core Team
@end macro
@macro permission{}
diff -Nru r-base-3.2.3/doc/manual/resources.texi r-base-3.3.1/doc/manual/resources.texi
--- r-base-3.2.3/doc/manual/resources.texi 2015-07-31 22:15:15.000000000 +0000
+++ r-base-3.3.1/doc/manual/resources.texi 2016-03-16 23:04:43.000000000 +0000
@@ -24,7 +24,7 @@
@lowersections
@html
Other Resources
-
+
@end html
diff -Nru r-base-3.2.3/doc/manual/R-exts.texi r-base-3.3.1/doc/manual/R-exts.texi
--- r-base-3.2.3/doc/manual/R-exts.texi 2015-12-03 23:15:23.000000000 +0000
+++ r-base-3.3.1/doc/manual/R-exts.texi 2016-04-17 22:15:04.000000000 +0000
@@ -270,11 +270,11 @@
@cindex configure file
@cindex cleanup file
-The optional files @file{configure} and @file{cleanup} are (Bourne
-shell) script files which are, respectively, executed before and
-(provided that option @option{--clean} was given) after installation on
-Unix-alikes, see @ref{Configure and cleanup}. The analogues on Windows
-are @file{configure.win} and @file{cleanup.win}.
+The optional files @file{configure} and @file{cleanup} are (Bourne)
+shell scripts which are, respectively, executed before and (if option
+@option{--clean} was given) after installation on Unix-alikes, see
+@ref{Configure and cleanup}. The analogues on Windows are
+@file{configure.win} and @file{cleanup.win}.
For the conventions for files @file{NEWS} and @file{ChangeLog} in the
@acronym{GNU} project see
@@ -624,7 +624,7 @@
One can add subject classifications for the content of the package using
the fields @samp{Classification/ACM} or @samp{Classification/ACM-2012}
(using the Computing Classification System of the Association for
-Computing Machinery, @uref{http://www.acm.org/class/}; the former refers
+Computing Machinery, @uref{http://www.acm.org/about/class/}; the former refers
to the 1998 version), @samp{Classification/JEL} (the Journal of Economic
Literature Classification System,
@uref{https://www.aeaweb.org/@/econlit/@/jelCodes.php}, or
@@ -648,15 +648,20 @@
codes.
@c DESCRIPTION field RdMacros
-As of @R{} 3.2.0, an @samp{RdMacros} field can be used to hold a
-comma-separated list of packages from which the current package will import
-Rd macro definitions. These will be imported after the system macros,
-in the order listed in the @samp{RdMacros} field, before any macro
-definitions in the current package are loaded. Macro definitions in
-individual @file{.Rd} files in the @file{man} directory are loaded
-last, and are local to later parts of that file. In case of any
-duplicates, the last loaded definition will be used@footnote{Duplicate
-definitions may trigger a warning: see @ref{User-defined macros}.}
+An @samp{RdMacros} field can be used to hold a comma-separated list of
+packages from which the current package will import @file{Rd} macro
+definitions. These will be imported after the system macros, in the
+order listed in the @samp{RdMacros} field, before any macro definitions
+in the current package are loaded. Macro definitions in individual
+@file{.Rd} files in the @file{man} directory are loaded last, and are
+local to later parts of that file. In case of duplicates, the last
+loaded definition will be used@footnote{Duplicate definitions may
+trigger a warning: see @ref{User-defined macros}.} Both @command{R CMD
+Rd2pdf} and @command{R CMD Rdconv} have an optional flag
+@option{--RdMacros=pkglist}. The option is also a comma-separated list
+of package names, and has priority over the value given in
+@file{DESCRIPTION}. Packages using @file{Rd} macros should depend on
+@R{} 3.2.0 or later.
@c DESCRIPTION field Built
@c DESCRIPTION field Packaged
@@ -1008,6 +1013,12 @@
give an error if the suggested package is not available, simply use
e.g.@: @code{rgl::plot3d}.
+Note that the recommendation to use suggested packages conditionally in
+tests does also apply to packages used to manage test suites: a
+notorious example was @pkg{testthat} which in version 1.0.0 contained
+illegal C++ code and hence could not be installed on standards-compliant
+platforms.
+
As noted above, packages in @samp{Enhances} @emph{must} be used
conditionally and hence objects within them should always be accessed
@emph{via} @code{::}.
@@ -1487,7 +1498,13 @@
comments later on about the Windows port of @R{}.
If your package needs some system-dependent configuration before
-installation you can include an executable (Bourne shell) script
+installation you can include an executable (Bourne@footnote{The script
+should only assume a POSIX-compliant @command{/bin/sh} -- see
+@uref{http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html}.
+In particular @command{bash} extensions must not be used, and not all
+@R{} platforms have a @command{bash} command, let alone one at
+@file{/bin/bash}. All known shells used with @R{} support the use of
+backticks, but not all support @samp{$(@var{cmd})}.}) shell script
@file{configure} in your package which (if present) is executed by
@code{R CMD INSTALL} before any other action is performed. This can be
a script created by the Autoconf mechanism, but may also be a script
@@ -1670,8 +1687,7 @@
variable, but that the secondary object is automatically resolved.
Another example is when a package installs support files that are
required at run time, and their location is substituted into an @R{}
-data structure at installation time. (This happens with the Java Archive
-files in the Omegahat @pkg{SJava} package.)
+data structure at installation time.
@vindex R_LIBRARY_DIR
@vindex R_PACKAGE_DIR
@vindex R_PACKAGE_NAME
@@ -1816,8 +1832,10 @@
library also contains LAPACK.
[@code{libRlapack} includes all the double-precision LAPACK routines
-current in 2003: a list of which routines are included is in file
-@file{src/modules/lapack/README}.]
+which were current in 2003: a list of which routines are included is in
+file @file{src/modules/lapack/README}. Note that an external LAPACK/BLAS
+library need not do so, as some were `deprecated' (and not compiled by
+default) in LAPACK 3.6.0 in late 2015.]
For portability, the macros @code{BLAS_LIBS} and @code{FLIBS} should
always be included @emph{after} @code{LAPACK_LIBS} (and in that order).
@@ -1894,14 +1912,21 @@
$(SHLIB): mylibs
mylibs:
- (cd subdir; make)
+ (cd subdir; $(MAKE))
@end example
@noindent
-Be careful to create all the necessary dependencies, as there is a no
+Be careful to create all the necessary dependencies, as there is no
guarantee that the dependencies of @code{all} will be run in a
particular order (and some of the @acronym{CRAN} build machines use
-multiple CPUs and parallel makes).
+multiple CPUs and parallel makes). In particular,
+
+@example
+all: mylibs
+@end example
+
+@noindent
+does @strong{not} suffice.
Note that on Windows it is required that @file{Makevars[.win]} does
create a DLL: this is needed as it is the only reliable way to ensure
@@ -2015,9 +2040,12 @@
Include the appropriate macro in @code{PKG_CFLAGS}, @code{PKG_CPPFLAGS}
and so on, and also in @code{PKG_LIBS}. C/C++ code that needs to be
conditioned on the use of OpenMP can be used inside @code{#ifdef
-_OPENMP}: note that some toolchains used for @R{} (including most of
-those using @command{clang}@footnote{Some builds of @command{clang} 3.7
-have support for OpenMP 3.1}) have no OpenMP support at all, not even
+_OPENMP}: note that some toolchains used for @R{} (including many of
+those using @command{clang}@footnote{Some builds of @command{clang}
+3.7.0 have support for OpenMP 3.1 (this is built by default as from
+3.8.0), but even if the compiler has, the @code{libomp} library may not
+be installed. At the time of writing Apple builds of @command{clang}
+for OS X had no support.}) have no OpenMP support at all, not even
@file{omp.h}.
For example, a package with C code written for OpenMP should have in
@@ -2128,17 +2156,17 @@
POSIX threads are not normally used on Windows, which has its own native
concepts of threads. However, there are two projects implementing
@code{pthreads} on top of Windows, @code{pthreads-w32} and
-@code{winpthreads} (a recent part of the MinGW-w64 project).
+@code{winpthreads} (part of the MinGW-w64 project).
Whether Windows toolchains implement @code{pthreads} is up to the
-toolchain provider: the currently recommended toolchain does by default
-provide it. A @command{make} variable @code{SHLIB_PTHREAD_FLAGS} is
-available: this should be included in both @code{PKG_CPPFLAGS} (or the
-Fortran or F9x equivalents) and @code{PKG_LIBS}.
+toolchain provider. A @command{make} variable
+@code{SHLIB_PTHREAD_FLAGS} is available: this should be included in both
+@code{PKG_CPPFLAGS} (or the Fortran or F9x equivalents) and
+@code{PKG_LIBS}.
The presence of a working @code{pthreads} implementation cannot be
unambiguously determined without testing for yourself: however, that
-@samp{_REENTRANT} is defined@footnote{some Windows toolchains have the
+@samp{_REENTRANT} is defined@footnote{some Windows toolchains had the
typo @samp{_REENTRANCE} instead.} in C/C++ code is a good indication.
See also the comments on thread-safety and performance under OpenMP: on
@@ -2401,11 +2429,21 @@
considerably from the standard). Some compilers have a concept of
`C++03' (`essentially a bug fix') or `C++ Technical Report 1' (TR1), an
optional addition to the `C++03' revision which was published in 2007.
-A revised standard was published in 2011 and compilers with fairly
+A revised standard was published in 2011 and compilers with pretty much
complete implementations are becoming available. C++11 added all of the
C99 features which are not otherwise implemented in C++, and C++
-compilers commonly accept C99 extensions to C++98. A minor update to
-C++11 (sometimes known as C++14) was approved in August 2014.
+compilers commonly accept C99 extensions to C++98. A minor update to
+C++11 (often known as C++14) was approved in August 2014.
+
+What standard a C++ compiler aims to support can be hard to determine.
+As from version 6 (to be released in 2016), @command{g++} will default
+to C++14: earlier versions aim to support C++03 with many extensions
+(including support for TR1). @command{clang} with its
+native@footnote{Some distributions, notably Debian, have supplied a
+build of @command{clang} with @command{g++}'s headers and library.
+Conversely, Apple's command named @command{g++} is based on
+@command{clang} using @code{libcxx}.} @code{libcxx} headers and library
+includes many C++11 features, and does not support TR1.
Since version 3.1.0, @R{} has provided support for C++11 in packages in
addition to C++98. This support is not uniform across platforms as it
@@ -2485,10 +2523,10 @@
essential that it selects the correct compiler, @emph{via} something like
@example
-CXX1X=`"$@{R_HOME@}/bin/R" CMD config CXX11X`
-CXX1XSTD=`"$@{R_HOME@}/bin/R" CMD config CXX11XSTD`
+CXX1X=`"$@{R_HOME@}/bin/R" CMD config CXX1X`
+CXX1XSTD=`"$@{R_HOME@}/bin/R" CMD config CXX1XSTD`
CXX="$(CXX1X) $(CXX1XSTD)"
-CXXFLAGS=`"$@{R_HOME@}/bin/R" CMD config CXX11XFLAGS`
+CXXFLAGS=`"$@{R_HOME@}/bin/R" CMD config CXX1XFLAGS`
AC_LANG(C++)
@end example
@@ -2810,8 +2848,8 @@
Complete checking of a package which contains a file @file{README.md}
needs @command{pandoc} installed: see
@uref{http://johnmacfarlane.net/@/pandoc/@/installing.html}. This
-should be reasonably current: @acronym{CRAN} used version 1.12.4.1 to
-process these files at the time of writing
+should be reasonably current: at the time of writing @acronym{CRAN} used
+version 1.12.4.2 to process these files.
You do need to ensure that the package is checked in a suitable locale
if it contains non-@acronym{ASCII} characters. Such packages are likely
@@ -3449,6 +3487,19 @@
selectively rather than @code{import} is good practice and recommended
notably when importing from packages with more than a dozen exports.
+To import every symbol from a package but for a few exceptions,
+pass the @code{except} argument to @code{import}. The directive
+
+@example
+import(foo, except=c(bar, baz))
+@end example
+
+@noindent
+imports every symbol from @pkg{foo} except @code{bar} and
+@code{baz}. The value of @code{except} should evaluate to something
+coercible to a character vector, after substituting each symbol for
+its corresponding string.
+
It is possible to export variables from a namespace which it has
imported from other namespaces: this has to be done explicitly and not
@emph{via} @code{exportPattern}.
@@ -3731,11 +3782,6 @@
@code{F_bkde} and so on, and so avoid clashes with @R{} code in the
namespace.
-
-@c More information about this symbol lookup, along with some approaches
-@c for customizing it, is available from
-@c @uref{http://www.omegahat.org/@/examples/@/RDotCall}.
-
@node An example, Namespaces with S4 classes and methods, useDynLib, Package namespaces
@subsection An example
@@ -4011,6 +4057,11 @@
@end example
@noindent
+and ensure that you use the value of environment variable @env{MAKE}
+(and not just @command{make}) in your scripts. (On some platforms GNU
+make is available under a name such as @command{gmake}, and there
+@code{SystemRequirements} is used to set @env{MAKE}.)
+
If you only need GNU make for parts of the package which are rarely
needed (for example to create bibliography files under
@file{vignettes}), use a file called @file{GNUmakefile} rather than
@@ -4024,13 +4075,13 @@
expressions in Makefiles (which are passed to the shell for processing).
Some @R{} platforms use strict@footnote{For example, @command{test}
options @option{-a} and @option{-e} are not portable, and not supported
-in the AT&T Bourne shell used on Solaris, even though they are in the
-POSIX standard.} Bourne shells: the @R{} toolset on Windows and some
-Unix-alike OSes use @command{ash}
-(@uref{https://en.wikipedia.org/@/wiki/@/Almquist_shell}), a rather
-minimal shell with few builtins. Beware of assuming that all the POSIX
-command-line utilities are available, especially on Windows where only a
-minimal set is provided for use with @R{}.
+in the AT&T Bourne shell used on Solaris 10/11, even though they are in
+the 2008 POSIX standard. Nor does Solaris support @samp{$(@var{cmd})}.}
+Bourne shells: the @R{} toolset on Windows and some Unix-alike OSes use
+@command{ash} (@uref{https://en.wikipedia.org/@/wiki/@/Almquist_shell}),
+a rather minimal shell with few builtins. Beware of assuming that all
+the POSIX command-line utilities are available, especially on Windows
+where only a minimal set is provided for use with @R{}.
@ifset UseExternalXrefs
(@xref{The command line tools, , The command line tools,
R-admin, R Installation and Administration}.)
@@ -4211,15 +4262,20 @@
The @command{ar} utility is often used in makefiles to make static
libraries. Its modifier @code{u} is defined by POSIX but is disabled in
GNU @command{ar} on some recent Linux distributions which use
-`deterministic mode'. The safe way to make a static library is to first
+`deterministic mode'. The safest way to make a static library is to first
remove any existing file of that name then use @command{ar -cr} and then
@command{ranlib} if needed (which is system-dependent: on most
systems@footnote{some versions of OS X did not.} @command{ar} always
-maintains a symbol table).
+maintains a symbol table). The POSIX standard says options should be
+preceded by a hyphen (as in @option{-cr}), although most OSes accept
+them without.
+@c flowWorkspace failed on OS X in Mar 2016 because a wildcard spec was empty
+Note that on some systems @command{ar -cr} must have at least one file
+specified.
@item
Some people have a need to set a locale. Locale names are not portable,
-and e.g.@: @samp{fr_FR.utf8} is common used on Linux but not accepted on
+and e.g.@: @samp{fr_FR.utf8} is commonly used on Linux but not accepted on
either Solaris or OS X. @samp{fr_FR.UTF-8} is more portable, being
accepted on recent Linux, AIX, FreeBSD, OS X and Solaris (at least).
However, some Linux distributions micro-package, so locales defined by
@@ -4449,6 +4505,15 @@
@uref{http://en.cppreference.com/w/} and compare what is defined in the
various standards.
+Both the compiler and OS (@emph{via} system header files, which differ
+by architecture even for nominally the same OS) affect the compilability
+of C/C++ code. Compilers from the GCC, @command{clang}, Intel and
+Solaris Studio suites are routinely used with @R{}, and both
+@command{clang} and Solaris have more than one implementation of C++
+headers and library. The range of possibilities makes comprehensive
+empirical checking impossible, and regrettably compilers are patchy at
+best on warning about non-standard code.
+
@itemize
@item
Mathematical functions such as @code{sqrt} are defined in C++ for
@@ -4457,13 +4522,21 @@
and possibly more. This means that calling @code{sqrt} on an integer
type may have `overloading ambiguity' as it could be promoted to any of
the supported floating-point types: this is commonly seen on Solaris,
-but for @code{pow} also seen on OS X. (C++11 requires additional
-overloads for integer types.)
+but for @code{pow} also seen on OS X. (C++98 has an overload for
+@code{std::pow(, )}, but this may not be visible from the
+main namespace. C++11 requires additional overloads for integer types,
+and ambiguous overloads are more common in C++11 (and later) compiler
+modes.)
A not-uncommonly-seen problem is to mistakenly call @code{floor(x/y)} or
@code{ceil(x/y)} for @code{int} arguments @code{x} and @code{y}. Since
@code{x/y} does integer division, the result is an @code{int} and
-`overloading ambiguity' may be reported.
+`overloading ambiguity' may be reported. Some people have (pointlessly)
+called @code{floor} and @code{ceil} on integer arguments, which may have
+an `overloading ambiguity'.
+
+A surprising common misuse is things like @code{pow(10, -3)}: this
+should be the constant @code{1e-3}.
@item
Function @code{fabs} is defined only for floating-point types, except in
@@ -4472,7 +4545,7 @@
@file{} for @code{int} and in C++98's @file{} for
integer types, overloaded in @file{} for floating-point types.
C++11 has additional overloads for @code{std::abs} in @file{} for
-integer types. The effect of calling @code{abs} for a floating-point
+integer types. The effect of calling @code{abs} with a floating-point
type is implementation-specific: it may truncate to an integer.
@item
@@ -4483,11 +4556,23 @@
currently in use on @R{} platforms: use @R{}'s versions such as
@code{ISNAN} and @code{R_FINITE} instead.
+If you must use them in C++11, beware that some
+compilers@footnote{E.g. @command{gcc 5.3} in C++11 mode.} provide both
+@code{std::isnan} and @code{::isnan}, so using
+
+@example
+using namespace std;
+@end example
+
+@noindent
+may cause `overloading ambiguity' and you must use @code{std::isnan}
+@emph{etc} explicitly.
+
It is an error (and make little sense, although has been seen) to call
these functions for integer arguments.
@item
-The GNU compilers have a large number of non-portable extensions. For
+The GNU compilers support a large number of non-portable extensions. For
example, @code{INFINITY} (which is in C99 but not C++98), for which @R{}
provides the portable @code{R_PosInf} (and @code{R_NegInf} for
@code{-INFINITY}). And @code{NAN} is just one NaN value: in @R{} code
@@ -4499,19 +4584,29 @@
@uref{https://gcc.gnu.org/@/onlinedocs/@/gcc/@/C_002b_002b-Extensions.html}.
@item
-Including C headers in C++ code is not portable. Including the C
-header @file{math.h} in C++ code often causes conflicts with
-@file{cmath} which may be included by other headers. This is
-particularly problematic with C++11 compilers, as functions like
-@code{sqrt} and @code{isnan} are defined for @code{double} arguments in
-@file{math.h} and for a range of types including @code{double} in
-@file{cmath}.
+Including C-style headers in C++ code is not portable. Including the
+legacy header@footnote{which often is the same as the header included by
+the C compiler, but some compilers have wrappers for some of the C
+headers.} @file{math.h} in C++ code may conflict with @file{cmath} which
+may be included by other headers. This is particularly problematic with
+C++11 compilers, as functions like @code{sqrt} and @code{isnan} are
+defined for @code{double} arguments in @file{math.h} and for a range of
+types including @code{double} in @file{cmath}. Similar issues have been
+seen for @file{stdlib.h} and @file{cstdlib}. Historically, including
+the C++ version first was a sufficient workaround but for some 2016
+compilers only one can be included.
@item
Variable-length arrays are C99, not supported by C++98 nor by the C++
compilers in use with @R{} on some platforms.
@item
+The @code{restrict} qualifier is C99/C11 but not part of C++11 and not
+supported by some C++ compilers used with @R{}.
+@c but package treatSens attempted to use it.
+@c http://stackoverflow.com/questions/6434549/does-c11-add-the-c99-restrict-specifier-if-not-why-not
+
+@item
Be careful to include the headers which define the functions you use.
Some compilers/OSes include other system headers in their headers which
are not required by the standards, and so code may compile on such
@@ -4519,7 +4614,11 @@
@code{} which is indirectly included by @code{} by
@command{g++}. Another frequent issue is the C header @code{}
which is included by other headers on Linux and Windows but not OS X nor
-Solaris.)
+Solaris.) Another common issue is that @code{malloc}, @code{calloc},
+@code{realloc} and @code{free} are defined by C99 in the header
+@file{stdlib.h} and (in the @code{std::} namespace) by C++ header
+@file{cstdlib}. Some earlier implementations used a header
+@file{malloc.h}, but that is not portable and does not exist on OS X.
@item
For C++ code, be careful to specify namespaces where needed. Many
@@ -4542,7 +4641,9 @@
as @code{CS}, @code{DS}, @code{ES}, @code{FS}, @code{GS} and @code{SS}
(and more with longer abbreviations) defined on i586/x64 Solaris in
@file{} and often included indirectly by @file{}
-and other core headers.
+and other core headers. Further examples are @code{ERR}, @code{zero}
+and @code{I} (which is defined in Solaris' @file{} as a
+compiler intrinsic for the imaginary unit).
@item
@code{typedef}s in OS headers can conflict with those in the package: an
@@ -5446,18 +5547,18 @@
Finally, there is @code{\donttest}, used (at the beginning of a separate
line) to mark code that should be run by @code{example()} but not by
-@code{R CMD check} (by default: as from @R{} 3.2.0 the option
-@option{--run-donttest} can be used). This should be needed only
-occasionally but can be used for code which might fail in circumstances
-that are hard to test for, for example in some locales. (Use
-e.g. @code{capabilities()} or @code{nzchar(Sys.which("someprogram"))} to
-test for features needed in the examples wherever possible, and you can
-also use @code{try()} or @code{tryCatch()}. Use @code{interactive()} to
-condition examples which need someone to interact with.) Note that code
-included in @code{\donttest} must be correct @R{} code, and any packages
-used should be declared in the @file{DESCRIPTION} file. It is good
-practice to include a comment in the @code{\donttest} section explaining
-why it is needed.
+@code{R CMD check} (by default: the option @option{--run-donttest} can
+be used). This should be needed only occasionally but can be used for
+code which might fail in circumstances that are hard to test for, for
+example in some locales. (Use e.g. @code{capabilities()} or
+@code{nzchar(Sys.which("someprogram"))} to test for features needed in
+the examples wherever possible, and you can also use @code{try()} or
+@code{tryCatch()}. Use @code{interactive()} to condition examples which
+need someone to interact with.) Note that code included in
+@code{\donttest} must be correct @R{} code, and any packages used should
+be declared in the @file{DESCRIPTION} file. It is good practice to
+include a comment in the @code{\donttest} section explaining why it is
+needed.
@findex \keyword
@item \keyword@{@var{key}@}
@@ -6035,8 +6136,8 @@
expert form), the following could be used:
@example
-\if@{html@}@{\figure@{logo.jpg@}@{Our logo@}@}
-\if@{latex@}@{\figure@{logo.jpg@}@{options: width=0.5in@}@}
+\if@{html@}@{\figure@{Rlogo.svg@}@{options: width=100 alt="R logo"@}@}
+\if@{latex@}@{\figure@{Rlogo.pdf@}@{options: width=0.5in@}@}
@end example
The files containing the figures should be stored in the directory
@@ -7748,13 +7849,11 @@
@command{AddressSanitizer} (`ASan') is a tool with similar aims to the
memory checker in @command{valgrind}. It is available with suitable
builds@footnote{currently only on @cputype{ix86}/@cputype{x86_64} Linux
-and OS X (including the builds in Xcode 7 beta but not earlier Apple
-releases). On some platforms, e.g.@: Fedora, the runtime library,
-@pkg{libasan}, needs to be installed separately. OS X users can install
-a suitable @command{clang} from the sources,
-@url{http://llvm.org/releases/} or possibly distributions such as
-MacPorts or Homebrew.} of @command{gcc} and @command{clang} on common
-Linux and OS X platforms. See
+and OS X (including the builds in Xcode 7 but not earlier Apple
+releases). On some platforms the runtime library, @pkg{libasan}, needs
+to be installed separately, and for checking C++ you may also need
+@pkg{libubsan}.} of @command{gcc} and @command{clang} on common Linux
+and OS X platforms. See
@uref{http://clang.llvm.org/@/docs/@/UsersManual.html#controlling-code-generation},
@uref{http://clang.llvm.org/@/docs/@/AddressSanitizer.html} and
@uref{https://code.google.com/@/p/@/address-sanitizer/}.
@@ -7809,10 +7908,10 @@
into the @R{} executable. However this check can be enabled on a
per-package basis by using a @file{~/.R/Makevars} file like
@example
-CC = gcc-4.9 -std=gnu99 -fsanitize=address -fno-omit-frame-pointer
-CXX = g++-4.9 -fsanitize=address -fno-omit-frame-pointer
-F77 = gfortran-4.9 -fsanitize=address
-FC = gfortran-4.9 -fsanitize=address
+CC = gcc -std=gnu99 -fsanitize=address -fno-omit-frame-pointer
+CXX = g++ -fsanitize=address -fno-omit-frame-pointer
+F77 = gfortran -fsanitize=address
+FC = gfortran -fsanitize=address
@end example
(Note that @code{-fsanitize=address} has to be part of the compiler
specification to ensure it is used for linking. These settings will not
@@ -7895,14 +7994,15 @@
might be @code{NA_INTEGER}.
`UBSanitizer' is a tool for C/C++ source code selected by
-@option{-fsanitize=undefined} in suitable builds of @command{clang}, and
-GCC as from 4.9.0. Its (main) runtime library is linked into each
-package's DLL, so it is less often needed to be included in
-@env{MAIN_LDFLAGS}.
+@option{-fsanitize=undefined} in suitable builds@footnote{On some
+platforms the runtime library, @pkg{libubsan}, needs to be installed
+separately.} of @command{clang} and GCC. Its (main) runtime library is
+linked into each package's DLL, so it is less often needed to be
+included in @env{MAIN_LDFLAGS}.
Some versions have greatly increased compilation times on a few
files@footnote{e.g.@: @file{src/main/dotcode.c} and parts of the
-@pkg{Matrix} sources with @command{clang} 3.7.0).}.
+@pkg{Matrix} sources with @command{clang} 3.7.0 amd later.}.
This sanitizer can be combined with the Address Sanitizer by
@option{-fsanitize=undefined,address} (where both are supported).
@@ -7950,15 +8050,20 @@
could try building @R{} with something like
@example
MAIN_LD="clang++ -fsanitize=undefined"
+@end example
+@noindent
+and perhaps for @command{clang} 3.7.x
+@example
R_OPENMP_CFLAGS="-fopenmp=libomp"
@end example
+@noindent
or add @code{-lclang_rt.asan_cxx-x86_64}@footnote{This includes the C++
UBSAN handlers, despite its name.} or similar to @code{LD_FLAGS}).
See @uref{https://gcc.gnu.org/@/onlinedocs/@/gcc/@/Debugging-Options.html} (or
the manual for your version of GCC, installed or @emph{via}
@uref{https://gcc.gnu.org/@/onlinedocs/}) for the options supported by
-GCC: 5.2.0 supports
+GCC: 5.3 supports
@example
-fsanitize=alignment,bool,bounds,enum,float-cast-overflow,
integer-divide-by-zero,non-null-attribute,null,object-size,
@@ -7976,6 +8081,13 @@
and @code{vptr} checks produced many warnings on GCC's own C++ headers,
so should be disabled.
+GCC 6 will add
+@example
+-fsanitize=bounds-strict
+@end example
+@noindent
+an extension of @code{bounds} to `flexible array member-like arrays'.
+
Other useful flags include
@example
@@ -8873,14 +8985,6 @@
as.integer(m), as.integer(n))$p
@end example
-
-@c These tools are not currently operational.
-@c Additionally, there are (experimental) tools that can be used to
-@c automate the generation of the code to register the routines for a
-@c collection of C files. See the @code{GccTranslationUnit} module on the
-@c Omegahat Web site at @uref{http://www.omegahat.org/GccTranslationUnit/}
-@c for more information.
-
@menu
* Speed considerations::
* Linking to native routines in other packages::
@@ -9242,13 +9346,29 @@
contained calls to C++ I/O upset @R{}'s own C I/O (for example by
resetting buffers on open files).
-Most @R{} header files can be included within C++ programs, and they
+Most @R{} header files can be included within C++ programs but they
should @strong{not} be included within an @code{extern "C"} block (as
-they include C++ system headers). It may not be possible to include
-some @R{} headers as they in turn include C header files that may cause
-conflicts---if this happens, define @samp{NO_C_HEADERS} before including
-the @R{} headers, and include C++ versions (such as @samp{cmath}) of the
-appropriate headers yourself before the @R{} headers.
+they include system headers@footnote{Even including C system headers in
+such a block has caused compilation errors.}). It may not be possible
+to include some @R{} headers as they in turn include system header files
+that may cause conflicts---if this happens, try defining
+@samp{NO_C_HEADERS} before including the @R{} headers, and include C++
+versions (such as @samp{cmath} and @samp{cstdlib}) of the appropriate
+headers yourself before the @R{} headers. (Headers @file{R.h} and
+@file{Rmath.h} support @samp{NO_C_HEADERS}: the legacy header @file{S.h}
+does not. Header @file{Rinternals.h} does as from @R{} 3.3.0.)
+
+By default header @file{Rmath.h} includes @file{math.h} or @file{cmath}.
+Header @file{R.h} includes
+
+@example
+limits.h math.h stddef.h stdio.h stdlib.h string.h
+@end example
+
+@noindent
+or their C++ equivalents directly or indirectly, and either
+@file{stddef.h} or @file{cstddef} needs to be included before @file{R.h}
+if @samp{NO_C_HEADERS} is defined.
@node Fortran I/O, Linking to other packages, Interfacing C++ code, System and foreign language interfaces
@section Fortran I/O
@@ -9505,7 +9625,8 @@
a set of functions and macros defined in the header file
@file{Rinternals.h} or some @Sl{}-compatibility macros@footnote{That is,
similar to those defined in @Sl{} version 4 from the 1990s: these are
-not kept up to date and are not recommended for new projects.} defined
+not kept up to date and are not recommended for new projects. Prior to
+@R{} 3.3.0 it was not compatible with defining @code{R_NO_REMAP}.} defined
in @file{Rdefines.h}. See @ref{Interface functions .Call and .External}
for details on @code{.Call} and @code{.External}.
@@ -11245,8 +11366,9 @@
that your code compiles without @samp{USE_RINTERNALS} defined, as this
provides a stricter test that the accessors have been used correctly.
Note too that the use of @samp{USE_RINTERNALS} when the header is
-included in C++ code is not supported: doing so uses C99 features which
-are not necessarily in C++.
+included in C++ code is not supported: doing so may use C99 features
+which are not necessarily supported by the C++ compiler. Nor is use
+with @file{Rdefines.h} supported.
@node Character encoding issues, , Vector accessor functions, System and foreign language interfaces
@section Character encoding issues
@@ -11361,19 +11483,8 @@
there that can be included too, but many of the features they contain
should be regarded as undocumented and unstable.
-An alternative is to include the header file @file{S.h}, which may be
-useful when porting code from @Sl{}. This includes rather less than
-@file{R.h}, and has some extra compatibility definitions (for example
-the @code{S_complex} type from @Sl{}).
-
-The defines used for compatibility with @Sl{} sometimes causes
-conflicts (notably with Windows headers), and the known
-problematic defines can be removed by defining @code{STRICT_R_HEADERS}.
-
Most of these header files, including all those included by @file{R.h},
-can be used from C++ code. Some others need to be included within an
-@code{extern "C"} declaration, and for clarity this is advisable for all
-@R{} header files.
+can be used from C++ code.
@quotation Note
Because @R{} re-maps many of its external names to avoid clashes with
@@ -12125,26 +12236,35 @@
This might be provided by your platform@footnote{It is an optional C11
extension.}, in which case it is not included in @file{Rmath.h}, but is
-in @file{math.h} which @file{Rmath.h} includes.
+in @file{math.h} which @file{Rmath.h} includes. (Ensure that
+neither @file{math.h} nor @file{cmath} is included before
+@file{Rmath.h} or define
+@example
+#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
+@end example
+@noindent
+before the first inclusion.)
@end deftypefun
@deftypefun double sinpi (double @var{x})
Computes @code{sin(pi * x)} accurately, notably for (half) integer @var{x}.
-This might be provided by your platform, in which case it is not included
-in @file{Rmath.h}, but is in @file{math.h} which @file{Rmath.h} includes.
+This might be provided by your platform, in which case it is not
+included in @file{Rmath.h}, but is in @file{math.h} which @file{Rmath.h}
+includes (but see the comments for @code{cospi}).
@end deftypefun
@deftypefun double tanpi (double @var{x})
Computes @code{tan(pi * x)} accurately, notably for (half) integer @var{x}.
This might be provided by your platform, in which case it is not included
-in @file{Rmath.h}, but is in @file{math.h} which @file{Rmath.h} includes.
+in @file{Rmath.h}, but is in @file{math.h} which @file{Rmath.h} includes
+(but see the comments for @code{cospi}).
@end deftypefun
@deftypefun double logspace_add (double @var{logx}, double @var{logy})
@deftypefunx double logspace_sub (double @var{logx}, double @var{logy})
-@deftypefunx double logspace_sum (double* @var{logx}, int @var{n})
+@deftypefunx double logspace_sum (const double* @var{logx}, int @var{n})
Compute the log of a sum or difference from logs of terms, i.e., ``x +
y'' as @code{log (exp(@var{logx}) + exp(@var{logy}))} and ``x - y'' as
@code{log (exp(@var{logx}) - exp(@var{logy}))},
@@ -12434,16 +12554,21 @@
The following is declared in header file @file{Rinternals.h}.
@deftypefun void R_orderVector (int* @var{indx}, int @var{n}, SEXP @var{arglist}, Rboolean @var{nalast}, Rboolean @var{decreasing})
+@deftypefunx void R_orderVector1 (int* @var{indx}, int @var{n}, SEXP @var{x}, Rboolean @var{nalast}, Rboolean @var{decreasing})
-This corresponds to @R{}'s @code{order(..., na.last, decreasing)}.
+@code{R_orderVector()} corresponds to @R{}'s @code{order(..., na.last, decreasing)}.
More specifically, @code{indx <- order(x, y, na.last, decreasing)} corresponds to
@code{R_orderVector(indx, n, Rf_lang2(x, y), nalast, decreasing)} and for
three vectors, @code{Rf_lang3(x,y,z)} is used as @var{arglist}.
-Note that @code{R_orderVector()} assumes the vector @code{indx}
-to be allocated to length @eqn{\ge n, >= n}. On return, @code{indx[]}
-contains a permutation of @code{0:(n-1)}, i.e., 0-based C indices (and not
-1-based @R{} indices, as @R{}'s @code{order()}).
+Both @code{R_orderVector} and @code{R_orderVector1} assume the vector
+@code{indx} to be allocated to length @eqn{\ge n, >= n}. On return,
+@code{indx[]} contains a permutation of @code{0:(n-1)}, i.e., 0-based C
+indices (and not 1-based @R{} indices, as @R{}'s @code{order()}).
+
+When ordering only one vector, @code{R_orderVector1} is faster and
+corresponds (but is 0-based) to @R{}'s @code{indx <- order(x, na.last,
+decreasing)}. It was added in @R{} 3.3.0.
@end deftypefun
All other sort routines are declared in header file
@@ -12513,6 +12638,7 @@
@end deftypefun
@deftypefun int findInterval (double* @var{xt}, int @var{n}, double @var{x}, Rboolean @var{rightmost_closed}, Rboolean @var{all_inside}, int @var{ilo}, int* @var{mflag})
+@deftypefunx int findInterval2(double* @var{xt}, int @var{n}, double @var{x}, Rboolean @var{rightmost_closed}, Rboolean @var{all_inside}, Rboolean @var{left_open}, int @var{ilo}, int* @var{mflag})
Given the ordered vector @var{xt} of length @var{n}, return the interval
or index of @var{x} in @code{@var{xt}[]}, typically max(@math{i}; @eqn{1
\le i \le @var{n}, 1 <= i <= @var{n}} & @math{@var{xt}[i]} @eqn{\le, <=}
@@ -12528,6 +12654,12 @@
result of @code{findInterval()} and @var{x} is a value of a sequence which
is increasing or decreasing for subsequent calls.
+@code{findInterval2()} is a generalization of @code{findInterval()},
+with an extra @code{Rboolean} argument @var{left_open}. Setting
+@code{left_open = TRUE} basically replaces all left-closed right-open
+intervals @eqn{[s, t)} by left-open ones @eqn{(s, t]}, see the help page
+of @R{} function @code{findInterval} for details.
+
There is also an @code{F77_CALL(interv)()} version of
@code{findInterval()} with the same arguments, but all pointers.
@end deftypefun
@@ -12639,12 +12771,8 @@
The macro @code{WORDS_BIGENDIAN} is defined on
big-endian@footnote{@uref{https://en.wikipedia.org/@/wiki/@/Endianness}.}
systems (e.g.@: most OSes on Sparc and PowerPC hardware) and not on
-little-endian systems (such as @code{i686} and @code{x86_64} on all
-OSes, and Linux on Alpha and Itanium). It can be useful when
-manipulating binary files. The macro @code{SUPPORT_OPENMP} is defined
-on suitable systems and can be used in conjunction with the
-@code{SUPPORT_OPENMP_*} macros in packages that want to make use of
-OpenMP.
+little-endian systems (nowadays all the commoner @R{} platforms). It
+can be useful when manipulating binary files.
Header file @file{Rversion.h} (@strong{not} included by @file{R.h})
defines a macro @code{R_VERSION} giving the version number encoded as an
@@ -12667,8 +12795,8 @@
version includes the patchlevel (as in @samp{2.2}).
Packages which use @code{alloca} need to ensure it is defined: as it is
-neither C99 nor POSIX there is no standard way to do so. As from @R{}
-3.2.2 one can use
+part of neither C nor POSIX there is no standard way to do so. As
+from @R{} 3.2.2 one can use
@example
#include // for HAVE_ALLOCA_H
@@ -12692,11 +12820,11 @@
@section Inlining C functions
@findex R_INLINE
-The C99 keyword @code{inline} should be recognized by all compilers now
-used to build @R{}. Portable code which might be used with earlier
-versions of @R{} can be written using the macro @code{R_INLINE} (defined
-in file @file{Rconfig.h} included by @file{R.h}), as for example from
-package @CRANpkg{cluster}
+The C99 keyword @code{inline} should be recognized by all compilers
+nowadays used to build @R{}. Portable code which might be used with
+earlier versions of @R{} can be written using the macro @code{R_INLINE}
+(defined in file @file{Rconfig.h} included by @file{R.h}), as for
+example from package @CRANpkg{cluster}
@example
#include
@@ -13722,9 +13850,9 @@
Recent versions have usage restrictions.
@item
-Another (D)COM server, @code{RDCOMServer}, is available from
-@uref{http://www.omegahat.org/}. Its philosophy is discussed in
-@uref{http://www.omegahat.org/@/RDCOMServer/@/Docs/@/Paradigm.html} and is
+Another (D)COM server, @code{RDCOMServer}, may be available from Omegahat,
+@uref{http://www.omegahat.net/}. Its philosophy is discussed in
+@uref{http://www.omegahat.net/@/RDCOMServer/@/Docs/@/Paradigm.html} and is
very different from the purpose of this section.
@end itemize
@node Calling R.dll directly, Finding R_HOME, Using (D)COM, Embedding R under Windows
diff -Nru r-base-3.2.3/doc/manual/R-FAQ.texi r-base-3.3.1/doc/manual/R-FAQ.texi
--- r-base-3.2.3/doc/manual/R-FAQ.texi 2015-12-04 23:15:10.000000000 +0000
+++ r-base-3.3.1/doc/manual/R-FAQ.texi 2016-06-14 22:15:06.000000000 +0000
@@ -4,14 +4,9 @@
@setfilename R-FAQ.info
@settitle R FAQ
@setchapternewpage on
-@set FAQ_YEAR 2015
-@set FAQ_DATE @value{FAQ_YEAR}-12-04
-@set REL_YEAR 2015
-@set REL_MAJOR 3
-@set REL_MINOR 2
-@set REL_PATCHLEVEL 3
-@set REL_VERSION @value{REL_MAJOR}.@value{REL_MINOR}.@value{REL_PATCHLEVEL}
-@set FAQ_VERSION @value{REL_MAJOR}.@value{REL_MINOR}.@value{FAQ_DATE}
+@set FAQ_YEAR 2016
+@set FAQ_DATE @value{FAQ_YEAR}-04-24
+@set FAQ_VERSION @value{FAQ_DATE}
@documentlanguage en
@documentencoding ISO-8859-1
@c %**end of header
@@ -177,7 +172,7 @@
@@Misc@{,
author = @{Kurt Hornik@},
title = @{@{R@} @{FAQ@}@},
- year = @{@value{REL_YEAR}@},
+ year = @{@value{FAQ_YEAR}@},
url = @{https://CRAN.R-project.org/doc/FAQ/R-FAQ.html@}
@}
@end group
@@ -315,12 +310,15 @@
@node What is the current version of R?, How can R be obtained?, What machines does R run on?, R Basics
@section What is the current version of R?
-The current released version is @value{REL_VERSION}. Based on this
-`major.minor.patchlevel' numbering scheme, there are two development
-versions of R, a patched version of the current release (`r-patched')
-and one working towards the next minor or eventually major (`r-devel')
-releases of R, respectively. Version r-patched is for bug fixes mostly.
-New features are typically introduced in r-devel.
+R uses a `major.minor.patchlevel' numbering scheme. Based on this,
+there are the current release version of R (`r-release') as well as two
+development versions of R, a patched version of the current release
+(`r-patched') and one working towards the next minor or eventually major
+(`r-devel') releases of R, respectively. New features are typically
+introduced in r-devel, while r-patched is for bug fixes mostly.
+
+See @url{https://CRAN.R-project.org/sources.html} for the current
+versions of r-release, r-patched and r-devel.
@node How can R be obtained?, How can R be installed?, What is the current version of R?, R Basics
@section How can R be obtained?
@@ -475,9 +473,9 @@
@subsection How can R be installed (Mac)
The @file{bin/macosx} directory of a @CRAN{} site contains a standard
-Apple installer package to run on OS X 10.6 (`Snow Leopard') and later.
+Apple installer package to run on OS X 10.9 (`Mavericks') and later.
Once downloaded and executed, the installer will install the current
-release of R and an R.app OS X @acronym{GUI}. This port of R for OS X
+release of R and R.app, the OS X @acronym{GUI}. This port of R for OS X
is maintained by @email{Simon.Urbanek@@R-project.org, Simon Urbanek}
(and previously by Stefano Iacus). The
@url{https://CRAN.R-project.org/bin/macosx/RMacOSX-FAQ.html, ``R for Mac
@@ -673,11 +671,14 @@
author = @{@{R Core Team@}@},
organization = @{R Foundation for Statistical Computing@},
address = @{Vienna, Austria@},
- year = @value{REL_YEAR},
+ year = @var{YEAR},
url = @{https://www.R-project.org@}
@}
@end group
@end example
+@noindent
+where @var{YEAR} is the release year of the version of R used and can
+determined as @code{R.version$year}.
Citation strings (or Bib@TeX{} entries) for R and R packages can also be
obtained by @code{citation()}.
@@ -793,6 +794,9 @@
documentation on R, existing mailing lists and the R Bug Tracking
system.
+Since March 2016, ``old'' material is made available from a central
+@CRAN{} archive server (@url{https://CRAN-archive.R-project.org/}).
+
Please always use the @acronym{URL} of the master site when referring to
@CRAN{}.
@@ -1573,8 +1577,8 @@
permissions. David's paper ``CGIwithR: Facilities for Processing Web
Forms Using R'' was published in the Journal of Statistical Software
(@url{http://www.jstatsoft.org/v08/i10/}). The package is now
-maintained by @email{duncan@@wald.ucdavis.edu, Duncan Temple Lang} and
-has a web page at @url{http://www.omegahat.org/CGIwithR/}.
+maintained by @email{duncan@@wald.ucdavis.edu, Duncan Temple Lang}.
+and has a web page at @url{http://www.omegahat.net/CGIwithR/}.
@c See
@c Link to web page no longer works.
@@ -1799,12 +1803,12 @@
@node Add-on packages from Omegahat, Add-on packages from Bioconductor, Add-on packages from CRAN, Which add-on packages exist for R?
@subsection Add-on packages from Omegahat
-The @url{http://www.omegahat.org/, Omega Project for Statistical
+The @url{http://www.omegahat.net/, Omega Project for Statistical
Computing} provides a variety of open-source software for statistical
applications, with special emphasis on web-based software, Java, the
Java virtual machine, and distributed computing. A @acronym{CRAN} style
-R package repository is available via @url{http://www.omegahat.org/R/}.
-See @url{http://www.omegahat.org/} for information on most R packages
+R package repository is available via @url{http://www.omegahat.net/R/}.
+See @url{http://www.omegahat.net/} for information on most R packages
available from the Omega project.
@node Add-on packages from Bioconductor, Other add-on packages, Add-on packages from Omegahat, Which add-on packages exist for R?
@@ -2207,6 +2211,7 @@
* Why does summary() report strange results for the R^2 estimate when I fit a linear model with no intercept?::
* Why is R apparently not releasing memory?::
* How can I enable secure https downloads in R?::
+* How can I get CRAN package binaries for outdated versions of R?::
@end menu
@c @node Why does R run out of memory?, Why does sourcing a correct file fail?, R Miscellanea, R Miscellanea
@@ -3352,7 +3357,7 @@
query the allocator about the layout of the allocations, including the
actually used memory as well as unused memory that cannot be released.
-@node How can I enable secure https downloads in R?, , Why is R apparently not releasing memory?, R Miscellanea
+@node How can I enable secure https downloads in R?, How can I get CRAN package binaries for outdated versions of R?, Why is R apparently not releasing memory?, R Miscellanea
@section How can I enable secure https downloads in R?
@c This should be re-phrased for 3.3.0.
@@ -3372,8 +3377,10 @@
The requisite code to add to @file{.Rprofile} or @file{Rprofile.site} is:
@example
-options(download.file.method = "wininet", url.method = "wininet") @r{(Windows)}
-options(download.file.method = "libcurl", url.method = "libcurl") @r{(Linux and OS X)}
+options(download.file.method = "wininet", url.method = "wininet")
+@r{(Windows)}
+options(download.file.method = "libcurl", url.method = "libcurl")
+@r{(Linux and OS X)}
@end example
@noindent
@@ -3388,6 +3395,22 @@
@code{"libcurl"} with @acronym{HTTPS} support is required except on
Windows.
+@node How can I get CRAN package binaries for outdated versions of R?, , How can I enable secure https downloads in R?, R Miscellanea
+@section How can I get CRAN package binaries for outdated versions of R?
+
+Since March 2016, Windows and OS X binaries of @CRAN{} packages for old
+versions of R (released more than 5 years ago) are made available from a
+central @CRAN{} archive server instead of the @CRAN{} mirrors. To get
+these, one should set the @CRAN{} ``mirror'' element of the @code{repos}
+option accordingly, by something like
+@example
+local(@{r <- getOption("repos")
+ r["CRAN"] <- "http://CRAN-archive.R-project.org"
+ options(repos = r)
+ @})
+@end example
+@noindent
+(see @code{?options} for more information).
@node R Programming, R Bugs, R Miscellanea, Top
@chapter R Programming
diff -Nru r-base-3.2.3/doc/manual/R-intro.texi r-base-3.3.1/doc/manual/R-intro.texi
--- r-base-3.2.3/doc/manual/R-intro.texi 2015-12-03 23:15:23.000000000 +0000
+++ r-base-3.3.1/doc/manual/R-intro.texi 2016-06-09 22:15:05.000000000 +0000
@@ -6504,8 +6504,8 @@
packages) are distributed with every binary distribution of @R{}. Most
are available for download from @acronym{CRAN}
(@uref{https://CRAN.R-project.org/} and its mirrors) and other
-repositories such as Bioconductor (@uref{https://www.bioconductor.org/})
-and Omegahat (@uref{http://www.omegahat.org/}). The @emph{R FAQ}
+repositories such as Bioconductor (@uref{https://www.bioconductor.org/}).
+and Omegahat (@uref{http://www.omegahat.net/}). The @emph{R FAQ}
contains a list of CRAN packages current at the time of release, but the
collection of available packages changes very frequently.
@@ -7536,9 +7536,12 @@
file @file{README.Rterm} for command-line editing under
@code{Rterm.exe}.
-When using @R{} with @strong{readline} capabilities, the functions
-described below are available, as well as others (probably) documented
-in @command{man readline} or @command{info readline} on your system.
+When using @R{} with GNU@footnote{It is possible to build @R{} using an
+emulation of GNU @strong{readline}, such as one based on NetBSD's
+@strong{editline}, it which case only a subset of the capabilities may
+be provided.} @strong{readline} capabilities, the functions described
+below are available, as well as others (probably) documented in
+@command{man readline} or @command{info readline} on your system.
Many of these use either Control or Meta characters. Control
characters, such as @kbd{Control-m}, are obtained by holding the
@@ -7554,6 +7557,10 @@
allowed on terminals with real Meta keys. Note that case is significant
for Meta characters.
+Some but not all versions@footnote{In particular, not versions 6.3 or
+later: this is worked around as from @R{} 3.4.0.} of @strong{readline}
+will recognize resizing of the terminal window so this is best avoided.
+
@appendixsection Editing actions
The @R{} program keeps a history of the command lines you type,
@@ -7583,7 +7590,8 @@
@item C-n
Go to the next command (forwards in the history).
@item C-r @var{text}
-Find the last command with the @var{text} string in it.
+Find the last command with the @var{text} string in it. This can be
+cancelled by @code{C-g} (and on some versions of @R{} by @code{C-c}).
@end table
On most terminals, you can also use the up and down arrow keys instead
diff -Nru r-base-3.2.3/doc/manual/R-ints.texi r-base-3.3.1/doc/manual/R-ints.texi
--- r-base-3.2.3/doc/manual/R-ints.texi 2015-11-27 23:15:10.000000000 +0000
+++ r-base-3.3.1/doc/manual/R-ints.texi 2016-05-19 22:15:05.000000000 +0000
@@ -540,7 +540,7 @@
There are additional places that `variables' can be looked up, called
`user databases' in comments in the code. These seem undocumented in
the @R{} sources, but apparently refer to the @pkg{RObjectTable} package
-at @uref{http://www.omegahat.org/RObjectTables/}.
+at @uref{http://www.omegahat.net/RObjectTables/}.
@cindex base environment
@cindex environment, base
@@ -611,7 +611,7 @@
@cindex namespace
Namespaces are environments associated with packages (and once again
the base package is special and will be considered separately). A
-package @code{@var{pkg}} with a namespace defines two environments
+package @code{@var{pkg}} defines two environments
@code{namespace:@var{pkg}} and @code{package:@var{pkg}}: it is
@code{package:@var{pkg}} that can be @code{attach}ed and form part of
the search path.
@@ -1428,20 +1428,20 @@
@node S4 methods, Mechanics of S4 dispatch, S4 classes, S4 objects
@subsection S4 methods
-Details of methods are stored in S4 objects of class
-@code{"MethodsList"}. They have a non-syntactic name of the form
-@code{.__M__@var{generic}:@var{package}} for all methods defined in the
-current environment for the named generic derived from a specific
-package (which might be @code{.GlobalEnv}).
-
-There is also environment @code{.__T__@var{generic}:@var{package}} which
-has names the signatures of the methods defined, and values the
-corresponding method functions. This is often referred to as a `methods
-table'.
-
-When a package without a namespace is attached these objects become
-visible on the search path. @code{library} calls
-@code{methods:::cacheMetaData} to update the internal tables.
+Details of the methods are stored in environments (typically hidden in the
+respective namespace) with a non-syntactic name of the form
+@code{.__T__@var{generic}:@var{package}} containing objects of class
+@code{MethodDefinition} for all methods defined in the current environment
+for the named generic derived from a specific package (which might be @code{.GlobalEnv}).
+This is sometimes referred to as a `methods table'.
+
+For example,
+@example
+ length(nM <- asNamespace("Matrix") ) # 941 for Matrix 1.2-6
+ length(meth <- grep("^[.]__T__", names(nM), value=TRUE))# 107 generics with methods
+ length(meth.Ops <- nM$`.__T__Ops:base`) # 71 methods for the 'Ops' (group)generic
+ head(sort(names(meth.Ops))) ## "abIndex#abIndex" ... "ANY#ddiMatrix" "ANY#ldiMatrix" "ANY#Matrix"
+@end example
During an @R{} session there is an environment associated with each
non-primitive generic containing objects @code{.AllMTable},
@@ -1456,8 +1456,8 @@
the namespace for a specified generic: the code also adds to the list
of generics any that are exported directly. For generics which are
listed via @code{exportMethods} or exported themselves, the
-corresponding @code{"MethodsList"} and environment are exported and so
-will appear (as hidden objects) in the package environment.
+corresponding environment is exported and so
+will appear (as hidden object) in the package environment.
Methods for primitives which are internally S4 generic (see below) are
always exported, whether mentioned in the @file{NAMESPACE} file or not.
@@ -1471,7 +1471,7 @@
generic could be imported from several different packages, the methods
tables are merged.
-When a package with a namespace is attached
+When a package is attached
@code{methods:::cacheMetaData} is called to update the internal tables:
only the visible methods will be cached.
@@ -1495,7 +1495,7 @@
paths, and which will be called depends on which search path is in use.
This is starkest for functions in the base namespace, where the
original will be found ahead of the newly created function from any
-other package with a namespace.
+other package.
Primitive functions are treated quite differently, for efficiency
reasons: this results in different semantics. @code{setGeneric} is
@@ -3855,8 +3855,8 @@
Default: -1.
@item _R_CHECK_XREFS_REPOSITORIES_
If set to a non-empty value, a space-separated list of repositories to
-use to determine known packages. Default: empty, when the CRAN,
-Omegahat and Bioconductor repositories known to @R{} is used.
+use to determine known packages. Default: empty, when the CRAN
+and Bioconductor repositories known to @R{} is used.
@item _R_CHECK_SRC_MINUS_W_IMPLICIT_
Control whether installation output is checked for compilation warnings
about implicit function declarations (as spotted by GCC with command
@@ -3920,17 +3920,19 @@
Default: false (but true for CRAN submission checks).
@item _R_CHECK_ALWAYS_LOG_VIGNETTE_OUTPUT_
By default the output from running the @R{} code in the vignettes is
-kept only if there is an error.
+kept only if there is an error. As from @R{} 3.2.4 this also applies to
+the @file{build_vignettes.log} log from the re-building of vignettes.
Default: false.
@item _R_CHECK_CLEAN_VIGN_TEST_
-Should the @file{vign_test} directory be removed if the test is successful?
+Should the @file{vign_test} directory be removed if the test is
+successful?
Default: true.
@item _R_CHECK_REPLACING_IMPORTS_
Should warnings about replacing imports be reported? These sometimes come
from auto-generated @file{NAMESPACE} files in other packages, but most
often from importing the whole of a namespace rather than using
@code{importFrom}.
-Default: false (but true for CRAN submission checks).
+Default: true.
@item _R_CHECK_UNSAFE_CALLS_
Check for calls that appear to tamper with (or allow tampering with)
already loaded code not from the current package: such calls may well
@@ -4070,6 +4072,11 @@
suggests and enhances.
Default: true (and true for CRAN submission checks).
+@item _R_CHECK_CODE_USAGE_WITH_ONLY_BASE_ATTACHED_
+If set, check code usage (via @CRANpkg{codetools}) with only the base
+package attached.
+Default: true.
+
@item _R_CHECK_EXIT_ON_FIRST_ERROR_
If set to a true value, the check will exit on the first error.
Default: false.
diff -Nru r-base-3.2.3/doc/manual/R-lang.texi r-base-3.3.1/doc/manual/R-lang.texi
--- r-base-3.2.3/doc/manual/R-lang.texi 2015-08-25 22:19:14.000000000 +0000
+++ r-base-3.3.1/doc/manual/R-lang.texi 2016-02-26 23:15:07.000000000 +0000
@@ -1360,10 +1360,8 @@
looping.@footnote{Looping is the repeated evaluation of a statement or
block of statements.} They are @code{for}, @code{while} and
@code{repeat}. The two built-in constructs, @code{next} and
-@code{break}, provide additional control over the evaluation. Each of
-the three statements returns the value of the last statement that was
-evaluated. It is possible, although uncommon, to assign the result of
-one of these statements to a symbol. @R{} provides other functions for
+@code{break}, provide additional control over the evaluation.
+@R{} provides other functions for
implicit looping such as @code{tapply}, @code{apply}, and @code{lapply}.
In addition many operations, especially arithmetic ones, are vectorized
so you may not need to use a loop.
diff -Nru r-base-3.2.3/doc/manual/rw-FAQ.texi r-base-3.3.1/doc/manual/rw-FAQ.texi
--- r-base-3.2.3/doc/manual/rw-FAQ.texi 2015-08-13 22:15:11.000000000 +0000
+++ r-base-3.3.1/doc/manual/rw-FAQ.texi 2016-06-09 22:15:05.000000000 +0000
@@ -536,9 +536,11 @@
@node Does R support automation?, The Internet download functions fail., Does R use the Registry?, Installation and Usage
@section Does R support automation (OLE, COM)?
-Directly, no. See packages such as @code{RDCOMClient} from
-@uref{http://www.omegahat.org/} and the non-Free project at
-@uref{http://www.statconn.com/}.
+Directly, no. See packages such as @code{RDCOMClient} from Omegahat
+(source and binary packages available from
+@uref{https://www.stats.ox.ac.uk/pub/RWin/})
+@c @uref{http://www.omegahat.net/}
+and the non-Free project at @uref{http://www.statconn.com/}.
@node The Internet download functions fail., Entering certain characters crashes Rgui., Does R support automation?, Installation and Usage
@section The Internet download functions fail.
@@ -1196,7 +1198,7 @@
For package @code{tcltk} to work (try @code{demo(tkdensity)} or
@code{demo(tkttest)} after @code{library(tcltk)}) you need to have Tcl/Tk
-installed. This part of the R installation, so it should be there.
+installed. This is part of the R installation, so it should be there.
However, if you have the environment variable @env{MY_TCLTK} set to a
non-empty value, it is assumed that you want to use a different Tcl/Tk
diff -Nru r-base-3.2.3/doc/NEWS r-base-3.3.1/doc/NEWS
--- r-base-3.2.3/doc/NEWS 2015-12-10 08:06:20.000000000 +0000
+++ r-base-3.3.1/doc/NEWS 2016-06-21 07:13:46.000000000 +0000
@@ -1,5 +1,731 @@
R News
+CHANGES IN R 3.3.1:
+
+ BUG FIXES:
+
+ * R CMD INSTALL and hence install.packages() gave an internal error
+ installing a package called description from a tarball on a
+ case-insensitive file system.
+
+ * match(x, t) (and hence x %in% t) failed when x was of length one,
+ and either character and x and t only differed in their Encoding
+ or when x and t where complex with NAs or NaNs. (PR#16885.)
+
+ * unloadNamespace(ns) also works again when ns is a 'namespace', as
+ from getNamespace().
+
+ * rgamma(1,Inf) or rgamma(1, 0,0) no longer give NaN but the
+ correct limit.
+
+ * length(baseenv()) is correct now.
+
+ * pretty(d, ..) for date-time d rarely failed when "halfmonth" time
+ steps were tried (PR#16923) and on 'inaccurate' platforms such as
+ 32-bit windows or a configuration with --disable-long-double; see
+ comment #15 of PR#16761.
+
+ * In text.default(x, y, labels), the rarely(?) used default for
+ labels is now correct also for the case of a 2-column matrix x
+ and missing y.
+
+ * as.factor(c(a = 1L)) preserves names() again as in R < 3.1.0.
+
+ * strtrim(""[0], 0[0]) now works.
+
+ * Use of Ctrl-C to terminate a reverse incremental search started
+ by Ctrl-R in the readline-based Unix terminal interface is now
+ supported for readline >= 6.3 (Ctrl-G always worked). (PR#16603)
+
+ * diff() now keeps the "units" attribute, as subtraction
+ already did, PR#16940.
+
+CHANGES IN R 3.3.0:
+
+ SIGNIFICANT USER-VISIBLE CHANGES:
+
+ * nchar(x, *)'s argument keepNA governing how the result for NAs in
+ x is determined, gets a new default keepNA = NA which returns NA
+ where x is NA, except for type = "width" which still returns 2,
+ the formatting / printing width of NA.
+
+ * All builds have support for https: URLs in the default methods
+ for download.file(), url() and code making use of them.
+
+ Unfortunately that cannot guarantee that any particular https:
+ URL can be accessed. For example, server and client have to
+ successfully negotiate a cryptographic protocol (TLS/SSL, ...)
+ and the server's identity has to be verifiable _via_ the
+ available certificates. Different access methods may allow
+ different protocols or use private certificate bundles: we
+ encountered a https: CRAN mirror which could be accessed by one
+ browser but not by another nor by download.file() on the same
+ Linux machine.
+
+ NEW FEATURES:
+
+ * The print method for methods() gains a byclass argument.
+
+ * New functions validEnc() and validUTF8() to give access to the
+ validity checks for inputs used by grep() and friends.
+
+ * Experimental new functionality for S3 method checking, notably
+ isS3method().
+
+ Also, the names of the R 'language elements' are exported as
+ character vector tools::langElts.
+
+ * str(x) now displays "Time-Series" also for matrix (multivariate)
+ time-series, i.e. when is.ts(x) is true.
+
+ * (Windows only) The GUI menu item to install local packages now
+ accepts *.tar.gz files as well as *.zip files (but defaults to
+ the latter).
+
+ * New programmeR's utility function chkDots().
+
+ * D() now signals an error when given invalid input, rather than
+ silently returning NA. (Request of John Nash.)
+
+ * formula objects are slightly more "first class": e.g., formula()
+ or new("formula", y ~ x) are now valid. Similarly, for "table",
+ "ordered" and "summary.table". Packages defining S4 classes with
+ the above S3/S4 classes as slots should be reinstalled.
+
+ * New function strrep() for repeating the elements of a character
+ vector.
+
+ * rapply() preserves attributes on the list when how = "replace".
+
+ * New S3 generic function sigma() with methods for extracting the
+ estimated standard deviation aka "residual standard deviation"
+ from a fitted model.
+
+ * news() now displays R and package news files within the HTML help
+ system if it is available. If no news file is found, a visible
+ NULL is returned to the console.
+
+ * as.raster(x) now also accepts raw arrays x assuming values in
+ 0:255.
+
+ * Subscripting of matrix/array objects of type "expression" is now
+ supported.
+
+ * type.convert("i") now returns a factor instead of a complex value
+ with zero real part and missing imaginary part.
+
+ * Graphics devices cairo_pdf() and cairo_ps() now allow non-default
+ values of the cairographics 'fallback resolution' to be set.
+
+ This now defaults to 300 on all platforms: that is the default
+ documented by cairographics, but apparently was not used by all
+ system installations.
+
+ * file() gains an explicit method argument rather than implicitly
+ using getOption("url.method", "default").
+
+ * Thanks to a patch from Tomas Kalibera, x[x != 0] is now typically
+ faster than x[which(x != 0)] (in the case where x has no NAs, the
+ two are equivalent).
+
+ * read.table() now always uses the names for a named colClasses
+ argument (previously names were only used when colClasses was too
+ short). (In part, wish of PR#16478.)
+
+ * (Windows only) download.file() with default method = "auto" and a
+ ftps:// URL chooses "libcurl" if that is available.
+
+ * The out-of-the box Bioconductor mirror has been changed to one
+ using https://: use chooseBioCmirror() to choose a http:// mirror
+ if required.
+
+ * The data frame and formula methods for aggregate() gain a drop
+ argument.
+
+ * available.packages() gains a repos argument.
+
+ * The undocumented switching of methods for url() on https: and
+ ftps: URLs is confined to method = "default" (and documented).
+
+ * smoothScatter() gains a ret.selection argument.
+
+ * qr() no longer has a ... argument to pass additional arguments to
+ methods.
+
+ * [ has a method for class "table".
+
+ * It is now possible (again) to replayPlot() a display list
+ snapshot that was created by recordPlot() in a different R
+ session.
+
+ It is still not a good idea to use snapshots as a persistent
+ storage format for R plots, but it is now not completely silly to
+ use a snapshot as a format for transferring an R plot between two
+ R sessions.
+
+ The underlying changes mean that packages providing graphics
+ devices (e.g., Cairo, RSvgDevice, cairoDevice, tikzDevice) will
+ need to be reinstalled.
+
+ Code for restoring snapshots was contributed by Jeroen Ooms and
+ JJ Allaire.
+
+ Some testing code is available at .
+
+ * tools::undoc(dir = D) and codoc(dir = D) now also work when D is
+ a directory whose normalizePath()ed version does not end in the
+ package name, e.g. from a symlink.
+
+ * abbreviate() has more support for multi-byte character sets - it
+ no longer removes bytes within characters and knows about Latin
+ vowels with accents. It is still only really suitable for (most)
+ European languages, and still warns on non-ASCII input.
+
+ abbreviate(use.classes = FALSE) is now implemented, and that is
+ more suitable for non-European languages.
+
+ * match(x, table) is faster (sometimes by an order of magnitude)
+ when x is of length one and incomparables is unchanged, thanks to
+ Peter Haverty (PR#16491).
+
+ * More consistent, partly not back-compatible behavior of NA and
+ NaN coercion to complex numbers, operations less often resulting
+ in complex NA (NA_complex_).
+
+ * lengths() considers methods for length and [[ on x, so it should
+ work automatically on any objects for which appropriate methods
+ on those generics are defined.
+
+ * The logic for selecting the default screen device on OS X has
+ been simplified: it is now quartz() if that is available even if
+ environment variable DISPLAY has been set by the user.
+
+ The choice can easily be overridden _via_ environment variable
+ R_INTERACTIVE_DEVICE.
+
+ * On Unix-like platforms which support the getline C library
+ function, system(*,intern = TRUE) no longer truncates (output)
+ lines longer than 8192 characters, thanks to Karl Millar.
+ (PR#16544)
+
+ * rank() gains a ties.method = "last" option, for convenience (and
+ symmetry).
+
+ * regmatches(invert = NA) can now be used to extract both
+ non-matched and matched substrings.
+
+ * data.frame() gains argument fix.empty.names; as.data.frame.list()
+ gets new cut.names, col.names and fix.empty.names.
+
+ * plot(x ~ x, *) now warns that it is the same as plot(x ~ 1, *).
+
+ * recordPlot() has new arguments load and attach to allow package
+ names to be stored as part of a recorded plot. replayPlot() has
+ new argument reloadPkgs to load/attach any package names that
+ were stored as part of a recorded plot.
+
+ * S4 dispatch works within calls to .Internal(). This means
+ explicit S4 generics are no longer needed for unlist() and
+ as.vector().
+
+ * Only font family names starting with "Hershey" (and not "Her" as
+ before) are given special treatment by the graphics engine.
+
+ * S4 values are automatically coerced to vector (via as.vector)
+ when subassigned into atomic vectors.
+
+ * findInterval() gets a left.open option.
+
+ * The version of LAPACK included in the sources has been updated to
+ 3.6.0, including those 'deprecated' routines which were
+ previously included. _Ca_ 40 double-complex routines have been
+ added at the request of a package maintainer.
+
+ As before, the details of what is included are in
+ src/modules/lapack/README and this now gives information on
+ earlier additions.
+
+ * tapply() has been made considerably more efficient without
+ changing functionality, thanks to proposals from Peter Haverty
+ and Suharto Anggono. (PR#16640)
+
+ * match.arg(arg) (the one-argument case) is faster; so is
+ sort.int(). (PR#16640)
+
+ * The format method for object_size objects now also accepts
+ "binary" units such as "KiB" and e.g., "Tb". (Partly from
+ PR#16649.)
+
+ * Profiling now records calls of the form foo::bar and some similar
+ cases directly rather than as calls to . Contributed
+ by Winston Chang.
+
+ * New string utilities startsWith(x, prefix) and endsWith(x,
+ suffix). Also provide speedups for some grepl("^...",*) uses
+ (related to proposals in PR#16490).
+
+ * Reference class finalizers run at exit, as well as on garbage
+ collection.
+
+ * Avoid parallel dependency on stats for port choice and random
+ number seeds. (PR#16668)
+
+ * The radix sort algorithm and implementation from data.table
+ (forder) replaces the previous radix (counting) sort and adds a
+ new method for order(). Contributed by Matt Dowle and Arun
+ Srinivasan, the new algorithm supports logical, integer (even
+ with large values), real, and character vectors. It outperforms
+ all other methods, but there are some caveats (see ?sort).
+
+ * The order() function gains a method argument for choosing between
+ "shell" and "radix".
+
+ * New function grouping() returns a permutation that stably
+ rearranges data so that identical values are adjacent. The
+ return value includes extra partitioning information on the
+ groups. The implementation came included with the new radix
+ sort.
+
+ * rhyper(nn, m, n, k) no longer returns NA when one of the three
+ parameters exceeds the maximal integer.
+
+ * switch() now warns when no alternatives are provided.
+
+ * parallel::detectCores() now has default logical = TRUE on all
+ platforms - as this was the default on Windows, this change only
+ affects Sparc Solaris.
+
+ Option logical = FALSE is now supported on Linux and recent
+ versions of OS X (for the latter, thanks to a suggestion of Kyaw
+ Sint).
+
+ * hist() for "Date" or "POSIXt" objects would sometimes give
+ misleading labels on the breaks, as they were set to the day
+ before the start of the period being displayed. The display
+ format has been changed, and the shift of the start day has been
+ made conditional on right = TRUE (the default). (PR#16679)
+
+ * R now uses a new version of the logo (donated to the R Foundation
+ by RStudio). It is defined in .svg format, so will resize
+ without unnecessary degradation when displayed on HTML
+ pages-there is also a vector PDF version. Thanks to Dirk
+ Eddelbuettel for producing the corresponding X11 icon.
+
+ * New function .traceback() returns the stack trace which
+ traceback() prints.
+
+ * lengths() dispatches internally.
+
+ * dotchart() gains a pt.cex argument to control the size of points
+ separately from the size of plot labels. Thanks to Michael
+ Friendly and Milan Bouchet-Valat for ideas and patches.
+
+ * as.roman(ch) now correctly deals with more diverse character
+ vectors ch; also arithmetic with the resulting roman numbers
+ works in more cases. (PR#16779)
+
+ * prcomp() gains a new option rank. allowing to directly aim for
+ less than min(n,p) PC's. The summary() and its print() method
+ have been amended, notably for this case.
+
+ * gzcon() gains a new option text, which marks the connection as
+ text-oriented (so e.g. pushBack() works). It is still always
+ opened in binary mode.
+
+ * The import() namespace directive now accepts an argument except
+ which names symbols to exclude from the imports. The except
+ expression should evaluate to a character vector (after
+ substituting symbols for strings). See Writing R Extensions.
+
+ * New convenience function Rcmd() in package tools for invoking R
+ CMD tools from within R.
+
+ * New functions makevars_user() and makevars_site() in package
+ tools to determine the location of the user and site specific
+ Makevars files for customizing package compilation.
+
+ UTILITIES:
+
+ * R CMD check has a new option --ignore-vignettes for use with
+ non-Sweave vignettes whose VignetteBuilder package is not
+ available.
+
+ * R CMD check now by default checks code usage (_via_ codetools)
+ with only the base package attached. Functions from default
+ packages other than base which are used in the package code but
+ not imported are reported as undefined globals, with a suggested
+ addition to the NAMESPACE file.
+
+ * R CMD check --as-cran now also checks DOIs in package CITATION
+ and Rd files.
+
+ * R CMD Rdconv and R CMD Rd2pdf each have a new option
+ --RdMacros=pkglist which allows Rd macros to be specified before
+ processing.
+
+ DEPRECATED AND DEFUNCT:
+
+ * The previously included versions of zlib, bzip2, xz and PCRE have
+ been removed, so suitable external (usually system) versions are
+ required (see the 'R Installation and Administration' manual).
+
+ * The unexported and undocumented Windows-only devices cairo_bmp(),
+ cairo_png() and cairo_tiff() have been removed. (These devices
+ should be used as e.g. bmp(type = "cairo").)
+
+ * (Windows only) Function setInternet2() has no effect and will be
+ removed in due course. The choice between methods "internal" and
+ "wininet" is now made by the method arguments of url() and
+ download.file() and their defaults can be set _via_ options. The
+ out-of-the-box default remains "wininet" (as it has been since R
+ 3.2.2).
+
+ * [<- with an S4 value into a list currently embeds the S4 object
+ into its own list such that the end result is roughly equivalent
+ to using [[<-. That behavior is deprecated. In the future, the
+ S4 value will be coerced to a list with as.list().
+
+ * Package tools' functions package.dependencies(), pkgDepends(),
+ etc are deprecated now, mostly in favor of package_dependencies()
+ which is both more flexible and efficient.
+
+ INSTALLATION and INCLUDED SOFTWARE:
+
+ * Support for very old versions of valgrind (e.g., 3.3.0) has been
+ removed.
+
+ * The included libtool script (generated by configure) has been
+ updated to version 2.4.6 (from 2.2.6a).
+
+ * libcurl version 7.28.0 or later with support for the https
+ protocol is required for installation (except on Windows).
+
+ * BSD networking is now required (except on Windows) and so
+ capabilities("http/ftp") is always true.
+
+ * configure uses pkg-config for PNG, TIFF and JPEG where this is
+ available. This should work better with multiple installs and
+ with those using static libraries.
+
+ * The minimum supported version of OS X is 10.6 ('Snow Leopard'):
+ even that has been unsupported by Apple since 2012.
+
+ * The configure default on OS X is --disable-R-framework: enable
+ this if you intend to install under /Library/Frameworks and use
+ with R.app.
+
+ * The minimum preferred version of PCRE has since R 3.0.0 been 8.32
+ (released in Nov 2012). Versions 8.10 to 8.31 are now deprecated
+ (with warnings from configure), but will still be accepted until
+ R 3.4.0.
+
+ * configure looks for C functions __cospi, __sinpi and __tanpi and
+ uses these if cospi _etc_ are not found. (OS X is the main
+ instance.)
+
+ * (Windows) R is now built using gcc 4.9.3. This build will
+ require recompilation of at least those packages that include C++
+ code, and possibly others. A build of R-devel using the older
+ toolchain will be temporarily available for comparison purposes.
+
+ During the transition, the environment variable R_COMPILED_BY has
+ been defined to indicate which toolchain was used to compile R
+ (and hence, which should be used to compile code in packages).
+ The COMPILED_BY variable described below will be a permanent
+ replacement for this.
+
+ * (Windows) A make and R CMD config variable named COMPILED_BY has
+ been added. This indicates which toolchain was used to compile R
+ (and hence, which should be used to compile code in packages).
+
+ PACKAGE INSTALLATION:
+
+ * The make macro AWK which used to be made available to files such
+ as src/Makefile is no longer set.
+
+ C-LEVEL FACILITIES:
+
+ * The API call logspace_sum introduced in R 3.2.0 is now remapped
+ as an entry point to Rf_logspace_sum, and its first argument has
+ gained a const qualifier. (PR#16470)
+
+ Code using it will need to be reinstalled.
+
+ Similarly, entry point log1pexp also defined in Rmath.h is
+ remapped there to Rf_log1pexp
+
+ * R_GE_version has been increased to 11.
+
+ * New API call R_orderVector1, a faster one-argument version of
+ R_orderVector.
+
+ * When R headers such as R.h and Rmath.h are called from C++ code
+ in packages they include the C++ versions of system headers such
+ as rather than the legacy headers such as .
+ (Headers Rinternals.h and Rinterface.h already did, and inclusion
+ of system headers can still be circumvented by defining
+ NO_C_HEADERS, including as from this version for those two
+ headers.)
+
+ The manual has long said that R headers should *not* be included
+ within an extern "C" block, and almost all the packages affected
+ by this change were doing so.
+
+ * Including header S.h from C++ code would fail on some platforms,
+ and so gives a compilation error on all.
+
+ * The deprecated header Rdefines.h is now compatible with defining
+ R_NO_REMAP.
+
+ * The connections API now includes a function R_GetConnection()
+ which allows packages implementing connections to convert R
+ connection objects to Rconnection handles used in the API. Code
+ which previously used the low-level R-internal getConnection()
+ entry point should switch to the official API.
+
+ BUG FIXES:
+
+ * C-level asChar(x) is fixed for when x is not a vector, and it
+ returns "TRUE"/"FALSE" instead of "T"/"F" for logical vectors.
+
+ * The first arguments of .colSums() etc (with an initial dot) are
+ now named x rather than X (matching colSums()): thus error
+ messages are corrected.
+
+ * A coef() method for class "maov" has been added to allow vcov()
+ to work with multivariate results. (PR#16380)
+
+ * method = "libcurl" connections signal errors rather than
+ retrieving HTTP error pages (where the ISP reports the error).
+
+ * xpdrows.data.frame() was not checking for unique row names; in
+ particular, this affected assignment to non-existing rows via
+ numerical indexing. (PR#16570)
+
+ * tail.matrix() did not work for zero rows matrices, and could
+ produce row "labels" such as "[1e+05,]".
+
+ * Data frames with a column named "stringsAsFactors" now format and
+ print correctly. (PR#16580)
+
+ * cor() is now guaranteed to return a value with absolute value
+ less than or equal to 1. (PR#16638)
+
+ * Array subsetting now keeps names(dim(.)).
+
+ * Blocking socket connection selection recovers more gracefully on
+ signal interrupts.
+
+ * The data.frame method of rbind() construction row.names works
+ better in borderline integer cases, but may change the names
+ assigned. (PR#16666)
+
+ * (X11 only) getGraphicsEvent() miscoded buttons and missed mouse
+ motion events. (PR#16700)
+
+ * methods(round) now also lists round.POSIXt.
+
+ * tar() now works with the default files = NULL. (PR#16716)
+
+ * Jumps to outer contexts, for example in error recovery, now make
+ intermediate jumps to contexts where on.exit() actions are
+ established instead of trying to run all on.exit() actions before
+ jumping to the final target. This unwinds the stack gradually,
+ releases resources held on the stack, and significantly reduces
+ the chance of a segfault when running out of C stack space. Error
+ handlers established using withCallingHandlers() and
+ options("error") specifications are ignored when handling a C
+ stack overflow error as attempting one of these would trigger a
+ cascade of C stack overflow errors. (These changes resolve
+ PR#16753.)
+
+ * The spacing could be wrong when printing a complex array.
+ (Report and patch by Lukas Stadler.)
+
+ * pretty(d, n, min.n, *) for date-time objects d works again in
+ border cases with large min.n, returns a labels attribute also
+ for small-range dates and in such cases its returned length is
+ closer to the desired n. (PR#16761) Additionally, it finally
+ does cover the range of d, as it always claimed.
+
+ * tsp(x) <- NULL did not handle correctly objects inheriting from
+ both "ts" and "mts". (PR#16769)
+
+ * install.packages() could give false errors when
+ options("pkgType") was "binary". (Reported by Jose Claudio
+ Faria.)
+
+ * A bug fix in R 3.0.2 fixed problems with locator() in X11, but
+ introduced problems in Windows. Now both should be fixed.
+ (PR#15700)
+
+ * download.file() with method = "wininet" incorrectly warned of
+ download file length difference when reported length was unknown.
+ (PR#16805)
+
+ * diag(NULL, 1) crashed because of missed type checking.
+ (PR#16853)
+
+CHANGES IN R 3.2.4 patched:
+
+ BUG FIXES:
+
+ * format.POSIXlt() behaved incorrectly in R 3.2.4. E.g. the output
+ of format(as.POSIXlt(paste0(1940:2000,"-01-01"), tz = "CET"),
+ usetz = TRUE) ended in two "CEST" time formats.
+
+CHANGES IN R 3.2.4:
+
+ NEW FEATURES:
+
+ * install.packages() and related functions now give a more
+ informative warning when an attempt is made to install a base
+ package.
+
+ * summary(x) now prints with less rounding when x contains infinite
+ values. (Request of PR#16620.)
+
+ * provideDimnames() gets an optional unique argument.
+
+ * shQuote() gains type = "cmd2" for quoting in cmd.exe in Windows.
+ (Response to PR#16636.)
+
+ * The data.frame method of rbind() gains an optional argument
+ stringsAsFactors (instead of only depending on
+ getOption("stringsAsFactors")).
+
+ * smooth(x, *) now also works for long vectors.
+
+ * tools::texi2dvi() has a workaround for problems with the texi2dvi
+ script supplied by texinfo 6.1.
+
+ It extracts more error messages from the LaTeX logs when in
+ emulation mode.
+
+ UTILITIES:
+
+ * R CMD check will leave a log file build_vignettes.log from the
+ re-building of vignettes in the .Rcheck directory if there is a
+ problem, and always if environment variable
+ _R_CHECK_ALWAYS_LOG_VIGNETTE_OUTPUT_ is set to a true value.
+
+ DEPRECATED AND DEFUNCT:
+
+ * Use of SUPPORT_OPENMP from header Rconfig.h is deprecated in
+ favour of the standard OpenMP define _OPENMP.
+
+ (This has been the recommendation in the manual for a while now.)
+
+ * The make macro AWK which is long unused by R itself but recorded
+ in file etc/Makeconf is deprecated and will be removed in R
+ 3.3.0.
+
+ * The C header file S.h is no longer documented: its use should be
+ replaced by R.h.
+
+ BUG FIXES:
+
+ * kmeans(x, centers = <1-row>) now works. (PR#16623)
+
+ * Vectorize() now checks for clashes in argument names. (PR#16577)
+
+ * file.copy(overwrite = FALSE) would signal a successful copy when
+ none had taken place. (PR#16576)
+
+ * ngettext() now uses the same default domain as gettext().
+ (PR#14605)
+
+ * array(.., dimnames = *) now warns about non-list dimnames and,
+ from R 3.3.0, will signal the same error for invalid dimnames as
+ matrix() has always done.
+
+ * addmargins() now adds dimnames for the extended margins in all
+ cases, as always documented.
+
+ * heatmap() evaluated its add.expr argument in the wrong
+ environment. (PR#16583)
+
+ * require() etc now give the correct entry of lib.loc in the
+ warning about an old version of a package masking a newer
+ required one.
+
+ * The internal deparser did not add parentheses when necessary,
+ e.g. before [] or [[]]. (Reported by Lukas Stadler; additional
+ fixes included as well).
+
+ * as.data.frame.vector(*, row.names=*) no longer produces
+ 'corrupted' data frames from row names of incorrect length, but
+ rather warns about them. This will become an error.
+
+ * url connections with method = "libcurl" are destroyed properly.
+ (PR#16681)
+
+ * withCallingHandler() now (again) handles warnings even during S4
+ generic's argument evaluation. (PR#16111)
+
+ * deparse(..., control = "quoteExpressions") incorrectly quoted
+ empty expressions. (PR#16686)
+
+ * format()ting datetime objects ("POSIX[cl]?t") could segfault or
+ recycle wrongly. (PR#16685)
+
+ * plot.ts(, las = 1) now does use las.
+
+ * saveRDS(*, compress = "gzip") now works as documented.
+ (PR#16653)
+
+ * (Windows only) The Rgui front end did not always initialize the
+ console properly, and could cause R to crash. (PR#16698)
+
+ * dummy.coef.lm() now works in more cases, thanks to a proposal by
+ Werner Stahel (PR#16665). In addition, it now works for
+ multivariate linear models ("mlm", manova) thanks to a proposal
+ by Daniel Wollschlaeger.
+
+ * The as.hclust() method for "dendrogram"s failed often when there
+ were ties in the heights.
+
+ * reorder() and midcache.dendrogram() now are non-recursive and
+ hence applicable to somewhat deeply nested dendrograms, thanks to
+ a proposal by Suharto Anggono in PR#16424.
+
+ * cor.test() now calculates very small p values more accurately
+ (affecting the result only in extreme not statistically relevant
+ cases). (PR#16704)
+
+ * smooth(*, do.ends=TRUE) did not always work correctly in R
+ versions between 3.0.0 and 3.2.3.
+
+ * pretty(D) for date-time objects D now also works well if range(D)
+ is (much) smaller than a second. In the case of only one unique
+ value in D, the pretty range now is more symmetric around that
+ value than previously.
+
+ Similarly, pretty(dt) no longer returns a length 5 vector with
+ duplicated entries for Date objects dt which span only a few
+ days.
+
+ * The figures in help pages such as ?points were accidentally
+ damaged, and did not appear in R 3.2.3. (PR#16708)
+
+ * available.packages() sometimes deleted the wrong file when
+ cleaning up temporary files. (PR#16712)
+
+ * The X11() device sometimes froze on Red Hat Enterprise Linux 6.
+ It now waits for MapNotify events instead of Expose events,
+ thanks to Siteshwar Vashisht. (PR#16497)
+
+ * [dpqr]nbinom(*, size=Inf, mu=.) now works as limit case, for
+ 'dpq' as the Poisson. (PR#16727)
+ pnbinom() no longer loops infinitely in border cases.
+
+ * approxfun(*, method="constant") and hence ecdf() which calls the
+ former now correctly "predict" NaN values as NaN.
+
+ * summary.data.frame() now displays NAs in Date columns in all
+ cases. (PR#16709)
+
CHANGES IN R 3.2.3:
NEW FEATURES:
@@ -1318,7 +2044,7 @@
breaks when some are very large. (PR#15988)
* sub() and gsub() did not handle regular expressions like "\s{2,}"
- properly if the text contained NA or non-ascii elements in a
+ properly if the text contained NA or non-ASCII elements in a
UTF-8 locale. Part of this was due to a bug in the TRE library.
(PR#16009)
diff -Nru r-base-3.2.3/doc/NEWS.2.Rd r-base-3.3.1/doc/NEWS.2.Rd
--- r-base-3.2.3/doc/NEWS.2.Rd 2015-03-18 23:04:13.000000000 +0000
+++ r-base-3.3.1/doc/NEWS.2.Rd 2016-03-16 23:04:40.000000000 +0000
@@ -1,5 +1,5 @@
% -*- coding: utf-8 -*-
-\newcommand{\Rlogo}{\if{html}{\figure{../../html/logo.jpg}}\if{latex}{\figure{logo.jpg}{options: width=0.5in}}}
+\newcommand{\Rlogo}{\if{html}{\figure{../../html/Rlogo.svg}{options: class="toplogo" alt="[R logo]"}}\if{latex}{\figure{Rlogo.pdf}{options: width=0.5in}}}
\name{NEWS}
\title{ R News}
Binary files /tmp/tmpr1xlqo/rKiOMPh78h/r-base-3.2.3/doc/NEWS.pdf and /tmp/tmpr1xlqo/EboCyhHyzT/r-base-3.3.1/doc/NEWS.pdf differ
diff -Nru r-base-3.2.3/doc/NEWS.Rd r-base-3.3.1/doc/NEWS.Rd
--- r-base-3.2.3/doc/NEWS.Rd 2015-12-06 23:15:08.000000000 +0000
+++ r-base-3.3.1/doc/NEWS.Rd 2016-06-11 22:15:12.000000000 +0000
@@ -1,10 +1,819 @@
% -*- coding: utf-8 -*-
-\newcommand{\Rlogo}{\if{html}{\figure{../../html/logo.jpg}}\if{latex}{\figure{logo.jpg}{options: width=0.5in}}}
+\newcommand{\Rlogo}{\if{html}{\figure{../../html/Rlogo.svg}{options: class="toplogo" alt="[R logo]"}}\if{latex}{\figure{Rlogo.pdf}{options: width=0.5in}}}
\name{NEWS}
\title{R News}
\encoding{UTF-8}
+\section{\Rlogo CHANGES IN R 3.3.1}{
+ \subsection{BUG FIXES}{
+ \itemize{
+ \item \command{R CMD INSTALL} and hence \code{install.packages()}
+ gave an internal error installing a package called
+ \pkg{description} from a tarball on a case-insensitive file system.
+
+ \item \code{match(x, t)} (and hence \code{x \%in\% t}) failed
+ when \code{x} was of length one, and either \code{character} and \code{x}
+ and \code{t} only differed in their \code{Encoding} or when
+ \code{x} and \code{t} where \code{complex} with \code{NA}s or \code{NaN}s.
+ (\PR{16885}.)
+
+ \item \code{unloadNamespace(ns)} also works again when \code{ns} is a
+ \sQuote{namespace}, as from \code{getNamespace()}.
+
+ \item \code{rgamma(1,Inf)} or \code{rgamma(1, 0,0)} no longer give
+ \code{NaN} but the correct limit.
+
+ \item \code{length(baseenv())} is correct now.
+
+ \item \code{pretty(d, ..)} for date-time \code{d} rarely failed
+ when \code{"halfmonth"} time steps were tried (\PR{16923}) and
+ on \sQuote{inaccurate} platforms such as 32-bit windows or
+ a configuration with \command{--disable-long-double}; see comment
+ #15 of \PR{16761}.
+
+ \item In \code{text.default(x, y, labels)}, the rarely(?) used
+ default for \code{labels} is now correct also for the case of a
+ 2-column matrix \code{x} and missing \code{y}.
+
+ \item \code{as.factor(c(a = 1L))} preserves \code{names()} again
+ as in \R < 3.1.0.
+
+ \item \code{strtrim(""[0], 0[0])} now works.
+
+ \item Use of \code{Ctrl-C} to terminate a reverse incremental
+ search started by \code{Ctrl-R} in the \code{readline}-based Unix
+ terminal interface is now supported for \code{readline} >= 6.3
+ (\code{Ctrl-G} always worked). (\PR{16603})
+
+ \item \code{diff()} now keeps the \code{"units"}
+ attribute, as subtraction already did, \PR{16940}.
+ }
+ }
+}
+
+\section{\Rlogo CHANGES IN R 3.3.0}{
+ \subsection{SIGNIFICANT USER-VISIBLE CHANGES}{
+ \itemize{
+ \item \code{nchar(x, *)}'s argument \code{keepNA} governing how
+ the result for \code{NA}s in \code{x} is determined, gets a new
+ default \code{keepNA = NA} which returns \code{NA} where
+ \code{x} is \code{NA}, except for \code{type = "width"} which still
+ returns \code{2}, the formatting / printing width of \code{NA}.
+
+ \item All builds have support for \samp{https:} URLs in the
+ default methods for \code{download.file()}, \code{url()} and code
+ making use of them.
+
+ Unfortunately that cannot guarantee that any particular
+ \samp{https:} URL can be accessed. For example, server and client
+ have to successfully negotiate a cryptographic protocol (TLS/SSL,
+ \dots) and the server's identity has to be verifiable \emph{via}
+ the available certificates. Different access methods may allow
+ different protocols or use private certificate bundles: we
+ encountered a \samp{https:} CRAN mirror which could be accessed by
+ one browser but not by another nor by \code{download.file()} on
+ the same Linux machine.
+ }
+ }
+
+ \subsection{NEW FEATURES}{
+ \itemize{
+ \item The \code{print} method for \code{methods()} gains a
+ \code{byclass} argument.
+
+ \item New functions \code{validEnc()} and \code{validUTF8()} to
+ give access to the validity checks for inputs used by
+ \code{grep()} and friends.
+
+ \item Experimental new functionality for S3 method checking, notably
+ \code{isS3method()}.
+
+ Also, the names of the \R \sQuote{language elements} are exported
+ as character vector \code{tools::langElts}.
+
+ \item \code{str(x)} now displays \code{"Time-Series"} also for
+ matrix (multivariate) time-series, i.e. when \code{is.ts(x)} is true.
+
+ \item (Windows only) The GUI menu item to install local packages
+ now accepts \file{*.tar.gz} files as well as \file{*.zip} files
+ (but defaults to the latter).
+
+ \item New programmeR's utility function \code{chkDots()}.
+
+ \item \code{D()} now signals an error when given invalid input,
+ rather than silently returning \code{NA}. (Request of John Nash.)
+
+ \item \code{formula} objects are slightly more \dQuote{first class}:
+ e.g., \code{formula()} or \code{new("formula", y ~ x)} are now
+ valid. Similarly, for \code{"table"}, \code{"ordered"} and
+ \code{"summary.table"}. Packages defining S4 classes with the above
+ S3/S4 classes as slots should be reinstalled.
+ % notably if their classes are reused in other
+ % packages. e.g. re-install arules for arulesSequence, flexmix for betareg
+
+ \item New function \code{strrep()} for repeating the elements of a
+ character vector.
+
+ \item \code{rapply()} preserves attributes on the list when
+ \code{how = "replace"}.
+
+ \item New S3 generic function \code{sigma()} with methods for
+ extracting the estimated standard deviation aka \dQuote{residual
+ standard deviation} from a fitted model.
+
+ \item \code{news()} now displays \R and package news files within
+ the HTML help system if it is available. If no news file is found,
+ a visible \code{NULL} is returned to the console.
+
+ \item \code{as.raster(x)} now also accepts \code{raw} arrays
+ \code{x} assuming values in \code{0:255}.
+
+ \item Subscripting of matrix/array objects of type
+ \code{"expression"} is now supported.
+
+ \item \code{type.convert("i")} now returns a factor instead of a
+ complex value with zero real part and missing imaginary part.
+
+ \item Graphics devices \code{cairo_pdf()} and \code{cairo_ps()}
+ now allow non-default values of the cairographics \sQuote{fallback
+ resolution} to be set.
+
+ This now defaults to 300 on all platforms: that is the default
+ documented by cairographics, but apparently was not used by all
+ system installations.
+
+ \item \code{file()} gains an explicit \code{method} argument
+ rather than implicitly using
+ \code{getOption("url.method", "default")}.
+
+ \item Thanks to a patch from Tomas Kalibera, \code{x[x != 0]} is
+ now typically faster than \code{x[which(x != 0)]} (in the case
+ where \code{x} has no NAs, the two are equivalent).
+
+ \item \code{read.table()} now always uses the names for a named
+ \code{colClasses} argument (previously names were only used when
+ \code{colClasses} was too short). (In part, wish of \PR{16478}.)
+
+ \item (Windows only) \code{download.file()} with default
+ \code{method = "auto"} and a \samp{ftps://} URL chooses
+ \code{"libcurl"} if that is available.
+
+ \item The out-of-the box Bioconductor mirror has been changed to
+ one using \samp{https://}: use \code{chooseBioCmirror()} to choose
+ a \samp{http://} mirror if required.
+
+ \item The data frame and formula methods for \code{aggregate()}
+ gain a \code{drop} argument.
+
+ \item \code{available.packages()} gains a \code{repos} argument.
+
+ \item The undocumented switching of methods for \code{url()} on
+ \samp{https:} and \samp{ftps:} URLs is confined to
+ \code{method = "default"} (and documented).
+
+ \item \code{smoothScatter()} gains a \code{ret.selection} argument.
+
+ \item \code{qr()} no longer has a \code{\dots} argument to pass
+ additional arguments to methods.
+
+ \item \code{[} has a method for class \code{"table"}.
+
+ \item It is now possible (again) to \code{replayPlot()} a
+ display list snapshot that was created by \code{recordPlot()}
+ in a different \R session.
+
+ It is still not a good idea to use snapshots as a persistent
+ storage format for \R plots, but it is now not completely silly to
+ use a snapshot as a format for transferring an R plot between two
+ R sessions.
+
+ The underlying changes mean that packages providing graphics
+ devices (e.g., \CRANpkg{Cairo}, \CRANpkg{RSvgDevice},
+ \CRANpkg{cairoDevice}, \CRANpkg{tikzDevice}) will need to be
+ reinstalled.
+
+ Code for restoring snapshots was contributed by Jeroen Ooms
+ and JJ Allaire.
+
+ Some testing code is available at
+ \url{https://github.com/pmur002/R-display-list}.
+
+ \item \code{tools::undoc(dir = D)} and \code{codoc(dir = D)} now
+ also work when \code{D} is a directory whose \code{normalizePath()}ed
+ version does not end in the package name, e.g.\sspace{}from a symlink.
+
+ \item \code{abbreviate()} has more support for multi-byte
+ character sets -- it no longer removes bytes within characters and
+ knows about Latin vowels with accents. It is still only
+ really suitable for (most) European languages, and still warns on
+ non-ASCII input.
+
+ \code{abbreviate(use.classes = FALSE)} is now implemented, and
+ that is more suitable for non-European languages.
+
+ \item \code{match(x, table)} is faster (sometimes by an order of
+ magnitude) when \code{x} is of length one and \code{incomparables}
+ is unchanged, thanks to Peter Haverty (\PR{16491}).
+
+ \item More consistent, partly not back-compatible behavior of
+ \code{NA} and \code{NaN} coercion to complex numbers, operations
+ less often resulting in complex \code{NA} (\code{NA_complex_}).
+
+ \item \code{lengths()} considers methods for \code{length} and
+ \code{[[} on \code{x}, so it should work automatically on any
+ objects for which appropriate methods on those generics are
+ defined.
+
+ \item The logic for selecting the default screen device on OS X
+ has been simplified: it is now \code{quartz()} if that is
+ available even if environment variable \env{DISPLAY} has been set
+ by the user.
+
+ The choice can easily be overridden \emph{via} environment
+ variable \env{R_INTERACTIVE_DEVICE}.
+
+ \item On Unix-like platforms which support the \command{getline} C
+ library function, \code{system(*,intern = TRUE)} no longer
+ truncates (output) lines longer than 8192 characters, thanks to
+ Karl Millar. (\PR{16544})
+
+ \item \code{rank()} gains a \code{ties.method = "last"} option,
+ for convenience (and symmetry).
+
+ %% \item \code{getRcode(vignette(..))} is the \R source file name of
+ %% a vignette.
+
+ \item \code{regmatches(invert = NA)} can now be used to extract
+ both non-matched and matched substrings.
+
+ \item \code{data.frame()} gains argument \code{fix.empty.names};
+ \code{as.data.frame.list()} gets new \code{cut.names},
+ \code{col.names} and \code{fix.empty.names}.
+
+ \item \code{plot(x ~ x, *)} now warns that it is the same as
+ \code{plot(x ~ 1, *)}.
+
+ \item \code{recordPlot()} has new arguments \code{load} and
+ \code{attach} to allow package names to be stored as part of a
+ recorded plot. \code{replayPlot()} has new argument
+ \code{reloadPkgs} to load/attach any package names that were
+ stored as part of a recorded plot.
+
+ \item S4 dispatch works within calls to \code{.Internal()}. This
+ means explicit S4 generics are no longer needed for
+ \code{unlist()} and \code{as.vector()}.
+
+ \item Only font family names starting with \samp{"Hershey"} (and
+ not \samp{"Her"} as before) are given special treatment by the
+ graphics engine.
+
+ \item S4 values are automatically coerced to vector (via
+ \code{as.vector}) when subassigned into atomic vectors.
+
+ \item \code{findInterval()} gets a \code{left.open} option.
+
+ \item The version of LAPACK included in the sources has been
+ updated to 3.6.0, including those \sQuote{deprecated} routines
+ which were previously included. \emph{Ca} 40 double-complex
+ routines have been added at the request of a package maintainer.
+
+ As before, the details of what is included are in
+ \file{src/modules/lapack/README} and this now gives information on
+ earlier additions.
+
+ \item \code{tapply()} has been made considerably more efficient
+ without changing functionality, thanks to proposals from Peter
+ Haverty and Suharto Anggono. (\PR{16640})
+
+ \item \code{match.arg(arg)} (the one-argument case) is faster; so
+ is \code{sort.int()}. (\PR{16640})
+
+ \item The \code{format} method for \code{object_size} objects now
+ also accepts \dQuote{binary} units such as \code{"KiB"} and e.g.,
+ \code{"Tb"}. (Partly from \PR{16649}.)
+
+ \item Profiling now records calls of the form \code{foo::bar} and
+ some similar cases directly rather than as calls to
+ \code{}. Contributed by Winston Chang.
+
+ \item New string utilities \code{startsWith(x, prefix)} and
+ \code{endsWith(x, suffix)}. Also provide speedups for some
+ \code{grepl("^...",*)} uses (related to proposals in \PR{16490}).
+
+ \item Reference class finalizers run at exit, as well as on
+ garbage collection.
+
+ \item Avoid \pkg{parallel} dependency on \pkg{stats} for port
+ choice and random number seeds. (\PR{16668})
+
+ \item The radix sort algorithm and implementation from
+ \CRANpkg{data.table} (\code{forder}) replaces the previous radix
+ (counting) sort and adds a new method for \code{order()}.
+ Contributed by Matt Dowle and Arun Srinivasan, the new algorithm
+ supports logical, integer (even with large values), real, and
+ character vectors. It outperforms all other methods, but there
+ are some caveats (see \code{?sort}).
+
+ \item The \code{order()} function gains a \code{method} argument
+ for choosing between \code{"shell"} and \code{"radix"}.
+
+ \item New function \code{grouping()} returns a permutation that
+ stably rearranges data so that identical values are adjacent. The
+ return value includes extra partitioning information on the
+ groups. The implementation came included with the new radix sort.
+
+ \item \code{rhyper(nn, m, n, k)} no longer returns \code{NA} when
+ one of the three parameters exceeds the maximal integer.
+
+ \item \code{switch()} now warns when no alternatives are provided.
+
+ \item \code{parallel::detectCores()} now has default \code{logical
+ = TRUE} on all platforms -- as this was the default on Windows,
+ this change only affects Sparc Solaris.
+
+ Option \code{logical = FALSE} is now supported on Linux and recent
+ versions of OS X (for the latter, thanks to a suggestion of Kyaw
+ Sint).
+
+ \item \code{hist()} for \code{"Date"} or \code{"POSIXt"} objects
+ would sometimes give misleading labels on the breaks, as they
+ were set to the day before the start of the period being
+ displayed. The display format has been changed, and the shift of the
+ start day has been made conditional on \code{right = TRUE} (the
+ default). (\PR{16679})
+
+ \item \R now uses a new version of the logo (donated to the R
+ Foundation by RStudio). It is defined in \file{.svg} format, so
+ will resize without unnecessary degradation when displayed on
+ HTML pages---there is also a vector PDF version. Thanks to
+ Dirk Eddelbuettel for producing the corresponding X11 icon.
+
+ \item New function \code{.traceback()} returns the stack trace
+ which \code{traceback()} prints.
+
+ \item \code{lengths()} dispatches internally.
+
+ \item \code{dotchart()} gains a \code{pt.cex} argument to control
+ the size of points separately from the size of plot labels.
+ Thanks to Michael Friendly and Milan Bouchet-Valat for ideas
+ and patches.
+
+ \item \code{as.roman(ch)} now correctly deals with more diverse
+ character vectors \code{ch}; also arithmetic with the resulting
+ roman numbers works in more cases. (\PR{16779})
+
+ \item \code{prcomp()} gains a new option \code{rank.} allowing to
+ directly aim for less than \code{min(n,p)} PC's. The
+ \code{summary()} and its \code{print()} method have been amended,
+ notably for this case.
+
+ \item \code{gzcon()} gains a new option \code{text}, which marks
+ the connection as text-oriented (so e.g.\sspace{}\code{pushBack()}
+ works). It is still always opened in binary mode.
+
+ \item The \code{import()} namespace directive now accepts an
+ argument \code{except} which names symbols to exclude from the
+ imports. The \code{except} expression should evaluate to a
+ character vector (after substituting symbols for strings). See
+ Writing R Extensions.
+
+ \item New convenience function \code{Rcmd()} in package
+ \pkg{tools} for invoking \command{R CMD} tools from within \R.
+
+ \item New functions \code{makevars_user()} and
+ \code{makevars_site()} in package \pkg{tools} to determine the
+ location of the user and site specific \file{Makevars} files for
+ customizing package compilation.
+ }
+ }
+
+ \subsection{UTILITIES}{
+ \itemize{
+ \item \command{R CMD check} has a new option
+ \option{--ignore-vignettes} for use with non-Sweave vignettes
+ whose \samp{VignetteBuilder} package is not available.
+
+ \item \command{R CMD check} now by default checks code usage
+ (\emph{via} \CRANpkg{codetools}) with only the base package
+ attached. Functions from default packages other than \pkg{base}
+ which are used in the package code but not imported are reported
+ as undefined globals, with a suggested addition to the
+ \code{NAMESPACE} file.
+
+ \item \command{R CMD check --as-cran} now also checks DOIs in
+ package \file{CITATION} and Rd files.
+
+ \item \command{R CMD Rdconv} and \command{R CMD Rd2pdf} each have
+ a new option \option{--RdMacros=pkglist} which allows Rd macros
+ to be specified before processing.
+ }
+ }
+
+ \subsection{DEPRECATED AND DEFUNCT}{
+ \itemize{
+ \item The previously included versions of \code{zlib},
+ \code{bzip2}, \code{xz} and PCRE have been removed, so suitable
+ external (usually system) versions are required (see the
+ \sQuote{R Installation and Administration} manual).
+
+ \item The unexported and undocumented Windows-only devices
+ \code{cairo_bmp()}, \code{cairo_png()} and \code{cairo_tiff()}
+ have been removed. (These devices should be used as
+ e.g.\sspace{}\code{bmp(type = "cairo")}.)
+
+ \item (Windows only) Function \code{setInternet2()} has no effect
+ and will be removed in due course. The choice between methods
+ \code{"internal"} and \code{"wininet"} is now made by the
+ \code{method} arguments of \code{url()} and \code{download.file()}
+ and their defaults can be set \emph{via} options. The
+ out-of-the-box default remains \code{"wininet"} (as it has been
+ since \R 3.2.2).
+
+ \item \code{[<-} with an S4 value into a list currently embeds the
+ S4 object into its own list such that the end result is roughly
+ equivalent to using \code{[[<-}. That behavior is deprecated. In
+ the future, the S4 value will be coerced to a list with
+ \code{as.list()}.
+
+ \item Package \pkg{tools}' functions
+ \code{package.dependencies()}, \code{pkgDepends()}, etc are
+ deprecated now, mostly in favor of \code{package_dependencies()}
+ which is both more flexible and efficient.
+ }
+ }
+
+ \subsection{INSTALLATION and INCLUDED SOFTWARE}{
+ \itemize{
+ \item Support for very old versions of \command{valgrind}
+ (e.g., 3.3.0) has been removed.
+
+ \item The included \command{libtool} script (generated by
+ \command{configure}) has been updated to version 2.4.6 (from 2.2.6a).
+
+ \item \code{libcurl} version 7.28.0 or later with support for the
+ \code{https} protocol is required for installation (except on
+ Windows).
+
+ \item BSD networking is now required (except on Windows) and so
+ \code{capabilities("http/ftp")} is always true.
+
+ \item \command{configure} uses \command{pkg-config} for PNG, TIFF
+ and JPEG where this is available. This should work better with
+ multiple installs and with those using static libraries.
+
+ \item The minimum supported version of OS X is 10.6 (\sQuote{Snow
+ Leopard}): even that has been unsupported by Apple since 2012.
+
+ \item The \command{configure} default on OS X is
+ \option{--disable-R-framework}: enable this if you intend to
+ install under \file{/Library/Frameworks} and use with \code{R.app}.
+
+ \item The minimum preferred version of PCRE has since \R 3.0.0
+ been 8.32 (released in Nov 2012). Versions 8.10 to 8.31 are now
+ deprecated (with warnings from \command{configure}), but will
+ still be accepted until \R 3.4.0.
+
+ \item \command{configure} looks for C functions \code{__cospi},
+ \code{__sinpi} and \code{__tanpi} and uses these if \code{cospi}
+ \emph{etc} are not found. (OS X is the main instance.)
+
+ \item (Windows) R is now built using \command{gcc}
+ 4.9.3. This build will require recompilation of at least those packages
+ that include C++ code, and possibly others. A build of R-devel using
+ the older toolchain will be temporarily available for comparison
+ purposes.
+
+ During the transition, the environment variable
+ \env{R_COMPILED_BY} has been defined to indicate which toolchain
+ was used to compile R (and hence, which should be used to compile
+ code in packages). The \code{COMPILED_BY} variable described below
+ will be a permanent replacement for this.
+
+ \item (Windows) A \command{make} and \command{R CMD config} variable
+ named \code{COMPILED_BY} has been added. This indicates
+ which toolchain was used to compile R (and hence, which should be
+ used to compile code in packages).
+ }
+ }
+
+ \subsection{PACKAGE INSTALLATION}{
+ \itemize{
+ \item The \command{make} macro \code{AWK} which used to be made
+ available to files such as \file{src/Makefile} is no longer set.
+ }
+ }
+
+ \subsection{C-LEVEL FACILITIES}{
+ \itemize{
+ \item The API call \code{logspace_sum} introduced in \R 3.2.0 is
+ now remapped as an entry point to \code{Rf_logspace_sum}, and its
+ first argument has gained a \code{const} qualifier. (\PR{16470})
+
+ Code using it will need to be reinstalled.
+
+ Similarly, entry point \code{log1pexp} also defined in
+ \file{Rmath.h} is remapped there to \code{Rf_log1pexp}
+
+ \item \code{R_GE_version} has been increased to \code{11}.
+
+ \item New API call \code{R_orderVector1}, a faster
+ one-argument version of \code{R_orderVector}.
+
+ \item When \R{} headers such as \file{R.h} and \file{Rmath.h} are
+ called from C++ code in packages they include the C++ versions of
+ system headers such as \file{} rather than the legacy
+ headers such as \file{}. (Headers \file{Rinternals.h} and
+ \file{Rinterface.h} already did, and inclusion of system headers
+ can still be circumvented by defining \code{NO_C_HEADERS},
+ including as from this version for those two headers.)
+
+ The manual has long said that \R{} headers should \bold{not} be
+ included within an \code{extern "C"} block, and almost all the
+ packages affected by this change were doing so.
+
+ \item Including header \file{S.h} from C++ code would fail on some
+ platforms, and so gives a compilation error on all.
+
+ \item The deprecated header \file{Rdefines.h} is now compatible
+ with defining \code{R_NO_REMAP}.
+
+ \item The connections API now includes a function
+ \code{R_GetConnection()} which allows packages implementing
+ connections to convert R \code{connection} objects to
+ \code{Rconnection} handles used in the API. Code which previously
+ used the low-level R-internal \code{getConnection()} entry point
+ should switch to the official API.
+ }
+ }
+
+ \subsection{BUG FIXES}{
+ \itemize{
+ \item C-level \code{asChar(x)} is fixed for when \code{x} is not a
+ vector, and it returns \code{"TRUE"}/\code{"FALSE"} instead of
+ \code{"T"}/\code{"F"} for logical vectors.
+
+ \item The first arguments of \code{.colSums()} etc (with an
+ initial dot) are now named \code{x} rather than \code{X} (matching
+ \code{colSums()}): thus error messages are corrected.
+
+ \item A \code{coef()} method for class \code{"maov"} has been
+ added to allow \code{vcov()} to work with multivariate
+ results. (\PR{16380})
+
+ \item \code{method = "libcurl"} connections signal errors rather
+ than retrieving HTTP error pages (where the ISP reports the
+ error).
+
+ \item \code{xpdrows.data.frame()} was not checking for unique
+ row names; in particular, this affected assignment to non-existing
+ rows via numerical indexing. (\PR{16570})
+
+ \item \code{tail.matrix()} did not work for zero rows matrices,
+ and could produce row \dQuote{labels} such as \code{"[1e+05,]"}.
+
+ \item Data frames with a column named \code{"stringsAsFactors"}
+ now format and print correctly. (\PR{16580})
+
+ \item \code{cor()} is now guaranteed to return a value with
+ absolute value less than or equal to 1. (\PR{16638})
+
+ \item Array subsetting now keeps \code{names(dim(.))}.
+
+ \item Blocking socket connection selection recovers more
+ gracefully on signal interrupts.
+
+ \item The \code{data.frame} method of \code{rbind()} construction
+ \code{row.names} works better in borderline integer cases, but
+ may change the names assigned. (\PR{16666})
+
+ \item (X11 only) \code{getGraphicsEvent()} miscoded buttons and
+ missed mouse motion events. (\PR{16700})
+
+ \item \code{methods(round)} now also lists \code{round.POSIXt}.
+
+ \item \code{tar()} now works with the default \code{files = NULL}.
+ (\PR{16716})
+
+ \item Jumps to outer contexts, for example in error recovery, now
+ make intermediate jumps to contexts where \code{on.exit()} actions
+ are established instead of trying to run all \code{on.exit()}
+ actions before jumping to the final target. This unwinds the stack
+ gradually, releases resources held on the stack, and significantly
+ reduces the chance of a segfault when running out of C stack
+ space. Error handlers established using
+ \code{withCallingHandlers()} and \code{options("error")}
+ specifications are ignored when handling a C stack overflow error
+ as attempting one of these would trigger a cascade of C stack
+ overflow errors. (These changes resolve \PR{16753}.)
+
+ \item The spacing could be wrong when printing a complex array.
+ (Report and patch by Lukas Stadler.)
+
+ \item \code{pretty(d, n, min.n, *)} for date-time objects \code{d}
+ works again in border cases with large \code{min.n}, returns a
+ \code{labels} attribute also for small-range dates and in such cases
+ its returned length is closer to the desired \code{n}. (\PR{16761})
+ Additionally, it finally does cover the range of \code{d}, as it
+ always claimed.
+
+ \item \code{tsp(x) <- NULL} did not handle correctly objects
+ inheriting from both \code{"ts"} and \code{"mts"}. (\PR{16769})
+
+ \item \code{install.packages()} could give false errors when
+ \code{options("pkgType")} was \code{"binary"}. (Reported by
+ Jose Claudio Faria.)
+
+ \item A bug fix in \R 3.0.2 fixed problems with \code{locator()}
+ in X11, but introduced problems in Windows. Now both should be
+ fixed. (\PR{15700})
+
+ \item \code{download.file()} with \code{method = "wininet"}
+ incorrectly warned of download file length difference when
+ reported length was unknown. (\PR{16805})
+
+ \item \code{diag(NULL, 1)} crashed because of missed type
+ checking. (\PR{16853})
+ }
+ }
+}
+
+\section{\Rlogo CHANGES IN R 3.2.4 patched}{
+ \subsection{BUG FIXES}{
+ \itemize{
+ \item \code{format.POSIXlt()} behaved incorrectly in \R 3.2.4.
+ E.g.\sspace{}the output of
+ \code{format(as.POSIXlt(paste0(1940:2000,"-01-01"), tz = "CET"),
+ usetz = TRUE)} ended in two \code{"CEST"} time formats.
+ }
+ }
+}
+
+\section{\Rlogo CHANGES IN R 3.2.4}{
+ \subsection{NEW FEATURES}{
+ \itemize{
+ \item \code{install.packages()} and related functions now give a
+ more informative warning when an attempt is made to install a base
+ package.
+
+ \item \code{summary(x)} now prints with less rounding when
+ \code{x} contains infinite values. (Request of \PR{16620}.)
+
+ \item \code{provideDimnames()} gets an optional \code{unique} argument.
+
+ \item \code{shQuote()} gains \code{type = "cmd2"} for quoting
+ in \command{cmd.exe} in Windows. (Response to \PR{16636}.)
+
+ \item The \code{data.frame} method of \code{rbind()} gains an
+ optional argument \code{stringsAsFactors} (instead of only
+ depending on \code{getOption("stringsAsFactors")}).
+
+ \item \code{smooth(x, *)} now also works for long vectors.
+
+ \item \code{tools::texi2dvi()} has a workaround for problems with
+ the \command{texi2dvi} script supplied by \pkg{texinfo 6.1}.
+
+ It extracts more error messages from the LaTeX logs when in
+ emulation mode.
+ }
+ }
+
+ \subsection{UTILITIES}{
+ \itemize{
+ \item \command{R CMD check} will leave a log file
+ \file{build_vignettes.log} from the re-building of vignettes in
+ the \file{.Rcheck} directory if there is a problem, and always if
+ environment variable \env{_R_CHECK_ALWAYS_LOG_VIGNETTE_OUTPUT_} is
+ set to a true value.
+ }
+ }
+
+ \subsection{DEPRECATED AND DEFUNCT}{
+ \itemize{
+ \item Use of \samp{SUPPORT_OPENMP} from header \file{Rconfig.h} is
+ deprecated in favour of the standard OpenMP define \samp{_OPENMP}.
+
+ (This has been the recommendation in the manual for a while now.)
+
+ \item The \command{make} macro \code{AWK} which is long unused by
+ \R itself but recorded in file \file{etc/Makeconf} is deprecated
+ and will be removed in \R 3.3.0.
+
+ \item The C header file \file{S.h} is no longer documented: its
+ use should be replaced by \file{R.h}.
+ }
+ }
+
+ \subsection{BUG FIXES}{
+ \itemize{
+ \item \code{kmeans(x, centers = <1-row>)} now works. (\PR{16623})
+
+ \item \code{Vectorize()} now checks for clashes in argument names.
+ (\PR{16577})
+
+ \item \code{file.copy(overwrite = FALSE)} would signal a successful
+ copy when none had taken place. (\PR{16576})
+
+ \item \code{ngettext()} now uses the same default domain as
+ \code{gettext()}. (\PR{14605})
+
+ \item \code{array(.., dimnames = *)} now warns about
+ non-\code{list} dimnames and, from \R 3.3.0, will signal the same
+ error for invalid dimnames as \code{matrix()} has always done.
+
+ \item \code{addmargins()} now adds dimnames for the extended
+ margins in all cases, as always documented.
+
+ \item \code{heatmap()} evaluated its \code{add.expr} argument
+ in the wrong environment. (\PR{16583})
+
+ \item \code{require()} etc now give the correct entry of
+ \code{lib.loc} in the warning about an old version of a package
+ masking a newer required one.
+
+ \item The internal deparser did not add parentheses when
+ necessary, e.g. before \code{[]} or \code{[[]]}. (Reported by
+ Lukas Stadler; additional fixes included as well).
+
+ \item \code{as.data.frame.vector(*, row.names=*)} no longer
+ produces \sQuote{corrupted} data frames from row names of incorrect
+ length, but rather warns about them. This will become an error.
+
+ \item \code{url} connections with \code{method = "libcurl"} are
+ destroyed properly. (\PR{16681})
+
+ \item \code{withCallingHandler()} now (again) handles warnings
+ even during S4 generic's argument evaluation. (\PR{16111})
+
+ \item \code{deparse(..., control = "quoteExpressions")}
+ incorrectly quoted empty expressions. (\PR{16686})
+
+ \item \code{format()}ting datetime objects (\code{"POSIX[cl]?t"})
+ could segfault or recycle wrongly. (\PR{16685})
+
+ \item \code{plot.ts(, las = 1)} now does use \code{las}.
+
+ \item \code{saveRDS(*, compress = "gzip")} now works as
+ documented. (\PR{16653})
+
+ \item (Windows only) The \command{Rgui} front end did not
+ always initialize the console properly, and could cause
+ \R to crash. (\PR{16698})
+
+ \item \code{dummy.coef.lm()} now works in more cases, thanks to a
+ proposal by Werner Stahel (\PR{16665}). In addition, it now works
+ for multivariate linear models (\code{"mlm"}, \code{\link{manova}})
+ thanks to a proposal by Daniel Wollschlaeger.
+
+ \item The \code{as.hclust()} method for \code{"dendrogram"}s
+ failed often when there were ties in the heights.
+
+ \item \code{reorder()} and \code{midcache.dendrogram()} now are
+ non-recursive and hence applicable to somewhat deeply nested
+ dendrograms, thanks to a proposal by Suharto Anggono in \PR{16424}.
+
+ \item \code{cor.test()} now calculates very small p values
+ more accurately (affecting the result only in extreme not
+ statistically relevant cases). (\PR{16704})
+
+ \item \code{smooth(*, do.ends=TRUE)} did not always work correctly
+ in \R versions between 3.0.0 and 3.2.3.
+
+ \item \code{pretty(D)} for date-time objects \code{D} now also
+ works well if \code{range(D)} is (much) smaller than a second. In
+ the case of only one unique value in \code{D}, the pretty range
+ now is more symmetric around that value than previously.
+ \cr
+ Similarly, \code{pretty(dt)} no longer returns a length 5 vector
+ with duplicated entries for \code{Date} objects \code{dt} which
+ span only a few days.
+
+ \item The figures in help pages such as \code{?points} were
+ accidentally damaged, and did not appear in \R 3.2.3.
+ (\PR{16708})
+
+ \item \code{available.packages()} sometimes deleted the wrong
+ file when cleaning up temporary files. (\PR{16712})
+
+ \item The \code{X11()} device sometimes froze on Red Hat
+ Enterprise Linux 6. It now waits for \code{MapNotify} events
+ instead of \code{Expose} events, thanks to Siteshwar
+ Vashisht. (\PR{16497})
+
+ \item \code{[dpqr]nbinom(*, size=Inf, mu=.)} now works as limit
+ case, for \sQuote{dpq} as the Poisson. (\PR{16727})\cr
+ \code{pnbinom()} no longer loops infinitely in border cases.
+
+ \item \code{approxfun(*, method="constant")} and hence \code{ecdf()}
+ which calls the former now correctly \dQuote{predict} \code{NaN}
+ values as \code{NaN}.
+
+ \item \code{summary.data.frame()} now displays \code{NA}s in
+ \code{Date} columns in all cases. (\PR{16709})
+ }
+ }
+}
+
\section{\Rlogo CHANGES IN R 3.2.3}{
\subsection{NEW FEATURES}{
\itemize{
@@ -41,10 +850,10 @@
\item \code{loess(..., iterTrace=TRUE)} now provides diagnostics
for robustness iterations, and the \code{print()} method for
\code{summary()} shows slightly more.
-
+
\item The included version of PCRE has been updated to 8.38, a
bug-fix release.
-
+
\item \code{View()} now displays nested data frames in a more
friendly way. (Request with patch in \PR{15915}.)
}
@@ -1495,7 +2304,7 @@
\item \code{sub()} and \code{gsub()} did not handle regular
expressions like \code{"\\s{2,}"} properly if the text
- contained \code{NA} or non-ascii elements in a UTF-8
+ contained \code{NA} or non-ASCII elements in a UTF-8
locale. Part of this was due to a bug in the TRE library.
(\PR{16009})
diff -Nru r-base-3.2.3/doc/THANKS r-base-3.3.1/doc/THANKS
--- r-base-3.2.3/doc/THANKS 2015-03-18 23:04:14.000000000 +0000
+++ r-base-3.3.1/doc/THANKS 2016-03-16 23:04:40.000000000 +0000
@@ -3,7 +3,7 @@
Valerio Aimale, Thomas Baier, Henrik Bengtsson, Roger Bivand,
Ben Bolker, David Brahm, G"oran Brostr"om, Patrick Burns, Vince Carey,
-Saikat DebRoy, Brian D'Urso, Lyndon Drake, Dirk Eddelbuettel,
+Saikat DebRoy, Matt Dowle, Brian D'Urso, Lyndon Drake, Dirk Eddelbuettel,
Claus Ekstrom, Sebastian Fischmeister, John Fox, Paul Gilbert,
Yu Gong, Gabor Grothendieck, Frank E Harrell Jr, Torsten Hothorn,
Robert King, Kjetil Kjernsmo, Roger Koenker, Philippe Lambert,
@@ -12,7 +12,7 @@
Jens Oehlschaegel, Steve Oncley, Richard O'Keefe, Hubert Palme,
Roger D. Peng, Jose' C. Pinheiro, Tony Plate, Anthony Rossini,
Jonathan Rougier, Petr Savicky, Guenther Sawitzki, Marc Schwartz,
-Detlef Steuer, Bill Simpson, Gordon Smyth, Adrian Trapletti,
+Arun Srinivasan, Detlef Steuer, Bill Simpson, Gordon Smyth, Adrian Trapletti,
Terry Therneau, Rolf Turner, Bill Venables, Gregory R. Warnes,
Andreas Weingessel, Morten Welinder, James Wettenhall, Simon Wood, and
Achim Zeileis.
diff -Nru r-base-3.2.3/etc/ldpaths.in r-base-3.3.1/etc/ldpaths.in
--- r-base-3.2.3/etc/ldpaths.in 2013-03-05 23:02:45.000000000 +0000
+++ r-base-3.3.1/etc/ldpaths.in 2016-01-09 23:15:11.000000000 +0000
@@ -8,7 +8,11 @@
if test -n "${R_JAVA_LD_LIBRARY_PATH}"; then
R_LD_LIBRARY_PATH="${R_LD_LIBRARY_PATH}:${R_JAVA_LD_LIBRARY_PATH}"
fi
-## This is DYLD_FALLBACK_LIBRARY_PATH on Darwin (OS X) and LD_LIBRARY_PATH elsewhere
+## This is DYLD_FALLBACK_LIBRARY_PATH on Darwin (OS X) and
+## LD_LIBRARY_PATH elsewhere.
+## However, on OS X 10.11 (if SIP is enabled, the default), the
+## environment value will not be passed to a script such as R.sh, so
+## would not seen here.
if test -z "${@Rshlibpath_var@}"; then
@Rshlibpath_var@="${R_LD_LIBRARY_PATH}"
else
diff -Nru r-base-3.2.3/etc/Makeconf.in r-base-3.3.1/etc/Makeconf.in
--- r-base-3.2.3/etc/Makeconf.in 2015-03-25 10:19:06.000000000 +0000
+++ r-base-3.3.1/etc/Makeconf.in 2016-03-16 23:04:44.000000000 +0000
@@ -10,8 +10,6 @@
include $(R_SHARE_DIR)/make/vars.mk
AR = @AR@
-## Used by packages 'maps' and 'mapdata'
-AWK = @AWK@
BLAS_LIBS = @BLAS_LIBS@
C_VISIBILITY = @C_VISIBILITY@
CC = @CC@
diff -Nru r-base-3.2.3/etc/repositories r-base-3.3.1/etc/repositories
--- r-base-3.2.3/etc/repositories 2015-08-06 22:02:03.000000000 +0000
+++ r-base-3.3.1/etc/repositories 2016-03-16 23:04:44.000000000 +0000
@@ -14,10 +14,7 @@
BioCann "BioC annotation" %bm/packages/%v/data/annotation FALSE TRUE TRUE TRUE
BioCexp "BioC experiment" %bm/packages/%v/data/experiment FALSE TRUE TRUE TRUE
BioCextra "BioC extra" %bm/packages/%v/extra FALSE TRUE TRUE TRUE
-CRANextra CRAN (extras) http://www.stats.ox.ac.uk/pub/RWin FALSE TRUE TRUE TRUE
-Omegahat Omegahat http://www.omegahat.org/R FALSE TRUE FALSE FALSE
-R-Forge R-Forge http://R-Forge.R-project.org FALSE TRUE TRUE TRUE
-rforge.net rforge.net http://www.rforge.net FALSE TRUE TRUE TRUE
-CRANextra[https] "CRAN (extras, https)" "https://www.stats.ox.ac.uk/pub/RWin" FALSE TRUE TRUE TRUE
-R-Forge[https] "R-Forge [https]" https://R-Forge.R-project.org FALSE TRUE TRUE TRUE
-rforge.net[https] "rforge.net [https]" https://www.rforge.net FALSE TRUE TRUE TRUE
+CRANextra CRAN (extras) https://www.stats.ox.ac.uk/pub/RWin FALSE TRUE TRUE TRUE
+Omegahat Omegahat http://www.omegahat.net/R FALSE TRUE FALSE FALSE
+R-Forge R-Forge https://R-Forge.R-project.org FALSE TRUE TRUE TRUE
+rforge.net rforge.net https://www.rforge.net FALSE TRUE TRUE TRUE
diff -Nru r-base-3.2.3/m4/cairo.m4 r-base-3.3.1/m4/cairo.m4
--- r-base-3.2.3/m4/cairo.m4 2014-06-13 22:15:06.000000000 +0000
+++ r-base-3.3.1/m4/cairo.m4 2016-03-16 23:02:07.000000000 +0000
@@ -16,7 +16,7 @@
###
### You should have received a copy of the GNU General Public License
### along with R; if not, a copy is available at
-### http://www.r-project.org/Licenses/
+### https://www.r-project.org/Licenses/
AC_DEFUN([R_PANGO_CAIRO], [
@@ -126,6 +126,7 @@
case "${host_os}" in
darwin*)
## This is for static OS X build
+ ## FIXME: doing that unconditionally is really not a good idea
CAIRO_LIBS=`"${PKGCONF}" --static --libs ${modlist}`
CAIROX11_LIBS=`"${PKGCONF}" --static --libs ${xmodlist}`
;;
diff -Nru r-base-3.2.3/m4/cxx_11.m4 r-base-3.3.1/m4/cxx_11.m4
--- r-base-3.2.3/m4/cxx_11.m4 2014-03-12 23:02:06.000000000 +0000
+++ r-base-3.3.1/m4/cxx_11.m4 2015-12-10 23:15:11.000000000 +0000
@@ -1,5 +1,5 @@
# ============================================================================
-# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
+# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# ============================================================================
#
# SYNOPSIS
diff -Nru r-base-3.2.3/m4/libtool.m4 r-base-3.3.1/m4/libtool.m4
--- r-base-3.2.3/m4/libtool.m4 2015-08-02 22:15:03.000000000 +0000
+++ r-base-3.3.1/m4/libtool.m4 2016-03-16 23:02:06.000000000 +0000
@@ -1,7 +1,6 @@
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-# 2006, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc.
# Written by Gordon Matzigkeit, 1996
#
# This file is free software; the Free Software Foundation gives
@@ -9,37 +8,31 @@
# modifications, as long as this notice is preserved.
m4_define([_LT_COPYING], [dnl
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-# 2006, 2007, 2008 Free Software Foundation, Inc.
-# Written by Gordon Matzigkeit, 1996
-#
-# This file is part of GNU Libtool.
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions. There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of of the License, or
+# (at your option) any later version.
#
-# GNU Libtool is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the same
+# distribution terms that you use for the rest of that program.
#
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
-#
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with GNU Libtool; see the file COPYING. If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program. If not, see .
])
-dnl Some changes for FreeBSD >= 10 ported from libtool 2.4.6.
-
-dnl # serial 56 LT_INIT
+dnl commented out to avoid autoconf warnings
+dnl # serial 58 LT_INIT
# LT_PREREQ(VERSION)
@@ -67,7 +60,8 @@
# LT_INIT([OPTIONS])
# ------------------
AC_DEFUN([LT_INIT],
-[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK
+AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
AC_BEFORE([$0], [LT_LANG])dnl
AC_BEFORE([$0], [LT_OUTPUT])dnl
AC_BEFORE([$0], [LTDL_INIT])dnl
@@ -84,11 +78,13 @@
AC_REQUIRE([LTOBSOLETE_VERSION])dnl
m4_require([_LT_PROG_LTMAIN])dnl
+_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])
+
dnl Parse OPTIONS
_LT_SET_OPTIONS([$0], [$1])
# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
# Always use our own libtool.
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -108,26 +104,43 @@
dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+# _LT_PREPARE_CC_BASENAME
+# -----------------------
+m4_defun([_LT_PREPARE_CC_BASENAME], [
+# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+ for cc_temp in @S|@*""; do
+ case $cc_temp in
+ compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+ distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+ done
+ func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+])# _LT_PREPARE_CC_BASENAME
+
+
# _LT_CC_BASENAME(CC)
# -------------------
-# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME,
+# but that macro is also expanded into generated libtool script, which
+# arranges for $SED and $ECHO to be set by different means.
m4_defun([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
- case $cc_temp in
- compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
- distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+[m4_require([_LT_PREPARE_CC_BASENAME])dnl
+AC_REQUIRE([_LT_DECL_SED])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+func_cc_basename $1
+cc_basename=$func_cc_basename_result
])
# _LT_FILEUTILS_DEFAULTS
# ----------------------
# It is okay to use these file commands and assume they have been set
-# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'.
m4_defun([_LT_FILEUTILS_DEFAULTS],
[: ${CP="cp -f"}
: ${MV="mv -f"}
@@ -140,6 +153,11 @@
m4_defun([_LT_SETUP],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+
+_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl
+dnl
_LT_DECL([], [host_alias], [0], [The host system])dnl
_LT_DECL([], [host], [0])dnl
_LT_DECL([], [host_os], [0])dnl
@@ -162,68 +180,54 @@
dnl
m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
m4_require([_LT_CMD_RELOAD])dnl
m4_require([_LT_CHECK_MAGIC_METHOD])dnl
+m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
m4_require([_LT_CMD_OLD_ARCHIVE])dnl
m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_WITH_SYSROOT])dnl
+m4_require([_LT_CMD_TRUNCATE])dnl
_LT_CONFIG_LIBTOOL_INIT([
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
# commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
setopt NO_GLOB_SUBST
fi
])
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
setopt NO_GLOB_SUBST
fi
_LT_CHECK_OBJDIR
m4_require([_LT_TAG_COMPILER])dnl
-_LT_PROG_ECHO_BACKSLASH
case $host_os in
aix3*)
# AIX sometimes has problems with the GCC collect2 program. For some
# reason, if we set the COLLECT_NAMES environment variable, the problems
# vanish in a puff of smoke.
- if test "X${COLLECT_NAMES+set}" != Xset; then
+ if test set != "${COLLECT_NAMES+set}"; then
COLLECT_NAMES=
export COLLECT_NAMES
fi
;;
esac
-# Sed substitution that helps us do robust quoting. It backslashifies
-# metacharacters that are still active within double-quoted strings.
-sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\([["`\\]]\)/\\\1/g'
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to delay expansion of an escaped single quote.
-delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-
# Global variables:
ofile=libtool
can_build_shared=yes
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
# which needs '.lib').
libext=a
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
# Set sane defaults for various variables
test -z "$CC" && CC=cc
@@ -252,16 +256,38 @@
])# _LT_SETUP
+# _LT_PREPARE_SED_QUOTE_VARS
+# --------------------------
+# Define a few sed substitution that help us do robust quoting.
+m4_defun([_LT_PREPARE_SED_QUOTE_VARS],
+[# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+])
+
# _LT_PROG_LTMAIN
# ---------------
-# Note that this code is called both from `configure', and `config.status'
+# Note that this code is called both from 'configure', and 'config.status'
# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
-# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# 'config.status' has no value for ac_aux_dir unless we are using Automake,
# so we pass a copy along to make sure it has a sensible value anyway.
m4_defun([_LT_PROG_LTMAIN],
[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
])# _LT_PROG_LTMAIN
@@ -271,7 +297,7 @@
# So that we can recreate a full libtool script including additional
# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
-# in macros and then make a single call at the end using the `libtool'
+# in macros and then make a single call at the end using the 'libtool'
# label.
@@ -406,11 +432,11 @@
# _LT_CONFIG_STATUS_DECLARE([VARNAME])
# ------------------------------------
-# Quote a variable value, and forward it to `config.status' so that its
-# declaration there will have the same value as in `configure'. VARNAME
+# Quote a variable value, and forward it to 'config.status' so that its
+# declaration there will have the same value as in 'configure'. VARNAME
# must have a single quote delimited value for this to work.
m4_define([_LT_CONFIG_STATUS_DECLARE],
-[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
+[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
# _LT_CONFIG_STATUS_DECLARATIONS
@@ -420,7 +446,7 @@
# embedded single quotes properly. In configure, this macro expands
# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
#
-# ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`'
+# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`'
m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
[m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
@@ -431,7 +457,7 @@
# Output comment and list of tags supported by the script
m4_defun([_LT_LIBTOOL_TAGS],
[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
-available_tags="_LT_TAGS"dnl
+available_tags='_LT_TAGS'dnl
])
@@ -459,7 +485,7 @@
# _LT_LIBTOOL_CONFIG_VARS
# -----------------------
# Produce commented declarations of non-tagged libtool config variables
-# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool'
# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
# section) are produced by _LT_LIBTOOL_TAG_VARS.
m4_defun([_LT_LIBTOOL_CONFIG_VARS],
@@ -485,8 +511,8 @@
# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
# variables for single and double quote escaping we saved from calls
# to _LT_DECL, we can put quote escaped variables declarations
-# into `config.status', and then the shell code to quote escape them in
-# for loops in `config.status'. Finally, any additional code accumulated
+# into 'config.status', and then the shell code to quote escape them in
+# for loops in 'config.status'. Finally, any additional code accumulated
# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
m4_defun([_LT_CONFIG_COMMANDS],
[AC_PROVIDE_IFELSE([LT_OUTPUT],
@@ -519,12 +545,20 @@
LTCFLAGS='$LTCFLAGS'
compiler='$compiler_DEFAULT'
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+ eval 'cat <<_LTECHO_EOF
+\$[]1
+_LTECHO_EOF'
+}
+
# Quote evaled strings.
for var in lt_decl_all_varnames([[ \
]], lt_decl_quote_varnames); do
- case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
*[[\\\\\\\`\\"\\\$]]*)
- eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
;;
*)
eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -535,9 +569,9 @@
# Double-quote double-evaled strings.
for var in lt_decl_all_varnames([[ \
]], lt_decl_dquote_varnames); do
- case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
*[[\\\\\\\`\\"\\\$]]*)
- eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
;;
*)
eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -545,16 +579,38 @@
esac
done
-# Fix-up fallback echo if it was mangled by the above quoting rules.
-case \$lt_ECHO in
-*'\\\[$]0 --fallback-echo"')dnl "
- lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
- ;;
-esac
-
_LT_OUTPUT_LIBTOOL_INIT
])
+# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])
+# ------------------------------------
+# Generate a child script FILE with all initialization necessary to
+# reuse the environment learned by the parent script, and make the
+# file executable. If COMMENT is supplied, it is inserted after the
+# '#!' sequence but before initialization text begins. After this
+# macro, additional text can be appended to FILE to form the body of
+# the child script. The macro ends with non-zero status if the
+# file could not be fully written (such as if the disk is full).
+m4_ifdef([AS_INIT_GENERATED],
+[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],
+[m4_defun([_LT_GENERATED_FILE_INIT],
+[m4_require([AS_PREPARE])]dnl
+[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
+[lt_write_fail=0
+cat >$1 <<_ASEOF || lt_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+$2
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$1 <<\_ASEOF || lt_write_fail=1
+AS_SHELL_SANITIZE
+_AS_PREPARE
+exec AS_MESSAGE_FD>&1
+_ASEOF
+test 0 = "$lt_write_fail" && chmod +x $1[]dnl
+m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
# LT_OUTPUT
# ---------
@@ -564,20 +620,11 @@
AC_DEFUN([LT_OUTPUT],
[: ${CONFIG_LT=./config.lt}
AC_MSG_NOTICE([creating $CONFIG_LT])
-cat >"$CONFIG_LT" <<_LTEOF
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate a libtool stub with the current configuration.
-
-lt_cl_silent=false
-SHELL=\${CONFIG_SHELL-$SHELL}
-_LTEOF
+_LT_GENERATED_FILE_INIT(["$CONFIG_LT"],
+[# Run this file to recreate a libtool stub with the current configuration.])
cat >>"$CONFIG_LT" <<\_LTEOF
-AS_SHELL_SANITIZE
-_AS_PREPARE
-
-exec AS_MESSAGE_FD>&1
+lt_cl_silent=false
exec AS_MESSAGE_LOG_FD>>config.log
{
echo
@@ -585,7 +632,7 @@
} >&AS_MESSAGE_LOG_FD
lt_cl_help="\
-\`$as_me' creates a local libtool stub from the current configuration,
+'$as_me' creates a local libtool stub from the current configuration,
for use in further configure time tests before the real libtool is
generated.
@@ -603,11 +650,11 @@
m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
configured by $[0], generated by m4_PACKAGE_STRING.
-Copyright (C) 2008 Free Software Foundation, Inc.
+Copyright (C) 2011 Free Software Foundation, Inc.
This config.lt script is free software; the Free Software Foundation
gives unlimited permision to copy, distribute and modify it."
-while test $[#] != 0
+while test 0 != $[#]
do
case $[1] in
--version | --v* | -V )
@@ -620,10 +667,10 @@
lt_cl_silent=: ;;
-*) AC_MSG_ERROR([unrecognized option: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
*) AC_MSG_ERROR([unrecognized argument: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
esac
shift
done
@@ -648,15 +695,13 @@
# appending to config.log, which fails on DOS, as config.log is still kept
# open by configure. Here we exec the FD to /dev/null, effectively closing
# config.log, so it can be properly (re)opened and appended to by config.lt.
-if test "$no_create" != yes; then
- lt_cl_success=:
- test "$silent" = yes &&
- lt_config_lt_args="$lt_config_lt_args --quiet"
- exec AS_MESSAGE_LOG_FD>/dev/null
- $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
- exec AS_MESSAGE_LOG_FD>>config.log
- $lt_cl_success || AS_EXIT(1)
-fi
+lt_cl_success=:
+test yes = "$silent" &&
+ lt_config_lt_args="$lt_config_lt_args --quiet"
+exec AS_MESSAGE_LOG_FD>/dev/null
+$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+exec AS_MESSAGE_LOG_FD>>config.log
+$lt_cl_success || AS_EXIT(1)
])# LT_OUTPUT
@@ -671,27 +716,31 @@
_LT_CONFIG_SAVE_COMMANDS([
m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
m4_if(_LT_TAG, [C], [
- # See if we are running on zsh, and set the options which allow our
+ # See if we are running on zsh, and set the options that allow our
# commands through without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
+ if test -n "${ZSH_VERSION+set}"; then
setopt NO_GLOB_SUBST
fi
- cfgfile="${ofile}T"
+ cfgfile=${ofile}T
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
$RM "$cfgfile"
cat <<_LT_EOF >> "$cfgfile"
#! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
_LT_COPYING
_LT_LIBTOOL_TAGS
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
+
# ### BEGIN LIBTOOL CONFIG
_LT_LIBTOOL_CONFIG_VARS
_LT_LIBTOOL_TAG_VARS
@@ -699,13 +748,24 @@
_LT_EOF
+ cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_PREPARE_MUNGE_PATH_LIST
+_LT_PREPARE_CC_BASENAME
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
case $host_os in
aix3*)
cat <<\_LT_EOF >> "$cfgfile"
# AIX sometimes has problems with the GCC collect2 program. For some
# reason, if we set the COLLECT_NAMES environment variable, the problems
# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
COLLECT_NAMES=
export COLLECT_NAMES
fi
@@ -719,15 +779,10 @@
# if finds mixed CR/LF and LF-only lines. Since sed operates in
# text mode, it properly converts lines to CR/LF. This bash problem
# is reportedly fixed, but why not run on old versions too?
- sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
- || (rm -f "$cfgfile"; exit 1)
+ sed '$q' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
- _LT_PROG_XSI_SHELLFNS
-
- sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
- || (rm -f "$cfgfile"; exit 1)
-
- mv -f "$cfgfile" "$ofile" ||
+ mv -f "$cfgfile" "$ofile" ||
(rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
chmod +x "$ofile"
],
@@ -744,7 +799,6 @@
[m4_if([$1], [], [
PACKAGE='$PACKAGE'
VERSION='$VERSION'
- TIMESTAMP='$TIMESTAMP'
RM='$RM'
ofile='$ofile'], [])
])dnl /_LT_CONFIG_SAVE_COMMANDS
@@ -772,6 +826,7 @@
m4_case([$1],
[C], [_LT_LANG(C)],
[C++], [_LT_LANG(CXX)],
+ [Go], [_LT_LANG(GO)],
[Java], [_LT_LANG(GCJ)],
[Fortran 77], [_LT_LANG(F77)],
[Fortran], [_LT_LANG(FC)],
@@ -793,6 +848,31 @@
])# _LT_LANG
+m4_ifndef([AC_PROG_GO], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into #
+# GNU Autoconf as AC_PROG_GO. When it is available in #
+# a released version of Autoconf we should remove this #
+# macro and use it instead. #
+############################################################
+m4_defun([AC_PROG_GO],
+[AC_LANG_PUSH(Go)dnl
+AC_ARG_VAR([GOC], [Go compiler command])dnl
+AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
+_AC_ARG_VAR_LDFLAGS()dnl
+AC_CHECK_TOOL(GOC, gccgo)
+if test -z "$GOC"; then
+ if test -n "$ac_tool_prefix"; then
+ AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo])
+ fi
+fi
+if test -z "$GOC"; then
+ AC_CHECK_PROG(GOC, gccgo, gccgo, false)
+fi
+])#m4_defun
+])#m4_ifndef
+
+
# _LT_LANG_DEFAULT_CONFIG
# -----------------------
m4_defun([_LT_LANG_DEFAULT_CONFIG],
@@ -823,6 +903,10 @@
m4_ifdef([LT_PROG_GCJ],
[m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
+AC_PROVIDE_IFELSE([AC_PROG_GO],
+ [LT_LANG(GO)],
+ [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])])
+
AC_PROVIDE_IFELSE([LT_PROG_RC],
[LT_LANG(RC)],
[m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
@@ -833,11 +917,13 @@
AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
+AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])
dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
dnl AC_DEFUN([AC_LIBTOOL_F77], [])
dnl AC_DEFUN([AC_LIBTOOL_FC], [])
dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+dnl AC_DEFUN([AC_LIBTOOL_RC], [])
# _LT_TAG_COMPILER
@@ -911,7 +997,7 @@
AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
[lt_cv_apple_cc_single_mod=no
- if test -z "${LT_MULTI_MODULE}"; then
+ if test -z "$LT_MULTI_MODULE"; then
# By default we will add the -single_module flag. You can override
# by either setting the environment variable LT_MULTI_MODULE
# non-empty at configure time, or by adding -multi_module to the
@@ -923,7 +1009,13 @@
$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
-dynamiclib -Wl,-single_module conftest.c 2>conftest.err
_lt_result=$?
- if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+ # If there is a non-empty error log, and "single_module"
+ # appears in it, assume the flag caused a linker warning
+ if test -s conftest.err && $GREP single_module conftest.err; then
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ # Otherwise, if the output was created with a 0 exit code from
+ # the compiler, it worked.
+ elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
lt_cv_apple_cc_single_mod=yes
else
cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -931,6 +1023,7 @@
rm -rf libconftest.dylib*
rm -f conftest.*
fi])
+
AC_CACHE_CHECK([for -exported_symbols_list linker flag],
[lt_cv_ld_exported_symbols_list],
[lt_cv_ld_exported_symbols_list=no
@@ -940,36 +1033,64 @@
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
[lt_cv_ld_exported_symbols_list=yes],
[lt_cv_ld_exported_symbols_list=no])
- LDFLAGS="$save_LDFLAGS"
+ LDFLAGS=$save_LDFLAGS
+ ])
+
+ AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
+ [lt_cv_ld_force_load=no
+ cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+ echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
+ $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
+ echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
+ $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
+ echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
+ $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
+ cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
+ $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+ _lt_result=$?
+ if test -s conftest.err && $GREP force_load conftest.err; then
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
+ lt_cv_ld_force_load=yes
+ else
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ fi
+ rm -f conftest.err libconftest.a conftest conftest.c
+ rm -rf conftest.dSYM
])
case $host_os in
rhapsody* | darwin1.[[012]])
- _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
darwin1.*)
- _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
darwin*) # darwin 5.x on
# if running on 10.5 or later, the deployment target defaults
# to the OS version, if on x86, and 10.4, the deployment
# target defaults to 10.4. Don't you love it?
case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
- _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
- 10.[[012]]*)
- _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+ 10.[[012]][[,.]]*)
+ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
10.*)
- _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
esac
;;
esac
- if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+ if test yes = "$lt_cv_apple_cc_single_mod"; then
_lt_dar_single_mod='$single_module'
fi
- if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
- _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+ if test yes = "$lt_cv_ld_exported_symbols_list"; then
+ _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
else
- _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
fi
- if test "$DSYMUTIL" != ":"; then
+ if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
_lt_dsymutil='~$DSYMUTIL $lib || :'
else
_lt_dsymutil=
@@ -979,8 +1100,8 @@
])
-# _LT_DARWIN_LINKER_FEATURES
-# --------------------------
+# _LT_DARWIN_LINKER_FEATURES([TAG])
+# ---------------------------------
# Checks for linker and compiler features on darwin
m4_defun([_LT_DARWIN_LINKER_FEATURES],
[
@@ -989,23 +1110,29 @@
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_automatic, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
- _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+ if test yes = "$lt_cv_ld_force_load"; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+ m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
+ [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes])
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+ fi
_LT_TAGVAR(link_all_deplibs, $1)=yes
- _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+ _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined
case $cc_basename in
- ifort*) _lt_dar_can_shared=yes ;;
+ ifort*|nagfor*) _lt_dar_can_shared=yes ;;
*) _lt_dar_can_shared=$GCC ;;
esac
- if test "$_lt_dar_can_shared" = "yes"; then
- output_verbose_link_cmd=echo
- _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
- _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
- _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
- _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+ if test yes = "$_lt_dar_can_shared"; then
+ output_verbose_link_cmd=func_echo_all
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+ _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+ _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
m4_if([$1], [CXX],
-[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
- _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
- _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+[ if test yes != "$lt_cv_apple_cc_single_mod"; then
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil"
fi
],[])
else
@@ -1013,234 +1140,176 @@
fi
])
-# _LT_SYS_MODULE_PATH_AIX
-# -----------------------
+# _LT_SYS_MODULE_PATH_AIX([TAGNAME])
+# ----------------------------------
# Links a minimal program and checks the executable
# for the system default hardcoded library path. In most cases,
# this is /usr/lib:/lib, but when the MPI compilers are used
# the location of the communication and MPI libs are included too.
# If we don't find anything, use the default library path according
# to the aix ld manual.
+# Store the results from the different compilers for each TAGNAME.
+# Allow to override them for all tags through lt_cv_aix_libpath.
m4_defun([_LT_SYS_MODULE_PATH_AIX],
[m4_require([_LT_DECL_SED])dnl
-AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],[
-lt_aix_libpath_sed='
- /Import File Strings/,/^$/ {
- /^0/ {
- s/^0 *\(.*\)$/\1/
- p
- }
- }'
-aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-# Check for a 64-bit object if we didn't find anything.
-if test -z "$aix_libpath"; then
- aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-fi],[])
-if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+if test set = "${lt_cv_aix_libpath+set}"; then
+ aix_libpath=$lt_cv_aix_libpath
+else
+ AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM],[
+ lt_aix_libpath_sed='[
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\([^ ]*\) *$/\1/
+ p
+ }
+ }]'
+ _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ # Check for a 64-bit object if we didn't find anything.
+ if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
+ _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+ fi],[])
+ if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
+ _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib
+ fi
+ ])
+ aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
+fi
])# _LT_SYS_MODULE_PATH_AIX
# _LT_SHELL_INIT(ARG)
# -------------------
m4_define([_LT_SHELL_INIT],
-[ifdef([AC_DIVERSION_NOTICE],
- [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
- [AC_DIVERT_PUSH(NOTICE)])
-$1
-AC_DIVERT_POP
-])# _LT_SHELL_INIT
+[m4_divert_text([M4SH-INIT], [$1
+])])# _LT_SHELL_INIT
+
# _LT_PROG_ECHO_BACKSLASH
# -----------------------
-# Add some code to the start of the generated configure script which
-# will find an echo command which doesn't interpret backslashes.
+# Find how we can fake an echo command that does not interpret backslash.
+# In particular, with Autoconf 2.60 or later we add some code to the start
+# of the generated configure script that will find a shell with a builtin
+# printf (that we can use as an echo command).
m4_defun([_LT_PROG_ECHO_BACKSLASH],
-[_LT_SHELL_INIT([
-# Check that we are running under the correct shell.
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-case X$lt_ECHO in
-X*--fallback-echo)
- # Remove one level of quotation (which was required for Make).
- ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
- ;;
-esac
-
-ECHO=${lt_ECHO-echo}
-if test "X[$]1" = X--no-reexec; then
- # Discard the --no-reexec flag, and continue.
- shift
-elif test "X[$]1" = X--fallback-echo; then
- # Avoid inline document here, it may be left over
- :
-elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
- # Yippee, $ECHO works!
- :
+[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+
+AC_MSG_CHECKING([how to print strings])
+# Test print first, because it will be a builtin if present.
+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
+ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+ ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+ ECHO='printf %s\n'
else
- # Restart under the correct shell.
- exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
-fi
-
-if test "X[$]1" = X--fallback-echo; then
- # used as fallback echo
- shift
- cat <<_LT_EOF
-[$]*
-_LT_EOF
- exit 0
+ # Use this function as a fallback that always works.
+ func_fallback_echo ()
+ {
+ eval 'cat <<_LTECHO_EOF
+$[]1
+_LTECHO_EOF'
+ }
+ ECHO='func_fallback_echo'
fi
-# The HP-UX ksh and POSIX shell print the target directory to stdout
-# if CDPATH is set.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-if test -z "$lt_ECHO"; then
- if test "X${echo_test_string+set}" != Xset; then
- # find a string as large as possible, as long as the shell can cope with it
- for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
- # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
- if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
- { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
- then
- break
- fi
- done
- fi
-
- if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- :
- else
- # The Solaris, AIX, and Digital Unix default echo programs unquote
- # backslashes. This makes it impossible to quote backslashes using
- # echo "$something" | sed 's/\\/\\\\/g'
- #
- # So, first we look for a working echo in the user's PATH.
-
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
- for dir in $PATH /usr/ucb; do
- IFS="$lt_save_ifs"
- if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
- test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- ECHO="$dir/echo"
- break
- fi
- done
- IFS="$lt_save_ifs"
-
- if test "X$ECHO" = Xecho; then
- # We didn't find a better echo, so look for alternatives.
- if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # This shell has a builtin print -r that does the trick.
- ECHO='print -r'
- elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
- test "X$CONFIG_SHELL" != X/bin/ksh; then
- # If we have ksh, try running configure again with it.
- ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
- export ORIGINAL_CONFIG_SHELL
- CONFIG_SHELL=/bin/ksh
- export CONFIG_SHELL
- exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
- else
- # Try using printf.
- ECHO='printf %s\n'
- if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
- echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- # Cool, printf works
- :
- elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
- export CONFIG_SHELL
- SHELL="$CONFIG_SHELL"
- export SHELL
- ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
- elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
- test "X$echo_testing_string" = 'X\t' &&
- echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
- test "X$echo_testing_string" = "X$echo_test_string"; then
- ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
- else
- # maybe with a smaller string...
- prev=:
-
- for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
- if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
- then
- break
- fi
- prev="$cmd"
- done
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+ $ECHO "$*"
+}
- if test "$prev" != 'sed 50q "[$]0"'; then
- echo_test_string=`eval $prev`
- export echo_test_string
- exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
- else
- # Oops. We lost completely, so just stick with echo.
- ECHO=echo
- fi
- fi
- fi
- fi
- fi
-fi
+case $ECHO in
+ printf*) AC_MSG_RESULT([printf]) ;;
+ print*) AC_MSG_RESULT([print -r]) ;;
+ *) AC_MSG_RESULT([cat]) ;;
+esac
-# Copy echo and quote the copy suitably for passing to libtool from
-# the Makefile, instead of quoting the original, which is used later.
-lt_ECHO=$ECHO
-if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
- lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
-fi
+m4_ifdef([_AS_DETECT_SUGGESTED],
+[_AS_DETECT_SUGGESTED([
+ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || (
+ ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+ PATH=/empty FPATH=/empty; export PATH FPATH
+ test "X`printf %s $ECHO`" = "X$ECHO" \
+ || test "X`print -r -- $ECHO`" = "X$ECHO" )])])
-AC_SUBST(lt_ECHO)
-])
_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
-_LT_DECL([], [ECHO], [1],
- [An echo program that does not interpret backslashes])
+_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
])# _LT_PROG_ECHO_BACKSLASH
+# _LT_WITH_SYSROOT
+# ----------------
+AC_DEFUN([_LT_WITH_SYSROOT],
+[AC_MSG_CHECKING([for sysroot])
+AC_ARG_WITH([sysroot],
+[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@],
+ [Search for dependent libraries within DIR (or the compiler's sysroot
+ if not specified).])],
+[], [with_sysroot=no])
+
+dnl lt_sysroot will always be passed unquoted. We quote it here
+dnl in case the user passed a directory name.
+lt_sysroot=
+case $with_sysroot in #(
+ yes)
+ if test yes = "$GCC"; then
+ lt_sysroot=`$CC --print-sysroot 2>/dev/null`
+ fi
+ ;; #(
+ /*)
+ lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
+ ;; #(
+ no|'')
+ ;; #(
+ *)
+ AC_MSG_RESULT([$with_sysroot])
+ AC_MSG_ERROR([The sysroot must be an absolute path.])
+ ;;
+esac
+
+ AC_MSG_RESULT([${lt_sysroot:-no}])
+_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
+[dependent libraries, and where our libraries should be installed.])])
+
# _LT_ENABLE_LOCK
# ---------------
m4_defun([_LT_ENABLE_LOCK],
[AC_ARG_ENABLE([libtool-lock],
[AS_HELP_STRING([--disable-libtool-lock],
[avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
# Some flags need to be propagated to the compiler or linker for good
# libtool support.
case $host in
ia64-*-hpux*)
- # Find out which ABI we are using.
+ # Find out what ABI is being produced by ac_compile, and set mode
+ # options accordingly.
echo 'int i;' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case `/usr/bin/file conftest.$ac_objext` in
*ELF-32*)
- HPUX_IA64_MODE="32"
+ HPUX_IA64_MODE=32
;;
*ELF-64*)
- HPUX_IA64_MODE="64"
+ HPUX_IA64_MODE=64
;;
esac
fi
rm -rf conftest*
;;
*-*-irix6*)
- # Find out which ABI we are using.
- echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+ # Find out what ABI is being produced by ac_compile, and set linker
+ # options accordingly.
+ echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
- if test "$lt_cv_prog_gnu_ld" = yes; then
+ if test yes = "$lt_cv_prog_gnu_ld"; then
case `/usr/bin/file conftest.$ac_objext` in
*32-bit*)
LD="${LD-ld} -melf32bsmip"
@@ -1269,9 +1338,46 @@
rm -rf conftest*
;;
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+mips64*-*linux*)
+ # Find out what ABI is being produced by ac_compile, and set linker
+ # options accordingly.
+ echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ emul=elf
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ emul="${emul}32"
+ ;;
+ *64-bit*)
+ emul="${emul}64"
+ ;;
+ esac
+ case `/usr/bin/file conftest.$ac_objext` in
+ *MSB*)
+ emul="${emul}btsmip"
+ ;;
+ *LSB*)
+ emul="${emul}ltsmip"
+ ;;
+ esac
+ case `/usr/bin/file conftest.$ac_objext` in
+ *N32*)
+ emul="${emul}n32"
+ ;;
+ esac
+ LD="${LD-ld} -m $emul"
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
- # Find out which ABI we are using.
+ # Find out what ABI is being produced by ac_compile, and set linker
+ # options accordingly. Note that the listed cases only cover the
+ # situations where additional linker options are needed (such as when
+ # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+ # vice versa); the common cases where no linker options are needed do
+ # not appear in the list.
echo 'int i;' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case `/usr/bin/file conftest.o` in
@@ -1281,9 +1387,19 @@
LD="${LD-ld} -m elf_i386_fbsd"
;;
x86_64-*linux*)
- LD="${LD-ld} -m elf_i386"
+ case `/usr/bin/file conftest.o` in
+ *x86-64*)
+ LD="${LD-ld} -m elf32_x86_64"
+ ;;
+ *)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ esac
+ ;;
+ powerpc64le-*linux*)
+ LD="${LD-ld} -m elf32lppclinux"
;;
- ppc64-*linux*|powerpc64-*linux*)
+ powerpc64-*linux*)
LD="${LD-ld} -m elf32ppclinux"
;;
s390x-*linux*)
@@ -1302,7 +1418,10 @@
x86_64-*linux*)
LD="${LD-ld} -m elf_x86_64"
;;
- ppc*-*linux*|powerpc*-*linux*)
+ powerpcle-*linux*)
+ LD="${LD-ld} -m elf64lppc"
+ ;;
+ powerpc-*linux*)
LD="${LD-ld} -m elf64ppc"
;;
s390*-*linux*|s390*-*tpf*)
@@ -1320,25 +1439,39 @@
*-*-sco3.2v5*)
# On SCO OpenServer 5, we need -belf to get full-featured binaries.
- SAVE_CFLAGS="$CFLAGS"
+ SAVE_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -belf"
AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
[AC_LANG_PUSH(C)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
AC_LANG_POP])
- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ if test yes != "$lt_cv_cc_needs_belf"; then
# this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
- CFLAGS="$SAVE_CFLAGS"
+ CFLAGS=$SAVE_CFLAGS
fi
;;
-sparc*-*solaris*)
- # Find out which ABI we are using.
+*-*solaris*)
+ # Find out what ABI is being produced by ac_compile, and set linker
+ # options accordingly.
echo 'int i;' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case `/usr/bin/file conftest.o` in
*64-bit*)
case $lt_cv_prog_gnu_ld in
- yes*) LD="${LD-ld} -m elf64_sparc" ;;
+ yes*)
+ case $host in
+ i?86-*-solaris*|x86_64-*-solaris*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ sparc*-*-solaris*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ # GNU ld 2.21 introduced _sol2 emulations. Use them if available.
+ if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+ LD=${LD-ld}_sol2
+ fi
+ ;;
*)
if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
LD="${LD-ld} -64"
@@ -1352,18 +1485,51 @@
;;
esac
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
])# _LT_ENABLE_LOCK
+# _LT_PROG_AR
+# -----------
+m4_defun([_LT_PROG_AR],
+[AC_CHECK_TOOLS(AR, [ar], false)
+: ${AR=ar}
+: ${AR_FLAGS=cru}
+_LT_DECL([], [AR], [1], [The archiver])
+_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
+
+AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
+ [lt_cv_ar_at_file=no
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
+ [echo conftest.$ac_objext > conftest.lst
+ lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
+ AC_TRY_EVAL([lt_ar_try])
+ if test 0 -eq "$ac_status"; then
+ # Ensure the archiver fails upon bogus file names.
+ rm -f conftest.$ac_objext libconftest.a
+ AC_TRY_EVAL([lt_ar_try])
+ if test 0 -ne "$ac_status"; then
+ lt_cv_ar_at_file=@
+ fi
+ fi
+ rm -f conftest.* libconftest.a
+ ])
+ ])
+
+if test no = "$lt_cv_ar_at_file"; then
+ archiver_list_spec=
+else
+ archiver_list_spec=$lt_cv_ar_at_file
+fi
+_LT_DECL([], [archiver_list_spec], [1],
+ [How to feed a file listing to the archiver])
+])# _LT_PROG_AR
+
+
# _LT_CMD_OLD_ARCHIVE
# -------------------
m4_defun([_LT_CMD_OLD_ARCHIVE],
-[AC_CHECK_TOOL(AR, ar, false)
-test -z "$AR" && AR=ar
-test -z "$AR_FLAGS" && AR_FLAGS=cru
-_LT_DECL([], [AR], [1], [The archiver])
-_LT_DECL([], [AR_FLAGS], [1])
+[_LT_PROG_AR
AC_CHECK_TOOL(STRIP, strip, :)
test -z "$STRIP" && STRIP=:
@@ -1381,19 +1547,28 @@
if test -n "$RANLIB"; then
case $host_os in
- openbsd*)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+ bitrig* | openbsd*)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
;;
*)
- old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
;;
esac
- old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
fi
+
+case $host_os in
+ darwin*)
+ lock_old_archive_extraction=yes ;;
+ *)
+ lock_old_archive_extraction=no ;;
+esac
_LT_DECL([], [old_postinstall_cmds], [2])
_LT_DECL([], [old_postuninstall_cmds], [2])
_LT_TAGDECL([], [old_archive_cmds], [2],
[Commands used to build an old-style archive])
+_LT_DECL([], [lock_old_archive_extraction], [0],
+ [Whether to use a lock for old archive extraction])
])# _LT_CMD_OLD_ARCHIVE
@@ -1408,7 +1583,7 @@
[$2=no
m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
echo "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$3"
+ lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment
# Insert the option either (1) after the last *FLAGS variable, or
# (2) before a word containing "conftest.", or (3) at the end.
# Note that $ac_compile itself does not contain backslashes and begins
@@ -1418,15 +1593,15 @@
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&AS_MESSAGE_LOG_FD
- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
- $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
$SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
$2=yes
@@ -1435,7 +1610,7 @@
$RM conftest*
])
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
m4_if([$5], , :, [$5])
else
m4_if([$6], , :, [$6])
@@ -1457,7 +1632,7 @@
m4_require([_LT_DECL_SED])dnl
AC_CACHE_CHECK([$1], [$2],
[$2=no
- save_LDFLAGS="$LDFLAGS"
+ save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS $3"
echo "$lt_simple_link_test_code" > conftest.$ac_ext
if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -1466,7 +1641,7 @@
if test -s conftest.err; then
# Append any errors to the config.log.
cat conftest.err 1>&AS_MESSAGE_LOG_FD
- $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
$SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
if diff conftest.exp conftest.er2 >/dev/null; then
$2=yes
@@ -1476,10 +1651,10 @@
fi
fi
$RM -r conftest*
- LDFLAGS="$save_LDFLAGS"
+ LDFLAGS=$save_LDFLAGS
])
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
m4_if([$4], , :, [$4])
else
m4_if([$5], , :, [$5])
@@ -1500,7 +1675,7 @@
AC_MSG_CHECKING([the maximum length of command line arguments])
AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
i=0
- teststring="ABCD"
+ teststring=ABCD
case $build_os in
msdosdjgpp*)
@@ -1529,13 +1704,18 @@
lt_cv_sys_max_cmd_len=8192;
;;
+ mint*)
+ # On MiNT this can take a long time and run out of memory.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
amigaos*)
# On AmigaOS with pdksh, this test takes hours, literally.
# So we just punt and use a minimum line length of 8192.
lt_cv_sys_max_cmd_len=8192;
;;
- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+ bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
# This has been around since 386BSD, at least. Likely further.
if test -x /sbin/sysctl; then
lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -1554,6 +1734,11 @@
lt_cv_sys_max_cmd_len=196608
;;
+ os2*)
+ # The test takes a long time on OS/2.
+ lt_cv_sys_max_cmd_len=8192
+ ;;
+
osf*)
# Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
# due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
@@ -1580,22 +1765,23 @@
;;
*)
lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
- if test -n "$lt_cv_sys_max_cmd_len"; then
+ if test -n "$lt_cv_sys_max_cmd_len" && \
+ test undefined != "$lt_cv_sys_max_cmd_len"; then
lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
else
# Make teststring a little bigger before we do anything with it.
# a 1K string should be a reasonable start.
- for i in 1 2 3 4 5 6 7 8 ; do
+ for i in 1 2 3 4 5 6 7 8; do
teststring=$teststring$teststring
done
SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
# If test is not a shell built-in, we'll probably end up computing a
# maximum length that is only half of the actual maximum length, but
# we can't tell.
- while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
- = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
- test $i != 17 # 1/2 MB should be enough
+ while { test X`env echo "$teststring$teststring" 2>/dev/null` \
+ = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+ test 17 != "$i" # 1/2 MB should be enough
do
i=`expr $i + 1`
teststring=$teststring$teststring
@@ -1611,7 +1797,7 @@
;;
esac
])
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
else
AC_MSG_RESULT(none)
@@ -1639,13 +1825,13 @@
# ----------------------------------------------------------------
m4_defun([_LT_TRY_DLOPEN_SELF],
[m4_require([_LT_HEADER_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
+if test yes = "$cross_compiling"; then :
[$4]
else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-[#line __oline__ "configure"
+[#line $LINENO "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -1686,7 +1872,13 @@
# endif
#endif
-void fnord() { int i=42;}
+/* When -fvisibility=hidden is used, assume the code has been annotated
+ correspondingly for the symbols needed. */
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
+
+int fnord () { return 42; }
int main ()
{
void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
@@ -1695,7 +1887,11 @@
if (self)
{
if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
- else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ else
+ {
+ if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ else puts (dlerror ());
+ }
/* dlclose (self); */
}
else
@@ -1704,7 +1900,7 @@
return status;
}]
_LT_EOF
- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+ if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then
(./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
lt_status=$?
case x$lt_status in
@@ -1725,7 +1921,7 @@
# ------------------
AC_DEFUN([LT_SYS_DLOPEN_SELF],
[m4_require([_LT_HEADER_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
+if test yes != "$enable_dlopen"; then
enable_dlopen=unknown
enable_dlopen_self=unknown
enable_dlopen_self_static=unknown
@@ -1735,44 +1931,52 @@
case $host_os in
beos*)
- lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen=load_add_on
lt_cv_dlopen_libs=
lt_cv_dlopen_self=yes
;;
mingw* | pw32* | cegcc*)
- lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen=LoadLibrary
lt_cv_dlopen_libs=
;;
cygwin*)
- lt_cv_dlopen="dlopen"
+ lt_cv_dlopen=dlopen
lt_cv_dlopen_libs=
;;
darwin*)
- # if libdl is installed we need to link against it
+ # if libdl is installed we need to link against it
AC_CHECK_LIB([dl], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
- lt_cv_dlopen="dyld"
+ [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[
+ lt_cv_dlopen=dyld
lt_cv_dlopen_libs=
lt_cv_dlopen_self=yes
])
;;
+ tpf*)
+ # Don't try to run any link tests for TPF. We know it's impossible
+ # because TPF is a cross-compiler, and we know how we open DSOs.
+ lt_cv_dlopen=dlopen
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=no
+ ;;
+
*)
AC_CHECK_FUNC([shl_load],
- [lt_cv_dlopen="shl_load"],
+ [lt_cv_dlopen=shl_load],
[AC_CHECK_LIB([dld], [shl_load],
- [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+ [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld],
[AC_CHECK_FUNC([dlopen],
- [lt_cv_dlopen="dlopen"],
+ [lt_cv_dlopen=dlopen],
[AC_CHECK_LIB([dl], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+ [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],
[AC_CHECK_LIB([svld], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+ [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld],
[AC_CHECK_LIB([dld], [dld_link],
- [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+ [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld])
])
])
])
@@ -1781,21 +1985,21 @@
;;
esac
- if test "x$lt_cv_dlopen" != xno; then
- enable_dlopen=yes
- else
+ if test no = "$lt_cv_dlopen"; then
enable_dlopen=no
+ else
+ enable_dlopen=yes
fi
case $lt_cv_dlopen in
dlopen)
- save_CPPFLAGS="$CPPFLAGS"
- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+ save_CPPFLAGS=$CPPFLAGS
+ test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
- save_LDFLAGS="$LDFLAGS"
+ save_LDFLAGS=$LDFLAGS
wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
- save_LIBS="$LIBS"
+ save_LIBS=$LIBS
LIBS="$lt_cv_dlopen_libs $LIBS"
AC_CACHE_CHECK([whether a program can dlopen itself],
@@ -1805,7 +2009,7 @@
lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
])
- if test "x$lt_cv_dlopen_self" = xyes; then
+ if test yes = "$lt_cv_dlopen_self"; then
wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
lt_cv_dlopen_self_static, [dnl
@@ -1815,9 +2019,9 @@
])
fi
- CPPFLAGS="$save_CPPFLAGS"
- LDFLAGS="$save_LDFLAGS"
- LIBS="$save_LIBS"
+ CPPFLAGS=$save_CPPFLAGS
+ LDFLAGS=$save_LDFLAGS
+ LIBS=$save_LIBS
;;
esac
@@ -1871,16 +2075,16 @@
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&AS_MESSAGE_LOG_FD
- echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
- $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
$SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
@@ -1905,12 +2109,12 @@
# ----------------------------------
# Check to see if we can do hard links to lock some files if needed
m4_defun([_LT_COMPILER_FILE_LOCKS],
-[dnl m4_require([_LT_ENABLE_LOCK])dnl
+[m4_require([_LT_ENABLE_LOCK])dnl
m4_require([_LT_FILEUTILS_DEFAULTS])dnl
_LT_COMPILER_C_O([$1])
-hard_links="nottested"
-if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then
# do not overwrite the value of need_locks provided by the user
AC_MSG_CHECKING([if we can lock with hard links])
hard_links=yes
@@ -1920,8 +2124,8 @@
ln conftest.a conftest.b 2>&5 || hard_links=no
ln conftest.a conftest.b 2>/dev/null && hard_links=no
AC_MSG_RESULT([$hard_links])
- if test "$hard_links" = no; then
- AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+ if test no = "$hard_links"; then
+ AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe])
need_locks=warn
fi
else
@@ -1948,8 +2152,8 @@
_LT_DECL([], [objdir], [0],
[The name of the directory that contains temporary libtool files])dnl
m4_pattern_allow([LT_OBJDIR])dnl
-AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
- [Define to the sub-directory in which libtool stores uninstalled libraries.])
+AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/",
+ [Define to the sub-directory where libtool stores uninstalled libraries.])
])# _LT_CHECK_OBJDIR
@@ -1961,15 +2165,15 @@
_LT_TAGVAR(hardcode_action, $1)=
if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
test -n "$_LT_TAGVAR(runpath_var, $1)" ||
- test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+ test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then
# We can hardcode non-existent directories.
- if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+ if test no != "$_LT_TAGVAR(hardcode_direct, $1)" &&
# If the only mechanism to avoid hardcoding is shlibpath_var, we
# have to relink, otherwise we might link with an installed library
# when we should be linking with a yet-to-be-installed one
- ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
- test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+ ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" &&
+ test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then
# Linking always hardcodes the temporary library directory.
_LT_TAGVAR(hardcode_action, $1)=relink
else
@@ -1983,12 +2187,12 @@
fi
AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
-if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
- test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+if test relink = "$_LT_TAGVAR(hardcode_action, $1)" ||
+ test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then
# Fast installation is not supported
enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+ test no = "$enable_shared"; then
# Fast installation is not necessary
enable_fast_install=needless
fi
@@ -2012,7 +2216,7 @@
# FIXME - insert some real tests, host_os isn't really good enough
case $host_os in
darwin*)
- if test -n "$STRIP" ; then
+ if test -n "$STRIP"; then
striplib="$STRIP -x"
old_striplib="$STRIP -S"
AC_MSG_RESULT([yes])
@@ -2030,6 +2234,47 @@
])# _LT_CMD_STRIPLIB
+# _LT_PREPARE_MUNGE_PATH_LIST
+# ---------------------------
+# Make sure func_munge_path_list() is defined correctly.
+m4_defun([_LT_PREPARE_MUNGE_PATH_LIST],
+[[# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+# string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+# string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+# string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+# "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+# VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+ case x@S|@2 in
+ x)
+ ;;
+ *:)
+ eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\"
+ ;;
+ x:*)
+ eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\"
+ ;;
+ *::*)
+ eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+ eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\"
+ ;;
+ *)
+ eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\"
+ ;;
+ esac
+}
+]])# _LT_PREPARE_PATH_LIST
+
+
# _LT_SYS_DYNAMIC_LINKER([TAG])
# -----------------------------
# PORTME Fill in your ld.so characteristics
@@ -2039,47 +2284,63 @@
m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_DECL_OBJDUMP])dnl
m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl
AC_MSG_CHECKING([dynamic linker characteristics])
m4_if([$1],
[], [
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
case $host_os in
- darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
- *) lt_awk_arg="/^libraries:/" ;;
+ darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+ *) lt_awk_arg='/^libraries:/' ;;
esac
- lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
- if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
+ case $host_os in
+ mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;;
+ *) lt_sed_strip_eq='s|=/|/|g' ;;
+ esac
+ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+ case $lt_search_path_spec in
+ *\;*)
# if the path contains ";" then we assume it to be the separator
# otherwise default to the standard path separator (i.e. ":") - it is
# assumed that no part of a normal pathname contains ";" but that should
# okay in the real world where ";" in dirpaths is itself problematic.
- lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
- else
- lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
- fi
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+ ;;
+ *)
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ esac
# Ok, now we have the path, separated by spaces, we can step through it
- # and add multilib dir if necessary.
+ # and add multilib dir if necessary...
lt_tmp_lt_search_path_spec=
- lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ # ...but if some path component already ends with the multilib dir we assume
+ # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+ case "$lt_multi_os_dir; $lt_search_path_spec " in
+ "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+ lt_multi_os_dir=
+ ;;
+ esac
for lt_sys_path in $lt_search_path_spec; do
- if test -d "$lt_sys_path/$lt_multi_os_dir"; then
- lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
- else
+ if test -d "$lt_sys_path$lt_multi_os_dir"; then
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+ elif test -n "$lt_multi_os_dir"; then
test -d "$lt_sys_path" && \
lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
fi
done
- lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
-BEGIN {RS=" "; FS="/|\n";} {
- lt_foo="";
- lt_count=0;
+ lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS = " "; FS = "/|\n";} {
+ lt_foo = "";
+ lt_count = 0;
for (lt_i = NF; lt_i > 0; lt_i--) {
if ($lt_i != "" && $lt_i != ".") {
if ($lt_i == "..") {
lt_count++;
} else {
if (lt_count == 0) {
- lt_foo="/" $lt_i lt_foo;
+ lt_foo = "/" $lt_i lt_foo;
} else {
lt_count--;
}
@@ -2089,14 +2350,20 @@
if (lt_foo != "") { lt_freq[[lt_foo]]++; }
if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
}'`
- sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
-else
+ # AWK program above erroneously prepends '/' to C:/dos/paths
+ # for these hosts.
+ case $host_os in
+ mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+ $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;;
+ esac
+ sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
fi])
library_names_spec=
libname_spec='lib$name'
soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
postinstall_cmds=
postuninstall_cmds=
finish_cmds=
@@ -2113,56 +2380,109 @@
# flags to be left without arguments
need_version=unknown
+AC_ARG_VAR([LT_SYS_LIBRARY_PATH],
+[User-defined run-time library search path.])
+
case $host_os in
aix3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
shlibpath_var=LIBPATH
# AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
+ soname_spec='$libname$release$shared_ext$major'
;;
aix[[4-9]]*)
- version_type=linux
+ version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
shlibpath_var=LD_LIBRARY_PATH
else
# With GCC up to 2.95.x, collect2 would create an import file
# for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
+ # the line '#! .'. This would cause the generated library to
+ # depend on '.', always an invalid library. This was fixed in
# development snapshots of GCC prior to 3.0.
case $host_os in
aix4 | aix4.[[01]] | aix4.[[01]].*)
if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
echo ' yes '
- echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
:
else
can_build_shared=no
fi
;;
esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # Using Import Files as archive members, it is possible to support
+ # filename-based versioning of shared library archives on AIX. While
+ # this would work for both with and without runtime linking, it will
+ # prevent static linking of such archives. So we do filename-based
+ # shared library versioning with .so extension only, which is used
+ # when both runtime linking and shared linking is enabled.
+ # Unfortunately, runtime linking may impact performance, so we do
+ # not want this to be the default eventually. Also, we use the
+ # versioned .so libs for executables only if there is the -brtl
+ # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+ # To allow for filename-based versioning support, we need to create
+ # libNAME.so.V as an archive file, containing:
+ # *) an Import File, referring to the versioned filename of the
+ # archive as well as the shared archive member, telling the
+ # bitwidth (32 or 64) of that shared object, and providing the
+ # list of exported symbols of that shared object, eventually
+ # decorated with the 'weak' keyword
+ # *) the shared object with the F_LOADONLY flag set, to really avoid
+ # it being seen by the linker.
+ # At run time we better use the real file rather than another symlink,
+ # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+ case $with_aix_soname,$aix_use_runtimelinking in
+ # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
# soname into executable. Probably we can add versioning support to
# collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
+ aix,yes) # traditional libtool
+ dynamic_linker='AIX unversionable lib.so'
# If using run time linking (on AIX 4.2 or later) use lib.so
# instead of lib.a to let people know that these are not
# typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ ;;
+ aix,no) # traditional AIX only
+ dynamic_linker='AIX lib.a[(]lib.so.V[)]'
# We preserve .a as extension for shared libraries through AIX4.2
# and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
+ library_names_spec='$libname$release.a $libname.a'
+ soname_spec='$libname$release$shared_ext$major'
+ ;;
+ svr4,*) # full svr4 only
+ dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]"
+ library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+ # We do not specify a path in Import Files, so LIBPATH fires.
+ shlibpath_overrides_runpath=yes
+ ;;
+ *,yes) # both, prefer svr4
+ dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]"
+ library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+ # unpreferred sharedlib libNAME.a needs extra handling
+ postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+ postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+ # We do not specify a path in Import Files, so LIBPATH fires.
+ shlibpath_overrides_runpath=yes
+ ;;
+ *,no) # both, prefer aix
+ dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]"
+ library_names_spec='$libname$release.a $libname.a'
+ soname_spec='$libname$release$shared_ext$major'
+ # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+ postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+ postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+ ;;
+ esac
shlibpath_var=LIBPATH
fi
;;
@@ -2172,27 +2492,27 @@
powerpc)
# Since July 2007 AmigaOS4 officially supports .so libraries.
# When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
;;
m68k)
library_names_spec='$libname.ixlibrary $libname.a'
# Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
;;
esac
;;
beos*)
- library_names_spec='${libname}${shared_ext}'
+ library_names_spec='$libname$shared_ext'
dynamic_linker="$host_os ld.so"
shlibpath_var=LIBRARY_PATH
;;
bsdi[[45]]*)
- version_type=linux
+ version_type=linux # correct to gnu/linux during the next big refactor
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
shlibpath_var=LD_LIBRARY_PATH
sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -2204,16 +2524,17 @@
cygwin* | mingw* | pw32* | cegcc*)
version_type=windows
- shrext_cmds=".dll"
+ shrext_cmds=.dll
need_version=no
need_lib_prefix=no
- case $GCC,$host_os in
- yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+ case $GCC,$cc_basename in
+ yes,*)
+ # gcc
library_names_spec='$libname.dll.a'
# DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ postinstall_cmds='base_file=`basename \$file`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
dldir=$destdir/`dirname \$dlpath`~
test -d \$dldir || mkdir -p \$dldir~
$install_prog $dir/$dlname \$dldir/$dlname~
@@ -2229,37 +2550,84 @@
case $host_os in
cygwin*)
# Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
+m4_if([$1], [],[
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
;;
mingw* | cegcc*)
# MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ ;;
+
+ *,cl*)
+ # Native MSVC
+ libname_spec='$name'
+ soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
+ library_names_spec='$libname.dll.lib'
+
+ case $build_os in
+ mingw*)
+ sys_lib_search_path_spec=
+ lt_save_ifs=$IFS
+ IFS=';'
+ for lt_path in $LIB
+ do
+ IFS=$lt_save_ifs
+ # Let DOS variable expansion print the short 8.3 style file name.
+ lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+ sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+ done
+ IFS=$lt_save_ifs
+ # Convert to MSYS style.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
+ ;;
+ cygwin*)
+ # Convert to unix form, then to dos form, then back to unix form
+ # but this time dos style (no spaces!) so that the unix form looks
+ # like /cygdrive/c/PROGRA~1:/cygdr...
+ sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+ sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+ sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ ;;
+ *)
+ sys_lib_search_path_spec=$LIB
if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
- # It is most probably a Windows format PATH printed by
- # mingw gcc, but we are running on Cygwin. Gcc prints its search
- # path with ; separators, and with drive letters. We can handle the
- # drive letters (cygwin fileutils understands them), so leave them,
- # especially as we might pass files found there to a mingw objdump,
- # which wouldn't understand a cygwinified path. Ahh.
+ # It is most probably a Windows format PATH.
sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
else
- sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
fi
- ;;
- pw32*)
- # pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ # FIXME: find the short name or the path components, as spaces are
+ # common. (e.g. "Program Files" -> "PROGRA~1")
;;
esac
+
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \$file`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+ dynamic_linker='Win32 link.exe'
;;
*)
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ # Assume MSVC wrapper
+ library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib'
+ dynamic_linker='Win32 ld.exe'
;;
esac
- dynamic_linker='Win32 ld.exe'
# FIXME: first we should search . and the directory the executable is in
shlibpath_var=PATH
;;
@@ -2269,8 +2637,8 @@
version_type=darwin
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
+ library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+ soname_spec='$libname$release$major$shared_ext'
shlibpath_overrides_runpath=yes
shlibpath_var=DYLD_LIBRARY_PATH
shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -2280,11 +2648,11 @@
;;
dgux*)
- version_type=linux
+ version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
;;
@@ -2295,19 +2663,20 @@
objformat=`/usr/bin/objformat`
else
case $host_os in
- freebsd[[23].]*) objformat=aout ;;
+ freebsd[[23]].*) objformat=aout ;;
*) objformat=elf ;;
esac
fi
version_type=freebsd-$objformat
case $version_type in
freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
need_version=no
need_lib_prefix=no
;;
freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
need_version=yes
;;
esac
@@ -2332,13 +2701,16 @@
esac
;;
-gnu*)
- version_type=linux
+haiku*)
+ version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
+ dynamic_linker="$host_os runtime_loader"
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
+ shlibpath_var=LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
hardcode_into_libs=yes
;;
@@ -2355,14 +2727,15 @@
dynamic_linker="$host_os dld.so"
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
+ if test 32 = "$HPUX_IA64_MODE"; then
sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ sys_lib_dlsearch_path_spec=/usr/lib/hpux32
else
sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ sys_lib_dlsearch_path_spec=/usr/lib/hpux64
fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
;;
hppa*64*)
shrext_cmds='.sl'
@@ -2370,8 +2743,8 @@
dynamic_linker="$host_os dld.sl"
shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
;;
@@ -2380,20 +2753,22 @@
dynamic_linker="$host_os dld.sl"
shlibpath_var=SHLIB_PATH
shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
;;
esac
- # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
postinstall_cmds='chmod 555 $lib'
+ # or fails outright, so override atomically:
+ install_override_mode=555
;;
interix[[3-9]]*)
- version_type=linux
+ version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
@@ -2404,16 +2779,16 @@
case $host_os in
nonstopux*) version_type=nonstopux ;;
*)
- if test "$lt_cv_prog_gnu_ld" = yes; then
- version_type=linux
+ if test yes = "$lt_cv_prog_gnu_ld"; then
+ version_type=linux # correct to gnu/linux during the next big refactor
else
version_type=irix
fi ;;
esac
need_lib_prefix=no
need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='$libname$release$shared_ext$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
case $host_os in
irix5* | nonstopux*)
libsuff= shlibsuff=
@@ -2432,8 +2807,8 @@
esac
shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+ sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
hardcode_into_libs=yes
;;
@@ -2442,35 +2817,65 @@
dynamic_linker=no
;;
-# This must be Linux ELF.
-linux* | k*bsd*-gnu)
- version_type=linux
+linux*android*)
+ version_type=none # Android doesn't support versioned libraries.
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='$libname$release$shared_ext'
+ soname_spec='$libname$release$shared_ext'
+ finish_cmds=
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ dynamic_linker='Android linker'
+ # Don't embed -rpath directories since the linker doesn't support them.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
+ version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
+
# Some binutils ld are patched to set DT_RUNPATH
- save_LDFLAGS=$LDFLAGS
- save_libdir=$libdir
- eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
- LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
- AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
- [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
- [shlibpath_overrides_runpath=yes])])
- LDFLAGS=$save_LDFLAGS
- libdir=$save_libdir
+ AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],
+ [lt_cv_shlibpath_overrides_runpath=no
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
+ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+ [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
+ [lt_cv_shlibpath_overrides_runpath=yes])])
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+ ])
+ shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
# This implies no fast_install, which is unacceptable.
# Some rework will be needed to allow for fast_install
# before this can be enabled.
hardcode_into_libs=yes
- # Append ld.so.conf contents to the search path
+ # Ideally, we could use ldconfig to report *all* directores which are
+ # searched for libraries, however this is still not possible. Aside from not
+ # being certain /sbin/ldconfig is available, command
+ # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+ # even though it is searched at run-time. Try to do the best guess by
+ # appending ld.so.conf contents (and includes) to the search path.
if test -f /etc/ld.so.conf; then
- lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
fi
@@ -2488,12 +2893,12 @@
need_lib_prefix=no
need_version=no
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
dynamic_linker='NetBSD (a.out) ld.so'
else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
dynamic_linker='NetBSD ld.elf_so'
fi
shlibpath_var=LD_LIBRARY_PATH
@@ -2502,8 +2907,8 @@
;;
newsos6)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
;;
@@ -2512,58 +2917,68 @@
version_type=qnx
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
dynamic_linker='ldqnx.so'
;;
-openbsd*)
+openbsd* | bitrig*)
version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
+ sys_lib_dlsearch_path_spec=/usr/lib
need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[[89]] | openbsd2.[[89]].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+ need_version=no
else
- shlibpath_overrides_runpath=yes
+ need_version=yes
fi
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
;;
os2*)
libname_spec='$name'
- shrext_cmds=".dll"
+ version_type=windows
+ shrext_cmds=.dll
+ need_version=no
need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
+ # OS/2 can only load a DLL with a base name of 8 characters or less.
+ soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+ v=$($ECHO $release$versuffix | tr -d .-);
+ n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+ $ECHO $n$v`$shared_ext'
+ library_names_spec='${libname}_dll.$libext'
dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
+ shlibpath_var=BEGINLIBPATH
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ postinstall_cmds='base_file=`basename \$file`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
;;
osf3* | osf4* | osf5*)
version_type=osf
need_lib_prefix=no
need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='$libname$release$shared_ext$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
shlibpath_var=LD_LIBRARY_PATH
sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
;;
rdos*)
@@ -2571,11 +2986,11 @@
;;
solaris*)
- version_type=linux
+ version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
hardcode_into_libs=yes
@@ -2585,20 +3000,20 @@
sunos4*)
version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
+ if test yes = "$with_gnu_ld"; then
need_lib_prefix=no
fi
need_version=yes
;;
sysv4 | sysv4.3*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
case $host_vendor in
sni)
@@ -2619,24 +3034,24 @@
;;
sysv4*MP*)
- if test -d /usr/nec ;then
- version_type=linux
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
+ if test -d /usr/nec; then
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+ soname_spec='$libname$shared_ext.$major'
shlibpath_var=LD_LIBRARY_PATH
fi
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
+ version_type=sco
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
+ if test yes = "$with_gnu_ld"; then
sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
else
sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -2651,19 +3066,19 @@
tpf*)
# TPF is a cross-target only. Preferred cross-host = GNU/Linux.
- version_type=linux
+ version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
;;
uts4*)
- version_type=linux
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ version_type=linux # correct to gnu/linux during the next big refactor
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
;;
@@ -2672,20 +3087,30 @@
;;
esac
AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
fi
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
- sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+ sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
- sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+ sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
fi
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
_LT_DECL([], [variables_saved_for_relink], [1],
[Variables whose values should be saved in libtool wrapper scripts and
restored at link time])
@@ -2703,6 +3128,8 @@
The last name is the one that the linker finds with -lNAME]])
_LT_DECL([], [soname_spec], [1],
[[The coded name of the library, if different from the real name]])
+_LT_DECL([], [install_override_mode], [1],
+ [Permission mode override for installation of shared libraries])
_LT_DECL([], [postinstall_cmds], [2],
[Command to use after installation of a shared archive])
_LT_DECL([], [postuninstall_cmds], [2],
@@ -2716,39 +3143,41 @@
[Whether we should hardcode library paths into libraries])
_LT_DECL([], [sys_lib_search_path_spec], [2],
[Compile-time system search path for libraries])
-_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
- [Run-time system search path for libraries])
+_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2],
+ [Detected run-time system search path for libraries])
+_LT_DECL([], [configure_time_lt_sys_library_path], [2],
+ [Explicit LT_SYS_LIBRARY_PATH set during ./configure time])
])# _LT_SYS_DYNAMIC_LINKER
# _LT_PATH_TOOL_PREFIX(TOOL)
# --------------------------
-# find a file program which can recognize shared library
+# find a file program that can recognize shared library
AC_DEFUN([_LT_PATH_TOOL_PREFIX],
[m4_require([_LT_DECL_EGREP])dnl
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
[case $MAGIC_CMD in
[[\\/*] | ?:[\\/]*])
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
;;
*)
- lt_save_MAGIC_CMD="$MAGIC_CMD"
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ lt_save_MAGIC_CMD=$MAGIC_CMD
+ lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
dnl $ac_dummy forces splitting on constant user-supplied paths.
dnl POSIX.2 word splitting is done only on the output of word expansions,
dnl not every word. This closes a longstanding sh security hole.
ac_dummy="m4_if([$2], , $PATH, [$2])"
for ac_dir in $ac_dummy; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$1; then
- lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+ if test -f "$ac_dir/$1"; then
+ lt_cv_path_MAGIC_CMD=$ac_dir/"$1"
if test -n "$file_magic_test_file"; then
case $deplibs_check_method in
"file_magic "*)
file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ MAGIC_CMD=$lt_cv_path_MAGIC_CMD
if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
$EGREP "$file_magic_regex" > /dev/null; then
:
@@ -2771,11 +3200,11 @@
break
fi
done
- IFS="$lt_save_ifs"
- MAGIC_CMD="$lt_save_MAGIC_CMD"
+ IFS=$lt_save_ifs
+ MAGIC_CMD=$lt_save_MAGIC_CMD
;;
esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
if test -n "$MAGIC_CMD"; then
AC_MSG_RESULT($MAGIC_CMD)
else
@@ -2793,7 +3222,7 @@
# _LT_PATH_MAGIC
# --------------
-# find a file program which can recognize a shared library
+# find a file program that can recognize a shared library
m4_defun([_LT_PATH_MAGIC],
[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
if test -z "$lt_cv_path_MAGIC_CMD"; then
@@ -2815,20 +3244,21 @@
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
m4_require([_LT_DECL_SED])dnl
m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
-dnl AC_ARG_WITH([gnu-ld],
-dnl [AS_HELP_STRING([--with-gnu-ld],
-dnl [assume the C compiler uses GNU ld @<:@default=no@:>@])],
-dnl [test "$withval" = no || with_gnu_ld=yes],
-dnl [with_gnu_ld=no])dnl
+AC_ARG_WITH([gnu-ld],
+ [AS_HELP_STRING([--with-gnu-ld],
+ [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+ [test no = "$withval" || with_gnu_ld=yes],
+ [with_gnu_ld=no])dnl
ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by $CC])
case $host in
*-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
+ # gcc leaves a trailing carriage return, which upsets mingw
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
*)
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -2842,7 +3272,7 @@
while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
done
- test -z "$LD" && LD="$ac_prog"
+ test -z "$LD" && LD=$ac_prog
;;
"")
# If it fails, then pretend we aren't using GCC.
@@ -2853,37 +3283,37 @@
with_gnu_ld=unknown
;;
esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL(lt_cv_path_LD,
[if test -z "$LD"; then
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
for ac_dir in $PATH; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- lt_cv_path_LD="$ac_dir/$ac_prog"
+ lt_cv_path_LD=$ac_dir/$ac_prog
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some variants of GNU ld only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
case `"$lt_cv_path_LD" -v 2>&1 conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd],
+[if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then
+ cmp -s conftest.i conftest.out \
+ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi])
+rm -f conftest.i conftest2.i conftest.out])
+])# _LT_PATH_DD
+
+
+# _LT_CMD_TRUNCATE
+# ----------------
+# find command to truncate a binary pipe
+m4_defun([_LT_CMD_TRUNCATE],
+[m4_require([_LT_PATH_DD])
+AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then
+ cmp -s conftest.i conftest.out \
+ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"])
+_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1],
+ [Command to truncate a binary pipe])
+])# _LT_CMD_TRUNCATE
+
+
# _LT_CHECK_MAGIC_METHOD
# ----------------------
# how to check for library dependencies
@@ -2964,13 +3436,13 @@
# Need to set the preceding variable on all platforms that support
# interlibrary dependencies.
# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
# 'pass_all' -- all dependencies passed with no checks.
# 'test_compile' -- check by making test program.
# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
case $host_os in
aix[[4-9]]*)
@@ -3001,12 +3473,13 @@
lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
lt_cv_file_magic_cmd='func_win32_libid'
else
- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+ # Keep this pattern in sync with the one in func_win32_libid.
+ lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
lt_cv_file_magic_cmd='$OBJDUMP -f'
fi
;;
-cegcc)
+cegcc*)
# use the weaker test based on 'objdump'. See mingw*.
lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
lt_cv_file_magic_cmd='$OBJDUMP -f'
@@ -3032,7 +3505,7 @@
fi
;;
-gnu*)
+haiku*)
lt_cv_deplibs_check_method=pass_all
;;
@@ -3044,11 +3517,11 @@
lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
;;
hppa*64*)
- [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+ [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]']
lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
;;
*)
- lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library'
lt_cv_file_magic_test_file=/usr/lib/libc.sl
;;
esac
@@ -3069,8 +3542,8 @@
lt_cv_deplibs_check_method=pass_all
;;
-# This must be Linux ELF.
-linux* | k*bsd*-gnu)
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
lt_cv_deplibs_check_method=pass_all
;;
@@ -3092,8 +3565,8 @@
lt_cv_deplibs_check_method=pass_all
;;
-openbsd*)
- if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
else
lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
@@ -3146,8 +3619,26 @@
tpf*)
lt_cv_deplibs_check_method=pass_all
;;
+os2*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
esac
])
+
+file_magic_glob=
+want_nocaseglob=no
+if test "$build" = "$host"; then
+ case $host_os in
+ mingw* | pw32*)
+ if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
+ want_nocaseglob=yes
+ else
+ file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"`
+ fi
+ ;;
+ esac
+fi
+
file_magic_cmd=$lt_cv_file_magic_cmd
deplibs_check_method=$lt_cv_deplibs_check_method
test -z "$deplibs_check_method" && deplibs_check_method=unknown
@@ -3155,7 +3646,11 @@
_LT_DECL([], [deplibs_check_method], [1],
[Method to check whether dependent libraries are shared objects])
_LT_DECL([], [file_magic_cmd], [1],
- [Command to use when deplibs_check_method == "file_magic"])
+ [Command to use when deplibs_check_method = "file_magic"])
+_LT_DECL([], [file_magic_glob], [1],
+ [How to find potential files when deplibs_check_method = "file_magic"])
+_LT_DECL([], [want_nocaseglob], [1],
+ [Find potential files using nocaseglob when deplibs_check_method = "file_magic"])
])# _LT_CHECK_MAGIC_METHOD
@@ -3167,33 +3662,38 @@
AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
[if test -n "$NM"; then
# Let the user override the test.
- lt_cv_path_NM="$NM"
+ lt_cv_path_NM=$NM
else
- lt_nm_to_check="${ac_tool_prefix}nm"
+ lt_nm_to_check=${ac_tool_prefix}nm
if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
lt_nm_to_check="$lt_nm_to_check nm"
fi
for lt_tmp_nm in $lt_nm_to_check; do
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
test -z "$ac_dir" && ac_dir=.
- tmp_nm="$ac_dir/$lt_tmp_nm"
- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ tmp_nm=$ac_dir/$lt_tmp_nm
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
# Check to see if the nm accepts a BSD-compat flag.
- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # Adding the 'sed 1q' prevents false positives on HP-UX, which says:
# nm: unknown option "B" ignored
# Tru64's nm complains that /dev/null is an invalid object file
- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
- */dev/null* | *'Invalid file or object type'*)
+ # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+ case $build_os in
+ mingw*) lt_bad_file=conftest.nm/nofile ;;
+ *) lt_bad_file=/dev/null ;;
+ esac
+ case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+ *$lt_bad_file* | *'Invalid file or object type'*)
lt_cv_path_NM="$tmp_nm -B"
- break
+ break 2
;;
*)
case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
*/dev/null*)
lt_cv_path_NM="$tmp_nm -p"
- break
+ break 2
;;
*)
lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -3204,18 +3704,30 @@
esac
fi
done
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
done
: ${lt_cv_path_NM=no}
fi])
-if test "$lt_cv_path_NM" != "no"; then
- NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+ NM=$lt_cv_path_NM
else
# Didn't find any BSD compatible name lister, look for dumpbin.
- AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
+ if test -n "$DUMPBIN"; then :
+ # Let the user override the test.
+ else
+ AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
+ case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
+ *COFF*)
+ DUMPBIN="$DUMPBIN -symbols -headers"
+ ;;
+ *)
+ DUMPBIN=:
+ ;;
+ esac
+ fi
AC_SUBST([DUMPBIN])
- if test "$DUMPBIN" != ":"; then
- NM="$DUMPBIN"
+ if test : != "$DUMPBIN"; then
+ NM=$DUMPBIN
fi
fi
test -z "$NM" && NM=nm
@@ -3225,13 +3737,13 @@
AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
[lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
- (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&AS_MESSAGE_LOG_FD
- (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
+ (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&AS_MESSAGE_LOG_FD
- (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
+ (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD)
cat conftest.out >&AS_MESSAGE_LOG_FD
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
@@ -3246,6 +3758,82 @@
dnl AC_DEFUN([AM_PROG_NM], [])
dnl AC_DEFUN([AC_PROG_NM], [])
+# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
+# --------------------------------
+# how to determine the name of the shared library
+# associated with a specific link library.
+# -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+m4_require([_LT_DECL_DLLTOOL])
+AC_CACHE_CHECK([how to associate runtime and link libraries],
+lt_cv_sharedlib_from_linklib_cmd,
+[lt_cv_sharedlib_from_linklib_cmd='unknown'
+
+case $host_os in
+cygwin* | mingw* | pw32* | cegcc*)
+ # two different shell functions defined in ltmain.sh;
+ # decide which one to use based on capabilities of $DLLTOOL
+ case `$DLLTOOL --help 2>&1` in
+ *--identify-strict*)
+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
+ ;;
+ *)
+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
+ ;;
+ esac
+ ;;
+*)
+ # fallback: assume linklib IS sharedlib
+ lt_cv_sharedlib_from_linklib_cmd=$ECHO
+ ;;
+esac
+])
+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
+
+_LT_DECL([], [sharedlib_from_linklib_cmd], [1],
+ [Command to associate shared and link libraries])
+])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
+
+
+# _LT_PATH_MANIFEST_TOOL
+# ----------------------
+# locate the manifest tool
+m4_defun([_LT_PATH_MANIFEST_TOOL],
+[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :)
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool],
+ [lt_cv_path_mainfest_tool=no
+ echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD
+ $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+ lt_cv_path_mainfest_tool=yes
+ fi
+ rm -f conftest*])
+if test yes != "$lt_cv_path_mainfest_tool"; then
+ MANIFEST_TOOL=:
+fi
+_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
+])# _LT_PATH_MANIFEST_TOOL
+
+
+# _LT_DLL_DEF_P([FILE])
+# ---------------------
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with func_dll_def_p in the libtool script
+AC_DEFUN([_LT_DLL_DEF_P],
+[dnl
+ test DEF = "`$SED -n dnl
+ -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace
+ -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments
+ -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl
+ -e q dnl Only consider the first "real" line
+ $1`" dnl
+])# _LT_DLL_DEF_P
+
# LT_LIB_M
# --------
@@ -3254,15 +3842,15 @@
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
LIBM=
case $host in
-*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
# These system don't have libm, or don't need it
;;
*-ncr-sysv4.3*)
- AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw)
AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
;;
*)
- AC_CHECK_LIB(m, cos, LIBM="-lm")
+ AC_CHECK_LIB(m, cos, LIBM=-lm)
;;
esac
AC_SUBST([LIBM])
@@ -3281,8 +3869,13 @@
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-if test "$GCC" = yes; then
- _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+if test yes = "$GCC"; then
+ case $cc_basename in
+ nvcc*)
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;
+ esac
_LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
lt_cv_prog_compiler_rtti_exceptions,
@@ -3299,6 +3892,7 @@
m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([LT_PATH_NM])dnl
AC_REQUIRE([LT_PATH_LD])dnl
m4_require([_LT_DECL_SED])dnl
@@ -3327,7 +3921,7 @@
symcode='[[ABCDGISTW]]'
;;
hpux*)
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
symcode='[[ABCDEGRST]]'
fi
;;
@@ -3360,14 +3954,44 @@
symcode='[[ABCDGIRSTW]]' ;;
esac
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Gets list of data symbols to import.
+ lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+ # Adjust the below global symbol transforms to fixup imported variables.
+ lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+ lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'"
+ lt_c_name_lib_hook="\
+ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\
+ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'"
+else
+ # Disable hooks by default.
+ lt_cv_sys_global_symbol_to_import=
+ lt_cdecl_hook=
+ lt_c_name_hook=
+ lt_c_name_lib_hook=
+fi
+
# Transform an extracted symbol line into a proper C declaration.
# Some systems (esp. on ia64) link data and code symbols differently,
# so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'"
# Handle CRLF in mingw tool chain
opt_cr=
@@ -3385,24 +4009,29 @@
# Write the raw and C identifiers.
if test "$lt_cv_nm_interface" = "MS dumpbin"; then
- # Fake it for dumpbin and say T for any non-static function
- # and D for any global variable.
+ # Fake it for dumpbin and say T for any non-static function,
+ # D for any global variable and I for any imported variable.
# Also find C++ and __fastcall symbols from MSVC++,
# which start with @ or ?.
lt_cv_sys_global_symbol_pipe="$AWK ['"\
" {last_section=section; section=\$ 3};"\
+" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
" \$ 0!~/External *\|/{next};"\
" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
" {if(hide[section]) next};"\
-" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-" s[1]~/^[@?]/{print s[1], s[1]; next};"\
-" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
" ' prfx=^$ac_symprfx]"
else
lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
fi
+ lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
# Check to see that the pipe works correctly.
pipe_works=no
@@ -3424,7 +4053,7 @@
if AC_TRY_EVAL(ac_compile); then
# Now try to grab the symbols.
nlist=conftest.nm
- if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+ if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
# Try sorting and uniquifying the output.
if sort "$nlist" | uniq > "$nlist"T; then
mv -f "$nlist"T "$nlist"
@@ -3436,6 +4065,18 @@
if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
cat <<_LT_EOF > conftest.$ac_ext
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
+ relocations are performed -- see ld's documentation on pseudo-relocs. */
+# define LT@&t@_DLSYM_CONST
+#elif defined __osf__
+/* This system does not cope well with relocations in const data. */
+# define LT@&t@_DLSYM_CONST
+#else
+# define LT@&t@_DLSYM_CONST const
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -3447,7 +4088,7 @@
cat <<_LT_EOF >> conftest.$ac_ext
/* The mapping between symbol names and symbols. */
-const struct {
+LT@&t@_DLSYM_CONST struct {
const char *name;
void *address;
}
@@ -3455,7 +4096,7 @@
{
{ "@PROGRAM@", (void *) 0 },
_LT_EOF
- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
cat <<\_LT_EOF >> conftest.$ac_ext
{0, (void *) 0}
};
@@ -3473,15 +4114,15 @@
_LT_EOF
# Now try linking the two files.
mv conftest.$ac_objext conftstm.$ac_objext
- lt_save_LIBS="$LIBS"
- lt_save_CFLAGS="$CFLAGS"
- LIBS="conftstm.$ac_objext"
+ lt_globsym_save_LIBS=$LIBS
+ lt_globsym_save_CFLAGS=$CFLAGS
+ LIBS=conftstm.$ac_objext
CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+ if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then
pipe_works=yes
fi
- LIBS="$lt_save_LIBS"
- CFLAGS="$lt_save_CFLAGS"
+ LIBS=$lt_globsym_save_LIBS
+ CFLAGS=$lt_globsym_save_CFLAGS
else
echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
fi
@@ -3498,7 +4139,7 @@
rm -rf conftest* conftst*
# Do not use the global_symbol_pipe unless it works.
- if test "$pipe_works" = yes; then
+ if test yes = "$pipe_works"; then
break
else
lt_cv_sys_global_symbol_pipe=
@@ -3514,16 +4155,29 @@
AC_MSG_RESULT(ok)
fi
+# Response file support.
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ nm_file_list_spec='@'
+elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then
+ nm_file_list_spec='@'
+fi
+
_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
[Take the output of nm and produce a listing of raw symbols and C names])
_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
[Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1],
+ [Transform the output of nm into a list of symbols to manually relocate])
_LT_DECL([global_symbol_to_c_name_address],
[lt_cv_sys_global_symbol_to_c_name_address], [1],
[Transform the output of nm in a C name address pair])
_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
[lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
[Transform the output of nm in a C name address pair when lib prefix is needed])
+_LT_DECL([nm_interface], [lt_cv_nm_interface], [1],
+ [The name lister interface])
+_LT_DECL([], [nm_file_list_spec], [1],
+ [Specify filename containing input files for $NM])
]) # _LT_CMD_GLOBAL_SYMBOLS
@@ -3535,20 +4189,20 @@
_LT_TAGVAR(lt_prog_compiler_pic, $1)=
_LT_TAGVAR(lt_prog_compiler_static, $1)=
-AC_MSG_CHECKING([for $compiler option to produce PIC])
m4_if([$1], [CXX], [
# C++ specific cases for pic, static, wl, etc.
- if test "$GXX" = yes; then
+ if test yes = "$GXX"; then
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
case $host_os in
aix*)
# All AIX code is PIC.
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
fi
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
amigaos*)
@@ -3559,8 +4213,8 @@
;;
m68k)
# FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
+ # adding the '-m68020' flag to GCC prevents building anything better,
+ # like '-m68040'.
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
;;
esac
@@ -3576,6 +4230,11 @@
# (--disable-auto-import) libraries
m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ case $host_os in
+ os2*)
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+ ;;
+ esac
;;
darwin* | rhapsody*)
# PIC is the default on this platform
@@ -3586,6 +4245,11 @@
# DJGPP does not support shared libraries at all
_LT_TAGVAR(lt_prog_compiler_pic, $1)=
;;
+ haiku*)
+ # PIC is the default for Haiku.
+ # The "-static" flag exists, but is broken.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)=
+ ;;
interix[[3-9]]*)
# Interix 3.x gcc -fpic/-fPIC options generate broken code.
# Instead, we relocate shared libraries at runtime.
@@ -3620,7 +4284,7 @@
case $host_os in
aix[[4-9]]*)
# All AIX code is PIC.
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
else
@@ -3635,6 +4299,12 @@
;;
esac
;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
dgux*)
case $cc_basename in
ec++*)
@@ -3655,14 +4325,14 @@
case $cc_basename in
CC*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
- if test "$host_cpu" != ia64; then
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
+ if test ia64 != "$host_cpu"; then
_LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
fi
;;
aCC*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
case $host_cpu in
hppa*64*|ia64*)
# +Z the default
@@ -3691,7 +4361,7 @@
;;
esac
;;
- linux* | k*bsd*-gnu)
+ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
KCC*)
# KAI C++ Compiler
@@ -3699,7 +4369,7 @@
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
ecpc* )
- # old Intel C++ for x86_64 which still supported -KPIC.
+ # old Intel C++ for x86_64, which still supported -KPIC.
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
@@ -3724,8 +4394,8 @@
_LT_TAGVAR(lt_prog_compiler_pic, $1)=
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
;;
- xlc* | xlC*)
- # IBM XL 8.0 on PPC
+ xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*)
+ # IBM XL 8.0, 9.0 on PPC and BlueGene
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
@@ -3787,7 +4457,7 @@
;;
solaris*)
case $cc_basename in
- CC*)
+ CC* | sunCC*)
# Sun C++ 4.2, 5.x and Centerline C++
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
@@ -3844,17 +4514,18 @@
fi
],
[
- if test "$GCC" = yes; then
+ if test yes = "$GCC"; then
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
case $host_os in
aix*)
# All AIX code is PIC.
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
fi
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
amigaos*)
@@ -3865,8 +4536,8 @@
;;
m68k)
# FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
+ # adding the '-m68020' flag to GCC prevents building anything better,
+ # like '-m68040'.
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
;;
esac
@@ -3883,6 +4554,11 @@
# (--disable-auto-import) libraries
m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ case $host_os in
+ os2*)
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+ ;;
+ esac
;;
darwin* | rhapsody*)
@@ -3891,6 +4567,12 @@
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
;;
+ haiku*)
+ # PIC is the default for Haiku.
+ # The "-static" flag exists, but is broken.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)=
+ ;;
+
hpux*)
# PIC is the default for 64-bit PA HP-UX, but not for 32-bit
# PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
@@ -3933,12 +4615,21 @@
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
esac
+
+ case $cc_basename in
+ nvcc*) # Cuda Compiler Driver 2.2
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker '
+ if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)"
+ fi
+ ;;
+ esac
else
# PORTME Check for flag to pass linker flags through the system compiler.
case $host_os in
aix*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
else
@@ -3946,11 +4637,30 @@
fi
;;
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ case $cc_basename in
+ nagfor*)
+ # NAG Fortran compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ esac
+ ;;
+
mingw* | cygwin* | pw32* | os2* | cegcc*)
# This hack is so that the source file can tell whether it is being
# built for inclusion in a dll (and should export symbols for example).
m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ case $host_os in
+ os2*)
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+ ;;
+ esac
;;
hpux9* | hpux10* | hpux11*)
@@ -3966,7 +4676,7 @@
;;
esac
# Is there a better lt_prog_compiler_static that works with the bundled CC?
- _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
;;
irix5* | irix6* | nonstopux*)
@@ -3975,9 +4685,9 @@
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
;;
- linux* | k*bsd*-gnu)
+ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
- # old Intel for x86_64 which still supported -KPIC.
+ # old Intel for x86_64, which still supported -KPIC.
ecc*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
@@ -3996,7 +4706,19 @@
_LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
_LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
;;
- pgcc* | pgf77* | pgf90* | pgf95*)
+ nagfor*)
+ # NAG Fortran compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ tcc*)
+ # Fabrice Bellard et al's Tiny C Compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
# Portland Group compilers (*not* the Pentium gcc compiler,
# which looks to be a dead project)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
@@ -4008,25 +4730,40 @@
# All Alpha code is PIC.
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
;;
- xl*)
- # IBM XL C 8.0/Fortran 10.1 on PPC
+ xl* | bgxl* | bgf* | mpixl*)
+ # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
;;
*)
case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
+ ;;
+ *Sun\ F* | *Sun*Fortran*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
*Sun\ C*)
# Sun C 5.9
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
;;
- *Sun\ F*)
- # Sun Fortran 8.3 passes all unrecognized flags to the linker
- _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ *Intel*\ [[CF]]*Compiler*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ *Portland\ Group*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
- _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
;;
esac
;;
@@ -4058,7 +4795,7 @@
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
case $cc_basename in
- f77* | f90* | f95*)
+ f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
@@ -4078,7 +4815,7 @@
;;
sysv4*MP*)
- if test -d /usr/nec ;then
+ if test -d /usr/nec; then
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
fi
@@ -4107,7 +4844,7 @@
fi
])
case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
+ # For platforms that do not support PIC, -DPIC is meaningless:
*djgpp*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)=
;;
@@ -4115,9 +4852,11 @@
_LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
;;
esac
-AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
-_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
- [How to pass a linker flag through the compiler])
+
+AC_CACHE_CHECK([for $compiler option to produce PIC],
+ [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)],
+ [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)
#
# Check to make sure the PIC flag actually works.
@@ -4136,6 +4875,8 @@
_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
[Additional compiler flags for building library objects])
+_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
+ [How to pass a linker flag through the compiler])
#
# Check to make sure the static flag actually works.
#
@@ -4156,6 +4897,7 @@
m4_defun([_LT_LINKER_SHLIBS],
[AC_REQUIRE([LT_PATH_LD])dnl
AC_REQUIRE([LT_PATH_NM])dnl
+m4_require([_LT_PATH_MANIFEST_TOOL])dnl
m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_DECL_EGREP])dnl
m4_require([_LT_DECL_SED])dnl
@@ -4164,27 +4906,41 @@
AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
m4_if([$1], [CXX], [
_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
case $host_os in
aix[[4-9]]*)
# If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+ # Without the "-l" option, or with the "-B" option, AIX nm treats
+ # weak defined symbols like other global defined symbols, whereas
+ # GNU nm marks them as "W".
+ # While the 'weak' keyword is ignored in the Export File, we need
+ # it in the Import File for the 'aix-soname' feature, so we have
+ # to replace the "-B" option with "-P" for AIX nm.
if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
- _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
else
- _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
fi
;;
pw32*)
- _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
- ;;
+ _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds
+ ;;
cygwin* | mingw* | cegcc*)
- _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
+ case $cc_basename in
+ cl*)
+ _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+ ;;
+ *)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
+ ;;
+ esac
+ ;;
*)
_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
- ;;
+ ;;
esac
- _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
], [
runpath_var=
_LT_TAGVAR(allow_undefined_flag, $1)=
@@ -4199,7 +4955,6 @@
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
- _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
_LT_TAGVAR(hardcode_libdir_separator, $1)=
_LT_TAGVAR(hardcode_minus_L, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
@@ -4215,9 +4970,9 @@
# included in the symbol list
_LT_TAGVAR(include_expsyms, $1)=
# exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
+ # it will be wrapped by ' (' and ')$', so one must not match beginning or
+ # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+ # as well as any symbol that contains 'd'.
_LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
# platforms (ab)use it in PIC code, but their linkers get confused if
@@ -4233,7 +4988,7 @@
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
- if test "$GCC" != yes; then
+ if test yes != "$GCC"; then
with_gnu_ld=no
fi
;;
@@ -4241,30 +4996,57 @@
# we just hope/assume this is gcc and not c89 (= MSVC++)
with_gnu_ld=yes
;;
- openbsd*)
+ openbsd* | bitrig*)
with_gnu_ld=no
;;
esac
_LT_TAGVAR(ld_shlibs, $1)=yes
- if test "$with_gnu_ld" = yes; then
+
+ # On some targets, GNU ld is compatible enough with the native linker
+ # that we're better off using the native interface for both.
+ lt_use_gnu_ld_interface=no
+ if test yes = "$with_gnu_ld"; then
+ case $host_os in
+ aix*)
+ # The AIX port of GNU ld has always aspired to compatibility
+ # with the native linker. However, as the warning in the GNU ld
+ # block says, versions before 2.19.5* couldn't really create working
+ # shared libraries, regardless of the interface used.
+ case `$LD -v 2>&1` in
+ *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+ *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;;
+ *\ \(GNU\ Binutils\)\ [[3-9]]*) ;;
+ *)
+ lt_use_gnu_ld_interface=yes
+ ;;
+ esac
+ ;;
+ *)
+ lt_use_gnu_ld_interface=yes
+ ;;
+ esac
+ fi
+
+ if test yes = "$lt_use_gnu_ld_interface"; then
# If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
+ wlarc='$wl'
# Set some defaults for GNU ld with shared library support. These
# are reset later if shared libraries are not supported. Putting them
# here allows them to be overridden if necessary.
runpath_var=LD_RUN_PATH
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
# ancient GNU ld didn't support --whole-archive et. al.
if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
- _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
else
_LT_TAGVAR(whole_archive_flag_spec, $1)=
fi
supports_anon_versioning=no
- case `$LD -v 2>&1` in
+ case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in
+ *GNU\ gold*) supports_anon_versioning=yes ;;
*\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
*\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
*\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
@@ -4276,15 +5058,16 @@
case $host_os in
aix[[3-9]]*)
# On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
+ if test ia64 != "$host_cpu"; then
_LT_TAGVAR(ld_shlibs, $1)=no
cat <<_LT_EOF 1>&2
-*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** Warning: the GNU linker, at least up to release 2.19, is reported
*** to be unable to reliably create shared libraries on AIX.
*** Therefore, libtool is disabling shared libraries support. If you
-*** really care for shared libraries, you may want to modify your PATH
-*** so that a non-GNU linker is found, and then restart.
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
_LT_EOF
fi
@@ -4294,7 +5077,7 @@
case $host_cpu in
powerpc)
# see comment about AmigaOS4 .so support
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)=''
;;
m68k)
@@ -4310,7 +5093,7 @@
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
# Joseph Beckenbach says some releases of gcc
# support --undefined. This deserves some investigation. FIXME
- _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
@@ -4320,61 +5103,97 @@
# _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
# as there is no search path for DLLs.
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
_LT_TAGVAR(always_export_symbols, $1)=no
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
- _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file, use it as
+ # is; otherwise, prepend EXPORTS...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
+ haiku*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ os2*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ shrext_cmds=.dll
+ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ prefix_cmds="$SED"~
+ if test EXPORTS = "`$SED 1q $export_symbols`"; then
+ prefix_cmds="$prefix_cmds -e 1d";
+ fi~
+ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ ;;
+
interix[[3-9]]*)
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
# Instead, shared libraries are loaded at an image base (0x10000000 by
# default) and relocated if they conflict, which is a slow very memory
# consuming and fragmenting process. To avoid this, we pick a random,
# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
# time. Moving up from 0x10000000 also allows more sbrk(2) space.
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
;;
- gnu* | linux* | tpf* | k*bsd*-gnu)
+ gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
tmp_diet=no
- if test "$host_os" = linux-dietlibc; then
+ if test linux-dietlibc = "$host_os"; then
case $cc_basename in
diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
esac
fi
if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
- && test "$tmp_diet" = no
+ && test no = "$tmp_diet"
then
- tmp_addflag=
+ tmp_addflag=' $pic_flag'
tmp_sharedflag='-shared'
case $cc_basename,$host_cpu in
pgcc*) # Portland Group C compiler
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
tmp_addflag=' $pic_flag'
;;
- pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ pgf77* | pgf90* | pgf95* | pgfortran*)
+ # Portland Group f77 and f90 compilers
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
tmp_addflag=' $pic_flag -Mnomain' ;;
ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
tmp_addflag=' -i_dynamic' ;;
@@ -4385,39 +5204,47 @@
lf95*) # Lahey Fortran 8.1
_LT_TAGVAR(whole_archive_flag_spec, $1)=
tmp_sharedflag='--shared' ;;
- xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+ nagfor*) # NAGFOR 5.3
+ tmp_sharedflag='-Wl,-shared' ;;
+ xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
tmp_sharedflag='-qmkshrobj'
tmp_addflag= ;;
+ nvcc*) # Cuda Compiler Driver 2.2
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+ ;;
esac
case `$CC -V 2>&1 | sed 5q` in
*Sun\ C*) # Sun C 5.9
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
_LT_TAGVAR(compiler_needs_object, $1)=yes
tmp_sharedflag='-G' ;;
*Sun\ F*) # Sun Fortran 8.3
tmp_sharedflag='-G' ;;
esac
- _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
- if test "x$supports_anon_versioning" = xyes; then
+ if test yes = "$supports_anon_versioning"; then
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
fi
case $cc_basename in
- xlf*)
+ tcc*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic'
+ ;;
+ xlf* | bgf* | bgxlf* | mpixlf*)
# IBM XL Fortran 10.1 on PPC cannot create shared libs itself
_LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
- _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
- _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
- if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+ if test yes = "$supports_anon_versioning"; then
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- echo "local: *; };" >> $output_objdir/$libname.ver~
- $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
fi
;;
esac
@@ -4431,8 +5258,8 @@
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
wlarc=
else
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
fi
;;
@@ -4450,8 +5277,8 @@
_LT_EOF
elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
@@ -4463,7 +5290,7 @@
_LT_TAGVAR(ld_shlibs, $1)=no
cat <<_LT_EOF 1>&2
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
*** reliably create shared libraries on SCO systems. Therefore, libtool
*** is disabling shared libraries support. We urge you to upgrade GNU
*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
@@ -4478,9 +5305,9 @@
# DT_RUNPATH tag from executables and libraries. But doing so
# requires that you compile everything twice, which is a pain.
if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
@@ -4497,15 +5324,15 @@
*)
if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
esac
- if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+ if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then
runpath_var=
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
_LT_TAGVAR(export_dynamic_flag_spec, $1)=
@@ -4521,7 +5348,7 @@
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
_LT_TAGVAR(hardcode_minus_L, $1)=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+ if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
_LT_TAGVAR(hardcode_direct, $1)=unsupported
@@ -4529,32 +5356,57 @@
;;
aix[[4-9]]*)
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
exp_sym_flag='-Bexport'
- no_entry_flag=""
+ no_entry_flag=
else
# If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+ # Without the "-l" option, or with the "-B" option, AIX nm treats
+ # weak defined symbols like other global defined symbols, whereas
+ # GNU nm marks them as "W".
+ # While the 'weak' keyword is ignored in the Export File, we need
+ # it in the Import File for the 'aix-soname' feature, so we have
+ # to replace the "-B" option with "-P" for AIX nm.
if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
- _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
else
- _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
fi
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
+ # have runtime linking enabled, and use it for executables.
+ # For shared libraries, we enable/disable runtime linking
+ # depending on the kind of the shared library created -
+ # when "with_aix_soname,aix_use_runtimelinking" is:
+ # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables
+ # "aix,yes" lib.so shared, rtl:yes, for executables
+ # lib.a static archive
+ # "both,no" lib.so.V(shr.o) shared, rtl:yes
+ # lib.a(lib.so.V) shared, rtl:no, for executables
+ # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+ # lib.a(lib.so.V) shared, rtl:no
+ # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables
+ # lib.a static archive
case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
aix_use_runtimelinking=yes
break
fi
done
+ if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+ # With aix-soname=svr4, we create the lib.so.V shared archives only,
+ # so we don't have lib.a shared libs to link our executables.
+ # We have to force runtime linking in this case.
+ aix_use_runtimelinking=yes
+ LDFLAGS="$LDFLAGS -Wl,-brtl"
+ fi
;;
esac
@@ -4573,13 +5425,21 @@
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
- _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+ _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+ case $with_aix_soname,$aix_use_runtimelinking in
+ aix,*) ;; # traditional, no import file
+ svr4,* | *,yes) # use import file
+ # The Import File defines what to hardcode.
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+ ;;
+ esac
- if test "$GCC" = yes; then
+ if test yes = "$GCC"; then
case $host_os in aix4.[[012]]|aix4.[[012]].*)
# We only want to do this on AIX 4.2 and lower, the check
# below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
+ collect2name=`$CC -print-prog-name=collect2`
if test -f "$collect2name" &&
strings "$collect2name" | $GREP resolve_lib_name >/dev/null
then
@@ -4598,56 +5458,80 @@
;;
esac
shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
+ if test yes = "$aix_use_runtimelinking"; then
+ shared_flag="$shared_flag "'$wl-G'
fi
+ # Need to ensure runtime linking is disabled for the traditional
+ # shared library, or the linker may eventually find shared libraries
+ # /with/ Import File - we do not want to mix them.
+ shared_flag_aix='-shared'
+ shared_flag_svr4='-shared $wl-G'
else
# not using gcc
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
# chokes on -Wl,-G. The following line is correct:
shared_flag='-G'
else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
+ if test yes = "$aix_use_runtimelinking"; then
+ shared_flag='$wl-G'
else
- shared_flag='${wl}-bM:SRE'
+ shared_flag='$wl-bM:SRE'
fi
+ shared_flag_aix='$wl-bM:SRE'
+ shared_flag_svr4='$wl-G'
fi
fi
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
# It seems that -bexpall does not export symbols beginning with
# underscore (_), so it is better to generate a list of symbols to export.
_LT_TAGVAR(always_export_symbols, $1)=yes
- if test "$aix_use_runtimelinking" = yes; then
+ if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
# Warning - without using the other runtime loading flags (-brtl),
# -berok will link without error, but may produce a broken library.
_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
# Determine the default libpath from the value encoded in an
# empty executable.
- _LT_SYS_MODULE_PATH_AIX
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
else
- if test "$host_cpu" = ia64; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ if test ia64 = "$host_cpu"; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
_LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
- _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
else
# Determine the default libpath from the value encoded in an
# empty executable.
- _LT_SYS_MODULE_PATH_AIX
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
# Warning - without using the other run time loading flags,
# -berok will link without error, but may produce a broken library.
- _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+ if test yes = "$with_gnu_ld"; then
+ # We only use this code for GNU lds that support --whole-archive.
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
+ else
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ fi
_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+ # -brtl affects multiple linker settings, -berok does not and is overridden later
+ compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+ if test svr4 != "$with_aix_soname"; then
+ # This is similar to how AIX traditionally builds its shared libraries.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+ fi
+ if test aix != "$with_aix_soname"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp'
+ else
+ # used by -dlpreopen to get the symbols
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir'
+ fi
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
fi
fi
;;
@@ -4656,7 +5540,7 @@
case $host_cpu in
powerpc)
# see comment about AmigaOS4 .so support
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)=''
;;
m68k)
@@ -4676,24 +5560,69 @@
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
- _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
- # Tell ltmain to make .lib files, not .a files.
- libext=lib
- # Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
- # FIXME: Setting linknames here is a bad hack.
- _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
- # The linker will automatically build a .lib file if we build a DLL.
- _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
- # FIXME: Should let the user specify the lib program.
- _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
- _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
- _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
- ;;
-
- darwin* | rhapsody*)
- _LT_DARWIN_LINKER_FEATURES($1)
+ case $cc_basename in
+ cl*)
+ # Native MSVC
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='@'
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=.dll
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+ cp "$export_symbols" "$output_objdir/$soname.def";
+ echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+ else
+ $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
+ # The linker will not automatically build a static lib if we build a DLL.
+ # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+ # Don't use ranlib
+ _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
+ _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile=$lt_outputfile.exe
+ lt_tool_outputfile=$lt_tool_outputfile.exe
+ ;;
+ esac~
+ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
+ ;;
+ *)
+ # Assume MSVC wrapper
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=.dll
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ # FIXME: Should let the user specify the lib program.
+ _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ ;;
+ esac
+ ;;
+
+ darwin* | rhapsody*)
+ _LT_DARWIN_LINKER_FEATURES($1)
;;
dgux*)
@@ -4723,41 +5652,40 @@
# FreeBSD 3 and greater uses gcc -shared to do shared libraries.
freebsd* | dragonfly*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
hpux9*)
- if test "$GCC" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
else
- _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
fi
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(hardcode_direct, $1)=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
_LT_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
;;
hpux10*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ if test yes,no = "$GCC,$with_gnu_ld"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
else
_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
fi
- if test "$with_gnu_ld" = no; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
- _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+ if test no = "$with_gnu_ld"; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
_LT_TAGVAR(hardcode_minus_L, $1)=yes
@@ -4765,33 +5693,40 @@
;;
hpux11*)
- if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ if test yes,no = "$GCC,$with_gnu_ld"; then
case $host_cpu in
hppa*64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
ia64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
;;
esac
else
case $host_cpu in
hppa*64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
ia64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ m4_if($1, [], [
+ # Older versions of the 11.00 compiler do not understand -b yet
+ # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+ _LT_LINKER_OPTION([if $CC understands -b],
+ _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
+ [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
+ [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
+ [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
;;
esac
fi
- if test "$with_gnu_ld" = no; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ if test no = "$with_gnu_ld"; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
case $host_cpu in
@@ -4802,7 +5737,7 @@
*)
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
@@ -4813,28 +5748,53 @@
;;
irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
# Try to use the -exported_symbol ld option, if it does not
# work, assume that -exports_file does not work either and
# implicitly export all symbols.
- save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
- AC_LINK_IFELSE([AC_LANG_SOURCE([[int foo(void) {}]])],
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
- )
- LDFLAGS="$save_LDFLAGS"
+ # This should be the same for all languages, so no per-tag cache variable.
+ AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
+ [lt_cv_irix_exported_symbol],
+ [save_LDFLAGS=$LDFLAGS
+ LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
+ AC_LINK_IFELSE(
+ [AC_LANG_SOURCE(
+ [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
+ [C++], [[int foo (void) { return 0; }]],
+ [Fortran 77], [[
+ subroutine foo
+ end]],
+ [Fortran], [[
+ subroutine foo
+ end]])])],
+ [lt_cv_irix_exported_symbol=yes],
+ [lt_cv_irix_exported_symbol=no])
+ LDFLAGS=$save_LDFLAGS])
+ if test yes = "$lt_cv_irix_exported_symbol"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
+ fi
else
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)='no'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(inherit_rpath, $1)=yes
_LT_TAGVAR(link_all_deplibs, $1)=yes
;;
+ linux*)
+ case $cc_basename in
+ tcc*)
+ # Fabrice Bellard et al's Tiny C Compiler
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
netbsd*)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
@@ -4849,7 +5809,7 @@
newsos6)
_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(hardcode_direct, $1)=yes
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
@@ -4857,27 +5817,19 @@
*nto* | *qnx*)
;;
- openbsd*)
+ openbsd* | bitrig*)
if test -f /usr/libexec/ld.so; then
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
- if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
else
- case $host_os in
- openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
- _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- ;;
- *)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- ;;
- esac
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
fi
else
_LT_TAGVAR(ld_shlibs, $1)=no
@@ -4888,33 +5840,53 @@
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(hardcode_minus_L, $1)=yes
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ shrext_cmds=.dll
+ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ prefix_cmds="$SED"~
+ if test EXPORTS = "`$SED 1q $export_symbols`"; then
+ prefix_cmds="$prefix_cmds -e 1d";
+ fi~
+ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
;;
osf3*)
- if test "$GCC" = yes; then
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
else
_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)='no'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
;;
osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
else
_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
- $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
# Both c and cxx compiler support -rpath directly
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -4925,24 +5897,24 @@
solaris*)
_LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ if test yes = "$GCC"; then
+ wlarc='$wl'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
else
case `$CC -V 2>&1` in
*"Compilers 5.0"*)
wlarc=''
- _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
;;
*)
- wlarc='${wl}'
- _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ wlarc='$wl'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
;;
esac
fi
@@ -4952,11 +5924,11 @@
solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
*)
# The compiler driver will combine and reorder linker options,
- # but understands `-z linker_flag'. GCC discards it without `$wl',
+ # but understands '-z linker_flag'. GCC discards it without '$wl',
# but is careful enough not to reorder.
# Supported since Solaris 2.6 (maybe 2.5.1?)
- if test "$GCC" = yes; then
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
else
_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
fi
@@ -4966,10 +5938,10 @@
;;
sunos4*)
- if test "x$host_vendor" = xsequent; then
+ if test sequent = "$host_vendor"; then
# Use $CC to link under sequent, because it throws in some extra .o
# files that make .init and .fini sections work.
- _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
else
_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
fi
@@ -5018,43 +5990,43 @@
;;
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
- _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
runpath_var='LD_RUN_PATH'
- if test "$GCC" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
else
- _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
fi
;;
sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
+ # Note: We CANNOT use -z defs as we might desire, because we do not
# link with -lc, and that would cause any symbols used from libc to
# always be unresolved, which means just about no library would
# ever link correctly. If we're not using GNU ld we use -z text
# though, which does catch some bad symbols but isn't as heavy-handed
# as -z defs.
- _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
runpath_var='LD_RUN_PATH'
- if test "$GCC" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
else
- _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
fi
;;
@@ -5069,17 +6041,17 @@
;;
esac
- if test x$host_vendor = xsni; then
+ if test sni = "$host_vendor"; then
case $host in
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym'
;;
esac
fi
fi
])
AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
@@ -5096,7 +6068,7 @@
# Assume -lc should be added
_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
- if test "$enable_shared" = yes && test "$GCC" = yes; then
+ if test yes,yes = "$GCC,$enable_shared"; then
case $_LT_TAGVAR(archive_cmds, $1) in
*'~'*)
# FIXME: we may have to deal with multi-command sequences.
@@ -5105,36 +6077,38 @@
# Test whether the compiler implicitly links with -lc since on some
# systems, -lgcc has to come before -lc. If gcc already passes -lc
# to ld, don't add -lc before -lgcc.
- AC_MSG_CHECKING([whether -lc should be explicitly linked in])
- $RM conftest*
- echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-
- if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
- soname=conftest
- lib=conftest
- libobjs=conftest.$ac_objext
- deplibs=
- wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
- pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
- compiler_flags=-v
- linker_flags=-v
- verstring=
- output_objdir=.
- libname=conftest
- lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
- _LT_TAGVAR(allow_undefined_flag, $1)=
- if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
- then
- _LT_TAGVAR(archive_cmds_need_lc, $1)=no
- else
- _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
- fi
- _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
- else
- cat conftest.err 1>&5
- fi
- $RM conftest*
- AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
+ AC_CACHE_CHECK([whether -lc should be explicitly linked in],
+ [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1),
+ [$RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
+ pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
+ _LT_TAGVAR(allow_undefined_flag, $1)=
+ if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
+ then
+ lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ else
+ lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ fi
+ _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+ ])
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)
;;
esac
fi
@@ -5171,18 +6145,15 @@
_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
[Flag to hardcode $libdir into a binary during linking.
This must work even if $libdir does not exist])
-_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
- [[If ld is used when linking, flag to hardcode $libdir into a binary
- during linking. This must work even if $libdir does not exist]])
_LT_TAGDECL([], [hardcode_libdir_separator], [1],
[Whether we need a single "-rpath" flag with a separated argument])
_LT_TAGDECL([], [hardcode_direct], [0],
- [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
DIR into the resulting binary])
_LT_TAGDECL([], [hardcode_direct_absolute], [0],
- [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
DIR into the resulting binary and the resulting library dependency is
- "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+ "absolute", i.e impossible to change by setting $shlibpath_var if the
library is relocated])
_LT_TAGDECL([], [hardcode_minus_L], [0],
[Set to "yes" if using the -LDIR flag during linking hardcodes DIR
@@ -5199,8 +6170,6 @@
to runtime path list])
_LT_TAGDECL([], [link_all_deplibs], [0],
[Whether libtool must link a program against all its dependency libraries])
-_LT_TAGDECL([], [fix_srcfile_path], [1],
- [Fix the shell variable $srcfile for the compiler])
_LT_TAGDECL([], [always_export_symbols], [0],
[Set to "yes" if exported symbols are required])
_LT_TAGDECL([], [export_symbols_cmds], [2],
@@ -5211,6 +6180,8 @@
[Symbols that must always be exported])
_LT_TAGDECL([], [prelink_cmds], [2],
[Commands necessary for linking programs (against libraries) with templates])
+_LT_TAGDECL([], [postlink_cmds], [2],
+ [Commands necessary for finishing linking programs])
_LT_TAGDECL([], [file_list_spec], [1],
[Specify filename containing input files])
dnl FIXME: Not yet implemented
@@ -5223,10 +6194,10 @@
# ------------------------
# Ensure that the configuration variables for a C compiler are suitably
# defined. These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_C_CONFIG],
[m4_require([_LT_DECL_EGREP])dnl
-lt_save_CC="$CC"
+lt_save_CC=$CC
AC_LANG_PUSH(C)
# Source file extension for C test sources.
@@ -5266,18 +6237,18 @@
LT_SYS_DLOPEN_SELF
_LT_CMD_STRIPLIB
- # Report which library types will actually be built
+ # Report what library types will actually be built
AC_MSG_CHECKING([if libtool supports shared libraries])
AC_MSG_RESULT([$can_build_shared])
AC_MSG_CHECKING([whether to build shared libraries])
- test "$can_build_shared" = "no" && enable_shared=no
+ test no = "$can_build_shared" && enable_shared=no
# On AIX, shared libraries and static libraries use the same namespace, and
# are all built from PIC.
case $host_os in
aix3*)
- test "$enable_shared" = yes && enable_static=no
+ test yes = "$enable_shared" && enable_static=no
if test -n "$RANLIB"; then
archive_cmds="$archive_cmds~\$RANLIB \$lib"
postinstall_cmds='$RANLIB $lib'
@@ -5285,8 +6256,12 @@
;;
aix[[4-9]]*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
+ if test ia64 != "$host_cpu"; then
+ case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+ yes,aix,yes) ;; # shared object as lib.so file only
+ yes,svr4,*) ;; # shared object as lib.so archive member only
+ yes,*) enable_static=no ;; # shared object in lib.a archive as well
+ esac
fi
;;
esac
@@ -5294,47 +6269,32 @@
AC_MSG_CHECKING([whether to build static libraries])
# Make sure either enable_shared or enable_static is yes.
- test "$enable_shared" = yes || enable_static=yes
+ test yes = "$enable_shared" || enable_static=yes
AC_MSG_RESULT([$enable_static])
_LT_CONFIG($1)
fi
AC_LANG_POP
-CC="$lt_save_CC"
+CC=$lt_save_CC
])# _LT_LANG_C_CONFIG
-# _LT_PROG_CXX
-# ------------
-# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
-# compiler, we have our own version here.
-m4_defun([_LT_PROG_CXX],
-[
-pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
-AC_PROG_CXX
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
- AC_PROG_CXXCPP
-else
- _lt_caught_CXX_error=yes
-fi
-popdef([AC_MSG_ERROR])
-])# _LT_PROG_CXX
-
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([_LT_PROG_CXX], [])
-
-
# _LT_LANG_CXX_CONFIG([TAG])
# --------------------------
# Ensure that the configuration variables for a C++ compiler are suitably
# defined. These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_CXX_CONFIG],
-[AC_REQUIRE([_LT_PROG_CXX])dnl
-m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_PATH_MANIFEST_TOOL])dnl
+if test -n "$CXX" && ( test no != "$CXX" &&
+ ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) ||
+ (test g++ != "$CXX"))); then
+ AC_PROG_CXXCPP
+else
+ _lt_caught_CXX_error=yes
+fi
AC_LANG_PUSH(C++)
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
@@ -5346,7 +6306,6 @@
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
_LT_TAGVAR(hardcode_libdir_separator, $1)=
_LT_TAGVAR(hardcode_minus_L, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
@@ -5356,6 +6315,8 @@
_LT_TAGVAR(module_expsym_cmds, $1)=
_LT_TAGVAR(link_all_deplibs, $1)=unknown
_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
_LT_TAGVAR(no_undefined_flag, $1)=
_LT_TAGVAR(whole_archive_flag_spec, $1)=
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
@@ -5371,7 +6332,7 @@
# the CXX compiler isn't working. Some variables (like enable_shared)
# are currently assumed to apply to all compilers on this platform,
# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
+if test yes != "$_lt_caught_CXX_error"; then
# Code to be used in simple compile tests
lt_simple_compile_test_code="int some_variable = 0;"
@@ -5387,6 +6348,7 @@
# Allow CC to be a program name with arguments.
lt_save_CC=$CC
+ lt_save_CFLAGS=$CFLAGS
lt_save_LD=$LD
lt_save_GCC=$GCC
GCC=$GXX
@@ -5404,6 +6366,7 @@
fi
test -z "${LDCXX+set}" || LD=$LDCXX
CC=${CXX-"c++"}
+ CFLAGS=$CXXFLAGS
compiler=$CC
_LT_TAGVAR(compiler, $1)=$CC
_LT_CC_BASENAME([$compiler])
@@ -5411,35 +6374,35 @@
if test -n "$compiler"; then
# We don't want -fno-exception when compiling C++ code, so set the
# no_builtin_flag separately
- if test "$GXX" = yes; then
+ if test yes = "$GXX"; then
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
else
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
fi
- if test "$GXX" = yes; then
+ if test yes = "$GXX"; then
# Set up default GNU C++ configuration
LT_PATH_LD
# Check if GNU C++ uses GNU ld as the underlying linker, since the
# archiving commands below assume that GNU ld is being used.
- if test "$with_gnu_ld" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ if test yes = "$with_gnu_ld"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
# If archive_cmds runs LD, not CC, wlarc should be empty
# XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
# investigate it a little bit more. (MM)
- wlarc='${wl}'
+ wlarc='$wl'
# ancient GNU ld didn't support --whole-archive et. al.
if eval "`$CC -print-prog-name=ld` --help 2>&1" |
$GREP 'no-whole-archive' > /dev/null; then
- _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
else
_LT_TAGVAR(whole_archive_flag_spec, $1)=
fi
@@ -5458,7 +6421,7 @@
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
else
GXX=no
@@ -5475,18 +6438,30 @@
_LT_TAGVAR(ld_shlibs, $1)=no
;;
aix[[4-9]]*)
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
exp_sym_flag='-Bexport'
- no_entry_flag=""
+ no_entry_flag=
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
+ # have runtime linking enabled, and use it for executables.
+ # For shared libraries, we enable/disable runtime linking
+ # depending on the kind of the shared library created -
+ # when "with_aix_soname,aix_use_runtimelinking" is:
+ # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables
+ # "aix,yes" lib.so shared, rtl:yes, for executables
+ # lib.a static archive
+ # "both,no" lib.so.V(shr.o) shared, rtl:yes
+ # lib.a(lib.so.V) shared, rtl:no, for executables
+ # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+ # lib.a(lib.so.V) shared, rtl:no
+ # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables
+ # lib.a static archive
case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
for ld_flag in $LDFLAGS; do
case $ld_flag in
@@ -5496,6 +6471,13 @@
;;
esac
done
+ if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+ # With aix-soname=svr4, we create the lib.so.V shared archives only,
+ # so we don't have lib.a shared libs to link our executables.
+ # We have to force runtime linking in this case.
+ aix_use_runtimelinking=yes
+ LDFLAGS="$LDFLAGS -Wl,-brtl"
+ fi
;;
esac
@@ -5514,13 +6496,21 @@
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
- _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+ _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+ case $with_aix_soname,$aix_use_runtimelinking in
+ aix,*) ;; # no import file
+ svr4,* | *,yes) # use import file
+ # The Import File defines what to hardcode.
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+ ;;
+ esac
- if test "$GXX" = yes; then
+ if test yes = "$GXX"; then
case $host_os in aix4.[[012]]|aix4.[[012]].*)
# We only want to do this on AIX 4.2 and lower, the check
# below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
+ collect2name=`$CC -print-prog-name=collect2`
if test -f "$collect2name" &&
strings "$collect2name" | $GREP resolve_lib_name >/dev/null
then
@@ -5538,59 +6528,84 @@
fi
esac
shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
+ if test yes = "$aix_use_runtimelinking"; then
+ shared_flag=$shared_flag' $wl-G'
fi
+ # Need to ensure runtime linking is disabled for the traditional
+ # shared library, or the linker may eventually find shared libraries
+ # /with/ Import File - we do not want to mix them.
+ shared_flag_aix='-shared'
+ shared_flag_svr4='-shared $wl-G'
else
# not using gcc
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
# chokes on -Wl,-G. The following line is correct:
shared_flag='-G'
else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
+ if test yes = "$aix_use_runtimelinking"; then
+ shared_flag='$wl-G'
else
- shared_flag='${wl}-bM:SRE'
+ shared_flag='$wl-bM:SRE'
fi
+ shared_flag_aix='$wl-bM:SRE'
+ shared_flag_svr4='$wl-G'
fi
fi
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
# It seems that -bexpall does not export symbols beginning with
# underscore (_), so it is better to generate a list of symbols to
# export.
_LT_TAGVAR(always_export_symbols, $1)=yes
- if test "$aix_use_runtimelinking" = yes; then
+ if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
# Warning - without using the other runtime loading flags (-brtl),
# -berok will link without error, but may produce a broken library.
- _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # The "-G" linker flag allows undefined symbols.
+ _LT_TAGVAR(no_undefined_flag, $1)='-bernotok'
# Determine the default libpath from the value encoded in an empty
# executable.
- _LT_SYS_MODULE_PATH_AIX
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
else
- if test "$host_cpu" = ia64; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ if test ia64 = "$host_cpu"; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
_LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
- _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
else
# Determine the default libpath from the value encoded in an
# empty executable.
- _LT_SYS_MODULE_PATH_AIX
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_SYS_MODULE_PATH_AIX([$1])
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
# Warning - without using the other run time loading flags,
# -berok will link without error, but may produce a broken library.
- _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
- # Exported symbols can be pulled into shared objects from archives
- _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+ if test yes = "$with_gnu_ld"; then
+ # We only use this code for GNU lds that support --whole-archive.
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
+ else
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ fi
_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
- # This is similar to how AIX traditionally builds its shared
- # libraries.
- _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+ # -brtl affects multiple linker settings, -berok does not and is overridden later
+ compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+ if test svr4 != "$with_aix_soname"; then
+ # This is similar to how AIX traditionally builds its shared
+ # libraries. Need -bnortl late, we may have -brtl in LDFLAGS.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+ fi
+ if test aix != "$with_aix_soname"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp'
+ else
+ # used by -dlpreopen to get the symbols
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir'
+ fi
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
fi
fi
;;
@@ -5600,7 +6615,7 @@
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
# Joseph Beckenbach says some releases of gcc
# support --undefined. This deserves some investigation. FIXME
- _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
@@ -5616,32 +6631,108 @@
;;
cygwin* | mingw* | pw32* | cegcc*)
- # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
- # as there is no search path for DLLs.
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_TAGVAR(always_export_symbols, $1)=no
- _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
-
- if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- else
- _LT_TAGVAR(ld_shlibs, $1)=no
- fi
- ;;
+ case $GXX,$cc_basename in
+ ,cl* | no,cl*)
+ # Native MSVC
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='@'
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=.dll
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+ cp "$export_symbols" "$output_objdir/$soname.def";
+ echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+ else
+ $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
+ # The linker will not automatically build a static lib if we build a DLL.
+ # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ # Don't use ranlib
+ _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
+ _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile=$lt_outputfile.exe
+ lt_tool_outputfile=$lt_tool_outputfile.exe
+ ;;
+ esac~
+ func_to_tool_file "$lt_outputfile"~
+ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
+ ;;
+ *)
+ # g++
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file, use it as
+ # is; otherwise, prepend EXPORTS...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
darwin* | rhapsody*)
_LT_DARWIN_LINKER_FEATURES($1)
;;
+ os2*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ shrext_cmds=.dll
+ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ prefix_cmds="$SED"~
+ if test EXPORTS = "`$SED 1q $export_symbols`"; then
+ prefix_cmds="$prefix_cmds -e 1d";
+ fi~
+ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ ;;
+
dgux*)
case $cc_basename in
ec++*)
@@ -5676,13 +6767,15 @@
_LT_TAGVAR(ld_shlibs, $1)=yes
;;
- gnu*)
+ haiku*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
;;
hpux9*)
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
# but as the default
@@ -5694,7 +6787,7 @@
_LT_TAGVAR(ld_shlibs, $1)=no
;;
aCC*)
- _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
@@ -5703,11 +6796,11 @@
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
- if test "$GXX" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ if test yes = "$GXX"; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
else
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
@@ -5717,15 +6810,15 @@
;;
hpux10*|hpux11*)
- if test $with_gnu_ld = no; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ if test no = "$with_gnu_ld"; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
case $host_cpu in
hppa*64*|ia64*)
;;
*)
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
;;
esac
fi
@@ -5751,13 +6844,13 @@
aCC*)
case $host_cpu in
hppa*64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
ia64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
esac
# Commands to make compiler produce verbose output that lists
@@ -5768,20 +6861,20 @@
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
- if test "$GXX" = yes; then
- if test $with_gnu_ld = no; then
+ if test yes = "$GXX"; then
+ if test no = "$with_gnu_ld"; then
case $host_cpu in
hppa*64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
ia64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
esac
fi
@@ -5796,22 +6889,22 @@
interix[[3-9]]*)
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
# Instead, shared libraries are loaded at an image base (0x10000000 by
# default) and relocated if they conflict, which is a slow very memory
# consuming and fragmenting process. To avoid this, we pick a random,
# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
# time. Moving up from 0x10000000 also allows more sbrk(2) space.
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
;;
irix5* | irix6*)
case $cc_basename in
CC*)
# SGI C++
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
# Archives containing C++ object files must be created using
# "CC -ar", where "CC" is the IRIX C++ compiler. This is
@@ -5820,22 +6913,22 @@
_LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
;;
*)
- if test "$GXX" = yes; then
- if test "$with_gnu_ld" = no; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ if test yes = "$GXX"; then
+ if test no = "$with_gnu_ld"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
else
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib'
fi
fi
_LT_TAGVAR(link_all_deplibs, $1)=yes
;;
esac
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(inherit_rpath, $1)=yes
;;
- linux* | k*bsd*-gnu)
+ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
KCC*)
# Kuck and Associates, Inc. (KAI) C++ Compiler
@@ -5843,8 +6936,8 @@
# KCC will only create a shared library if the output file
# ends with ".so" (or ".sl" for HP-UX), so rename the library
# to its proper name (with version) after linking.
- _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
@@ -5853,10 +6946,10 @@
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
# Archives containing C++ object files must be created using
# "CC -Bstatic", where "CC" is the KAI C++ compiler.
@@ -5870,59 +6963,59 @@
# earlier do not add the objects themselves.
case `$CC -V 2>&1` in
*"Version 7."*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
;;
*) # Version 8.0 or newer
tmp_idyn=
case $host_cpu in
ia64*) tmp_idyn=' -i_dynamic';;
esac
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
;;
esac
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
;;
pgCC* | pgcpp*)
# Portland Group C++ compiler
case `$CC -V` in
- *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
+ *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
_LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
- rm -rf $tpldir~
- $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
- compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
_LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
- rm -rf $tpldir~
- $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
- $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
- $RANLIB $oldlib'
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+ $RANLIB $oldlib'
_LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
- rm -rf $tpldir~
- $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
- $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
- rm -rf $tpldir~
- $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
- $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
;;
- *) # Version 6 will use weak symbols
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ *) # Version 6 and above use weak symbols
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
;;
esac
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
;;
cxx*)
# Compaq C++
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols'
runpath_var=LD_RUN_PATH
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -5936,18 +7029,18 @@
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
;;
- xl*)
+ xl* | mpixl* | bgxl*)
# IBM XL 8.0 on PPC, with GNU ld
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ if test yes = "$supports_anon_versioning"; then
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
fi
;;
*)
@@ -5955,16 +7048,16 @@
*Sun\ C*)
# Sun C++ 5.9
_LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
- _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
_LT_TAGVAR(compiler_needs_object, $1)=yes
# Not sure whether something based on
# $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
# would be better.
- output_verbose_link_cmd='echo'
+ output_verbose_link_cmd='func_echo_all'
# Archives containing C++ object files must be created using
# "CC -xar", where "CC" is the Sun C++ compiler. This is
@@ -6016,24 +7109,19 @@
_LT_TAGVAR(ld_shlibs, $1)=yes
;;
- openbsd2*)
- # C++ shared libraries are fairly broken
- _LT_TAGVAR(ld_shlibs, $1)=no
- ;;
-
- openbsd*)
+ openbsd* | bitrig*)
if test -f /usr/libexec/ld.so; then
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
fi
- output_verbose_link_cmd=echo
+ output_verbose_link_cmd=func_echo_all
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
@@ -6047,9 +7135,9 @@
# KCC will only create a shared library if the output file
# ends with ".so" (or ".sl" for HP-UX), so rename the library
# to its proper name (with version) after linking.
- _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
# Archives containing C++ object files must be created using
@@ -6067,17 +7155,17 @@
cxx*)
case $host in
osf3*)
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
;;
*)
_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
- echo "-hidden">> $lib.exp~
- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
- $RM $lib.exp'
+ echo "-hidden">> $lib.exp~
+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~
+ $RM $lib.exp'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
;;
esac
@@ -6092,27 +7180,27 @@
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ if test yes,no = "$GXX,$with_gnu_ld"; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
case $host in
osf3*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
;;
esac
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
else
# FIXME: insert proper C++ library support
@@ -6148,13 +7236,13 @@
solaris*)
case $cc_basename in
- CC*)
+ CC* | sunCC*)
# Sun C++ 4.2, 5.x and Centerline C++
_LT_TAGVAR(archive_cmds_need_lc,$1)=yes
_LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
- _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+ $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -6162,14 +7250,14 @@
solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
*)
# The compiler driver will combine and reorder linker options,
- # but understands `-z linker_flag'.
+ # but understands '-z linker_flag'.
# Supported since Solaris 2.6 (maybe 2.5.1?)
_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
;;
esac
_LT_TAGVAR(link_all_deplibs, $1)=yes
- output_verbose_link_cmd='echo'
+ output_verbose_link_cmd='func_echo_all'
# Archives containing C++ object files must be created using
# "CC -xar", where "CC" is the Sun C++ compiler. This is
@@ -6179,42 +7267,42 @@
;;
gcx*)
# Green Hills C++ Compiler
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
# The C++ compiler must be used to create the archive.
_LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
;;
*)
# GNU C++ compiler with Solaris linker
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+ if test yes,no = "$GXX,$with_gnu_ld"; then
+ _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs'
if $CC --version | $GREP -v '^2\.7' > /dev/null; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+ $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
- output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
else
- # g++ 2.7 appears to require `-G' NOT `-shared' on this
+ # g++ 2.7 appears to require '-G' NOT '-shared' on this
# platform.
- _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+ $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
- output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
fi
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir'
case $host_os in
solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
*)
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
;;
esac
fi
@@ -6223,48 +7311,52 @@
;;
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
- _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
runpath_var='LD_RUN_PATH'
case $cc_basename in
CC*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
esac
;;
sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
+ # Note: We CANNOT use -z defs as we might desire, because we do not
# link with -lc, and that would cause any symbols used from libc to
# always be unresolved, which means just about no library would
# ever link correctly. If we're not using GNU ld we use -z text
# though, which does catch some bad symbols but isn't as heavy-handed
# as -z defs.
- _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
runpath_var='LD_RUN_PATH'
case $cc_basename in
CC*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
+ '"$_LT_TAGVAR(old_archive_cmds, $1)"
+ _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
+ '"$_LT_TAGVAR(reload_cmds, $1)"
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
esac
;;
@@ -6295,10 +7387,10 @@
esac
AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
- test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+ test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
- _LT_TAGVAR(GCC, $1)="$GXX"
- _LT_TAGVAR(LD, $1)="$LD"
+ _LT_TAGVAR(GCC, $1)=$GXX
+ _LT_TAGVAR(LD, $1)=$LD
## CAVEAT EMPTOR:
## There is no encapsulation within the following macros, do not change
@@ -6316,6 +7408,7 @@
fi # test -n "$compiler"
CC=$lt_save_CC
+ CFLAGS=$lt_save_CFLAGS
LDCXX=$LD
LD=$lt_save_LD
GCC=$lt_save_GCC
@@ -6324,12 +7417,36 @@
lt_cv_path_LD=$lt_save_path_LD
lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test yes != "$_lt_caught_CXX_error"
AC_LANG_POP
])# _LT_LANG_CXX_CONFIG
+# _LT_FUNC_STRIPNAME_CNF
+# ----------------------
+# func_stripname_cnf prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+#
+# This function is identical to the (non-XSI) version of func_stripname,
+# except this one can be used by m4 code that may be executed by configure,
+# rather than the libtool script.
+m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl
+AC_REQUIRE([_LT_DECL_SED])
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
+func_stripname_cnf ()
+{
+ case @S|@2 in
+ .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;;
+ *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;;
+ esac
+} # func_stripname_cnf
+])# _LT_FUNC_STRIPNAME_CNF
+
+
# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
# ---------------------------------
# Figure out "hidden" library dependencies from verbose
@@ -6338,6 +7455,7 @@
# objects, libraries and library flags.
m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl
# Dependencies to place before and after the object being linked:
_LT_TAGVAR(predep_objects, $1)=
_LT_TAGVAR(postdep_objects, $1)=
@@ -6387,7 +7505,20 @@
}
};
_LT_EOF
+], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF
+package foo
+func foo() {
+}
+_LT_EOF
])
+
+_lt_libdeps_save_CFLAGS=$CFLAGS
+case "$CC $CFLAGS " in #(
+*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
+*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
+esac
+
dnl Parse the compiler output and extract the necessary
dnl objects, libraries and library flags.
if AC_TRY_EVAL(ac_compile); then
@@ -6399,29 +7530,38 @@
pre_test_object_deps_done=no
for p in `eval "$output_verbose_link_cmd"`; do
- case $p in
+ case $prev$p in
-L* | -R* | -l*)
# Some compilers place space between "-{L,R}" and the path.
# Remove the space.
- if test $p = "-L" ||
- test $p = "-R"; then
+ if test x-L = "$p" ||
+ test x-R = "$p"; then
prev=$p
continue
- else
- prev=
fi
- if test "$pre_test_object_deps_done" = no; then
- case $p in
- -L* | -R*)
+ # Expand the sysroot to ease extracting the directories later.
+ if test -z "$prev"; then
+ case $p in
+ -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
+ -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
+ -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
+ esac
+ fi
+ case $p in
+ =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
+ esac
+ if test no = "$pre_test_object_deps_done"; then
+ case $prev in
+ -L | -R)
# Internal compiler library paths should come after those
# provided the user. The postdeps already come after the
# user supplied libs so there is no need to process them.
if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
- _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+ _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p
else
- _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p"
fi
;;
# The "-l" case would never come before the object being
@@ -6429,13 +7569,15 @@
esac
else
if test -z "$_LT_TAGVAR(postdeps, $1)"; then
- _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+ _LT_TAGVAR(postdeps, $1)=$prev$p
else
- _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+ _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p"
fi
fi
+ prev=
;;
+ *.lto.$objext) ;; # Ignore GCC LTO objects
*.$objext)
# This assumes that the test object file only shows up
# once in the compiler output.
@@ -6444,15 +7586,15 @@
continue
fi
- if test "$pre_test_object_deps_done" = no; then
+ if test no = "$pre_test_object_deps_done"; then
if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
- _LT_TAGVAR(predep_objects, $1)="$p"
+ _LT_TAGVAR(predep_objects, $1)=$p
else
_LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
fi
else
if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
- _LT_TAGVAR(postdep_objects, $1)="$p"
+ _LT_TAGVAR(postdep_objects, $1)=$p
else
_LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
fi
@@ -6471,6 +7613,7 @@
fi
$RM -f confest.$objext
+CFLAGS=$_lt_libdeps_save_CFLAGS
# PORTME: override above test on systems where it is broken
m4_if([$1], [CXX],
@@ -6482,51 +7625,6 @@
_LT_TAGVAR(postdep_objects,$1)=
_LT_TAGVAR(postdeps,$1)=
;;
-
-linux*)
- case `$CC -V 2>&1 | sed 5q` in
- *Sun\ C*)
- # Sun C++ 5.9
-
- # The more standards-conforming stlport4 library is
- # incompatible with the Cstd library. Avoid specifying
- # it if it's in CXXFLAGS. Ignore libCrun as
- # -library=stlport4 depends on it.
- case " $CXX $CXXFLAGS " in
- *" -library=stlport4 "*)
- solaris_use_stlport4=yes
- ;;
- esac
-
- if test "$solaris_use_stlport4" != yes; then
- _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
- fi
- ;;
- esac
- ;;
-
-solaris*)
- case $cc_basename in
- CC*)
- # The more standards-conforming stlport4 library is
- # incompatible with the Cstd library. Avoid specifying
- # it if it's in CXXFLAGS. Ignore libCrun as
- # -library=stlport4 depends on it.
- case " $CXX $CXXFLAGS " in
- *" -library=stlport4 "*)
- solaris_use_stlport4=yes
- ;;
- esac
-
- # Adding this requires a known-good setup of shared libraries for
- # Sun compiler versions before 5.6, else PIC objects from an old
- # archive will be linked into the output, leading to subtle bugs.
- if test "$solaris_use_stlport4" != yes; then
- _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
- fi
- ;;
- esac
- ;;
esac
])
@@ -6535,7 +7633,7 @@
esac
_LT_TAGVAR(compiler_lib_search_dirs, $1)=
if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
- _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'`
fi
_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
[The directories searched by this compiler when creating a shared library])
@@ -6551,32 +7649,16 @@
])# _LT_SYS_HIDDEN_LIBDEPS
-# _LT_PROG_F77
-# ------------
-# Since AC_PROG_F77 is broken, in that it returns the empty string
-# if there is no fortran compiler, we have our own version here.
-m4_defun([_LT_PROG_F77],
-[
-pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
-AC_PROG_F77
-if test -z "$F77" || test "X$F77" = "Xno"; then
- _lt_disable_F77=yes
-fi
-popdef([AC_MSG_ERROR])
-])# _LT_PROG_F77
-
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([_LT_PROG_F77], [])
-
-
# _LT_LANG_F77_CONFIG([TAG])
# --------------------------
# Ensure that the configuration variables for a Fortran 77 compiler are
# suitably defined. These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_F77_CONFIG],
-[AC_REQUIRE([_LT_PROG_F77])dnl
-AC_LANG_PUSH(Fortran 77)
+[AC_LANG_PUSH(Fortran 77)
+if test -z "$F77" || test no = "$F77"; then
+ _lt_disable_F77=yes
+fi
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(allow_undefined_flag, $1)=
@@ -6586,7 +7668,6 @@
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
_LT_TAGVAR(hardcode_libdir_separator, $1)=
_LT_TAGVAR(hardcode_minus_L, $1)=no
_LT_TAGVAR(hardcode_automatic, $1)=no
@@ -6595,6 +7676,8 @@
_LT_TAGVAR(module_expsym_cmds, $1)=
_LT_TAGVAR(link_all_deplibs, $1)=unknown
_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
_LT_TAGVAR(no_undefined_flag, $1)=
_LT_TAGVAR(whole_archive_flag_spec, $1)=
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
@@ -6610,7 +7693,7 @@
# the F77 compiler isn't working. Some variables (like enable_shared)
# are currently assumed to apply to all compilers on this platform,
# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_F77" != yes; then
+if test yes != "$_lt_disable_F77"; then
# Code to be used in simple compile tests
lt_simple_compile_test_code="\
subroutine t
@@ -6632,9 +7715,11 @@
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
- lt_save_CC="$CC"
+ lt_save_CC=$CC
lt_save_GCC=$GCC
+ lt_save_CFLAGS=$CFLAGS
CC=${F77-"f77"}
+ CFLAGS=$FFLAGS
compiler=$CC
_LT_TAGVAR(compiler, $1)=$CC
_LT_CC_BASENAME([$compiler])
@@ -6644,21 +7729,25 @@
AC_MSG_RESULT([$can_build_shared])
AC_MSG_CHECKING([whether to build shared libraries])
- test "$can_build_shared" = "no" && enable_shared=no
+ test no = "$can_build_shared" && enable_shared=no
# On AIX, shared libraries and static libraries use the same namespace, and
# are all built from PIC.
case $host_os in
aix3*)
- test "$enable_shared" = yes && enable_static=no
+ test yes = "$enable_shared" && enable_static=no
if test -n "$RANLIB"; then
archive_cmds="$archive_cmds~\$RANLIB \$lib"
postinstall_cmds='$RANLIB $lib'
fi
;;
aix[[4-9]]*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
+ if test ia64 != "$host_cpu"; then
+ case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+ yes,aix,yes) ;; # shared object as lib.so file only
+ yes,svr4,*) ;; # shared object as lib.so archive member only
+ yes,*) enable_static=no ;; # shared object in lib.a archive as well
+ esac
fi
;;
esac
@@ -6666,11 +7755,11 @@
AC_MSG_CHECKING([whether to build static libraries])
# Make sure either enable_shared or enable_static is yes.
- test "$enable_shared" = yes || enable_static=yes
+ test yes = "$enable_shared" || enable_static=yes
AC_MSG_RESULT([$enable_static])
- _LT_TAGVAR(GCC, $1)="$G77"
- _LT_TAGVAR(LD, $1)="$LD"
+ _LT_TAGVAR(GCC, $1)=$G77
+ _LT_TAGVAR(LD, $1)=$LD
## CAVEAT EMPTOR:
## There is no encapsulation within the following macros, do not change
@@ -6687,39 +7776,25 @@
fi # test -n "$compiler"
GCC=$lt_save_GCC
- CC="$lt_save_CC"
-fi # test "$_lt_disable_F77" != yes
+ CC=$lt_save_CC
+ CFLAGS=$lt_save_CFLAGS
+fi # test yes != "$_lt_disable_F77"
AC_LANG_POP
])# _LT_LANG_F77_CONFIG
-# _LT_PROG_FC
-# -----------
-# Since AC_PROG_FC is broken, in that it returns the empty string
-# if there is no fortran compiler, we have our own version here.
-m4_defun([_LT_PROG_FC],
-[
-pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
-AC_PROG_FC
-if test -z "$FC" || test "X$FC" = "Xno"; then
- _lt_disable_FC=yes
-fi
-popdef([AC_MSG_ERROR])
-])# _LT_PROG_FC
-
-dnl aclocal-1.4 backwards compatibility:
-dnl AC_DEFUN([_LT_PROG_FC], [])
-
-
# _LT_LANG_FC_CONFIG([TAG])
# -------------------------
# Ensure that the configuration variables for a Fortran compiler are
# suitably defined. These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_FC_CONFIG],
-[AC_REQUIRE([_LT_PROG_FC])dnl
-AC_LANG_PUSH(Fortran)
+[AC_LANG_PUSH(Fortran)
+
+if test -z "$FC" || test no = "$FC"; then
+ _lt_disable_FC=yes
+fi
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(allow_undefined_flag, $1)=
@@ -6729,7 +7804,6 @@
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=no
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
-_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
_LT_TAGVAR(hardcode_libdir_separator, $1)=
_LT_TAGVAR(hardcode_minus_L, $1)=no
_LT_TAGVAR(hardcode_automatic, $1)=no
@@ -6738,6 +7812,8 @@
_LT_TAGVAR(module_expsym_cmds, $1)=
_LT_TAGVAR(link_all_deplibs, $1)=unknown
_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
_LT_TAGVAR(no_undefined_flag, $1)=
_LT_TAGVAR(whole_archive_flag_spec, $1)=
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
@@ -6753,7 +7829,7 @@
# the FC compiler isn't working. Some variables (like enable_shared)
# are currently assumed to apply to all compilers on this platform,
# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_FC" != yes; then
+if test yes != "$_lt_disable_FC"; then
# Code to be used in simple compile tests
lt_simple_compile_test_code="\
subroutine t
@@ -6775,9 +7851,11 @@
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
- lt_save_CC="$CC"
+ lt_save_CC=$CC
lt_save_GCC=$GCC
+ lt_save_CFLAGS=$CFLAGS
CC=${FC-"f95"}
+ CFLAGS=$FCFLAGS
compiler=$CC
GCC=$ac_cv_fc_compiler_gnu
@@ -6789,21 +7867,25 @@
AC_MSG_RESULT([$can_build_shared])
AC_MSG_CHECKING([whether to build shared libraries])
- test "$can_build_shared" = "no" && enable_shared=no
+ test no = "$can_build_shared" && enable_shared=no
# On AIX, shared libraries and static libraries use the same namespace, and
# are all built from PIC.
case $host_os in
aix3*)
- test "$enable_shared" = yes && enable_static=no
+ test yes = "$enable_shared" && enable_static=no
if test -n "$RANLIB"; then
archive_cmds="$archive_cmds~\$RANLIB \$lib"
postinstall_cmds='$RANLIB $lib'
fi
;;
aix[[4-9]]*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
+ if test ia64 != "$host_cpu"; then
+ case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+ yes,aix,yes) ;; # shared object as lib.so file only
+ yes,svr4,*) ;; # shared object as lib.so archive member only
+ yes,*) enable_static=no ;; # shared object in lib.a archive as well
+ esac
fi
;;
esac
@@ -6811,11 +7893,11 @@
AC_MSG_CHECKING([whether to build static libraries])
# Make sure either enable_shared or enable_static is yes.
- test "$enable_shared" = yes || enable_static=yes
+ test yes = "$enable_shared" || enable_static=yes
AC_MSG_RESULT([$enable_static])
- _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
- _LT_TAGVAR(LD, $1)="$LD"
+ _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu
+ _LT_TAGVAR(LD, $1)=$LD
## CAVEAT EMPTOR:
## There is no encapsulation within the following macros, do not change
@@ -6833,8 +7915,9 @@
fi # test -n "$compiler"
GCC=$lt_save_GCC
- CC="$lt_save_CC"
-fi # test "$_lt_disable_FC" != yes
+ CC=$lt_save_CC
+ CFLAGS=$lt_save_CFLAGS
+fi # test yes != "$_lt_disable_FC"
AC_LANG_POP
])# _LT_LANG_FC_CONFIG
@@ -6844,7 +7927,7 @@
# --------------------------
# Ensure that the configuration variables for the GNU Java Compiler compiler
# are suitably defined. These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_GCJ_CONFIG],
[AC_REQUIRE([LT_PROG_GCJ])dnl
AC_LANG_SAVE
@@ -6870,19 +7953,23 @@
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
lt_save_GCC=$GCC
GCC=yes
CC=${GCJ-"gcj"}
+CFLAGS=$GCJFLAGS
compiler=$CC
_LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
_LT_CC_BASENAME([$compiler])
# GCJ did not exist at the time GCC didn't implicitly link libc in.
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
## CAVEAT EMPTOR:
## There is no encapsulation within the following macros, do not change
@@ -6902,15 +7989,87 @@
AC_LANG_RESTORE
GCC=$lt_save_GCC
-CC="$lt_save_CC"
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
])# _LT_LANG_GCJ_CONFIG
+# _LT_LANG_GO_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Go compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to 'libtool'.
+m4_defun([_LT_LANG_GO_CONFIG],
+[AC_REQUIRE([LT_PROG_GO])dnl
+AC_LANG_SAVE
+
+# Source file extension for Go test sources.
+ac_ext=go
+
+# Object file extension for compiled Go test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="package main; func main() { }"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='package main; func main() { }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GOC-"gccgo"}
+CFLAGS=$GOFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)=$LD
+_LT_CC_BASENAME([$compiler])
+
+# Go did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_GO_CONFIG
+
+
# _LT_LANG_RC_CONFIG([TAG])
# -------------------------
# Ensure that the configuration variables for the Windows resource compiler
# are suitably defined. These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_RC_CONFIG],
[AC_REQUIRE([LT_PROG_RC])dnl
AC_LANG_SAVE
@@ -6926,7 +8085,7 @@
lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
+lt_simple_link_test_code=$lt_simple_compile_test_code
# ltmain only uses $CC for tagged configurations so make sure $CC is set.
_LT_TAG_COMPILER
@@ -6936,10 +8095,12 @@
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
lt_save_GCC=$GCC
GCC=
CC=${RC-"windres"}
+CFLAGS=
compiler=$CC
_LT_TAGVAR(compiler, $1)=$CC
_LT_CC_BASENAME([$compiler])
@@ -6952,7 +8113,8 @@
GCC=$lt_save_GCC
AC_LANG_RESTORE
-CC="$lt_save_CC"
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
])# _LT_LANG_RC_CONFIG
@@ -6962,7 +8124,7 @@
[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
[m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
[AC_CHECK_TOOL(GCJ, gcj,)
- test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+ test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2"
AC_SUBST(GCJFLAGS)])])[]dnl
])
@@ -6972,6 +8134,13 @@
dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+# LT_PROG_GO
+# ----------
+AC_DEFUN([LT_PROG_GO],
+[AC_CHECK_TOOL(GOC, gccgo,)
+])
+
+
# LT_PROG_RC
# ----------
AC_DEFUN([LT_PROG_RC],
@@ -7011,6 +8180,15 @@
AC_SUBST([OBJDUMP])
])
+# _LT_DECL_DLLTOOL
+# ----------------
+# Ensure DLLTOOL variable is set.
+m4_defun([_LT_DECL_DLLTOOL],
+[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [1], [DLL creation program])
+AC_SUBST([DLLTOOL])
+])
# _LT_DECL_SED
# ------------
@@ -7057,7 +8235,7 @@
# Add /usr/xpg4/bin/sed as it is typically found on Solaris
# along with /bin/sed that truncates output.
for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
- test ! -f $lt_ac_sed && continue
+ test ! -f "$lt_ac_sed" && continue
cat /dev/null > conftest.in
lt_ac_count=0
echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -7074,9 +8252,9 @@
$lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
cmp -s conftest.out conftest.nl || break
# 10000 chars as input seems more than enough
- test $lt_ac_count -gt 10 && break
+ test 10 -lt "$lt_ac_count" && break
lt_ac_count=`expr $lt_ac_count + 1`
- if test $lt_ac_count -gt $lt_ac_max; then
+ if test "$lt_ac_count" -gt "$lt_ac_max"; then
lt_ac_max=$lt_ac_count
lt_cv_path_SED=$lt_ac_sed
fi
@@ -7100,27 +8278,7 @@
# Find out whether the shell is Bourne or XSI compatible,
# or has some other useful features.
m4_defun([_LT_CHECK_SHELL_FEATURES],
-[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
- test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
- = c,a/b,, \
- && eval 'test $(( 1 + 1 )) -eq 2 \
- && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
- && xsi_shell=yes
-AC_MSG_RESULT([$xsi_shell])
-_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
-
-AC_MSG_CHECKING([whether the shell understands "+="])
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
- >/dev/null 2>&1 \
- && lt_shell_append=yes
-AC_MSG_RESULT([$lt_shell_append])
-_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
-
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
lt_unset=unset
else
lt_unset=false
@@ -7144,208 +8302,69 @@
])# _LT_CHECK_SHELL_FEATURES
-# _LT_PROG_XSI_SHELLFNS
-# ---------------------
-# Bourne and XSI compatible variants of some useful shell functions.
-m4_defun([_LT_PROG_XSI_SHELLFNS],
-[case $xsi_shell in
- yes)
- cat << \_LT_EOF >> "$cfgfile"
-
-# func_dirname file append nondir_replacement
-# Compute the dirname of FILE. If nonempty, add APPEND to the result,
-# otherwise set result to NONDIR_REPLACEMENT.
-func_dirname ()
-{
- case ${1} in
- */*) func_dirname_result="${1%/*}${2}" ;;
- * ) func_dirname_result="${3}" ;;
- esac
-}
-
-# func_basename file
-func_basename ()
-{
- func_basename_result="${1##*/}"
-}
-
-# func_dirname_and_basename file append nondir_replacement
-# perform func_basename and func_dirname in a single function
-# call:
-# dirname: Compute the dirname of FILE. If nonempty,
-# add APPEND to the result, otherwise set result
-# to NONDIR_REPLACEMENT.
-# value returned in "$func_dirname_result"
-# basename: Compute filename of FILE.
-# value retuned in "$func_basename_result"
-# Implementation must be kept synchronized with func_dirname
-# and func_basename. For efficiency, we do not delegate to
-# those functions but instead duplicate the functionality here.
-func_dirname_and_basename ()
-{
- case ${1} in
- */*) func_dirname_result="${1%/*}${2}" ;;
- * ) func_dirname_result="${3}" ;;
- esac
- func_basename_result="${1##*/}"
-}
-
-# func_stripname prefix suffix name
-# strip PREFIX and SUFFIX off of NAME.
-# PREFIX and SUFFIX must not contain globbing or regex special
-# characters, hashes, percent signs, but SUFFIX may contain a leading
-# dot (in which case that matches only a dot).
-func_stripname ()
-{
- # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
- # positional parameters, so assign one to ordinary parameter first.
- func_stripname_result=${3}
- func_stripname_result=${func_stripname_result#"${1}"}
- func_stripname_result=${func_stripname_result%"${2}"}
-}
-
-# func_opt_split
-func_opt_split ()
-{
- func_opt_split_opt=${1%%=*}
- func_opt_split_arg=${1#*=}
-}
-
-# func_lo2o object
-func_lo2o ()
-{
- case ${1} in
- *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
- *) func_lo2o_result=${1} ;;
- esac
-}
-
-# func_xform libobj-or-source
-func_xform ()
-{
- func_xform_result=${1%.*}.lo
-}
-
-# func_arith arithmetic-term...
-func_arith ()
-{
- func_arith_result=$(( $[*] ))
-}
-
-# func_len string
-# STRING may not start with a hyphen.
-func_len ()
-{
- func_len_result=${#1}
-}
-
-_LT_EOF
+# _LT_PATH_CONVERSION_FUNCTIONS
+# -----------------------------
+# Determine what file name conversion functions should be used by
+# func_to_host_file (and, implicitly, by func_to_host_path). These are needed
+# for certain cross-compile configurations and native mingw.
+m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_MSG_CHECKING([how to convert $build file names to $host format])
+AC_CACHE_VAL(lt_cv_to_host_file_cmd,
+[case $host in
+ *-*-mingw* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
+ ;;
+ *-*-cygwin* )
+ lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
+ ;;
+ * ) # otherwise, assume *nix
+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
+ ;;
+ esac
;;
- *) # Bourne compatible functions.
- cat << \_LT_EOF >> "$cfgfile"
-
-# func_dirname file append nondir_replacement
-# Compute the dirname of FILE. If nonempty, add APPEND to the result,
-# otherwise set result to NONDIR_REPLACEMENT.
-func_dirname ()
-{
- # Extract subdirectory from the argument.
- func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
- if test "X$func_dirname_result" = "X${1}"; then
- func_dirname_result="${3}"
- else
- func_dirname_result="$func_dirname_result${2}"
- fi
-}
-
-# func_basename file
-func_basename ()
-{
- func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
-}
-
-dnl func_dirname_and_basename
-dnl A portable version of this function is already defined in general.m4sh
-dnl so there is no need for it here.
-
-# func_stripname prefix suffix name
-# strip PREFIX and SUFFIX off of NAME.
-# PREFIX and SUFFIX must not contain globbing or regex special
-# characters, hashes, percent signs, but SUFFIX may contain a leading
-# dot (in which case that matches only a dot).
-# func_strip_suffix prefix name
-func_stripname ()
-{
- case ${2} in
- .*) func_stripname_result=`$ECHO "X${3}" \
- | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
- *) func_stripname_result=`$ECHO "X${3}" \
- | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
- esac
-}
-
-# sed scripts:
-my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
-my_sed_long_arg='1s/^-[[^=]]*=//'
-
-# func_opt_split
-func_opt_split ()
-{
- func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
- func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
-}
-
-# func_lo2o object
-func_lo2o ()
-{
- func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
-}
-
-# func_xform libobj-or-source
-func_xform ()
-{
- func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
-}
-
-# func_arith arithmetic-term...
-func_arith ()
-{
- func_arith_result=`expr "$[@]"`
-}
-
-# func_len string
-# STRING may not start with a hyphen.
-func_len ()
-{
- func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
-}
-
-_LT_EOF
-esac
-
-case $lt_shell_append in
- yes)
- cat << \_LT_EOF >> "$cfgfile"
-
-# func_append var value
-# Append VALUE to the end of shell variable VAR.
-func_append ()
-{
- eval "$[1]+=\$[2]"
-}
-_LT_EOF
+ *-*-cygwin* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
+ ;;
+ *-*-cygwin* )
+ lt_cv_to_host_file_cmd=func_convert_file_noop
+ ;;
+ * ) # otherwise, assume *nix
+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
+ ;;
+ esac
;;
- *)
- cat << \_LT_EOF >> "$cfgfile"
-
-# func_append var value
-# Append VALUE to the end of shell variable VAR.
-func_append ()
-{
- eval "$[1]=\$$[1]\$[2]"
-}
-
-_LT_EOF
+ * ) # unhandled hosts (and "normal" native builds)
+ lt_cv_to_host_file_cmd=func_convert_file_noop
;;
- esac
+esac
+])
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+AC_MSG_RESULT([$lt_cv_to_host_file_cmd])
+_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd],
+ [0], [convert $build file names to $host format])dnl
+
+AC_MSG_CHECKING([how to convert $build file names to toolchain format])
+AC_CACHE_VAL(lt_cv_to_tool_file_cmd,
+[#assume ordinary cross tools, or native build.
+lt_cv_to_tool_file_cmd=func_convert_file_noop
+case $host in
+ *-*-mingw* )
+ case $build in
+ *-*-mingw* ) # actually msys
+ lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
+ ;;
+ esac
+ ;;
+esac
])
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+AC_MSG_RESULT([$lt_cv_to_tool_file_cmd])
+_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],
+ [0], [convert $build files to toolchain format])dnl
+])# _LT_PATH_CONVERSION_FUNCTIONS
diff -Nru r-base-3.2.3/m4/lt~obsolete.m4 r-base-3.3.1/m4/lt~obsolete.m4
--- r-base-3.2.3/m4/lt~obsolete.m4 2010-03-17 14:43:04.000000000 +0000
+++ r-base-3.3.1/m4/lt~obsolete.m4 2016-03-16 23:02:07.000000000 +0000
@@ -1,17 +1,18 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
-# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software
+# Foundation, Inc.
# Written by Scott James Remnant, 2004.
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
-dnl # serial 4 lt~obsolete.m4
+dnl # serial 5 lt~obsolete.m4
# These exist entirely to fool aclocal when bootstrapping libtool.
#
-# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN),
# which have later been changed to m4_define as they aren't part of the
# exported API, or moved to Autoconf or Automake where they belong.
#
@@ -25,7 +26,7 @@
# included after everything else. This provides aclocal with the
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
# because those macros already exist, or will be overwritten later.
-# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
#
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
# Yes, that means every name once taken will need to remain here until
@@ -77,7 +78,6 @@
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
-m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])])
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
@@ -90,3 +90,10 @@
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
+m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
+m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
+m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
+m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
+m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
+m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
diff -Nru r-base-3.2.3/m4/ltoptions.m4 r-base-3.3.1/m4/ltoptions.m4
--- r-base-3.2.3/m4/ltoptions.m4 2010-03-17 14:43:04.000000000 +0000
+++ r-base-3.3.1/m4/ltoptions.m4 2016-03-16 23:02:07.000000000 +0000
@@ -1,13 +1,14 @@
# Helper functions for option handling. -*- Autoconf -*-
#
-# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
+# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
-dnl # serial 6 ltoptions.m4
+dnl # serial 8 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@@ -28,7 +29,7 @@
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]),
- [m4_warning([Unknown $1 option `$2'])])[]dnl
+ [m4_warning([Unknown $1 option '$2'])])[]dnl
])
@@ -74,13 +75,15 @@
dnl
dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither
- dnl `shared' nor `disable-shared' was passed, we enable building of shared
+ dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
- [_LT_ENABLE_FAST_INSTALL])
+ [_LT_ENABLE_FAST_INSTALL])
+ _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
+ [_LT_WITH_AIX_SONAME([aix])])
])
])# _LT_SET_OPTIONS
@@ -111,7 +114,7 @@
[_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `dlopen' option into LT_INIT's first parameter.])
+put the 'dlopen' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
@@ -125,7 +128,7 @@
[enable_win32_dll=yes
case $host in
-*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*)
+*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
@@ -133,13 +136,13 @@
esac
test -z "$AS" && AS=as
-_LT_DECL([], [AS], [0], [Assembler program])dnl
+_LT_DECL([], [AS], [1], [Assembler program])dnl
test -z "$DLLTOOL" && DLLTOOL=dlltool
-_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
+_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
test -z "$OBJDUMP" && OBJDUMP=objdump
-_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
+_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
])# win32-dll
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
@@ -147,7 +150,7 @@
_LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `win32-dll' option into LT_INIT's first parameter.])
+put the 'win32-dll' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
@@ -156,9 +159,9 @@
# _LT_ENABLE_SHARED([DEFAULT])
# ----------------------------
-# implement the --enable-shared flag, and supports the `shared' and
-# `disable-shared' LT_INIT options.
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+# implement the --enable-shared flag, and supports the 'shared' and
+# 'disable-shared' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared],
@@ -171,14 +174,14 @@
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
;;
esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
@@ -210,9 +213,9 @@
# _LT_ENABLE_STATIC([DEFAULT])
# ----------------------------
-# implement the --enable-static flag, and support the `static' and
-# `disable-static' LT_INIT options.
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+# implement the --enable-static flag, and support the 'static' and
+# 'disable-static' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static],
@@ -225,14 +228,14 @@
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
;;
esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
@@ -264,15 +267,14 @@
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ----------------------------------
-# implement the --enable-fast-install flag, and support the `fast-install'
-# and `disable-fast-install' LT_INIT options.
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+# implement the --enable-fast-install flag, and support the 'fast-install'
+# and 'disable-fast-install' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install],
-dnl [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
-dnl [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
- ,
+ [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+ [(libtool) optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
[p=${PACKAGE-default}
case $enableval in
yes) enable_fast_install=yes ;;
@@ -280,14 +282,14 @@
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
;;
esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
@@ -304,14 +306,14 @@
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `fast-install' option into LT_INIT's first parameter.])
+the 'fast-install' option into LT_INIT's first parameter.])
])
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `disable-fast-install' option into LT_INIT's first parameter.])
+the 'disable-fast-install' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
@@ -319,19 +321,85 @@
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
+# _LT_WITH_AIX_SONAME([DEFAULT])
+# ----------------------------------
+# implement the --with-aix-soname flag, and support the `aix-soname=aix'
+# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
+# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
+m4_define([_LT_WITH_AIX_SONAME],
+[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
+shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[[5-9]]*,yes)
+ AC_MSG_CHECKING([which variant of shared library versioning to provide])
+ AC_ARG_WITH([aix-soname],
+ [AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
+ [(libtool( shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
+ [case $withval in
+ aix|svr4|both)
+ ;;
+ *)
+ AC_MSG_ERROR([Unknown argument to --with-aix-soname])
+ ;;
+ esac
+ lt_cv_with_aix_soname=$with_aix_soname],
+ [AC_CACHE_VAL([lt_cv_with_aix_soname],
+ [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
+ with_aix_soname=$lt_cv_with_aix_soname])
+ AC_MSG_RESULT([$with_aix_soname])
+ if test aix != "$with_aix_soname"; then
+ # For the AIX way of multilib, we name the shared archive member
+ # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+ # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+ # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+ # the AIX toolchain works better with OBJECT_MODE set (default 32).
+ if test 64 = "${OBJECT_MODE-32}"; then
+ shared_archive_member_spec=shr_64
+ else
+ shared_archive_member_spec=shr
+ fi
+ fi
+ ;;
+*)
+ with_aix_soname=aix
+ ;;
+esac
+
+_LT_DECL([], [shared_archive_member_spec], [0],
+ [Shared archive member basename, for filename based shared library versioning on AIX])dnl
+])# _LT_WITH_AIX_SONAME
+
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
+
+
# _LT_WITH_PIC([MODE])
# --------------------
-# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
# LT_INIT options.
-# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
+# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
- [AS_HELP_STRING([--with-pic],
- [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
- [pic_mode="$withval"],
- [pic_mode=default])
-
-test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+ [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
+ [(libtool) try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+ [lt_p=${PACKAGE-default}
+ case $withval in
+ yes|no) pic_mode=$withval ;;
+ *)
+ pic_mode=default
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
+ for lt_pkg in $withval; do
+ IFS=$lt_save_ifs
+ if test "X$lt_pkg" = "X$lt_p"; then
+ pic_mode=yes
+ fi
+ done
+ IFS=$lt_save_ifs
+ ;;
+ esac],
+ [pic_mode=m4_default([$1], [default])])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
@@ -344,7 +412,7 @@
[_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `pic-only' option into LT_INIT's first parameter.])
+put the 'pic-only' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
diff -Nru r-base-3.2.3/m4/ltsugar.m4 r-base-3.3.1/m4/ltsugar.m4
--- r-base-3.2.3/m4/ltsugar.m4 2010-03-17 14:43:04.000000000 +0000
+++ r-base-3.3.1/m4/ltsugar.m4 2016-03-16 23:02:07.000000000 +0000
@@ -1,6 +1,7 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
-# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software
+# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
@@ -33,7 +34,7 @@
# ------------
# Manipulate m4 lists.
# These macros are necessary as long as will still need to support
-# Autoconf-2.59 which quotes differently.
+# Autoconf-2.59, which quotes differently.
m4_define([lt_car], [[$1]])
m4_define([lt_cdr],
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
@@ -44,7 +45,7 @@
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
# ------------------------------------------
-# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'.
# Note that neither SEPARATOR nor STRING are expanded; they are appended
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
diff -Nru r-base-3.2.3/m4/ltversion.m4 r-base-3.3.1/m4/ltversion.m4
--- r-base-3.2.3/m4/ltversion.m4 2010-03-17 14:43:04.000000000 +0000
+++ r-base-3.3.1/m4/ltversion.m4 2016-03-16 23:02:07.000000000 +0000
@@ -1,23 +1,23 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
-# Copyright (C) 2004 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
-# Generated from ltversion.in.
+# @configure_input@
-dnl # serial 3012 ltversion.m4
+dnl # serial 4179 ltversion.m4
# This file is part of GNU Libtool
-m4_define([LT_PACKAGE_VERSION], [2.2.6])
-m4_define([LT_PACKAGE_REVISION], [1.3012])
+m4_define([LT_PACKAGE_VERSION], [2.4.6])
+m4_define([LT_PACKAGE_REVISION], [2.4.6])
AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.2.6'
-macro_revision='1.3012'
+[macro_version='2.4.6'
+macro_revision='2.4.6'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])
diff -Nru r-base-3.2.3/m4/R.m4 r-base-3.3.1/m4/R.m4
--- r-base-3.2.3/m4/R.m4 2015-08-21 13:36:53.000000000 +0000
+++ r-base-3.3.1/m4/R.m4 2016-03-16 23:02:06.000000000 +0000
@@ -16,7 +16,7 @@
###
### You should have received a copy of the GNU General Public License
### along with R; if not, a copy is available at
-### http://www.r-project.org/Licenses/
+### https://www.r-project.org/Licenses/
### * General support macros
@@ -1968,36 +1968,29 @@
[AC_CACHE_CHECK([for BSD networking],
[r_cv_bsd_networking],
[if test "${ac_cv_header_netdb_h}" = yes \
+dnl needed for Rhttpd.c but missed before R 3.2.4
+ && test "${ac_cv_header_arpa_inet_h}" = yes \
&& test "${ac_cv_header_netinet_in_h}" = yes \
&& test "${ac_cv_header_sys_socket_h}" = yes \
&& test "${ac_cv_search_connect}" != no \
&& test "${ac_cv_search_gethostbyname}" != no; then
r_cv_bsd_networking=yes
else
- r_cv_bsd_networking=no
+ AC_MSG_ERROR([BSD networking functions are required])
fi])
-if test "${r_cv_bsd_networking}" = yes; then
- AC_DEFINE(HAVE_BSD_NETWORKING, 1,
- [Define if you have BSD networking headers and libraries.])
- AC_DEFINE(HAVE_SOCKETS, 1,
- [Define if you have support for sockets.])
- AC_DEFINE(HAVE_INTERNET, 1,
- [Define if you have support for ftp/http access.])
- AC_DEFINE(SUPPORT_LIBXML, 1,
- [Define if you provide support for the libxml ftp/http
- functions.])
-fi
])# R_BSD_NETWORKING
## R_BITMAPS
## ---------
+## This is the version used without png-config
## Here we only need any old -lz, and don't need zlib.h.
## However, we do need recent enough libpng and jpeg, and so check both
## the header versions and for key routines in the library.
## The png code will do a run-time check of the consistency of libpng
## versions.
AC_DEFUN([R_BITMAPS],
-[BITMAP_LIBS=
+[BITMAP_CPPFLAGS=
+BITMAP_LIBS=
if test "${use_jpeglib}" = yes; then
_R_HEADER_JPEGLIB
have_jpeg=${r_cv_header_jpeglib_h}
@@ -2052,9 +2045,104 @@
fi
fi
fi
+AC_SUBST(BITMAP_CPPFLAGS)
AC_SUBST(BITMAP_LIBS)
])# R_BITMAPS
+## R_BITMAPS2
+## ---------
+## This is the version used with png-config
+AC_DEFUN([R_BITMAPS2],
+[BITMAP_CPPFLAGS=
+BITMAP_LIBS=
+if test "${use_jpeglib}" = yes; then
+ save_CPPFLAGS=${CPPFLAGS}
+ ## jpeglib does not support pkg-config, although some OSes add it.
+ ## This is untested.
+ if "${PKGCONF}" --exists jpeg; then
+ JPG_CPPFLAGS=`"${PKGCONF}" --cflags jpeg`
+ JPG_LIBS=`"${PKGCONF}" --libs jpeg`
+ CPPFLAGS="${CPPFLAGS} ${JPG_CPPFLAGS}"
+ fi
+ _R_HEADER_JPEGLIB
+ CPPFLAGS=${save_CPPFLAGS}
+ have_jpeg=${r_cv_header_jpeglib_h}
+ if test "${have_jpeg}" = yes; then
+ AC_CHECK_LIB(jpeg, jpeg_destroy_compress,
+ [have_jpeg=yes], [have_jpeg=no], [${JPG_LIBS} ${LIBS}])
+ fi
+ if test "${have_jpeg}" = yes; then
+ if test -n "${JPG_LIBS}"; then
+ BITMAP_LIBS="${JPG_LIBS}"
+ else
+ BITMAP_LIBS=-ljpeg
+ fi
+ AC_DEFINE(HAVE_JPEG, 1,
+ [Define if you have the JPEG headers and libraries.])
+ fi
+fi
+if test "${use_libpng}" = yes; then
+ if "${PKGCONF}" --exists libpng; then
+ save_CPPFLAGS=${CPPFLAGS}
+ PNG_CPPFLAGS=`"${PKGCONF}" --cflags libpng`
+ CPPFLAGS="${CPPFLAGS} ${PNG_CPPFLAGS}"
+ _R_HEADER_PNG
+ have_png=${r_cv_header_png_h}
+ CPPFLAGS=${save_CPPFLAGS}
+ if test "${have_png}" = yes; then
+ PNG_LIBS=`"${PKGCONF}" --libs libpng`
+ AC_CHECK_LIB(png, png_create_write_struct,
+ [have_png=yes], [have_png=no], [${PNG_LIBS} ${LIBS}])
+ if test "${have_png}" = no; then
+ PNG_LIBS=`"${PKGCONF}" --static --libs libpng`
+ AC_CHECK_LIB(png, png_create_write_struct,
+ [have_png=yes], [have_png=no], [${PNG_LIBS} ${LIBS}])
+ fi
+ fi
+ if test "${have_png}" = yes; then
+ BITMAP_CPPFLAGS="${BITMAP_CPPFLAGS} ${PNG_CPPFLAGS}"
+ BITMAP_LIBS="${BITMAP_LIBS} ${PNG_LIBS}"
+ AC_DEFINE(HAVE_PNG, 1,
+ [Define if you have the PNG headers and libraries.])
+ fi
+ fi
+fi
+if test "${use_libtiff}" = yes; then
+ mod=
+ ## pkg-config support was introduced in libtiff 4.0.0
+ ## I guess the module name might change in future, so
+ ## program defensively here.
+ if "${PKGCONF}" --exists libtiff-4; then
+ mod=libtiff-4
+ fi
+ if test -n "${mod}"; then
+ save_CPPFLAGS=${CPPFLAGS}
+ TIF_CPPFLAGS=`"${PKGCONF}" --cflags ${mod}`
+ CPPFLAGS="${CPPFLAGS} ${TIF_CPPFLAGS}"
+ AC_CHECK_HEADERS(tiffio.h)
+ CPPFLAGS=${save_CPPFLAGS}
+ if test "x${ac_cv_header_tiffio_h}" = xyes ; then
+ TIF_LIBS=`"${PKGCONF}" --libs ${mod}`
+ AC_CHECK_LIB(tiff, TIFFOpen, [have_tiff=yes], [have_tiff=no],
+ [${TIF_LIBS} ${BITMAP_LIBS}])
+ if test "x${have_tiff}" = xno; then
+ TIF_LIBS=`"${PKGCONF}" --static --libs ${mod}`
+ AC_CHECK_LIB(tiff, TIFFOpen, [have_tiff=yes], [have_tiff=no],
+ [${TIF_LIBS} ${BITMAP_LIBS}])
+ fi
+ if test "x${have_tiff}" = xyes; then
+ AC_DEFINE(HAVE_TIFF, 1, [Define this if libtiff is available.])
+ BITMAP_LIBS="${TIF_LIBS} ${BITMAP_LIBS}"
+ BITMAP_CPPFLAGS="${BITMAP_CPPFLAGS} ${TIF_CPPFLAGS}"
+ fi
+ fi
+ fi
+fi
+AC_SUBST(BITMAP_CPPFLAGS)
+AC_SUBST(BITMAP_LIBS)
+])# R_BITMAPS2
+
+
## _R_HEADER_JPEGLIB
## -----------------
## Set shell variable r_cv_header_jpeglib_h to 'yes' if a recent enough
@@ -2303,6 +2391,7 @@
if test "${have_tcltk}" = yes; then
## Part 2. Check for tk.h.
found_tk_h=no
+ found_tk_by_config=no
if test -n "${TK_CONFIG}"; then
. ${TK_CONFIG}
## TK_INCLUDE_SPEC (if set) is what we want.
@@ -2312,6 +2401,7 @@
AC_CHECK_HEADER([tk.h],
[TCLTK_CPPFLAGS="${TCLTK_CPPFLAGS} ${TK_INCLUDE_SPEC}"
found_tk_h=yes])
+ found_tk_by_config=yes
CPPFLAGS="${r_save_CPPFLAGS}"
fi
if test "${found_tk_h}" = no; then
@@ -2353,8 +2443,12 @@
fi
fi
fi
+## TK_XINCLUDES should be empty for Aqua Tk, so earlier test was wrong
+## Our code does not include any X headers, but tk.h may ....
+## That is true even on OS X, but Aqua Tk has a private version of
+## X11 headers, and we want that one and not the XQuartz one.
if test "${have_tcltk}" = yes; then
- if test -n "${TK_XINCLUDES}"; then
+ if test "${found_tk_by_config}" = yes; then
TCLTK_CPPFLAGS="${TCLTK_CPPFLAGS} ${TK_XINCLUDES}"
else
TCLTK_CPPFLAGS="${TCLTK_CPPFLAGS} ${X_CFLAGS}"
@@ -2366,8 +2460,7 @@
## -------------
## Find the tcl and tk libraries.
AC_DEFUN([_R_TCLTK_LIBS],
-[AC_REQUIRE([AC_PATH_XTRA])
-AC_REQUIRE([_R_TCLTK_CONFIG])
+[AC_REQUIRE([_R_TCLTK_CONFIG])
if test -z "${TCLTK_LIBS}"; then
## We have to do the work.
if test "${have_tcltk}" = yes; then
@@ -2498,7 +2591,7 @@
##
## This is based on ACX_BLAS by Steven G. Johnson
## from the Official Autoconf Macro Archive
-## (http://www.gnu.org/software/ac-archive/htmldoc/acx_blas.m4),
+## (https://www.gnu.org/software/ac-archive/htmldoc/acx_blas.m4),
## with the following changes:
## * We also handle HPUX .sl command line specifications.
## * We explictly deal with the case of f2c. Most likely pointless.
@@ -2864,7 +2957,7 @@
##
## This is roughly based on ACX_LAPACK by Steven G. Johnson
## from the Official Autoconf Macro Archive
-## (http://www.gnu.org/software/ac-archive/htmldoc/acx_lapack.m4),
+## (https://www.gnu.org/software/ac-archive/htmldoc/acx_lapack.m4),
## with the following changes:
## * We also handle HPUX .sl command line specifications.
## * We explictly deal with the case of f2c. Most likely pointless.
@@ -2988,27 +3081,22 @@
## Try finding zlib library and headers.
## We check that both are installed, and that the header >= 1.2.3
AC_DEFUN([R_ZLIB],
-[if test "x${use_system_zlib}" = xyes; then
- AC_CHECK_LIB(z, inflateInit2_, [have_zlib=yes], [have_zlib=no])
- if test "${have_zlib}" = yes; then
- AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
- fi
- if test "${have_zlib}" = yes; then
- _R_HEADER_ZLIB
- have_zlib=${r_cv_header_zlib_h}
- fi
-else
- have_zlib="no"
+[AC_CHECK_LIB(z, inflateInit2_, [have_zlib=yes], [have_zlib=no])
+if test "${have_zlib}" = yes; then
+ AC_CHECK_HEADER(zlib.h, [have_zlib=yes], [have_zlib=no])
fi
-AC_MSG_CHECKING([whether zlib support needs to be compiled])
if test "${have_zlib}" = yes; then
- AC_MSG_RESULT([no])
- LIBS="-lz ${LIBS}"
+ _R_HEADER_ZLIB
+ have_zlib=${r_cv_header_zlib_h}
+fi
+AC_MSG_CHECKING([whether zlib support suffices])
+if test "${have_zlib}" != yes; then
+ AC_MSG_ERROR([zlib library and headers are required])
else
+ LIBS="-lz ${LIBS}"
AC_MSG_RESULT([yes])
_R_ZLIB_MMAP
fi
-AM_CONDITIONAL(BUILD_ZLIB, [test "x${have_zlib}" = xno])
AM_CONDITIONAL(USE_MMAP_ZLIB,
[test "x${have_zlib}" = xno && test "x${r_cv_zlib_mmap}" = xyes])
])# R_ZLIB
@@ -3065,22 +3153,18 @@
## ------
## If selected, try finding system pcre library and headers.
## RedHat put the headers in /usr/include/pcre.
-## There are known problems < 8.10.
+## There are known problems < 8.10, and important bug fixes in 8.32
AC_DEFUN([R_PCRE],
-[if test "x${use_system_pcre}" = xyes; then
- AC_CHECK_LIB(pcre, pcre_fullinfo, [have_pcre=yes], [have_pcre=no])
- if test "${have_pcre}" = yes; then
- AC_CHECK_HEADERS(pcre.h pcre/pcre.h)
- if test "${ac_cv_header_pcre_h}" = no \
- && test "${ac_cv_header_pcre_pcre_h}" = no; then
- have_pcre=no
- fi
+[AC_CHECK_LIB(pcre, pcre_fullinfo, [have_pcre=yes], [have_pcre=no])
+if test "${have_pcre}" = yes; then
+ AC_CHECK_HEADERS(pcre.h pcre/pcre.h)
+ if test "${ac_cv_header_pcre_h}" = no \
+ && test "${ac_cv_header_pcre_pcre_h}" = no; then
+ have_pcre=no
fi
-else
- have_pcre=no
fi
-r_save_LIBS="${LIBS}"
if test "x${have_pcre}" = xyes; then
+r_save_LIBS="${LIBS}"
LIBS="-lpcre ${LIBS}"
AC_CACHE_CHECK([if PCRE version >= 8.10, < 10.0 and has UTF-8 support], [r_cv_have_pcre810],
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
@@ -3113,14 +3197,36 @@
if test "x${r_cv_have_pcre810}" != xyes; then
have_pcre=no
LIBS="${r_save_LIBS}"
+else
+AC_CACHE_CHECK([if PCRE version >= 8.32], [r_cv_have_pcre832],
+[AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#ifdef HAVE_PCRE_PCRE_H
+#include
+#else
+#ifdef HAVE_PCRE_H
+#include
+#endif
+#endif
+int main() {
+#if PCRE_MAJOR == 8 && PCRE_MINOR >= 32
+ exit(0);
+#else
+ exit(1);
+#endif
+}
+]])], [r_cv_have_pcre832=yes], [r_cv_have_pcre832=no], [r_cv_have_pcre832=no])])
fi
-AC_MSG_CHECKING([whether PCRE support needs to be compiled])
-if test "x${r_cv_have_pcre810}" = xyes; then
- AC_MSG_RESULT([no])
+
+AC_MSG_CHECKING([whether PCRE support suffices])
+if test "x${r_cv_have_pcre810}" != xyes; then
+ AC_MSG_ERROR([pcre >= 8.10 library and headers are required])
else
AC_MSG_RESULT([yes])
fi
-AM_CONDITIONAL(BUILD_PCRE, [test "x${r_cv_have_pcre810}" != xyes])
+if test "x${r_cv_have_pcre832}" != xyes; then
+ warn_pcre_version="pcre < 8.32 is deprecated"
+ AC_MSG_WARN([${warn_pcre_version}])
+fi
])# R_PCRE
## R_BZLIB
@@ -3129,13 +3235,9 @@
## We check that both are installed,
## and that BZ2_bzlibVersion is in the library.
AC_DEFUN([R_BZLIB],
-[if test "x${use_system_bzlib}" = xyes; then
- AC_CHECK_LIB(bz2, BZ2_bzlibVersion, [have_bzlib=yes], [have_bzlib=no])
- if test "${have_bzlib}" = yes; then
- AC_CHECK_HEADERS(bzlib.h, [have_bzlib=yes], [have_bzlib=no])
- fi
-else
- have_bzlib=no
+[AC_CHECK_LIB(bz2, BZ2_bzlibVersion, [have_bzlib=yes], [have_bzlib=no])
+if test "${have_bzlib}" = yes; then
+ AC_CHECK_HEADERS(bzlib.h, [have_bzlib=yes], [have_bzlib=no])
fi
if test "x${have_bzlib}" = xyes; then
AC_CACHE_CHECK([if bzip2 version >= 1.0.6], [r_cv_have_bzlib],
@@ -3157,14 +3259,13 @@
if test "x${r_cv_have_bzlib}" = xno; then
have_bzlib=no
fi
-AC_MSG_CHECKING([whether bzip2 support needs to be compiled])
+AC_MSG_CHECKING([whether bzip2 support suffices])
if test "x${have_bzlib}" = xyes; then
AC_MSG_RESULT([no])
LIBS="-lbz2 ${LIBS}"
else
- AC_MSG_RESULT([yes])
+ AC_MSG_ERROR([bzip2 library and headers are required])
fi
-AM_CONDITIONAL(BUILD_BZLIB, [test "x${have_bzlib}" = xno])
])# R_BZLIB
## R_TRE
@@ -3192,11 +3293,10 @@
## Try finding liblzma library and headers.
## We check that both are installed,
AC_DEFUN([R_LZMA],
-[if test "x${use_system_xz}" = xyes; then
- AC_CHECK_LIB(lzma, lzma_version_number, [have_lzma=yes], [have_lzma=no])
- if test "${have_lzma}" = yes; then
- AC_CHECK_HEADERS(lzma.h, [have_lzma=yes], [have_lzma=no])
- fi
+[AC_CHECK_LIB(lzma, lzma_version_number, [have_lzma=yes], [have_lzma=no])
+if test "${have_lzma}" = yes; then
+ AC_CHECK_HEADERS(lzma.h, [have_lzma=yes], [have_lzma=no])
+fi
if test "x${have_lzma}" = xyes; then
AC_CACHE_CHECK([if lzma version >= 5.0.3], [r_cv_have_lzma],
[AC_LANG_PUSH(C)
@@ -3223,11 +3323,9 @@
if test "x${have_lzma}" = xyes; then
AC_DEFINE(HAVE_LZMA, 1, [Define if your system has lzma >= 5.0.3.])
LIBS="-llzma ${LIBS}"
-fi
else
- have_lzma="no"
+ AC_MSG_ERROR("liblzma library and headers are required")
fi
-AM_CONDITIONAL(BUILD_XZ, [test x${have_lzma} != xyes])
])# R_LZMA
@@ -4048,6 +4146,87 @@
AC_ARG_VAR([SHLIB_CXX1XLDFLAGS], [special flags used by SHLIB_CXX1XLD])
])# R_CXX1X
+## R_LIBCURL
+## ----------------
+AC_DEFUN([R_LIBCURL],
+[## curl-config might not match the installed libcurl,
+## so we allow the user to set CURL_CPPFLAGS, CURL_LIBS
+## and check the version directly rather than by curl-config --checkfor
+AC_PATH_PROG(CURL_CONFIG, curl-config)
+if test -n "${CURL_CONFIG}"; then
+ echo "checking libcurl version ..." \
+ `${CURL_CONFIG} --version | sed -e 's,^[[^0-9]]*,,'`
+ if test -z "${CURL_CPPFLAGS}"; then
+ CURL_CPPFLAGS=`${CURL_CONFIG} --cflags`
+ fi
+ ## This should be correct for a static-only build, user will
+ ## need to override to specify static linking (see config.site)
+ if test -z "${CURL_LIBS}"; then
+ CURL_LIBS=`${CURL_CONFIG} --libs`
+ fi
+fi
+r_save_CPPFLAGS="${CPPLAGS}"
+CPPFLAGS="${CURL_CPPFLAGS} ${CPPFLAGS}"
+r_save_LIBS="${LIBS}"
+LIBS="${CURL_LIBS} ${LIBS}"
+AC_CHECK_HEADERS(curl/curl.h, [have_libcurl=yes], [have_libcurl=no])
+
+if test "x${have_libcurl}" = "xyes"; then
+AC_CACHE_CHECK([if libcurl is version 7 and >= 7.28.0], [r_cv_have_curl728],
+[AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include
+#include
+int main()
+{
+#ifdef LIBCURL_VERSION_MAJOR
+#if LIBCURL_VERSION_MAJOR > 7
+ exit(1);
+#elif LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 28
+ exit(0);
+#else
+ exit(1);
+#endif
+#else
+ exit(1);
+#endif
+}
+]])], [r_cv_have_curl728=yes], [r_cv_have_curl728=no], [r_cv_have_curl728=no])])
+fi
+if test "x${r_cv_have_curl728}" = xno; then
+ have_libcurl=no
+fi
+
+if test "x${have_libcurl}" = "xyes"; then
+AC_CACHE_CHECK([if libcurl supports https], [r_cv_have_curl_https],
+[AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include
+#include
+int main()
+{
+ curl_version_info_data *data = curl_version_info(CURLVERSION_NOW);
+ const char * const *p = data->protocols;
+ int found = 0;
+ for (; *p; p++)
+ if(strcmp(*p, "https") == 0) {found = 1; break;}
+ exit(found ? 0 : 1);
+}
+]])], [r_cv_have_curl_https=yes], [r_cv_have_curl_https=no], [r_cv_have_curl_https=no])])
+fi
+if test "x${r_cv_have_curl_https}" = xno; then
+ have_libcurl=no
+fi
+if test "x${have_libcurl}" = xyes; then
+ AC_DEFINE(HAVE_LIBCURL, 1, [Define if your system has libcurl >= 7.28.0 with support for https.])
+ CPPFLAGS="${r_save_CPPFLAGS}"
+ LIBS="${r_save_LIBS}"
+ AC_SUBST(CURL_CPPFLAGS)
+ AC_SUBST(CURL_LIBS)
+else
+ AC_MSG_ERROR([libcurl >= 7.28.0 library and headers are required with support for https])
+fi
+])# R_LIBCURL
+
+
### Local variables: ***
### mode: outline-minor ***
diff -Nru r-base-3.2.3/share/Rd/macros/system.Rd r-base-3.3.1/share/Rd/macros/system.Rd
--- r-base-3.2.3/share/Rd/macros/system.Rd 2015-08-25 22:19:12.000000000 +0000
+++ r-base-3.3.1/share/Rd/macros/system.Rd 2016-03-16 23:04:39.000000000 +0000
@@ -44,4 +44,4 @@
\newcommand{\packageIndices}{\Sexpr[results=rd,stage=build]{tools:::Rd_package_indices("#1")}}
% To indicate a DOI.
-\newcommand{\doi}{doi:\sspace\href{http://doi.org/#1}{#1}}
+\newcommand{\doi}{\Sexpr[results=rd,stage=build]{tools:::Rd_expr_doi("#1")}}
diff -Nru r-base-3.2.3/share/texmf/bibtex/bib/RJournal.bib r-base-3.3.1/share/texmf/bibtex/bib/RJournal.bib
--- r-base-3.2.3/share/texmf/bibtex/bib/RJournal.bib 2015-12-09 23:15:26.000000000 +0000
+++ r-base-3.3.1/share/texmf/bibtex/bib/RJournal.bib 2016-06-20 22:15:14.000000000 +0000
@@ -1,3 +1,321 @@
+
+
+
+
+
+
+@Article{messner-mayr-zeileis:,
+ author = {Jakob W. Messner and Georg J. Mayr and Achim Zeileis},
+ title = {Heteroscedastic Censored and Truncated Regression with crch},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/messner-mayr-zeileis.pdf}
+
+
+
+@Article{joblin-mauerer:,
+ author = {Mitchell Joblin and Wolfgang Mauerer},
+ title = {An Interactive Survey Application for Validating Social Network Analysis Techniques},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/joblin-mauerer.pdf}
+
+
+
+@Article{linares-lopez-moliner:,
+ author = {Daniel Linares and Joan L{\' o}pez-Moliner},
+ title = {quickpsy: An R Package to Fit Psychometric Functions for Multiple Groups},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/linares-lopez-moliner.pdf}
+
+
+
+@Article{calvo-santafe:,
+ author = {Borja Calvo and Guzm{\' a}n Santaf{\' e}},
+ title = {scmamp: Statistical Comparison of Multiple Algorithms in Multiple Problems},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/calvo-santafe.pdf}
+
+
+
+@Article{eder-rybicki-kestemont:,
+ author = {Maciej Eder and Jan Rybicki and Mike Kestemont},
+ title = {Stylometry with R: A Package for Computational Text Analysis},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/eder-rybicki-kestemont.pdf}
+
+
+
+@Article{demirhan:,
+ author = {Haydar Demirhan},
+ title = {rTableICC: An R Package for Random Generation of 2*2*K and R*C Contingency Tables},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/demirhan.pdf}
+
+
+
+@Article{beck:,
+ author = {Marcus W Beck},
+ title = {SWMPr: An R Package for Retrieving, Organizing, and Analyzing Environmental Data for Estuaries},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/beck.pdf}
+
+
+
+@Article{north:,
+ author = {Michael North},
+ title = {SchemaOnRead: A Package for Schema-on-Read in R},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/north.pdf}
+
+
+
+@Article{sophie-brouste-istas:,
+ author = {Lambert-Lacroix Sophie and Alexandre Brouste and Jacques Istas},
+ title = {Bridges associated to fractional Brownian motion and multifractional Brownian motion.},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/sophie-brouste-istas.pdf}
+
+
+
+@Article{franck-osborne:,
+ author = {Christopher T. Franck and Jason A. Osborne},
+ title = {Exploring Interaction Effects in Factorial Studies using the hiddenf Package in R},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/franck-osborne.pdf}
+
+
+
+@Article{pritikin-schmidt:,
+ author = {Joshua Pritikin and Karen Schmidt},
+ title = {Model Builder for Item Factor Analysis with OpenMx},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/pritikin-schmidt.pdf}
+
+
+
+@Article{demirhan-bitirim:,
+ author = {Haydar Demirhan and Nihan Bitirim},
+ title = {CryptRndTest: An R Package for Testing the Cryptographic Randomness},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/demirhan-bitirim.pdf}
+
+
+
+@Article{jacques-yengo-biernacki-etal:,
+ author = {Julien Jacques and Loïc Yengo and Christophe Biernacki and Mickael Canouil},
+ title = {Variable Clustering in High-Dimensional Linear Regression: The R Package clere},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/jacques-yengo-biernacki-etal.pdf}
+
+
+
+@Article{sestelo-villanueva-meiramachado-etal:,
+ author = {Marta Sestelo and Nora M. Villanueva and LuÃs Meira-Machado and Javier Roca-Pardiñas},
+ title = {FWDselect: An R Package for Variable Selection in Regression Models},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/sestelo-villanueva-meiramachado-etal.pdf}
+
+
+
+@Article{szkaliczki:,
+ author = {Tibor Szkaliczki},
+ title = {clustering.sc.dp: Optimal Clustering with Sequential Constraint by Using Dynamic Programming},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/szkaliczki.pdf}
+
+
+
+@Article{an-liu:,
+ author = {Weihua An and Yu-Hsin Liu},
+ title = {keyplayer: An R Package for Locating Key Players in Social Networks},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/an-liu.pdf}
+
+
+
+@Article{hu-qutub:,
+ author = {Chenyue W. Hu and Amina A. Qutub},
+ title = {progenyClust: an R package for Progeny Clustering},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/hu-qutub.pdf}
+
+
+
+@Article{wright:,
+ author = {Erik Wright},
+ title = {Using DECIPHER v2.0 to Analyze Big Biological Sequence Data in R},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/wright.pdf}
+
+
+
+@Article{beath:,
+ author = {Dr Ken J. Beath},
+ title = {metaplus: An R Package for the Analysis of Robust Meta-Analysis and Meta-Regression},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/beath.pdf}
+
+
+
+@Article{leeper:,
+ author = {Thomas J. Leeper},
+ title = {Crowdsourced Data Preprocessing with R and Amazon Mechanical Turk},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/leeper.pdf}
+
+
+
+@Article{na-pebesma-heuvelink:,
+ author = {Benedikt Gräler and Edzer Pebesma and Gerard Heuvelink},
+ title = {Spatio-Temporal Geostatistics using gstat},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/na-pebesma-heuvelink.pdf}
+
+
+
+@Article{keyes-rudis-jacobs:,
+ author = {Oliver Keyes and Bob Rudis and Jay Jacobs},
+ title = {R Packages to Aid in Handling Web Access Logs},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/keyes-rudis-jacobs.pdf}
+
+
+
+@Article{yozgatligil-dag:,
+ author = {Osman Dag and Ceylan Yozgatligil},
+ title = {GMDH: An R Package for Short Term Forecasting via GMDH - Type Neural Network Algorithms},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/yozgatligil-dag.pdf}
+
+
+
+@Article{scrucca-fop-murphy-etal:,
+ author = {Luca Scrucca and Michael Fop and T. Brendan Murphy and Adrian E. Raftery},
+ title = {mclust 5: Clustering, Classification and Density Estimation Using Gaussian Finite Mixture Models},
+ journal = {The R Journal},
+ year = ,
+ volume = ,
+ number = ,
+ pages = {},
+ month = ,
+ url = {http://journal.r-project.org/archive/-/scrucca-fop-murphy-etal.pdf}
+
+
+
@Article{RJournal:2009-1:Chambers,
author = {John M. Chambers},
title = {Facets of {R}},
@@ -1097,7 +1415,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {4--6},
+ pages = {4--5},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/editorial.pdf}
@@ -1110,7 +1428,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {6--13},
+ pages = {6--12},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/collingwood-jurka-boydstun-etal.pdf}
@@ -1123,7 +1441,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {13--29},
+ pages = {13--28},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/xiang-gubian-suomela-etal.pdf}
@@ -1136,7 +1454,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {29--39},
+ pages = {29--38},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/kostov-becuebertaut-husson.pdf}
@@ -1149,7 +1467,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {39--53},
+ pages = {39--52},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/fox-friendly-weisberg.pdf}
@@ -1162,7 +1480,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {53--64},
+ pages = {53--63},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/eugster-schlesinger.pdf}
@@ -1175,7 +1493,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {64--73},
+ pages = {64--72},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/shang.pdf}
@@ -1188,7 +1506,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {73--80},
+ pages = {73--79},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/godfrey.pdf}
@@ -1201,7 +1519,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {80--87},
+ pages = {80--86},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/zagaglia.pdf}
@@ -1214,7 +1532,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {87--98},
+ pages = {87--97},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/thiem-dusa.pdf}
@@ -1227,7 +1545,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {98--108},
+ pages = {98--107},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/colleter-guitton-gascuel.pdf}
@@ -1240,7 +1558,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {108--117},
+ pages = {108--116},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/valle-dellomodarme.pdf}
@@ -1253,7 +1571,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {117--130},
+ pages = {117--129},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/hofmann-unwin-cook.pdf}
@@ -1266,7 +1584,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {130--144},
+ pages = {130--143},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/wilhelm-matos.pdf}
@@ -1279,7 +1597,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {144--162},
+ pages = {144--161},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/kahle-wickham.pdf}
@@ -1292,7 +1610,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {162--171},
+ pages = {162--170},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/kahle.pdf}
@@ -1305,7 +1623,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {171--181},
+ pages = {171--180},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/forcheh-verbeke-kasim-etal.pdf}
@@ -1318,7 +1636,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {181--188},
+ pages = {181--187},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/mcdaniel-henderson-rathouz.pdf}
@@ -1331,7 +1649,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {188--197},
+ pages = {188--196},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/bouchetvalat-bastin.pdf}
@@ -1344,7 +1662,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {197--207},
+ pages = {197--206},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/ooms.pdf}
@@ -1357,7 +1675,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {207--210},
+ pages = {207--209},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/lebauer-dietze-bolker.pdf}
@@ -1370,7 +1688,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {210--212},
+ pages = {210--211},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/chinese-r-conf.pdf}
@@ -1383,7 +1701,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {212--215},
+ pages = {212--214},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/r-finance.pdf}
@@ -1396,7 +1714,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {215--218},
+ pages = {215--217},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/user2013.pdf}
@@ -1409,7 +1727,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {218--220},
+ pages = {218--219},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/bioconductor.pdf}
@@ -1422,7 +1740,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {220--221},
+ pages = {220--220},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/r-foundation.pdf}
@@ -1435,7 +1753,7 @@
year = 2013,
volume = 5,
number = 1,
- pages = {221--239},
+ pages = {221--238},
month = jun,
url = {http://journal.r-project.org/archive/2013-1/r-changes.pdf}
@@ -1461,7 +1779,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {3--4},
+ pages = {3--3},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/editorial.pdf}
@@ -1474,7 +1792,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {4--16},
+ pages = {4--15},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/armstrong.pdf}
@@ -1487,7 +1805,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {16--29},
+ pages = {16--28},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/sartore.pdf}
@@ -1500,7 +1818,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {29--37},
+ pages = {29--36},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/michna-woods.pdf}
@@ -1513,7 +1831,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {37--53},
+ pages = {37--52},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/roediger-bohm-schimke.pdf}
@@ -1539,7 +1857,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {62--71},
+ pages = {62--70},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/wang-shan.pdf}
@@ -1552,7 +1870,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {71--80},
+ pages = {71--79},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/bilgic-susmann.pdf}
@@ -1565,7 +1883,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {80--88},
+ pages = {80--87},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/sax-steiner.pdf}
@@ -1578,7 +1896,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {88--97},
+ pages = {88--96},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/boehringer.pdf}
@@ -1591,7 +1909,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {97--104},
+ pages = {97--103},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/nadarajah-bakar.pdf}
@@ -1604,7 +1922,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {104--117},
+ pages = {104--116},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/gaure.pdf}
@@ -1617,7 +1935,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {117--129},
+ pages = {117--128},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/dietrich-zug-kaiser.pdf}
@@ -1630,7 +1948,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {129--137},
+ pages = {129--136},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/hofert.pdf}
@@ -1643,7 +1961,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {137--148},
+ pages = {137--147},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/sucarrat.pdf}
@@ -1656,7 +1974,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {148--161},
+ pages = {148--160},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/murrell.pdf}
@@ -1669,7 +1987,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {161--162},
+ pages = {161--161},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/r-foundation.pdf}
@@ -1682,7 +2000,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {162--164},
+ pages = {162--163},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/bioconductor.pdf}
@@ -1695,7 +2013,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {164--166},
+ pages = {164--165},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/siberchicot-dray.pdf}
@@ -1708,7 +2026,7 @@
year = 2013,
volume = 5,
number = 2,
- pages = {166--192},
+ pages = {166--191},
month = dec,
url = {http://journal.r-project.org/archive/2013-2/cran.pdf}
@@ -2534,7 +2852,7 @@
@Article{r-foundation:2015,
- author = {Martin M{\" a}chler and Kurt Hornik},
+ author = {Kurt Hornik},
title = {{R} {F}oundation News},
journal = {The R Journal},
year = 2015,
@@ -2583,3 +2901,341 @@
month = jun,
url = {http://journal.r-project.org/archive/2015-1/bioconductor.pdf}
+
+
+@Article{editorial:2015,
+ author = {Bettina Gr{\" u}n},
+ title = {Editorial},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {4},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/editorial.pdf}
+
+
+
+@Article{alam-ronnegard-shen:2015,
+ author = {Moudud Alam and Lars R\"onneg{\aa}rd and Xia Shen},
+ title = {Fitting Conditional and Simultaneous Autoregressive Spatial Models in hglm},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {5--18},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/alam-ronnegard-shen.pdf}
+
+
+
+@Article{genuer-poggi-tuleaumalot:2015,
+ author = {Robin Genuer and Jean-Michel Poggi and Christine Tuleau-Malot},
+ title = {{VSURF}: An {R} Package for Variable Selection Using Random Forests},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {19--33},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/genuer-poggi-tuleaumalot.pdf}
+
+
+
+@Article{liu-kong:2015,
+ author = {Fang Liu and Yunchuan Kong},
+ title = {zoib: An {R} Package for Bayesian Inference for Beta Regression and Zero/One Inflated Beta Regression},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {34--51},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/liu-kong.pdf}
+
+
+
+@Article{nielsen:2015,
+ author = {Bent Nielsen},
+ title = {{apc}: An {R} Package for Age-Period-Cohort Analysis},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {52--64},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/nielsen.pdf}
+
+
+
+@Article{charlier-paindaveine-saracco:2015,
+ author = {Isabelle Charlier and Davy Paindaveine, and J{\' e}r{\^ o}me Saracco},
+ title = {{QuantifQuantile}: An {R} Package for Performing Quantile Regression Through Optimal Quantization},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {65--80},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/charlier-paindaveine-saracco.pdf}
+
+
+
+@Article{hankin:2015,
+ author = {Robin K. S. Hankin},
+ title = {Numerical Evaluation of the {G}auss Hypergeometric Function with the hypergeo Package},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {81--88},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/hankin.pdf}
+
+
+
+@Article{villacorta-saez:2015,
+ author = {Pablo J. Villacorta and Jos{\' e} A. S{\' a}ez},
+ title = {{SRCS}: Statistical Ranking Color Scheme for Visualizing Parameterized Multiple Pairwise Comparisons with {R}},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {89--104},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/villacorta-saez.pdf}
+
+
+
+@Article{vegabayo:2015,
+ author = {Ainhoa Vega-Bayo},
+ title = {An {R} Package for the Panel Approach Method for Program Evaluation: pampe},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {105--121},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/vegabayo.pdf}
+
+
+
+@Article{lee-chen:2015,
+ author = {Kuo-Jung Lee and Ray-Bing Chen},
+ title = {{BSGS}: {B}ayesian Sparse Group Selection},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {122--133},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/lee-chen.pdf}
+
+
+
+@Article{vigneau-chen-qannari:2015,
+ author = {Evelyne Vigneau and Mingkun Chen and El Mostafa Qannari},
+ title = {{ClustVarLV}: An {R} Package for the Clustering of Variables Around Latent Variables},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {134--148},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/vigneau-chen-qannari.pdf}
+
+
+
+@Article{charte-charte:2015,
+ author = {Francisco Charte and David Charte},
+ title = {Working with Multilabel Datasets in {R}: The mldr Package},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {149--162},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/charte-charte.pdf}
+
+
+
+@Article{valliant-dever-kreuter:2015,
+ author = {Richard Valliant and Jill A. Dever and Frauke Kreuter},
+ title = {{PracTools}: Computations for Design of Finite Population Samples},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {163--176},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/valliant-dever-kreuter.pdf}
+
+
+
+@Article{seo-pan:2015,
+ author = {Kangwon Seo and Rong Pan},
+ title = {{ALTopt}: An {R} Package for Optimal Experimental Design of Accelerated Life Testing},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {177--188},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/seo-pan.pdf}
+
+
+
+@Article{nunes-prangle:2015,
+ author = {Matthew A. Nunes and Dennis Prangle},
+ title = {{abctools}: An {R} Package for Tuning Approximate {B}ayesian Computation Analyses},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {189--205},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/nunes-prangle.pdf}
+
+
+
+@Article{wang-faivre-richard-etal:2015,
+ author = {Juhui Wang and Robert Faivre and Herv{\' e} Richard and Herv{\' e} Monod},
+ title = {{mtk}: A General-Purpose and Extensible {R} Environment for Uncertainty and Sensitivity Analyses of Numerical Experiments},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {206--226},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/wang-faivre-richard-etal.pdf}
+
+
+
+@Article{buttrey-whitaker:2015,
+ author = {Samuel E. Buttrey and Lyn R. Whitaker},
+ title = {{treeClust}: An {R} Package for Tree-Based Clustering Dissimilarities},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {227--236},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/buttrey-whitaker.pdf}
+
+
+
+@Article{hino-takano-murata:2015,
+ author = {Hideitsu Hino and Ken Takano and Noboru Murata},
+ title = {mmpp: A Package for Calculating Similarity and Distance Metrics for Simple and Marked Point Processes},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {237--248},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/hino-takano-murata.pdf}
+
+
+
+@Article{koohafkan-younis:2015,
+ author = {Michael C. Koohafkan and Bassam A. Younis},
+ title = {Open-Channel Computation with {R}},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {249--262},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/koohafkan-younis.pdf}
+
+
+
+@Article{morina-higueras-puig-etal:2015,
+ author = {David Mori{\~n}a and Manuel Higueras and Pedro Puig and Mar{\' i}a Oliveira},
+ title = {Generalized {H}ermite Distribution Modelling with the {R} Package hermite},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {263--274},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/morina-higueras-puig-etal.pdf}
+
+
+
+@Article{rubio-villar:2015,
+ author = {Angel Rubio and Fernando de Villar},
+ title = {Code Profiling in {R}: A Review of Existing Methods and an Introduction to Package {GUIProfiler}},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {275--287},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/rubio-villar.pdf}
+
+
+
+@Article{plummer:2015,
+ author = {Martyn Plummer},
+ title = {The {R} Consortium and the {R} Foundation},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {288},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/plummer.pdf}
+
+
+
+@Article{tvedebrink:2015,
+ author = {Torben Tvedebrink},
+ title = {Conference Report: {useR!} 2015},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {289--290},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/tvedebrink.pdf}
+
+
+
+@Article{bioconductor:2015,
+ author = {The Bioconductor Team},
+ title = {News from the {B}ioconductor Project},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {291--292},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/bioconductor.pdf}
+
+
+
+@Article{r-changes:2015,
+ author = {The R Core Team},
+ title = {Changes in {R}},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {293--297},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/r-changes.pdf}
+
+
+
+@Article{cran:2015,
+ author = {Kurt Hornik and Achim Zeileis},
+ title = {Changes on {CRAN}},
+ journal = {The R Journal},
+ year = 2015,
+ volume = 7,
+ number = 2,
+ pages = {298--339},
+ month = dec,
+ url = {http://journal.r-project.org/archive/2015-2/cran.pdf}
+
diff -Nru r-base-3.2.3/src/appl/integrate.c r-base-3.3.1/src/appl/integrate.c
--- r-base-3.2.3/src/appl/integrate.c 2015-08-25 22:19:01.000000000 +0000
+++ r-base-3.3.1/src/appl/integrate.c 2015-12-10 23:15:18.000000000 +0000
@@ -18,7 +18,7 @@
*
* Most of this file is C translations of Fortran routines in
* QUADPACK: the latter is part of SLATEC 'and therefore in the public
- * domain' (http://en.wikipedia.org/wiki/QUADPACK).
+ * domain' (https://en.wikipedia.org/wiki/QUADPACK).
*
*
*/
diff -Nru r-base-3.2.3/src/appl/interv.c r-base-3.3.1/src/appl/interv.c
--- r-base-3.2.3/src/appl/interv.c 2015-08-25 22:19:01.000000000 +0000
+++ r-base-3.3.1/src/appl/interv.c 2016-03-16 23:04:26.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 2002 The R Core Team
+ * Copyright (C) 2002--2015 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,9 +35,9 @@
return findInterval(xt, *n, *x, *rightmost_closed, *all_inside, *ilo, mflag);
}
-int findInterval(double *xt, int n, double x,
- Rboolean rightmost_closed, Rboolean all_inside, int ilo,
- int *mflag)
+int findInterval2(double *xt, int n, double x,
+ Rboolean rightmost_closed, Rboolean all_inside, Rboolean left_open,
+ int ilo, int *mflag)
{
int istep, middle, ihi;
@@ -51,8 +51,10 @@
to be determined.
rightmost_closed {logical} indicating if the rightmost xt[] interval
should be closed, i.e. result := n-1 if x == x[n]
- mflag =: all_inside {logical} indicating if result should be coerced
+ (when left_open, the *leftmost* interval should be closed.)
+ all_inside {logical} indicating if result should be coerced
to lie inside {1, n-1}
+ left_open {logical} use intervals (s, t] instead of [s, t)
ilo typically the result of the last call to findInterval(.)
`ilo' used to be a static variable (in Fortran) which is not
desirable in R anymore (threads!).
@@ -95,56 +97,75 @@
left = ilo is then returned.
*/
-#define left_boundary { *mflag = -1; return(all_inside ? 1 : 0); }
+#define left_boundary { *mflag = -1; \
+ return((all_inside || (rightmost_closed && x == xt[1])) ? 1 : 0); }
#define right_boundary { *mflag = +1; \
return((all_inside || (rightmost_closed && x == xt[n])) \
? (n - 1) : n); }
+#define X_grtr(XT_v) x > XT_v || (!left_open && x >= XT_v)
+#define X_smlr(XT_v) x < XT_v || (left_open && x <= XT_v)
+
+
/* 1-indexing : */
--xt;
if(ilo <= 0) {
- if (x < xt[1]) left_boundary;
+ if (X_smlr(xt[1])) left_boundary;
ilo = 1;
}
ihi = ilo + 1;
if (ihi >= n) {
- if (x >= xt[n]) right_boundary;
+ if (X_grtr(xt[n])) right_boundary;
if (n <= 1) /* x < xt[1] */ left_boundary;
ilo = n - 1;
ihi = n;
}
- if (x < xt[ihi]) {
- if (x >= xt[ilo]) { /* `lucky': same interval as last time */
+ if (X_smlr(xt[ihi])) {
+ if (X_grtr(xt[ilo])) {
+ /* `lucky': same interval as last time */
*mflag = 0; return ilo;
}
/* **** now x < xt[ilo] . decrease ilo to capture x */
- for(istep = 1; ; istep *= 2) {
+ if(!left_open) for(istep = 1; ; istep *= 2) {
ihi = ilo;
ilo = ihi - istep;
if (ilo <= 1)
break;
if (x >= xt[ilo]) goto L50;
+ } else for(istep = 1; ; istep *= 2) {
+ ihi = ilo;
+ ilo = ihi - istep;
+ if (ilo <= 1)
+ break;
+ if (x > xt[ilo]) goto L51;
}
ilo = 1;
- if (x < xt[1]) left_boundary;
+ if (X_smlr(xt[1])) left_boundary;
}
else {
/* **** now x >= xt[ihi] . increase ihi to capture x */
- for(istep = 1; ; istep *= 2) {
+ if(!left_open) for(istep = 1; ; istep *= 2) {
ilo = ihi;
ihi = ilo + istep;
if (ihi >= n)
break;
if (x < xt[ihi]) goto L50;
}
- if (x >= xt[n]) right_boundary;
+ else for(istep = 1; ; istep *= 2) {
+ ilo = ihi;
+ ihi = ilo + istep;
+ if (ihi >= n)
+ break;
+ if (x <= xt[ihi]) goto L51;
+ }
+ if (X_grtr(xt[n])) right_boundary;
ihi = n;
}
- L50:
+L50: // ! left_open
/* **** now xt[ilo] <= x < xt[ihi] . narrow the interval. */
for(;;) {
middle = (ilo + ihi) / 2;
@@ -157,4 +178,26 @@
else
ihi = middle;
}
-} /* findInterval */
+
+L51: // left_open
+ /* **** now xt[ilo] < x <= xt[ihi] . narrow the interval. */
+ for(;;) {
+ middle = (ilo + ihi) / 2;
+ if (middle == ilo) {
+ *mflag = 0; return ilo;
+ }
+ /* note. it is assumed that middle = ilo in case ihi = ilo+1 . */
+ if (x > xt[middle])
+ ilo = middle;
+ else
+ ihi = middle;
+ }
+} /* findInterval2 */
+
+// has been in API -- keep for compatibility:
+int findInterval(double *xt, int n, double x,
+ Rboolean rightmost_closed, Rboolean all_inside, int ilo,
+ int *mflag)
+{
+ return findInterval2(xt, n, x, rightmost_closed, all_inside, FALSE, ilo, mflag);
+}
diff -Nru r-base-3.2.3/src/appl/Makefile.in r-base-3.3.1/src/appl/Makefile.in
--- r-base-3.2.3/src/appl/Makefile.in 2015-08-25 22:19:00.000000000 +0000
+++ r-base-3.3.1/src/appl/Makefile.in 2015-12-10 23:15:18.000000000 +0000
@@ -47,8 +47,8 @@
@$(MAKE) libappl.a
libappl.a: $(OBJECTS)
- rm -f $@
- $(AR) cr $@ $(OBJECTS)
+ @rm -f $@
+ $(AR) -cr $@ $(OBJECTS)
$(RANLIB) $@
blas.o: $(top_srcdir)/src/extra/blas/blas.f
diff -Nru r-base-3.2.3/src/extra/blas/Makefile.in r-base-3.3.1/src/extra/blas/Makefile.in
--- r-base-3.2.3/src/extra/blas/Makefile.in 2015-08-25 22:15:07.000000000 +0000
+++ r-base-3.3.1/src/extra/blas/Makefile.in 2016-03-16 23:02:11.000000000 +0000
@@ -33,8 +33,8 @@
@$(MAKE) rhome="$(abs_top_builddir)" Rblas_install
blas_OBJS=blas.o @COMPILE_FORTRAN_DOUBLE_COMPLEX_FALSE@ cmplxblas.o
-@USE_EXTERNAL_BLAS_FALSE@$(Rblas_la): $(blas_OBJS) @BUILD_CYGWIN_TRUE@ xerbla.o
-@USE_EXTERNAL_BLAS_FALSE@ $(DYLIB_LINK) -o $(Rblas_la) $(blas_OBJS) $(Rblas_la_LIBADD) @BUILD_CYGWIN_TRUE@ xerbla.o
+@USE_EXTERNAL_BLAS_FALSE@$(Rblas_la): $(blas_OBJS)
+@USE_EXTERNAL_BLAS_FALSE@ $(DYLIB_LINK) -o $(Rblas_la) $(blas_OBJS) $(Rblas_la_LIBADD)
@USE_EXTERNAL_BLAS_TRUE@$(Rblas_la): blas00.o
@USE_EXTERNAL_BLAS_TRUE@ $(DYLIB_LINK) -o $(Rblas_la) $^ @BLAS_LIBS0@ $(Rblas_la_LIBADD0)
@@ -65,7 +65,7 @@
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
DISTFILES = Makefile.in Makefile.win Rblas.def \
- $(SOURCES) $(HEADERS) xerbla.c
+ $(SOURCES) $(HEADERS)
distdir: $(DISTFILES)
@for f in $(DISTFILES); do \
diff -Nru r-base-3.2.3/src/extra/blas/xerbla.c r-base-3.3.1/src/extra/blas/xerbla.c
--- r-base-3.2.3/src/extra/blas/xerbla.c 2010-03-17 14:43:05.000000000 +0000
+++ r-base-3.3.1/src/extra/blas/xerbla.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,14 +0,0 @@
-/* It seems Cygwin does not allow mutually dependent dlls, so fake xerbla */
-
-#include
-
-/* Fortran-callable error routine for lapack */
-
-void F77_NAME(xerbla)(const char *srname, int *info)
-{
- /* srname is not null-terminated. It should be 6 characters. */
- char buf[7];
- strncpy(buf, srname, 6);
- buf[6] = '\0';
- printf("BLAS/LAPACK routine '%6s' gave error code %d", buf, -(*info));
-}
diff -Nru r-base-3.2.3/src/extra/bzip2/blocksort.c r-base-3.3.1/src/extra/bzip2/blocksort.c
--- r-base-3.2.3/src/extra/bzip2/blocksort.c 2015-03-18 23:02:09.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/blocksort.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,1099 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Block sorting machinery ---*/
-/*--- blocksort.c ---*/
-/*-------------------------------------------------------------*/
-
-/* ------------------------------------------------------------------
- This file is part of bzip2/libbzip2, a program and library for
- lossless, block-sorting data compression.
-
- bzip2/libbzip2 version 1.0.6 of 6 September 2010
- Copyright (C) 1996-2010 Julian Seward
-
- Please read the WARNING, DISCLAIMER and PATENTS sections in the
- README file.
-
- This program is released under the terms of the license contained
- in the file LICENSE.
- ------------------------------------------------------------------ */
-
-
-#include "bzlib_private.h"
-
-/*---------------------------------------------*/
-/*--- Fallback O(N log(N)^2) sorting ---*/
-/*--- algorithm, for repetitive blocks ---*/
-/*---------------------------------------------*/
-
-/*---------------------------------------------*/
-static
-R_INLINE
-void fallbackSimpleSort ( UInt32* fmap,
- UInt32* eclass,
- Int32 lo,
- Int32 hi )
-{
- Int32 i, j, tmp;
- UInt32 ec_tmp;
-
- if (lo == hi) return;
-
- if (hi - lo > 3) {
- for ( i = hi-4; i >= lo; i-- ) {
- tmp = fmap[i];
- ec_tmp = eclass[tmp];
- for ( j = i+4; j <= hi && ec_tmp > eclass[fmap[j]]; j += 4 )
- fmap[j-4] = fmap[j];
- fmap[j-4] = tmp;
- }
- }
-
- for ( i = hi-1; i >= lo; i-- ) {
- tmp = fmap[i];
- ec_tmp = eclass[tmp];
- for ( j = i+1; j <= hi && ec_tmp > eclass[fmap[j]]; j++ )
- fmap[j-1] = fmap[j];
- fmap[j-1] = tmp;
- }
-}
-
-
-/*---------------------------------------------*/
-#define fswap(zz1, zz2) \
- { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; }
-
-#define fvswap(zzp1, zzp2, zzn) \
-{ \
- Int32 yyp1 = (zzp1); \
- Int32 yyp2 = (zzp2); \
- Int32 yyn = (zzn); \
- while (yyn > 0) { \
- fswap(fmap[yyp1], fmap[yyp2]); \
- yyp1++; yyp2++; yyn--; \
- } \
-}
-
-
-#define fmin(a,b) ((a) < (b)) ? (a) : (b)
-
-#define fpush(lz,hz) { stackLo[sp] = lz; \
- stackHi[sp] = hz; \
- sp++; }
-
-#define fpop(lz,hz) { sp--; \
- lz = stackLo[sp]; \
- hz = stackHi[sp]; }
-
-#define FALLBACK_QSORT_SMALL_THRESH 10
-#define FALLBACK_QSORT_STACK_SIZE 100
-
-
-static
-void fallbackQSort3 ( UInt32* fmap,
- UInt32* eclass,
- Int32 loSt,
- Int32 hiSt )
-{
- Int32 unLo, unHi, ltLo, gtHi, n, m;
- Int32 sp, lo, hi;
- UInt32 med, r, r3;
- Int32 stackLo[FALLBACK_QSORT_STACK_SIZE];
- Int32 stackHi[FALLBACK_QSORT_STACK_SIZE];
-
- r = 0;
-
- sp = 0;
- fpush ( loSt, hiSt );
-
- while (sp > 0) {
-
- AssertH ( sp < FALLBACK_QSORT_STACK_SIZE - 1, 1004 );
-
- fpop ( lo, hi );
- if (hi - lo < FALLBACK_QSORT_SMALL_THRESH) {
- fallbackSimpleSort ( fmap, eclass, lo, hi );
- continue;
- }
-
- /* Random partitioning. Median of 3 sometimes fails to
- avoid bad cases. Median of 9 seems to help but
- looks rather expensive. This too seems to work but
- is cheaper. Guidance for the magic constants
- 7621 and 32768 is taken from Sedgewick's algorithms
- book, chapter 35.
- */
- r = ((r * 7621) + 1) % 32768;
- r3 = r % 3;
- if (r3 == 0) med = eclass[fmap[lo]]; else
- if (r3 == 1) med = eclass[fmap[(lo+hi)>>1]]; else
- med = eclass[fmap[hi]];
-
- unLo = ltLo = lo;
- unHi = gtHi = hi;
-
- while (1) {
- while (1) {
- if (unLo > unHi) break;
- n = (Int32)eclass[fmap[unLo]] - (Int32)med;
- if (n == 0) {
- fswap(fmap[unLo], fmap[ltLo]);
- ltLo++; unLo++;
- continue;
- };
- if (n > 0) break;
- unLo++;
- }
- while (1) {
- if (unLo > unHi) break;
- n = (Int32)eclass[fmap[unHi]] - (Int32)med;
- if (n == 0) {
- fswap(fmap[unHi], fmap[gtHi]);
- gtHi--; unHi--;
- continue;
- };
- if (n < 0) break;
- unHi--;
- }
- if (unLo > unHi) break;
- fswap(fmap[unLo], fmap[unHi]); unLo++; unHi--;
- }
-
- AssertD ( unHi == unLo-1, "fallbackQSort3(2)" );
-
- if (gtHi < ltLo) continue;
-
- n = fmin(ltLo-lo, unLo-ltLo); fvswap(lo, unLo-n, n);
- m = fmin(hi-gtHi, gtHi-unHi); fvswap(unLo, hi-m+1, m);
-
- n = lo + unLo - ltLo - 1;
- m = hi - (gtHi - unHi) + 1;
-
- if (n - lo > hi - m) {
- fpush ( lo, n );
- fpush ( m, hi );
- } else {
- fpush ( m, hi );
- fpush ( lo, n );
- }
- }
-}
-
-#undef fmin
-#undef fpush
-#undef fpop
-#undef fswap
-#undef fvswap
-#undef FALLBACK_QSORT_SMALL_THRESH
-#undef FALLBACK_QSORT_STACK_SIZE
-
-
-/*---------------------------------------------*/
-/* Pre:
- nblock > 0
- eclass exists for [0 .. nblock-1]
- ((UChar*)eclass) [0 .. nblock-1] holds block
- ptr exists for [0 .. nblock-1]
-
- Post:
- ((UChar*)eclass) [0 .. nblock-1] holds block
- All other areas of eclass destroyed
- fmap [0 .. nblock-1] holds sorted order
- bhtab [ 0 .. 2+(nblock/32) ] destroyed
-*/
-
-// R_change: these shifts on signed ints are undefined behaviour.
-#define SET_BH(zz) bhtab[(zz) >> 5] |= (1U << ((zz) & 31))
-#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~(1U << ((zz) & 31))
-#define ISSET_BH(zz) (bhtab[(zz) >> 5] & (1U << ((zz) & 31)))
-#define WORD_BH(zz) bhtab[(zz) >> 5]
-#define UNALIGNED_BH(zz) ((zz) & 0x01f)
-
-static
-void fallbackSort ( UInt32* fmap,
- UInt32* eclass,
- UInt32* bhtab,
- Int32 nblock,
- Int32 verb )
-{
- Int32 ftab[257];
- Int32 ftabCopy[256];
- Int32 H, i, j, k, l, r, cc, cc1;
- Int32 nNotDone;
- Int32 nBhtab;
- UChar* eclass8 = (UChar*)eclass;
-
- /*--
- Initial 1-char radix sort to generate
- initial fmap and initial BH bits.
- --*/
- if (verb >= 4)
- VPrintf0 ( " bucket sorting ...\n" );
- for (i = 0; i < 257; i++) ftab[i] = 0;
- for (i = 0; i < nblock; i++) ftab[eclass8[i]]++;
- for (i = 0; i < 256; i++) ftabCopy[i] = ftab[i];
- for (i = 1; i < 257; i++) ftab[i] += ftab[i-1];
-
- for (i = 0; i < nblock; i++) {
- j = eclass8[i];
- k = ftab[j] - 1;
- ftab[j] = k;
- fmap[k] = i;
- }
-
- nBhtab = 2 + (nblock / 32);
- for (i = 0; i < nBhtab; i++) bhtab[i] = 0;
- for (i = 0; i < 256; i++) SET_BH(ftab[i]);
-
- /*--
- Inductively refine the buckets. Kind-of an
- "exponential radix sort" (!), inspired by the
- Manber-Myers suffix array construction algorithm.
- --*/
-
- /*-- set sentinel bits for block-end detection --*/
- for (i = 0; i < 32; i++) {
- SET_BH(nblock + 2*i);
- CLEAR_BH(nblock + 2*i + 1);
- }
-
- /*-- the log(N) loop --*/
- H = 1;
- while (1) {
-
- if (verb >= 4)
- VPrintf1 ( " depth %6d has ", H );
-
- j = 0;
- for (i = 0; i < nblock; i++) {
- if (ISSET_BH(i)) j = i;
- k = fmap[i] - H; if (k < 0) k += nblock;
- eclass[k] = j;
- }
-
- nNotDone = 0;
- r = -1;
- while (1) {
-
- /*-- find the next non-singleton bucket --*/
- k = r + 1;
- while (ISSET_BH(k) && UNALIGNED_BH(k)) k++;
- if (ISSET_BH(k)) {
- while (WORD_BH(k) == 0xffffffff) k += 32;
- while (ISSET_BH(k)) k++;
- }
- l = k - 1;
- if (l >= nblock) break;
- while (!ISSET_BH(k) && UNALIGNED_BH(k)) k++;
- if (!ISSET_BH(k)) {
- while (WORD_BH(k) == 0x00000000) k += 32;
- while (!ISSET_BH(k)) k++;
- }
- r = k - 1;
- if (r >= nblock) break;
-
- /*-- now [l, r] bracket current bucket --*/
- if (r > l) {
- nNotDone += (r - l + 1);
- fallbackQSort3 ( fmap, eclass, l, r );
-
- /*-- scan bucket and generate header bits-- */
- cc = -1;
- for (i = l; i <= r; i++) {
- cc1 = eclass[fmap[i]];
- if (cc != cc1) { SET_BH(i); cc = cc1; };
- }
- }
- }
-
- if (verb >= 4)
- VPrintf1 ( "%6d unresolved strings\n", nNotDone );
-
- H *= 2;
- if (H > nblock || nNotDone == 0) break;
- }
-
- /*--
- Reconstruct the original block in
- eclass8 [0 .. nblock-1], since the
- previous phase destroyed it.
- --*/
- if (verb >= 4)
- VPrintf0 ( " reconstructing block ...\n" );
- j = 0;
- for (i = 0; i < nblock; i++) {
- while (ftabCopy[j] == 0) j++;
- ftabCopy[j]--;
- eclass8[fmap[i]] = (UChar)j;
- }
- AssertH ( j < 256, 1005 );
-}
-
-#undef SET_BH
-#undef CLEAR_BH
-#undef ISSET_BH
-#undef WORD_BH
-#undef UNALIGNED_BH
-
-
-/*---------------------------------------------*/
-/*--- The main, O(N^2 log(N)) sorting ---*/
-/*--- algorithm. Faster for "normal" ---*/
-/*--- non-repetitive blocks. ---*/
-/*---------------------------------------------*/
-
-/*---------------------------------------------*/
-/* Solaris cc objects to inlining functions whose names start with `main' */
-#ifdef __SUNPRO_C
-# define mainGtU BZmainGtU
-#endif
-static
-R_INLINE
-Bool mainGtU ( UInt32 i1,
- UInt32 i2,
- UChar* block,
- UInt16* quadrant,
- UInt32 nblock,
- Int32* budget )
-{
- Int32 k;
- UChar c1, c2;
- UInt16 s1, s2;
-
- AssertD ( i1 != i2, "mainGtU" );
- /* 1 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 2 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 3 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 4 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 5 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 6 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 7 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 8 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 9 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 10 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 11 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
- /* 12 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- i1++; i2++;
-
- k = nblock + 8;
-
- do {
- /* 1 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 2 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 3 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 4 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 5 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 6 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 7 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
- /* 8 */
- c1 = block[i1]; c2 = block[i2];
- if (c1 != c2) return (c1 > c2);
- s1 = quadrant[i1]; s2 = quadrant[i2];
- if (s1 != s2) return (s1 > s2);
- i1++; i2++;
-
- if (i1 >= nblock) i1 -= nblock;
- if (i2 >= nblock) i2 -= nblock;
-
- k -= 8;
- (*budget)--;
- }
- while (k >= 0);
-
- return False;
-}
-
-
-/*---------------------------------------------*/
-/*--
- Knuth's increments seem to work better
- than Incerpi-Sedgewick here. Possibly
- because the number of elems to sort is
- usually small, typically <= 20.
---*/
-static
-Int32 incs[14] = { 1, 4, 13, 40, 121, 364, 1093, 3280,
- 9841, 29524, 88573, 265720,
- 797161, 2391484 };
-
-static
-void mainSimpleSort ( UInt32* ptr,
- UChar* block,
- UInt16* quadrant,
- Int32 nblock,
- Int32 lo,
- Int32 hi,
- Int32 d,
- Int32* budget )
-{
- Int32 i, j, h, bigN, hp;
- UInt32 v;
-
- bigN = hi - lo + 1;
- if (bigN < 2) return;
-
- hp = 0;
- while (incs[hp] < bigN) hp++;
- hp--;
-
- for (; hp >= 0; hp--) {
- h = incs[hp];
-
- i = lo + h;
- while (True) {
-
- /*-- copy 1 --*/
- if (i > hi) break;
- v = ptr[i];
- j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
- ) ) {
- ptr[j] = ptr[j-h];
- j = j - h;
- if (j <= (lo + h - 1)) break;
- }
- ptr[j] = v;
- i++;
-
- /*-- copy 2 --*/
- if (i > hi) break;
- v = ptr[i];
- j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
- ) ) {
- ptr[j] = ptr[j-h];
- j = j - h;
- if (j <= (lo + h - 1)) break;
- }
- ptr[j] = v;
- i++;
-
- /*-- copy 3 --*/
- if (i > hi) break;
- v = ptr[i];
- j = i;
- while ( mainGtU (
- ptr[j-h]+d, v+d, block, quadrant, nblock, budget
- ) ) {
- ptr[j] = ptr[j-h];
- j = j - h;
- if (j <= (lo + h - 1)) break;
- }
- ptr[j] = v;
- i++;
-
- if (*budget < 0) return;
- }
- }
-}
-
-
-/*---------------------------------------------*/
-/*--
- The following is an implementation of
- an elegant 3-way quicksort for strings,
- described in a paper "Fast Algorithms for
- Sorting and Searching Strings", by Robert
- Sedgewick and Jon L. Bentley.
---*/
-
-#define mswap(zz1, zz2) \
- { Int32 zztmp = zz1; zz1 = zz2; zz2 = zztmp; }
-
-#define mvswap(zzp1, zzp2, zzn) \
-{ \
- Int32 yyp1 = (zzp1); \
- Int32 yyp2 = (zzp2); \
- Int32 yyn = (zzn); \
- while (yyn > 0) { \
- mswap(ptr[yyp1], ptr[yyp2]); \
- yyp1++; yyp2++; yyn--; \
- } \
-}
-
-static
-R_INLINE
-UChar mmed3 ( UChar a, UChar b, UChar c )
-{
- UChar t;
- if (a > b) { t = a; a = b; b = t; };
- if (b > c) {
- b = c;
- if (a > b) b = a;
- }
- return b;
-}
-
-#define mmin(a,b) ((a) < (b)) ? (a) : (b)
-
-#define mpush(lz,hz,dz) { stackLo[sp] = lz; \
- stackHi[sp] = hz; \
- stackD [sp] = dz; \
- sp++; }
-
-#define mpop(lz,hz,dz) { sp--; \
- lz = stackLo[sp]; \
- hz = stackHi[sp]; \
- dz = stackD [sp]; }
-
-
-#define mnextsize(az) (nextHi[az]-nextLo[az])
-
-#define mnextswap(az,bz) \
- { Int32 tz; \
- tz = nextLo[az]; nextLo[az] = nextLo[bz]; nextLo[bz] = tz; \
- tz = nextHi[az]; nextHi[az] = nextHi[bz]; nextHi[bz] = tz; \
- tz = nextD [az]; nextD [az] = nextD [bz]; nextD [bz] = tz; }
-
-
-#define MAIN_QSORT_SMALL_THRESH 20
-#define MAIN_QSORT_DEPTH_THRESH (BZ_N_RADIX + BZ_N_QSORT)
-#define MAIN_QSORT_STACK_SIZE 100
-
-static
-void mainQSort3 ( UInt32* ptr,
- UChar* block,
- UInt16* quadrant,
- Int32 nblock,
- Int32 loSt,
- Int32 hiSt,
- Int32 dSt,
- Int32* budget )
-{
- Int32 unLo, unHi, ltLo, gtHi, n, m, med;
- Int32 sp, lo, hi, d;
-
- Int32 stackLo[MAIN_QSORT_STACK_SIZE];
- Int32 stackHi[MAIN_QSORT_STACK_SIZE];
- Int32 stackD [MAIN_QSORT_STACK_SIZE];
-
- Int32 nextLo[3];
- Int32 nextHi[3];
- Int32 nextD [3];
-
- sp = 0;
- mpush ( loSt, hiSt, dSt );
-
- while (sp > 0) {
-
- AssertH ( sp < MAIN_QSORT_STACK_SIZE - 2, 1001 );
-
- mpop ( lo, hi, d );
- if (hi - lo < MAIN_QSORT_SMALL_THRESH ||
- d > MAIN_QSORT_DEPTH_THRESH) {
- mainSimpleSort ( ptr, block, quadrant, nblock, lo, hi, d, budget );
- if (*budget < 0) return;
- continue;
- }
-
- med = (Int32)
- mmed3 ( block[ptr[ lo ]+d],
- block[ptr[ hi ]+d],
- block[ptr[ (lo+hi)>>1 ]+d] );
-
- unLo = ltLo = lo;
- unHi = gtHi = hi;
-
- while (True) {
- while (True) {
- if (unLo > unHi) break;
- n = ((Int32)block[ptr[unLo]+d]) - med;
- if (n == 0) {
- mswap(ptr[unLo], ptr[ltLo]);
- ltLo++; unLo++; continue;
- };
- if (n > 0) break;
- unLo++;
- }
- while (True) {
- if (unLo > unHi) break;
- n = ((Int32)block[ptr[unHi]+d]) - med;
- if (n == 0) {
- mswap(ptr[unHi], ptr[gtHi]);
- gtHi--; unHi--; continue;
- };
- if (n < 0) break;
- unHi--;
- }
- if (unLo > unHi) break;
- mswap(ptr[unLo], ptr[unHi]); unLo++; unHi--;
- }
-
- AssertD ( unHi == unLo-1, "mainQSort3(2)" );
-
- if (gtHi < ltLo) {
- mpush(lo, hi, d+1 );
- continue;
- }
-
- n = mmin(ltLo-lo, unLo-ltLo); mvswap(lo, unLo-n, n);
- m = mmin(hi-gtHi, gtHi-unHi); mvswap(unLo, hi-m+1, m);
-
- n = lo + unLo - ltLo - 1;
- m = hi - (gtHi - unHi) + 1;
-
- nextLo[0] = lo; nextHi[0] = n; nextD[0] = d;
- nextLo[1] = m; nextHi[1] = hi; nextD[1] = d;
- nextLo[2] = n+1; nextHi[2] = m-1; nextD[2] = d+1;
-
- if (mnextsize(0) < mnextsize(1)) mnextswap(0,1);
- if (mnextsize(1) < mnextsize(2)) mnextswap(1,2);
- if (mnextsize(0) < mnextsize(1)) mnextswap(0,1);
-
- AssertD (mnextsize(0) >= mnextsize(1), "mainQSort3(8)" );
- AssertD (mnextsize(1) >= mnextsize(2), "mainQSort3(9)" );
-
- mpush (nextLo[0], nextHi[0], nextD[0]);
- mpush (nextLo[1], nextHi[1], nextD[1]);
- mpush (nextLo[2], nextHi[2], nextD[2]);
- }
-}
-
-#undef mswap
-#undef mvswap
-#undef mpush
-#undef mpop
-#undef mmin
-#undef mnextsize
-#undef mnextswap
-#undef MAIN_QSORT_SMALL_THRESH
-#undef MAIN_QSORT_DEPTH_THRESH
-#undef MAIN_QSORT_STACK_SIZE
-
-
-/*---------------------------------------------*/
-/* Pre:
- nblock > N_OVERSHOOT
- block32 exists for [0 .. nblock-1 +N_OVERSHOOT]
- ((UChar*)block32) [0 .. nblock-1] holds block
- ptr exists for [0 .. nblock-1]
-
- Post:
- ((UChar*)block32) [0 .. nblock-1] holds block
- All other areas of block32 destroyed
- ftab [0 .. 65536 ] destroyed
- ptr [0 .. nblock-1] holds sorted order
- if (*budget < 0), sorting was abandoned
-*/
-
-#define BIGFREQ(b) (ftab[((b)+1) << 8] - ftab[(b) << 8])
-#define SETMASK (1 << 21)
-#define CLEARMASK (~(SETMASK))
-
-static
-void mainSort ( UInt32* ptr,
- UChar* block,
- UInt16* quadrant,
- UInt32* ftab,
- Int32 nblock,
- Int32 verb,
- Int32* budget )
-{
- Int32 i, j, k, ss, sb;
- Int32 runningOrder[256];
- Bool bigDone[256];
- Int32 copyStart[256];
- Int32 copyEnd [256];
- UChar c1;
- Int32 numQSorted;
- UInt16 s;
- if (verb >= 4) VPrintf0 ( " main sort initialise ...\n" );
-
- /*-- set up the 2-byte frequency table --*/
- for (i = 65536; i >= 0; i--) ftab[i] = 0;
-
- j = block[0] << 8;
- i = nblock-1;
- for (; i >= 3; i -= 4) {
- quadrant[i] = 0;
- j = (j >> 8) | ( ((UInt16)block[i]) << 8);
- ftab[j]++;
- quadrant[i-1] = 0;
- j = (j >> 8) | ( ((UInt16)block[i-1]) << 8);
- ftab[j]++;
- quadrant[i-2] = 0;
- j = (j >> 8) | ( ((UInt16)block[i-2]) << 8);
- ftab[j]++;
- quadrant[i-3] = 0;
- j = (j >> 8) | ( ((UInt16)block[i-3]) << 8);
- ftab[j]++;
- }
- for (; i >= 0; i--) {
- quadrant[i] = 0;
- j = (j >> 8) | ( ((UInt16)block[i]) << 8);
- ftab[j]++;
- }
-
- /*-- (emphasises close relationship of block & quadrant) --*/
- for (i = 0; i < BZ_N_OVERSHOOT; i++) {
- block [nblock+i] = block[i];
- quadrant[nblock+i] = 0;
- }
-
- if (verb >= 4) VPrintf0 ( " bucket sorting ...\n" );
-
- /*-- Complete the initial radix sort --*/
- for (i = 1; i <= 65536; i++) ftab[i] += ftab[i-1];
-
- s = block[0] << 8;
- i = nblock-1;
- for (; i >= 3; i -= 4) {
- s = (s >> 8) | (block[i] << 8);
- j = ftab[s] -1;
- ftab[s] = j;
- ptr[j] = i;
- s = (s >> 8) | (block[i-1] << 8);
- j = ftab[s] -1;
- ftab[s] = j;
- ptr[j] = i-1;
- s = (s >> 8) | (block[i-2] << 8);
- j = ftab[s] -1;
- ftab[s] = j;
- ptr[j] = i-2;
- s = (s >> 8) | (block[i-3] << 8);
- j = ftab[s] -1;
- ftab[s] = j;
- ptr[j] = i-3;
- }
- for (; i >= 0; i--) {
- s = (s >> 8) | (block[i] << 8);
- j = ftab[s] -1;
- ftab[s] = j;
- ptr[j] = i;
- }
-
- /*--
- Now ftab contains the first loc of every small bucket.
- Calculate the running order, from smallest to largest
- big bucket.
- --*/
- for (i = 0; i <= 255; i++) {
- bigDone [i] = False;
- runningOrder[i] = i;
- }
-
- {
- Int32 vv;
- Int32 h = 1;
- do h = 3 * h + 1; while (h <= 256);
- do {
- h = h / 3;
- for (i = h; i <= 255; i++) {
- vv = runningOrder[i];
- j = i;
- while ( BIGFREQ(runningOrder[j-h]) > BIGFREQ(vv) ) {
- runningOrder[j] = runningOrder[j-h];
- j = j - h;
- if (j <= (h - 1)) goto zero;
- }
- zero:
- runningOrder[j] = vv;
- }
- } while (h != 1);
- }
-
- /*--
- The main sorting loop.
- --*/
-
- numQSorted = 0;
-
- for (i = 0; i <= 255; i++) {
-
- /*--
- Process big buckets, starting with the least full.
- Basically this is a 3-step process in which we call
- mainQSort3 to sort the small buckets [ss, j], but
- also make a big effort to avoid the calls if we can.
- --*/
- ss = runningOrder[i];
-
- /*--
- Step 1:
- Complete the big bucket [ss] by quicksorting
- any unsorted small buckets [ss, j], for j != ss.
- Hopefully previous pointer-scanning phases have already
- completed many of the small buckets [ss, j], so
- we don't have to sort them at all.
- --*/
- for (j = 0; j <= 255; j++) {
- if (j != ss) {
- sb = (ss << 8) + j;
- if ( ! (ftab[sb] & SETMASK) ) {
- Int32 lo = ftab[sb] & CLEARMASK;
- Int32 hi = (ftab[sb+1] & CLEARMASK) - 1;
- if (hi > lo) {
- if (verb >= 4)
- VPrintf4 ( " qsort [0x%x, 0x%x] "
- "done %d this %d\n",
- ss, j, numQSorted, hi - lo + 1 );
- mainQSort3 (
- ptr, block, quadrant, nblock,
- lo, hi, BZ_N_RADIX, budget
- );
- numQSorted += (hi - lo + 1);
- if (*budget < 0) return;
- }
- }
- ftab[sb] |= SETMASK;
- }
- }
-
- AssertH ( !bigDone[ss], 1006 );
-
- /*--
- Step 2:
- Now scan this big bucket [ss] so as to synthesise the
- sorted order for small buckets [t, ss] for all t,
- including, magically, the bucket [ss,ss] too.
- This will avoid doing Real Work in subsequent Step 1's.
- --*/
- {
- for (j = 0; j <= 255; j++) {
- copyStart[j] = ftab[(j << 8) + ss] & CLEARMASK;
- copyEnd [j] = (ftab[(j << 8) + ss + 1] & CLEARMASK) - 1;
- }
- for (j = ftab[ss << 8] & CLEARMASK; j < copyStart[ss]; j++) {
- k = ptr[j]-1; if (k < 0) k += nblock;
- c1 = block[k];
- if (!bigDone[c1])
- ptr[ copyStart[c1]++ ] = k;
- }
- for (j = (ftab[(ss+1) << 8] & CLEARMASK) - 1; j > copyEnd[ss]; j--) {
- k = ptr[j]-1; if (k < 0) k += nblock;
- c1 = block[k];
- if (!bigDone[c1])
- ptr[ copyEnd[c1]-- ] = k;
- }
- }
-
- AssertH ( (copyStart[ss]-1 == copyEnd[ss])
- ||
- /* Extremely rare case missing in bzip2-1.0.0 and 1.0.1.
- Necessity for this case is demonstrated by compressing
- a sequence of approximately 48.5 million of character
- 251; 1.0.0/1.0.1 will then die here. */
- (copyStart[ss] == 0 && copyEnd[ss] == nblock-1),
- 1007 )
-
- for (j = 0; j <= 255; j++) ftab[(j << 8) + ss] |= SETMASK;
-
- /*--
- Step 3:
- The [ss] big bucket is now done. Record this fact,
- and update the quadrant descriptors. Remember to
- update quadrants in the overshoot area too, if
- necessary. The "if (i < 255)" test merely skips
- this updating for the last bucket processed, since
- updating for the last bucket is pointless.
-
- The quadrant array provides a way to incrementally
- cache sort orderings, as they appear, so as to
- make subsequent comparisons in fullGtU() complete
- faster. For repetitive blocks this makes a big
- difference (but not big enough to be able to avoid
- the fallback sorting mechanism, exponential radix sort).
-
- The precise meaning is: at all times:
-
- for 0 <= i < nblock and 0 <= j <= nblock
-
- if block[i] != block[j],
-
- then the relative values of quadrant[i] and
- quadrant[j] are meaningless.
-
- else {
- if quadrant[i] < quadrant[j]
- then the string starting at i lexicographically
- precedes the string starting at j
-
- else if quadrant[i] > quadrant[j]
- then the string starting at j lexicographically
- precedes the string starting at i
-
- else
- the relative ordering of the strings starting
- at i and j has not yet been determined.
- }
- --*/
- bigDone[ss] = True;
-
- if (i < 255) {
- Int32 bbStart = ftab[ss << 8] & CLEARMASK;
- Int32 bbSize = (ftab[(ss+1) << 8] & CLEARMASK) - bbStart;
- Int32 shifts = 0;
-
- while ((bbSize >> shifts) > 65534) shifts++;
-
- for (j = bbSize-1; j >= 0; j--) {
- Int32 a2update = ptr[bbStart + j];
- UInt16 qVal = (UInt16)(j >> shifts);
- quadrant[a2update] = qVal;
- if (a2update < BZ_N_OVERSHOOT)
- quadrant[a2update + nblock] = qVal;
- }
- AssertH ( ((bbSize-1) >> shifts) <= 65535, 1002 );
- }
-
- }
-
- if (verb >= 4)
- VPrintf3 ( " %d pointers, %d sorted, %d scanned\n",
- nblock, numQSorted, nblock - numQSorted );
-}
-
-#undef BIGFREQ
-#undef SETMASK
-#undef CLEARMASK
-
-
-/*---------------------------------------------*/
-/* Pre:
- nblock > 0
- arr2 exists for [0 .. nblock-1 +N_OVERSHOOT]
- ((UChar*)arr2) [0 .. nblock-1] holds block
- arr1 exists for [0 .. nblock-1]
-
- Post:
- ((UChar*)arr2) [0 .. nblock-1] holds block
- All other areas of block destroyed
- ftab [ 0 .. 65536 ] destroyed
- arr1 [0 .. nblock-1] holds sorted order
-*/
-void BZ2_blockSort ( EState* s )
-{
- UInt32* ptr = s->ptr;
- UChar* block = s->block;
- UInt32* ftab = s->ftab;
- Int32 nblock = s->nblock;
- Int32 verb = s->verbosity;
- Int32 wfact = s->workFactor;
- UInt16* quadrant;
- Int32 budget;
- Int32 budgetInit;
- Int32 i;
-
- if (nblock < 10000) {
- fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
- } else {
- /* Calculate the location for quadrant, remembering to get
- the alignment right. Assumes that &(block[0]) is at least
- 2-byte aligned -- this should be ok since block is really
- the first section of arr2.
- */
- i = nblock+BZ_N_OVERSHOOT;
- if (i & 1) i++;
- quadrant = (UInt16*)(&(block[i]));
-
- /* (wfact-1) / 3 puts the default-factor-30
- transition point at very roughly the same place as
- with v0.1 and v0.9.0.
- Not that it particularly matters any more, since the
- resulting compressed stream is now the same regardless
- of whether or not we use the main sort or fallback sort.
- */
- if (wfact < 1 ) wfact = 1;
- if (wfact > 100) wfact = 100;
- budgetInit = nblock * ((wfact-1) / 3);
- budget = budgetInit;
-
- mainSort ( ptr, block, quadrant, ftab, nblock, verb, &budget );
- if (verb >= 3)
- VPrintf3 ( " %d work, %d block, ratio %5.2f\n",
- budgetInit - budget,
- nblock,
- (float)(budgetInit - budget) /
- (float)(nblock==0 ? 1 : nblock) );
- if (budget < 0) {
- if (verb >= 2)
- VPrintf0 ( " too repetitive; using fallback"
- " sorting algorithm\n" );
- fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb );
- }
- }
-
- s->origPtr = -1;
- for (i = 0; i < s->nblock; i++)
- if (ptr[i] == 0)
- { s->origPtr = i; break; };
-
- AssertH( s->origPtr != -1, 1003 );
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end blocksort.c ---*/
-/*-------------------------------------------------------------*/
diff -Nru r-base-3.2.3/src/extra/bzip2/bzlib.c r-base-3.3.1/src/extra/bzip2/bzlib.c
--- r-base-3.2.3/src/extra/bzip2/bzlib.c 2015-03-18 23:02:09.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/bzlib.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,1586 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Library top-level functions. ---*/
-/*--- bzlib.c ---*/
-/*-------------------------------------------------------------*/
-
-/* ------------------------------------------------------------------
- This file is part of bzip2/libbzip2, a program and library for
- lossless, block-sorting data compression.
-
- bzip2/libbzip2 version 1.0.6 of 6 September 2010
- Copyright (C) 1996-2010 Julian Seward
-
- Please read the WARNING, DISCLAIMER and PATENTS sections in the
- README file.
-
- This program is released under the terms of the license contained
- in the file LICENSE.
- ------------------------------------------------------------------ */
-
-/* CHANGES
- 0.9.0 -- original version.
- 0.9.0a/b -- no changes in this file.
- 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress().
- fixed bzWrite/bzRead to ignore zero-length requests.
- fixed bzread to correctly handle read requests after EOF.
- wrong parameter order in call to bzDecompressInit in
- bzBuffToBuffDecompress. Fixed.
-*/
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------------*/
-/*--- Compression stuff ---*/
-/*---------------------------------------------------*/
-
-
-/*---------------------------------------------------*/
-#ifndef BZ_NO_STDIO
-void BZ2_bz__AssertH__fail ( int errcode )
-{
- fprintf(stderr,
- "\n\nbzip2/libbzip2: internal error number %d.\n"
- "This is a bug in bzip2/libbzip2, %s.\n"
- "Please report it to me at: jseward@bzip.org. If this happened\n"
- "when you were using some program which uses libbzip2 as a\n"
- "component, you should also report this bug to the author(s)\n"
- "of that program. Please make an effort to report this bug;\n"
- "timely and accurate bug reports eventually lead to higher\n"
- "quality software. Thanks. Julian Seward, 10 December 2007.\n\n",
- errcode,
- BZ2_bzlibVersion()
- );
-
- /* split up over-long message */
- if (errcode == 1007) {
- fprintf(stderr, "%s%s%s",
- "\n*** A special note about internal error number 1007 ***\n"
- "\n"
- "Experience suggests that a common cause of i.e. 1007\n"
- "is unreliable memory or other hardware. The 1007 assertion\n"
- "just happens to cross-check the results of huge numbers of\n"
- "memory reads/writes, and so acts (unintendedly) as a stress\n"
- "test of your memory system.\n"
- "\n",
- "I suggest the following: try compressing the file again,\n"
- "possibly monitoring progress in detail with the -vv flag.\n"
- "\n"
- "* If the error cannot be reproduced, and/or happens at different\n"
- " points in compression, you may have a flaky memory system.\n"
- " Try a memory-test program. I have used Memtest86\n"
- " (www.memtest86.com). At the time of writing it is free (GPLd).\n"
- " Memtest86 tests memory much more thorougly than your BIOSs\n"
- " power-on test, and may find failures that the BIOS doesn't.\n"
- "\n",
- "* If the error can be repeatably reproduced, this is a bug in\n"
- " bzip2, and I would very much like to hear about it. Please\n"
- " let me know, and, ideally, save a copy of the file causing the\n"
- " problem -- without which I will be unable to investigate it.\n"
- "\n"
- );
- }
-
- exit(3);
-}
-#endif
-
-
-/*---------------------------------------------------*/
-static
-int bz_config_ok ( void )
-{
- if (sizeof(int) != 4) return 0;
- if (sizeof(short) != 2) return 0;
- if (sizeof(char) != 1) return 0;
- return 1;
-}
-
-
-/*---------------------------------------------------*/
-static
-void* default_bzalloc ( void* opaque, Int32 items, Int32 size )
-{
- void* v = malloc ( items * size );
- return v;
-}
-
-static
-void default_bzfree ( void* opaque, void* addr )
-{
- if (addr != NULL) free ( addr );
-}
-
-
-/*---------------------------------------------------*/
-static
-void prepare_new_block ( EState* s )
-{
- Int32 i;
- s->nblock = 0;
- s->numZ = 0;
- s->state_out_pos = 0;
- BZ_INITIALISE_CRC ( s->blockCRC );
- for (i = 0; i < 256; i++) s->inUse[i] = False;
- s->blockNo++;
-}
-
-
-/*---------------------------------------------------*/
-static
-void init_RL ( EState* s )
-{
- s->state_in_ch = 256;
- s->state_in_len = 0;
-}
-
-
-static
-Bool isempty_RL ( EState* s )
-{
- if (s->state_in_ch < 256 && s->state_in_len > 0)
- return False; else
- return True;
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompressInit)
- ( bz_stream* strm,
- int blockSize100k,
- int verbosity,
- int workFactor )
-{
- Int32 n;
- EState* s;
-
- if (!bz_config_ok()) return BZ_CONFIG_ERROR;
-
- if (strm == NULL ||
- blockSize100k < 1 || blockSize100k > 9 ||
- workFactor < 0 || workFactor > 250)
- return BZ_PARAM_ERROR;
-
- if (workFactor == 0) workFactor = 30;
- if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
- if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
-
- s = (EState *) BZALLOC( sizeof(EState) );
- if (s == NULL) return BZ_MEM_ERROR;
- s->strm = strm;
-
- s->arr1 = NULL;
- s->arr2 = NULL;
- s->ftab = NULL;
-
- n = 100000 * blockSize100k;
- s->arr1 = (UInt32 *) BZALLOC( n * sizeof(UInt32) );
- s->arr2 = (UInt32 *) BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
- s->ftab = (UInt32 *) BZALLOC( 65537 * sizeof(UInt32) );
-
- if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
- if (s->arr1 != NULL) BZFREE(s->arr1);
- if (s->arr2 != NULL) BZFREE(s->arr2);
- if (s->ftab != NULL) BZFREE(s->ftab);
- if (s != NULL) BZFREE(s);
- return BZ_MEM_ERROR;
- }
-
- s->blockNo = 0;
- s->state = BZ_S_INPUT;
- s->mode = BZ_M_RUNNING;
- s->combinedCRC = 0;
- s->blockSize100k = blockSize100k;
- s->nblockMAX = 100000 * blockSize100k - 19;
- s->verbosity = verbosity;
- s->workFactor = workFactor;
-
- s->block = (UChar*)s->arr2;
- s->mtfv = (UInt16*)s->arr1;
- s->zbits = NULL;
- s->ptr = (UInt32*)s->arr1;
-
- strm->state = s;
- strm->total_in_lo32 = 0;
- strm->total_in_hi32 = 0;
- strm->total_out_lo32 = 0;
- strm->total_out_hi32 = 0;
- init_RL ( s );
- prepare_new_block ( s );
- return BZ_OK;
-}
-
-
-/*---------------------------------------------------*/
-static
-void add_pair_to_block ( EState* s )
-{
- Int32 i;
- UChar ch = (UChar)(s->state_in_ch);
- for (i = 0; i < s->state_in_len; i++) {
- BZ_UPDATE_CRC( s->blockCRC, ch );
- }
- s->inUse[s->state_in_ch] = True;
- switch (s->state_in_len) {
- case 1:
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- break;
- case 2:
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- break;
- case 3:
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- break;
- default:
- s->inUse[s->state_in_len-4] = True;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = (UChar)ch; s->nblock++;
- s->block[s->nblock] = ((UChar)(s->state_in_len-4));
- s->nblock++;
- break;
- }
-}
-
-
-/*---------------------------------------------------*/
-static
-void flush_RL ( EState* s )
-{
- if (s->state_in_ch < 256) add_pair_to_block ( s );
- init_RL ( s );
-}
-
-
-/*---------------------------------------------------*/
-#define ADD_CHAR_TO_BLOCK(zs,zchh0) \
-{ \
- UInt32 zchh = (UInt32)(zchh0); \
- /*-- fast track the common case --*/ \
- if (zchh != zs->state_in_ch && \
- zs->state_in_len == 1) { \
- UChar ch = (UChar)(zs->state_in_ch); \
- BZ_UPDATE_CRC( zs->blockCRC, ch ); \
- zs->inUse[zs->state_in_ch] = True; \
- zs->block[zs->nblock] = (UChar)ch; \
- zs->nblock++; \
- zs->state_in_ch = zchh; \
- } \
- else \
- /*-- general, uncommon cases --*/ \
- if (zchh != zs->state_in_ch || \
- zs->state_in_len == 255) { \
- if (zs->state_in_ch < 256) \
- add_pair_to_block ( zs ); \
- zs->state_in_ch = zchh; \
- zs->state_in_len = 1; \
- } else { \
- zs->state_in_len++; \
- } \
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool copy_input_until_stop ( EState* s )
-{
- Bool progress_in = False;
-
- if (s->mode == BZ_M_RUNNING) {
-
- /*-- fast track the common case --*/
- while (True) {
- /*-- block full? --*/
- if (s->nblock >= s->nblockMAX) break;
- /*-- no input? --*/
- if (s->strm->avail_in == 0) break;
- progress_in = True;
- ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
- s->strm->next_in++;
- s->strm->avail_in--;
- s->strm->total_in_lo32++;
- if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
- }
-
- } else {
-
- /*-- general, uncommon case --*/
- while (True) {
- /*-- block full? --*/
- if (s->nblock >= s->nblockMAX) break;
- /*-- no input? --*/
- if (s->strm->avail_in == 0) break;
- /*-- flush/finish end? --*/
- if (s->avail_in_expect == 0) break;
- progress_in = True;
- ADD_CHAR_TO_BLOCK ( s, (UInt32)(*((UChar*)(s->strm->next_in))) );
- s->strm->next_in++;
- s->strm->avail_in--;
- s->strm->total_in_lo32++;
- if (s->strm->total_in_lo32 == 0) s->strm->total_in_hi32++;
- s->avail_in_expect--;
- }
- }
- return progress_in;
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool copy_output_until_stop ( EState* s )
-{
- Bool progress_out = False;
-
- while (True) {
-
- /*-- no output space? --*/
- if (s->strm->avail_out == 0) break;
-
- /*-- block done? --*/
- if (s->state_out_pos >= s->numZ) break;
-
- progress_out = True;
- *(s->strm->next_out) = s->zbits[s->state_out_pos];
- s->state_out_pos++;
- s->strm->avail_out--;
- s->strm->next_out++;
- s->strm->total_out_lo32++;
- if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
- }
-
- return progress_out;
-}
-
-
-/*---------------------------------------------------*/
-static
-Bool handle_compress ( bz_stream* strm )
-{
- Bool progress_in = False;
- Bool progress_out = False;
- EState* s = (EState *) strm->state;
-
- while (True) {
-
- if (s->state == BZ_S_OUTPUT) {
- progress_out |= copy_output_until_stop ( s );
- if (s->state_out_pos < s->numZ) break;
- if (s->mode == BZ_M_FINISHING &&
- s->avail_in_expect == 0 &&
- isempty_RL(s)) break;
- prepare_new_block ( s );
- s->state = BZ_S_INPUT;
- if (s->mode == BZ_M_FLUSHING &&
- s->avail_in_expect == 0 &&
- isempty_RL(s)) break;
- }
-
- if (s->state == BZ_S_INPUT) {
- progress_in |= copy_input_until_stop ( s );
- if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) {
- flush_RL ( s );
- BZ2_compressBlock ( s, (Bool)(s->mode == BZ_M_FINISHING) );
- s->state = BZ_S_OUTPUT;
- }
- else
- if (s->nblock >= s->nblockMAX) {
- BZ2_compressBlock ( s, False );
- s->state = BZ_S_OUTPUT;
- }
- else
- if (s->strm->avail_in == 0) {
- break;
- }
- }
-
- }
-
- return progress_in || progress_out;
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action )
-{
- Bool progress;
- EState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
- s = (EState *) strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
- preswitch:
- switch (s->mode) {
-
- case BZ_M_IDLE:
- return BZ_SEQUENCE_ERROR;
-
- case BZ_M_RUNNING:
- if (action == BZ_RUN) {
- progress = handle_compress ( strm );
- return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;
- }
- else
- if (action == BZ_FLUSH) {
- s->avail_in_expect = strm->avail_in;
- s->mode = BZ_M_FLUSHING;
- goto preswitch;
- }
- else
- if (action == BZ_FINISH) {
- s->avail_in_expect = strm->avail_in;
- s->mode = BZ_M_FINISHING;
- goto preswitch;
- }
- else
- return BZ_PARAM_ERROR;
-
- case BZ_M_FLUSHING:
- if (action != BZ_FLUSH) return BZ_SEQUENCE_ERROR;
- if (s->avail_in_expect != s->strm->avail_in)
- return BZ_SEQUENCE_ERROR;
- progress = handle_compress ( strm );
- if (s->avail_in_expect > 0 || !isempty_RL(s) ||
- s->state_out_pos < s->numZ) return BZ_FLUSH_OK;
- s->mode = BZ_M_RUNNING;
- return BZ_RUN_OK;
-
- case BZ_M_FINISHING:
- if (action != BZ_FINISH) return BZ_SEQUENCE_ERROR;
- if (s->avail_in_expect != s->strm->avail_in)
- return BZ_SEQUENCE_ERROR;
- progress = handle_compress ( strm );
- if (!progress) return BZ_SEQUENCE_ERROR;
- if (s->avail_in_expect > 0 || !isempty_RL(s) ||
- s->state_out_pos < s->numZ) return BZ_FINISH_OK;
- s->mode = BZ_M_IDLE;
- return BZ_STREAM_END;
- }
- return BZ_OK; /*--not reached--*/
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm )
-{
- EState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
- s = (EState *) strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
- if (s->arr1 != NULL) BZFREE(s->arr1);
- if (s->arr2 != NULL) BZFREE(s->arr2);
- if (s->ftab != NULL) BZFREE(s->ftab);
- BZFREE(strm->state);
-
- strm->state = NULL;
-
- return BZ_OK;
-}
-
-
-/*---------------------------------------------------*/
-/*--- Decompression stuff ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompressInit)
- ( bz_stream* strm,
- int verbosity,
- int small )
-{
- DState* s;
-
- if (!bz_config_ok()) return BZ_CONFIG_ERROR;
-
- if (strm == NULL) return BZ_PARAM_ERROR;
- if (small != 0 && small != 1) return BZ_PARAM_ERROR;
- if (verbosity < 0 || verbosity > 4) return BZ_PARAM_ERROR;
-
- if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
- if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
-
- s = (DState *) BZALLOC( sizeof(DState) );
- if (s == NULL) return BZ_MEM_ERROR;
- s->strm = strm;
- strm->state = s;
- s->state = BZ_X_MAGIC_1;
- s->bsLive = 0;
- s->bsBuff = 0;
- s->calculatedCombinedCRC = 0;
- strm->total_in_lo32 = 0;
- strm->total_in_hi32 = 0;
- strm->total_out_lo32 = 0;
- strm->total_out_hi32 = 0;
- s->smallDecompress = (Bool)small;
- s->ll4 = NULL;
- s->ll16 = NULL;
- s->tt = NULL;
- s->currBlockNo = 0;
- s->verbosity = verbosity;
-
- return BZ_OK;
-}
-
-
-/*---------------------------------------------------*/
-/* Return True iff data corruption is discovered.
- Returns False if there is no problem.
-*/
-static
-Bool unRLE_obuf_to_output_FAST ( DState* s )
-{
- UChar k1;
-
- if (s->blockRandomised) {
-
- while (True) {
- /* try to finish existing run */
- while (True) {
- if (s->strm->avail_out == 0) return False;
- if (s->state_out_len == 0) break;
- *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
- BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
- s->state_out_len--;
- s->strm->next_out++;
- s->strm->avail_out--;
- s->strm->total_out_lo32++;
- if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
- }
-
- /* can a new run be started? */
- if (s->nblock_used == s->save_nblock+1) return False;
-
- /* Only caused by corrupt data stream? */
- if (s->nblock_used > s->save_nblock+1)
- return True;
-
- s->state_out_len = 1;
- s->state_out_ch = s->k0;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 2;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 3;
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- BZ_GET_FAST(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- s->state_out_len = ((Int32)k1) + 4;
- BZ_GET_FAST(s->k0); BZ_RAND_UPD_MASK;
- s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
- }
-
- } else {
-
- /* restore */
- UInt32 c_calculatedBlockCRC = s->calculatedBlockCRC;
- UChar c_state_out_ch = s->state_out_ch;
- Int32 c_state_out_len = s->state_out_len;
- Int32 c_nblock_used = s->nblock_used;
- Int32 c_k0 = s->k0;
- UInt32* c_tt = s->tt;
- UInt32 c_tPos = s->tPos;
- char* cs_next_out = s->strm->next_out;
- unsigned int cs_avail_out = s->strm->avail_out;
- Int32 ro_blockSize100k = s->blockSize100k;
- /* end restore */
-
- UInt32 avail_out_INIT = cs_avail_out;
- Int32 s_save_nblockPP = s->save_nblock+1;
- unsigned int total_out_lo32_old;
-
- while (True) {
-
- /* try to finish existing run */
- if (c_state_out_len > 0) {
- while (True) {
- if (cs_avail_out == 0) goto return_notr;
- if (c_state_out_len == 1) break;
- *( (UChar*)(cs_next_out) ) = c_state_out_ch;
- BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
- c_state_out_len--;
- cs_next_out++;
- cs_avail_out--;
- }
- s_state_out_len_eq_one:
- {
- if (cs_avail_out == 0) {
- c_state_out_len = 1; goto return_notr;
- };
- *( (UChar*)(cs_next_out) ) = c_state_out_ch;
- BZ_UPDATE_CRC ( c_calculatedBlockCRC, c_state_out_ch );
- cs_next_out++;
- cs_avail_out--;
- }
- }
- /* Only caused by corrupt data stream? */
- if (c_nblock_used > s_save_nblockPP)
- return True;
-
- /* can a new run be started? */
- if (c_nblock_used == s_save_nblockPP) {
- c_state_out_len = 0; goto return_notr;
- };
- c_state_out_ch = c_k0;
- BZ_GET_FAST_C(k1); c_nblock_used++;
- if (k1 != c_k0) {
- c_k0 = k1; goto s_state_out_len_eq_one;
- };
- if (c_nblock_used == s_save_nblockPP)
- goto s_state_out_len_eq_one;
-
- c_state_out_len = 2;
- BZ_GET_FAST_C(k1); c_nblock_used++;
- if (c_nblock_used == s_save_nblockPP) continue;
- if (k1 != c_k0) { c_k0 = k1; continue; };
-
- c_state_out_len = 3;
- BZ_GET_FAST_C(k1); c_nblock_used++;
- if (c_nblock_used == s_save_nblockPP) continue;
- if (k1 != c_k0) { c_k0 = k1; continue; };
-
- BZ_GET_FAST_C(k1); c_nblock_used++;
- c_state_out_len = ((Int32)k1) + 4;
- BZ_GET_FAST_C(c_k0); c_nblock_used++;
- }
-
- return_notr:
- total_out_lo32_old = s->strm->total_out_lo32;
- s->strm->total_out_lo32 += (avail_out_INIT - cs_avail_out);
- if (s->strm->total_out_lo32 < total_out_lo32_old)
- s->strm->total_out_hi32++;
-
- /* save */
- s->calculatedBlockCRC = c_calculatedBlockCRC;
- s->state_out_ch = c_state_out_ch;
- s->state_out_len = c_state_out_len;
- s->nblock_used = c_nblock_used;
- s->k0 = c_k0;
- s->tt = c_tt;
- s->tPos = c_tPos;
- s->strm->next_out = cs_next_out;
- s->strm->avail_out = cs_avail_out;
- /* end save */
- }
- return False;
-}
-
-
-
-/*---------------------------------------------------*/
-Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
-{
- Int32 nb, na, mid;
- nb = 0;
- na = 256;
- do {
- mid = (nb + na) >> 1;
- if (indx >= cftab[mid]) nb = mid; else na = mid;
- }
- while (na - nb != 1);
- return nb;
-}
-
-
-/*---------------------------------------------------*/
-/* Return True iff data corruption is discovered.
- Returns False if there is no problem.
-*/
-static
-Bool unRLE_obuf_to_output_SMALL ( DState* s )
-{
- UChar k1;
-
- if (s->blockRandomised) {
-
- while (True) {
- /* try to finish existing run */
- while (True) {
- if (s->strm->avail_out == 0) return False;
- if (s->state_out_len == 0) break;
- *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
- BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
- s->state_out_len--;
- s->strm->next_out++;
- s->strm->avail_out--;
- s->strm->total_out_lo32++;
- if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
- }
-
- /* can a new run be started? */
- if (s->nblock_used == s->save_nblock+1) return False;
-
- /* Only caused by corrupt data stream? */
- if (s->nblock_used > s->save_nblock+1)
- return True;
-
- s->state_out_len = 1;
- s->state_out_ch = s->k0;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 2;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 3;
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- BZ_GET_SMALL(k1); BZ_RAND_UPD_MASK;
- k1 ^= BZ_RAND_MASK; s->nblock_used++;
- s->state_out_len = ((Int32)k1) + 4;
- BZ_GET_SMALL(s->k0); BZ_RAND_UPD_MASK;
- s->k0 ^= BZ_RAND_MASK; s->nblock_used++;
- }
-
- } else {
-
- while (True) {
- /* try to finish existing run */
- while (True) {
- if (s->strm->avail_out == 0) return False;
- if (s->state_out_len == 0) break;
- *( (UChar*)(s->strm->next_out) ) = s->state_out_ch;
- BZ_UPDATE_CRC ( s->calculatedBlockCRC, s->state_out_ch );
- s->state_out_len--;
- s->strm->next_out++;
- s->strm->avail_out--;
- s->strm->total_out_lo32++;
- if (s->strm->total_out_lo32 == 0) s->strm->total_out_hi32++;
- }
-
- /* can a new run be started? */
- if (s->nblock_used == s->save_nblock+1) return False;
-
- /* Only caused by corrupt data stream? */
- if (s->nblock_used > s->save_nblock+1)
- return True;
-
- s->state_out_len = 1;
- s->state_out_ch = s->k0;
- BZ_GET_SMALL(k1); s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 2;
- BZ_GET_SMALL(k1); s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- s->state_out_len = 3;
- BZ_GET_SMALL(k1); s->nblock_used++;
- if (s->nblock_used == s->save_nblock+1) continue;
- if (k1 != s->k0) { s->k0 = k1; continue; };
-
- BZ_GET_SMALL(k1); s->nblock_used++;
- s->state_out_len = ((Int32)k1) + 4;
- BZ_GET_SMALL(s->k0); s->nblock_used++;
- }
-
- }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompress) ( bz_stream *strm )
-{
- Bool corrupt;
- DState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
- s = (DState *) strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
- while (True) {
- if (s->state == BZ_X_IDLE) return BZ_SEQUENCE_ERROR;
- if (s->state == BZ_X_OUTPUT) {
- if (s->smallDecompress)
- corrupt = unRLE_obuf_to_output_SMALL ( s ); else
- corrupt = unRLE_obuf_to_output_FAST ( s );
- if (corrupt) return BZ_DATA_ERROR;
- if (s->nblock_used == s->save_nblock+1 && s->state_out_len == 0) {
- BZ_FINALISE_CRC ( s->calculatedBlockCRC );
- if (s->verbosity >= 3)
- VPrintf2 ( " {0x%08x, 0x%08x}", s->storedBlockCRC,
- s->calculatedBlockCRC );
- if (s->verbosity >= 2) VPrintf0 ( "]" );
- if (s->calculatedBlockCRC != s->storedBlockCRC)
- return BZ_DATA_ERROR;
- s->calculatedCombinedCRC
- = (s->calculatedCombinedCRC << 1) |
- (s->calculatedCombinedCRC >> 31);
- s->calculatedCombinedCRC ^= s->calculatedBlockCRC;
- s->state = BZ_X_BLKHDR_1;
- } else {
- return BZ_OK;
- }
- }
- if (s->state >= BZ_X_MAGIC_1) {
- Int32 r = BZ2_decompress ( s );
- if (r == BZ_STREAM_END) {
- if (s->verbosity >= 3)
- VPrintf2 ( "\n combined CRCs: stored = 0x%08x, computed = 0x%08x",
- s->storedCombinedCRC, s->calculatedCombinedCRC );
- if (s->calculatedCombinedCRC != s->storedCombinedCRC)
- return BZ_DATA_ERROR;
- return r;
- }
- if (s->state != BZ_X_OUTPUT) return r;
- }
- }
-
-#ifdef UNREACHED
- AssertH ( 0, 6001 );
-
- return 0; /*NOTREACHED*/
-#endif
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm )
-{
- DState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
- s = (DState *) strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
- if (s->tt != NULL) BZFREE(s->tt);
- if (s->ll16 != NULL) BZFREE(s->ll16);
- if (s->ll4 != NULL) BZFREE(s->ll4);
-
- BZFREE(strm->state);
- strm->state = NULL;
-
- return BZ_OK;
-}
-
-
-#ifndef BZ_NO_STDIO
-/*---------------------------------------------------*/
-/*--- File I/O stuff ---*/
-/*---------------------------------------------------*/
-
-#define BZ_SETERR(eee) \
-{ \
- if (bzerror != NULL) *bzerror = eee; \
- if (bzf != NULL) bzf->lastErr = eee; \
-}
-
-typedef
- struct {
- FILE* handle;
- Char buf[BZ_MAX_UNUSED];
- Int32 bufN;
- Bool writing;
- bz_stream strm;
- Int32 lastErr;
- Bool initialisedOk;
- }
- bzFile;
-
-
-/*---------------------------------------------*/
-static Bool myfeof ( FILE* f )
-{
- Int32 c = fgetc ( f );
- if (c == EOF) return True;
- ungetc ( c, f );
- return False;
-}
-
-
-/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzWriteOpen)
- ( int* bzerror,
- FILE* f,
- int blockSize100k,
- int verbosity,
- int workFactor )
-{
- Int32 ret;
- bzFile* bzf = NULL;
-
- BZ_SETERR(BZ_OK);
-
- if (f == NULL ||
- (blockSize100k < 1 || blockSize100k > 9) ||
- (workFactor < 0 || workFactor > 250) ||
- (verbosity < 0 || verbosity > 4))
- { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
-
- if (ferror(f))
- { BZ_SETERR(BZ_IO_ERROR); return NULL; };
-
- bzf = (bzFile *) malloc ( sizeof(bzFile) );
- if (bzf == NULL)
- { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
-
- BZ_SETERR(BZ_OK);
- bzf->initialisedOk = False;
- bzf->bufN = 0;
- bzf->handle = f;
- bzf->writing = True;
- bzf->strm.bzalloc = NULL;
- bzf->strm.bzfree = NULL;
- bzf->strm.opaque = NULL;
-
- if (workFactor == 0) workFactor = 30;
- ret = BZ2_bzCompressInit ( &(bzf->strm), blockSize100k,
- verbosity, workFactor );
- if (ret != BZ_OK)
- { BZ_SETERR(ret); free(bzf); return NULL; };
-
- bzf->strm.avail_in = 0;
- bzf->initialisedOk = True;
- return bzf;
-}
-
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzWrite)
- ( int* bzerror,
- BZFILE* b,
- void* buf,
- int len )
-{
- Int32 n, n2, ret;
- bzFile* bzf = (bzFile*)b;
-
- BZ_SETERR(BZ_OK);
- if (bzf == NULL || buf == NULL || len < 0)
- { BZ_SETERR(BZ_PARAM_ERROR); return; };
- if (!(bzf->writing))
- { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
- if (ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return; };
-
- if (len == 0)
- { BZ_SETERR(BZ_OK); return; };
-
- bzf->strm.avail_in = len;
- bzf->strm.next_in = (char *) buf;
-
- while (True) {
- bzf->strm.avail_out = BZ_MAX_UNUSED;
- bzf->strm.next_out = bzf->buf;
- ret = BZ2_bzCompress ( &(bzf->strm), BZ_RUN );
- if (ret != BZ_RUN_OK)
- { BZ_SETERR(ret); return; };
-
- if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
- n = BZ_MAX_UNUSED - bzf->strm.avail_out;
- n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
- n, bzf->handle );
- if (n != n2 || ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return; };
- }
-
- if (bzf->strm.avail_in == 0)
- { BZ_SETERR(BZ_OK); return; };
- }
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzWriteClose)
- ( int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in,
- unsigned int* nbytes_out )
-{
- BZ2_bzWriteClose64 ( bzerror, b, abandon,
- nbytes_in, NULL, nbytes_out, NULL );
-}
-
-
-void BZ_API(BZ2_bzWriteClose64)
- ( int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in_lo32,
- unsigned int* nbytes_in_hi32,
- unsigned int* nbytes_out_lo32,
- unsigned int* nbytes_out_hi32 )
-{
- Int32 n, n2, ret;
- bzFile* bzf = (bzFile*)b;
-
- if (bzf == NULL)
- { BZ_SETERR(BZ_OK); return; };
- if (!(bzf->writing))
- { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
- if (ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return; };
-
- if (nbytes_in_lo32 != NULL) *nbytes_in_lo32 = 0;
- if (nbytes_in_hi32 != NULL) *nbytes_in_hi32 = 0;
- if (nbytes_out_lo32 != NULL) *nbytes_out_lo32 = 0;
- if (nbytes_out_hi32 != NULL) *nbytes_out_hi32 = 0;
-
- if ((!abandon) && bzf->lastErr == BZ_OK) {
- while (True) {
- bzf->strm.avail_out = BZ_MAX_UNUSED;
- bzf->strm.next_out = bzf->buf;
- ret = BZ2_bzCompress ( &(bzf->strm), BZ_FINISH );
- if (ret != BZ_FINISH_OK && ret != BZ_STREAM_END)
- { BZ_SETERR(ret); return; };
-
- if (bzf->strm.avail_out < BZ_MAX_UNUSED) {
- n = BZ_MAX_UNUSED - bzf->strm.avail_out;
- n2 = fwrite ( (void*)(bzf->buf), sizeof(UChar),
- n, bzf->handle );
- if (n != n2 || ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return; };
- }
-
- if (ret == BZ_STREAM_END) break;
- }
- }
-
- if ( !abandon && !ferror ( bzf->handle ) ) {
- fflush ( bzf->handle );
- if (ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return; };
- }
-
- if (nbytes_in_lo32 != NULL)
- *nbytes_in_lo32 = bzf->strm.total_in_lo32;
- if (nbytes_in_hi32 != NULL)
- *nbytes_in_hi32 = bzf->strm.total_in_hi32;
- if (nbytes_out_lo32 != NULL)
- *nbytes_out_lo32 = bzf->strm.total_out_lo32;
- if (nbytes_out_hi32 != NULL)
- *nbytes_out_hi32 = bzf->strm.total_out_hi32;
-
- BZ_SETERR(BZ_OK);
- BZ2_bzCompressEnd ( &(bzf->strm) );
- free ( bzf );
-}
-
-
-/*---------------------------------------------------*/
-BZFILE* BZ_API(BZ2_bzReadOpen)
- ( int* bzerror,
- FILE* f,
- int verbosity,
- int small,
- void* unused,
- int nUnused )
-{
- bzFile* bzf = NULL;
- int ret;
-
- BZ_SETERR(BZ_OK);
-
- if (f == NULL ||
- (small != 0 && small != 1) ||
- (verbosity < 0 || verbosity > 4) ||
- (unused == NULL && nUnused != 0) ||
- (unused != NULL && (nUnused < 0 || nUnused > BZ_MAX_UNUSED)))
- { BZ_SETERR(BZ_PARAM_ERROR); return NULL; };
-
- if (ferror(f))
- { BZ_SETERR(BZ_IO_ERROR); return NULL; };
-
- bzf = (bzFile *) malloc ( sizeof(bzFile) );
- if (bzf == NULL)
- { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
-
- BZ_SETERR(BZ_OK);
-
- bzf->initialisedOk = False;
- bzf->handle = f;
- bzf->bufN = 0;
- bzf->writing = False;
- bzf->strm.bzalloc = NULL;
- bzf->strm.bzfree = NULL;
- bzf->strm.opaque = NULL;
-
- while (nUnused > 0) {
- bzf->buf[bzf->bufN] = *((UChar*)(unused)); bzf->bufN++;
- unused = ((void*)( 1 + ((UChar*)(unused)) ));
- nUnused--;
- }
-
- ret = BZ2_bzDecompressInit ( &(bzf->strm), verbosity, small );
- if (ret != BZ_OK)
- { BZ_SETERR(ret); free(bzf); return NULL; };
-
- bzf->strm.avail_in = bzf->bufN;
- bzf->strm.next_in = bzf->buf;
-
- bzf->initialisedOk = True;
- return bzf;
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzReadClose) ( int *bzerror, BZFILE *b )
-{
- bzFile* bzf = (bzFile*)b;
-
- BZ_SETERR(BZ_OK);
- if (bzf == NULL)
- { BZ_SETERR(BZ_OK); return; };
-
- if (bzf->writing)
- { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
-
- if (bzf->initialisedOk)
- (void)BZ2_bzDecompressEnd ( &(bzf->strm) );
- free ( bzf );
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzRead)
- ( int* bzerror,
- BZFILE* b,
- void* buf,
- int len )
-{
- Int32 n, ret;
- bzFile* bzf = (bzFile*)b;
-
- BZ_SETERR(BZ_OK);
-
- if (bzf == NULL || buf == NULL || len < 0)
- { BZ_SETERR(BZ_PARAM_ERROR); return 0; };
-
- if (bzf->writing)
- { BZ_SETERR(BZ_SEQUENCE_ERROR); return 0; };
-
- if (len == 0)
- { BZ_SETERR(BZ_OK); return 0; };
-
- bzf->strm.avail_out = len;
- bzf->strm.next_out = (char *) buf;
-
- while (True) {
-
- if (ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return 0; };
-
- if (bzf->strm.avail_in == 0 && !myfeof(bzf->handle)) {
- n = fread ( bzf->buf, sizeof(UChar),
- BZ_MAX_UNUSED, bzf->handle );
- if (ferror(bzf->handle))
- { BZ_SETERR(BZ_IO_ERROR); return 0; };
- bzf->bufN = n;
- bzf->strm.avail_in = bzf->bufN;
- bzf->strm.next_in = bzf->buf;
- }
-
- ret = BZ2_bzDecompress ( &(bzf->strm) );
-
- if (ret != BZ_OK && ret != BZ_STREAM_END)
- { BZ_SETERR(ret); return 0; };
-
- if (ret == BZ_OK && myfeof(bzf->handle) &&
- bzf->strm.avail_in == 0 && bzf->strm.avail_out > 0)
- { BZ_SETERR(BZ_UNEXPECTED_EOF); return 0; };
-
- if (ret == BZ_STREAM_END)
- { BZ_SETERR(BZ_STREAM_END);
- return len - bzf->strm.avail_out; };
- if (bzf->strm.avail_out == 0)
- { BZ_SETERR(BZ_OK); return len; };
-
- }
-
-#ifdef UNREACHED
- return 0; /*not reached*/
-#endif
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzReadGetUnused)
- ( int* bzerror,
- BZFILE* b,
- void** unused,
- int* nUnused )
-{
- bzFile* bzf = (bzFile*)b;
- if (bzf == NULL)
- { BZ_SETERR(BZ_PARAM_ERROR); return; };
- if (bzf->lastErr != BZ_STREAM_END)
- { BZ_SETERR(BZ_SEQUENCE_ERROR); return; };
- if (unused == NULL || nUnused == NULL)
- { BZ_SETERR(BZ_PARAM_ERROR); return; };
-
- BZ_SETERR(BZ_OK);
- *nUnused = bzf->strm.avail_in;
- *unused = bzf->strm.next_in;
-}
-#endif
-
-
-/*---------------------------------------------------*/
-/*--- Misc convenience stuff ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffCompress)
- ( char* dest,
- unsigned int* destLen,
- char* source,
- unsigned int sourceLen,
- int blockSize100k,
- int verbosity,
- int workFactor )
-{
- bz_stream strm;
- int ret;
-
- if (dest == NULL || destLen == NULL ||
- source == NULL ||
- blockSize100k < 1 || blockSize100k > 9 ||
- verbosity < 0 || verbosity > 4 ||
- workFactor < 0 || workFactor > 250)
- return BZ_PARAM_ERROR;
-
- if (workFactor == 0) workFactor = 30;
- strm.bzalloc = NULL;
- strm.bzfree = NULL;
- strm.opaque = NULL;
- ret = BZ2_bzCompressInit ( &strm, blockSize100k,
- verbosity, workFactor );
- if (ret != BZ_OK) return ret;
-
- strm.next_in = source;
- strm.next_out = dest;
- strm.avail_in = sourceLen;
- strm.avail_out = *destLen;
-
- ret = BZ2_bzCompress ( &strm, BZ_FINISH );
- if (ret == BZ_FINISH_OK) goto output_overflow;
- if (ret != BZ_STREAM_END) goto errhandler;
-
- /* normal termination */
- *destLen -= strm.avail_out;
- BZ2_bzCompressEnd ( &strm );
- return BZ_OK;
-
- output_overflow:
- BZ2_bzCompressEnd ( &strm );
- return BZ_OUTBUFF_FULL;
-
- errhandler:
- BZ2_bzCompressEnd ( &strm );
- return ret;
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzBuffToBuffDecompress)
- ( char* dest,
- unsigned int* destLen,
- char* source,
- unsigned int sourceLen,
- int small,
- int verbosity )
-{
- bz_stream strm;
- int ret;
-
- if (dest == NULL || destLen == NULL ||
- source == NULL ||
- (small != 0 && small != 1) ||
- verbosity < 0 || verbosity > 4)
- return BZ_PARAM_ERROR;
-
- strm.bzalloc = NULL;
- strm.bzfree = NULL;
- strm.opaque = NULL;
- ret = BZ2_bzDecompressInit ( &strm, verbosity, small );
- if (ret != BZ_OK) return ret;
-
- strm.next_in = source;
- strm.next_out = dest;
- strm.avail_in = sourceLen;
- strm.avail_out = *destLen;
-
- ret = BZ2_bzDecompress ( &strm );
- if (ret == BZ_OK) goto output_overflow_or_eof;
- if (ret != BZ_STREAM_END) goto errhandler;
-
- /* normal termination */
- *destLen -= strm.avail_out;
- BZ2_bzDecompressEnd ( &strm );
- return BZ_OK;
-
- output_overflow_or_eof:
- if (strm.avail_out > 0) {
- BZ2_bzDecompressEnd ( &strm );
- return BZ_UNEXPECTED_EOF;
- } else {
- BZ2_bzDecompressEnd ( &strm );
- return BZ_OUTBUFF_FULL;
- };
-
- errhandler:
- BZ2_bzDecompressEnd ( &strm );
- return ret;
-}
-
-
-/*---------------------------------------------------*/
-/*--
- Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
- to support better zlib compatibility.
- This code is not _officially_ part of libbzip2 (yet);
- I haven't tested it, documented it, or considered the
- threading-safeness of it.
- If this code breaks, please contact both Yoshioka and me.
---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-/*--
- return version like "0.9.5d, 4-Sept-1999".
---*/
-const char * BZ_API(BZ2_bzlibVersion)(void)
-{
- return BZ_VERSION;
-}
-
-
-#ifndef BZ_NO_STDIO
-/*---------------------------------------------------*/
-
-#if defined(_WIN32) || defined(OS2) || defined(MSDOS)
-# include
-# include
-# define SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY)
-#else
-# define SET_BINARY_MODE(file)
-#endif
-
-#if !defined(fdopen) && defined(HAVE_FDOPEN)
- FILE *fdopen(int fildes, const char *mode)
-#ifdef __cplusplus
- throw ()
-#endif
- ;
-#endif
-
-static
-BZFILE * bzopen_or_bzdopen
- ( const char *path, /* no use when bzdopen */
- int fd, /* no use when bzdopen */
- const char *mode,
- int open_mode) /* bzopen: 0, bzdopen:1 */
-{
- int bzerr;
- char unused[BZ_MAX_UNUSED];
- int blockSize100k = 9;
- int writing = 0;
- char mode2[10] = "";
- FILE *fp = NULL;
- BZFILE *bzfp = NULL;
- int verbosity = 0;
- int workFactor = 30;
- int smallMode = 0;
- int nUnused = 0;
-
- if (mode == NULL) return NULL;
- while (*mode) {
- switch (*mode) {
- case 'r':
- writing = 0; break;
- case 'w':
- writing = 1; break;
- case 's':
- smallMode = 1; break;
- default:
- if (isdigit((int)(*mode))) {
- blockSize100k = *mode-BZ_HDR_0;
- }
- }
- mode++;
- }
- strcat(mode2, writing ? "w" : "r" );
- strcat(mode2,"b"); /* binary mode */
-
- if (open_mode==0) {
- if (path==NULL || strcmp(path,"")==0) {
- fp = (writing ? stdout : stdin);
- SET_BINARY_MODE(fp);
- } else {
- fp = fopen(path,mode2);
- }
- } else {
-#ifndef HAVE_FDOPEN
- fp = NULL;
-#else
- fp = fdopen(fd,mode2);
-#endif
- }
- if (fp == NULL) return NULL;
-
- if (writing) {
- /* Guard against total chaos and anarchy -- JRS */
- if (blockSize100k < 1) blockSize100k = 1;
- if (blockSize100k > 9) blockSize100k = 9;
- bzfp = BZ2_bzWriteOpen(&bzerr,fp,blockSize100k,
- verbosity,workFactor);
- } else {
- bzfp = BZ2_bzReadOpen(&bzerr,fp,verbosity,smallMode,
- unused,nUnused);
- }
- if (bzfp == NULL) {
- if (fp != stdin && fp != stdout) fclose(fp);
- return NULL;
- }
- return bzfp;
-}
-
-
-/*---------------------------------------------------*/
-/*--
- open file for read or write.
- ex) bzopen("file","w9")
- case path="" or NULL => use stdin or stdout.
---*/
-BZFILE * BZ_API(BZ2_bzopen)
- ( const char *path,
- const char *mode )
-{
- return bzopen_or_bzdopen(path,-1,mode,/*bzopen*/0);
-}
-
-
-/*---------------------------------------------------*/
-BZFILE * BZ_API(BZ2_bzdopen)
- ( int fd,
- const char *mode )
-{
- return bzopen_or_bzdopen(NULL,fd,mode,/*bzdopen*/1);
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzread) (BZFILE* b, void* buf, int len )
-{
- int bzerr, nread;
- if (((bzFile*)b)->lastErr == BZ_STREAM_END) return 0;
- nread = BZ2_bzRead(&bzerr,b,buf,len);
- if (bzerr == BZ_OK || bzerr == BZ_STREAM_END) {
- return nread;
- } else {
- return -1;
- }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzwrite) (BZFILE* b, void* buf, int len )
-{
- int bzerr;
-
- BZ2_bzWrite(&bzerr,b,buf,len);
- if(bzerr == BZ_OK){
- return len;
- }else{
- return -1;
- }
-}
-
-
-/*---------------------------------------------------*/
-int BZ_API(BZ2_bzflush) (BZFILE *b)
-{
- /* do nothing now... */
- return 0;
-}
-
-
-/*---------------------------------------------------*/
-void BZ_API(BZ2_bzclose) (BZFILE* b)
-{
- if (b==NULL) return;
-
- int bzerr;
- FILE *fp = ((bzFile *)b)->handle;
-
- if(((bzFile*)b)->writing){
- BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL);
- if(bzerr != BZ_OK){
- BZ2_bzWriteClose(NULL,b,1,NULL,NULL);
- }
- }else{
- BZ2_bzReadClose(&bzerr,b);
- }
- if(fp!=stdin && fp!=stdout){
- fclose(fp);
- }
-}
-
-
-/*---------------------------------------------------*/
-/*--
- return last error code
---*/
-static const char *bzerrorstrings[] = {
- "OK"
- ,"SEQUENCE_ERROR"
- ,"PARAM_ERROR"
- ,"MEM_ERROR"
- ,"DATA_ERROR"
- ,"DATA_ERROR_MAGIC"
- ,"IO_ERROR"
- ,"UNEXPECTED_EOF"
- ,"OUTBUFF_FULL"
- ,"CONFIG_ERROR"
- ,"???" /* for future */
- ,"???" /* for future */
- ,"???" /* for future */
- ,"???" /* for future */
- ,"???" /* for future */
- ,"???" /* for future */
-};
-
-
-const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum)
-{
- int err = ((bzFile *)b)->lastErr;
-
- if(err>0) err = 0;
- *errnum = err;
- return bzerrorstrings[err*-1];
-}
-#endif
-
-
-/*-------------------------------------------------------------*/
-/*--- end bzlib.c ---*/
-/*-------------------------------------------------------------*/
diff -Nru r-base-3.2.3/src/extra/bzip2/bzlib.h r-base-3.3.1/src/extra/bzip2/bzlib.h
--- r-base-3.2.3/src/extra/bzip2/bzlib.h 2010-09-27 22:05:02.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/bzlib.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,282 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Public header file for the library. ---*/
-/*--- bzlib.h ---*/
-/*-------------------------------------------------------------*/
-
-/* ------------------------------------------------------------------
- This file is part of bzip2/libbzip2, a program and library for
- lossless, block-sorting data compression.
-
- bzip2/libbzip2 version 1.0.6 of 6 September 2010
- Copyright (C) 1996-2010 Julian Seward
-
- Please read the WARNING, DISCLAIMER and PATENTS sections in the
- README file.
-
- This program is released under the terms of the license contained
- in the file LICENSE.
- ------------------------------------------------------------------ */
-
-
-#ifndef _BZLIB_H
-#define _BZLIB_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define BZ_RUN 0
-#define BZ_FLUSH 1
-#define BZ_FINISH 2
-
-#define BZ_OK 0
-#define BZ_RUN_OK 1
-#define BZ_FLUSH_OK 2
-#define BZ_FINISH_OK 3
-#define BZ_STREAM_END 4
-#define BZ_SEQUENCE_ERROR (-1)
-#define BZ_PARAM_ERROR (-2)
-#define BZ_MEM_ERROR (-3)
-#define BZ_DATA_ERROR (-4)
-#define BZ_DATA_ERROR_MAGIC (-5)
-#define BZ_IO_ERROR (-6)
-#define BZ_UNEXPECTED_EOF (-7)
-#define BZ_OUTBUFF_FULL (-8)
-#define BZ_CONFIG_ERROR (-9)
-
-typedef
- struct {
- char *next_in;
- unsigned int avail_in;
- unsigned int total_in_lo32;
- unsigned int total_in_hi32;
-
- char *next_out;
- unsigned int avail_out;
- unsigned int total_out_lo32;
- unsigned int total_out_hi32;
-
- void *state;
-
- void *(*bzalloc)(void *,int,int);
- void (*bzfree)(void *,void *);
- void *opaque;
- }
- bz_stream;
-
-
-#ifndef BZ_IMPORT
-#define BZ_EXPORT
-#endif
-
-#ifndef BZ_NO_STDIO
-/* Need a definitition for FILE */
-#include
-#endif
-
-#ifdef _WIN32
-# include
-# ifdef small
- /* windows.h define small to char */
-# undef small
-# endif
-# ifdef BZ_EXPORT
-# define BZ_API(func) WINAPI func
-# define BZ_EXTERN extern
-# else
- /* import windows dll dynamically */
-# define BZ_API(func) (WINAPI * func)
-# define BZ_EXTERN
-# endif
-#else
-# define BZ_API(func) func
-# define BZ_EXTERN extern
-#endif
-
-
-/*-- Core (low-level) library functions --*/
-
-BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
- bz_stream* strm,
- int blockSize100k,
- int verbosity,
- int workFactor
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzCompress) (
- bz_stream* strm,
- int action
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
- bz_stream* strm
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) (
- bz_stream *strm,
- int verbosity,
- int small
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzDecompress) (
- bz_stream* strm
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) (
- bz_stream *strm
- );
-
-
-
-/*-- High(er) level library functions --*/
-
-#ifndef BZ_NO_STDIO
-#define BZ_MAX_UNUSED 5000
-
-typedef void BZFILE;
-
-BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
- int* bzerror,
- FILE* f,
- int verbosity,
- int small,
- void* unused,
- int nUnused
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
- int* bzerror,
- BZFILE* b
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
- int* bzerror,
- BZFILE* b,
- void** unused,
- int* nUnused
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzRead) (
- int* bzerror,
- BZFILE* b,
- void* buf,
- int len
- );
-
-BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
- int* bzerror,
- FILE* f,
- int blockSize100k,
- int verbosity,
- int workFactor
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzWrite) (
- int* bzerror,
- BZFILE* b,
- void* buf,
- int len
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
- int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in,
- unsigned int* nbytes_out
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
- int* bzerror,
- BZFILE* b,
- int abandon,
- unsigned int* nbytes_in_lo32,
- unsigned int* nbytes_in_hi32,
- unsigned int* nbytes_out_lo32,
- unsigned int* nbytes_out_hi32
- );
-#endif
-
-
-/*-- Utility functions --*/
-
-BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
- char* dest,
- unsigned int* destLen,
- char* source,
- unsigned int sourceLen,
- int blockSize100k,
- int verbosity,
- int workFactor
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
- char* dest,
- unsigned int* destLen,
- char* source,
- unsigned int sourceLen,
- int small,
- int verbosity
- );
-
-
-/*--
- Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp)
- to support better zlib compatibility.
- This code is not _officially_ part of libbzip2 (yet);
- I haven't tested it, documented it, or considered the
- threading-safeness of it.
- If this code breaks, please contact both Yoshioka and me.
---*/
-
-BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) (
- void
- );
-
-#ifndef BZ_NO_STDIO
-BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) (
- const char *path,
- const char *mode
- );
-
-BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) (
- int fd,
- const char *mode
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzread) (
- BZFILE* b,
- void* buf,
- int len
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzwrite) (
- BZFILE* b,
- void* buf,
- int len
- );
-
-BZ_EXTERN int BZ_API(BZ2_bzflush) (
- BZFILE* b
- );
-
-BZ_EXTERN void BZ_API(BZ2_bzclose) (
- BZFILE* b
- );
-
-BZ_EXTERN const char * BZ_API(BZ2_bzerror) (
- BZFILE *b,
- int *errnum
- );
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-/*-------------------------------------------------------------*/
-/*--- end bzlib.h ---*/
-/*-------------------------------------------------------------*/
diff -Nru r-base-3.2.3/src/extra/bzip2/bzlib_private.h r-base-3.3.1/src/extra/bzip2/bzlib_private.h
--- r-base-3.2.3/src/extra/bzip2/bzlib_private.h 2010-09-27 22:05:02.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/bzlib_private.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,512 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Private header file for the library. ---*/
-/*--- bzlib_private.h ---*/
-/*-------------------------------------------------------------*/
-
-/* ------------------------------------------------------------------
- This file is part of bzip2/libbzip2, a program and library for
- lossless, block-sorting data compression.
-
- bzip2/libbzip2 version 1.0.6 of 6 September 2010
- Copyright (C) 1996-2010 Julian Seward
-
- Please read the WARNING, DISCLAIMER and PATENTS sections in the
- README file.
-
- This program is released under the terms of the license contained
- in the file LICENSE.
- ------------------------------------------------------------------ */
-
-
-#ifndef _BZLIB_PRIVATE_H
-#define _BZLIB_PRIVATE_H
-
-#include /* for R_INLINE */
-#undef HAVE_FDOPEN /* we may have, but this re-declares it and
- we don't use BZ2_bzdopen */
-#include
-
-#ifndef BZ_NO_STDIO
-#include
-#include
-#include
-#endif
-
-#include "bzlib.h"
-
-
-
-/*-- General stuff. --*/
-
-#define BZ_VERSION "1.0.6, 6-Sept-2010"
-
-typedef char Char;
-typedef unsigned char Bool;
-typedef unsigned char UChar;
-typedef int Int32;
-typedef unsigned int UInt32;
-typedef short Int16;
-typedef unsigned short UInt16;
-
-#define True ((Bool)1)
-#define False ((Bool)0)
-
-#ifndef __GNUC__
-#define __inline__ /* */
-#endif
-
-#ifndef BZ_NO_STDIO
-
-extern void BZ2_bz__AssertH__fail ( int errcode );
-#define AssertH(cond,errcode) \
- { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); }
-
-#if BZ_DEBUG
-#define AssertD(cond,msg) \
- { if (!(cond)) { \
- fprintf ( stderr, \
- "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\
- exit(1); \
- }}
-#else
-#define AssertD(cond,msg) /* */
-#endif
-
-#define VPrintf0(zf) \
- fprintf(stderr,zf)
-#define VPrintf1(zf,za1) \
- fprintf(stderr,zf,za1)
-#define VPrintf2(zf,za1,za2) \
- fprintf(stderr,zf,za1,za2)
-#define VPrintf3(zf,za1,za2,za3) \
- fprintf(stderr,zf,za1,za2,za3)
-#define VPrintf4(zf,za1,za2,za3,za4) \
- fprintf(stderr,zf,za1,za2,za3,za4)
-#define VPrintf5(zf,za1,za2,za3,za4,za5) \
- fprintf(stderr,zf,za1,za2,za3,za4,za5)
-
-#else
-
-extern void bz_internal_error ( int errcode );
-#define AssertH(cond,errcode) \
- { if (!(cond)) bz_internal_error ( errcode ); }
-#define AssertD(cond,msg) do { } while (0)
-#define VPrintf0(zf) do { } while (0)
-#define VPrintf1(zf,za1) do { } while (0)
-#define VPrintf2(zf,za1,za2) do { } while (0)
-#define VPrintf3(zf,za1,za2,za3) do { } while (0)
-#define VPrintf4(zf,za1,za2,za3,za4) do { } while (0)
-#define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0)
-
-#endif
-
-
-#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1)
-#define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp))
-
-
-/*-- Header bytes. --*/
-
-#define BZ_HDR_B 0x42 /* 'B' */
-#define BZ_HDR_Z 0x5a /* 'Z' */
-#define BZ_HDR_h 0x68 /* 'h' */
-#define BZ_HDR_0 0x30 /* '0' */
-
-/*-- Constants for the back end. --*/
-
-#define BZ_MAX_ALPHA_SIZE 258
-#define BZ_MAX_CODE_LEN 23
-
-#define BZ_RUNA 0
-#define BZ_RUNB 1
-
-#define BZ_N_GROUPS 6
-#define BZ_G_SIZE 50
-#define BZ_N_ITERS 4
-
-#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
-
-
-
-/*-- Stuff for randomising repetitive blocks. --*/
-
-extern Int32 BZ2_rNums[512];
-
-#define BZ_RAND_DECLS \
- Int32 rNToGo; \
- Int32 rTPos \
-
-#define BZ_RAND_INIT_MASK \
- s->rNToGo = 0; \
- s->rTPos = 0 \
-
-#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0)
-
-#define BZ_RAND_UPD_MASK \
- if (s->rNToGo == 0) { \
- s->rNToGo = BZ2_rNums[s->rTPos]; \
- s->rTPos++; \
- if (s->rTPos == 512) s->rTPos = 0; \
- } \
- s->rNToGo--;
-
-
-
-/*-- Stuff for doing CRCs. --*/
-
-extern UInt32 BZ2_crc32Table[256];
-
-#define BZ_INITIALISE_CRC(crcVar) \
-{ \
- crcVar = 0xffffffffL; \
-}
-
-#define BZ_FINALISE_CRC(crcVar) \
-{ \
- crcVar = ~(crcVar); \
-}
-
-#define BZ_UPDATE_CRC(crcVar,cha) \
-{ \
- crcVar = (crcVar << 8) ^ \
- BZ2_crc32Table[(crcVar >> 24) ^ \
- ((UChar)cha)]; \
-}
-
-
-
-/*-- States and modes for compression. --*/
-
-#define BZ_M_IDLE 1
-#define BZ_M_RUNNING 2
-#define BZ_M_FLUSHING 3
-#define BZ_M_FINISHING 4
-
-#define BZ_S_OUTPUT 1
-#define BZ_S_INPUT 2
-
-#define BZ_N_RADIX 2
-#define BZ_N_QSORT 12
-#define BZ_N_SHELL 18
-#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
-
-
-
-
-/*-- Structure holding all the compression-side stuff. --*/
-
-typedef
- struct {
- /* pointer back to the struct bz_stream */
- bz_stream* strm;
-
- /* mode this stream is in, and whether inputting */
- /* or outputting data */
- Int32 mode;
- Int32 state;
-
- /* remembers avail_in when flush/finish requested */
- UInt32 avail_in_expect;
-
- /* for doing the block sorting */
- UInt32* arr1;
- UInt32* arr2;
- UInt32* ftab;
- Int32 origPtr;
-
- /* aliases for arr1 and arr2 */
- UInt32* ptr;
- UChar* block;
- UInt16* mtfv;
- UChar* zbits;
-
- /* for deciding when to use the fallback sorting algorithm */
- Int32 workFactor;
-
- /* run-length-encoding of the input */
- UInt32 state_in_ch;
- Int32 state_in_len;
- BZ_RAND_DECLS;
-
- /* input and output limits and current posns */
- Int32 nblock;
- Int32 nblockMAX;
- Int32 numZ;
- Int32 state_out_pos;
-
- /* map of bytes used in block */
- Int32 nInUse;
- Bool inUse[256];
- UChar unseqToSeq[256];
-
- /* the buffer for bit stream creation */
- UInt32 bsBuff;
- Int32 bsLive;
-
- /* block and combined CRCs */
- UInt32 blockCRC;
- UInt32 combinedCRC;
-
- /* misc administratium */
- Int32 verbosity;
- Int32 blockNo;
- Int32 blockSize100k;
-
- /* stuff for coding the MTF values */
- Int32 nMTF;
- Int32 mtfFreq [BZ_MAX_ALPHA_SIZE];
- UChar selector [BZ_MAX_SELECTORS];
- UChar selectorMtf[BZ_MAX_SELECTORS];
-
- UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- /* second dimension: only 3 needed; 4 makes index calculations faster */
- UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4];
-
- }
- EState;
-
-
-
-/*-- externs for compression. --*/
-
-extern void
-BZ2_blockSort ( EState* );
-
-extern void
-BZ2_compressBlock ( EState*, Bool );
-
-extern void
-BZ2_bsInitWrite ( EState* );
-
-extern void
-BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 );
-
-extern void
-BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 );
-
-
-
-/*-- states for decompression. --*/
-
-#define BZ_X_IDLE 1
-#define BZ_X_OUTPUT 2
-
-#define BZ_X_MAGIC_1 10
-#define BZ_X_MAGIC_2 11
-#define BZ_X_MAGIC_3 12
-#define BZ_X_MAGIC_4 13
-#define BZ_X_BLKHDR_1 14
-#define BZ_X_BLKHDR_2 15
-#define BZ_X_BLKHDR_3 16
-#define BZ_X_BLKHDR_4 17
-#define BZ_X_BLKHDR_5 18
-#define BZ_X_BLKHDR_6 19
-#define BZ_X_BCRC_1 20
-#define BZ_X_BCRC_2 21
-#define BZ_X_BCRC_3 22
-#define BZ_X_BCRC_4 23
-#define BZ_X_RANDBIT 24
-#define BZ_X_ORIGPTR_1 25
-#define BZ_X_ORIGPTR_2 26
-#define BZ_X_ORIGPTR_3 27
-#define BZ_X_MAPPING_1 28
-#define BZ_X_MAPPING_2 29
-#define BZ_X_SELECTOR_1 30
-#define BZ_X_SELECTOR_2 31
-#define BZ_X_SELECTOR_3 32
-#define BZ_X_CODING_1 33
-#define BZ_X_CODING_2 34
-#define BZ_X_CODING_3 35
-#define BZ_X_MTF_1 36
-#define BZ_X_MTF_2 37
-#define BZ_X_MTF_3 38
-#define BZ_X_MTF_4 39
-#define BZ_X_MTF_5 40
-#define BZ_X_MTF_6 41
-#define BZ_X_ENDHDR_2 42
-#define BZ_X_ENDHDR_3 43
-#define BZ_X_ENDHDR_4 44
-#define BZ_X_ENDHDR_5 45
-#define BZ_X_ENDHDR_6 46
-#define BZ_X_CCRC_1 47
-#define BZ_X_CCRC_2 48
-#define BZ_X_CCRC_3 49
-#define BZ_X_CCRC_4 50
-
-
-
-/*-- Constants for the fast MTF decoder. --*/
-
-#define MTFA_SIZE 4096
-#define MTFL_SIZE 16
-
-
-
-/*-- Structure holding all the decompression-side stuff. --*/
-
-typedef
- struct {
- /* pointer back to the struct bz_stream */
- bz_stream* strm;
-
- /* state indicator for this stream */
- Int32 state;
-
- /* for doing the final run-length decoding */
- UChar state_out_ch;
- Int32 state_out_len;
- Bool blockRandomised;
- BZ_RAND_DECLS;
-
- /* the buffer for bit stream reading */
- UInt32 bsBuff;
- Int32 bsLive;
-
- /* misc administratium */
- Int32 blockSize100k;
- Bool smallDecompress;
- Int32 currBlockNo;
- Int32 verbosity;
-
- /* for undoing the Burrows-Wheeler transform */
- Int32 origPtr;
- UInt32 tPos;
- Int32 k0;
- Int32 unzftab[256];
- Int32 nblock_used;
- Int32 cftab[257];
- Int32 cftabCopy[257];
-
- /* for undoing the Burrows-Wheeler transform (FAST) */
- UInt32 *tt;
-
- /* for undoing the Burrows-Wheeler transform (SMALL) */
- UInt16 *ll16;
- UChar *ll4;
-
- /* stored and calculated CRCs */
- UInt32 storedBlockCRC;
- UInt32 storedCombinedCRC;
- UInt32 calculatedBlockCRC;
- UInt32 calculatedCombinedCRC;
-
- /* map of bytes used in block */
- Int32 nInUse;
- Bool inUse[256];
- Bool inUse16[16];
- UChar seqToUnseq[256];
-
- /* for decoding the MTF values */
- UChar mtfa [MTFA_SIZE];
- Int32 mtfbase[256 / MTFL_SIZE];
- UChar selector [BZ_MAX_SELECTORS];
- UChar selectorMtf[BZ_MAX_SELECTORS];
- UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
-
- Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 minLens[BZ_N_GROUPS];
-
- /* save area for scalars in the main decompress code */
- Int32 save_i;
- Int32 save_j;
- Int32 save_t;
- Int32 save_alphaSize;
- Int32 save_nGroups;
- Int32 save_nSelectors;
- Int32 save_EOB;
- Int32 save_groupNo;
- Int32 save_groupPos;
- Int32 save_nextSym;
- Int32 save_nblockMAX;
- Int32 save_nblock;
- Int32 save_es;
- Int32 save_N;
- Int32 save_curr;
- Int32 save_zt;
- Int32 save_zn;
- Int32 save_zvec;
- Int32 save_zj;
- Int32 save_gSel;
- Int32 save_gMinlen;
- Int32* save_gLimit;
- Int32* save_gBase;
- Int32* save_gPerm;
-
- }
- DState;
-
-
-
-/*-- Macros for decompression. --*/
-
-#define BZ_GET_FAST(cccc) \
- /* c_tPos is unsigned, hence test < 0 is pointless. */ \
- if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
- s->tPos = s->tt[s->tPos]; \
- cccc = (UChar)(s->tPos & 0xff); \
- s->tPos >>= 8;
-
-#define BZ_GET_FAST_C(cccc) \
- /* c_tPos is unsigned, hence test < 0 is pointless. */ \
- if (c_tPos >= (UInt32)100000 * (UInt32)ro_blockSize100k) return True; \
- c_tPos = c_tt[c_tPos]; \
- cccc = (UChar)(c_tPos & 0xff); \
- c_tPos >>= 8;
-
-#define SET_LL4(i,n) \
- { if (((i) & 0x1) == 0) \
- s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \
- s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \
- }
-
-#define GET_LL4(i) \
- ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF)
-
-#define SET_LL(i,n) \
- { s->ll16[i] = (UInt16)(n & 0x0000ffff); \
- SET_LL4(i, n >> 16); \
- }
-
-#define GET_LL(i) \
- (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16))
-
-#define BZ_GET_SMALL(cccc) \
- /* c_tPos is unsigned, hence test < 0 is pointless. */ \
- if (s->tPos >= (UInt32)100000 * (UInt32)s->blockSize100k) return True; \
- cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
- s->tPos = GET_LL(s->tPos);
-
-
-/*-- externs for decompression. --*/
-
-extern Int32
-BZ2_indexIntoF ( Int32, Int32* );
-
-extern Int32
-BZ2_decompress ( DState* );
-
-extern void
-BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*,
- Int32, Int32, Int32 );
-
-
-#endif
-
-
-/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/
-
-#ifdef BZ_NO_STDIO
-#ifndef NULL
-#define NULL 0
-#endif
-#endif
-
-
-/*-------------------------------------------------------------*/
-/*--- end bzlib_private.h ---*/
-/*-------------------------------------------------------------*/
diff -Nru r-base-3.2.3/src/extra/bzip2/compress.c r-base-3.3.1/src/extra/bzip2/compress.c
--- r-base-3.2.3/src/extra/bzip2/compress.c 2015-03-18 23:02:09.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/compress.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,672 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Compression machinery (not incl block sorting) ---*/
-/*--- compress.c ---*/
-/*-------------------------------------------------------------*/
-
-/* ------------------------------------------------------------------
- This file is part of bzip2/libbzip2, a program and library for
- lossless, block-sorting data compression.
-
- bzip2/libbzip2 version 1.0.5 of 10 December 2007
- Copyright (C) 1996-2007 Julian Seward
-
- Please read the WARNING, DISCLAIMER and PATENTS sections in the
- README file.
-
- This program is released under the terms of the license contained
- in the file LICENSE.
- ------------------------------------------------------------------ */
-
-
-/* CHANGES
- 0.9.0 -- original version.
- 0.9.0a/b -- no changes in this file.
- 0.9.0c -- changed setting of nGroups in sendMTFValues()
- so as to do a bit better on small files
-*/
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------------*/
-/*--- Bit stream I/O ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-void BZ2_bsInitWrite ( EState* s )
-{
- s->bsLive = 0;
- s->bsBuff = 0;
-}
-
-
-/*---------------------------------------------------*/
-static
-void bsFinishWrite ( EState* s )
-{
- while (s->bsLive > 0) {
- s->zbits[s->numZ] = (UChar)(s->bsBuff >> 24);
- s->numZ++;
- s->bsBuff <<= 8;
- s->bsLive -= 8;
- }
-}
-
-
-/*---------------------------------------------------*/
-#define bsNEEDW(nz) \
-{ \
- while (s->bsLive >= 8) { \
- s->zbits[s->numZ] \
- = (UChar)(s->bsBuff >> 24); \
- s->numZ++; \
- s->bsBuff <<= 8; \
- s->bsLive -= 8; \
- } \
-}
-
-
-/*---------------------------------------------------*/
-static
-R_INLINE
-void bsW ( EState* s, Int32 n, UInt32 v )
-{
- bsNEEDW ( n );
- s->bsBuff |= (v << (32 - s->bsLive - n));
- s->bsLive += n;
-}
-
-
-/*---------------------------------------------------*/
-static
-void bsPutUInt32 ( EState* s, UInt32 u )
-{
- bsW ( s, 8, (u >> 24) & 0xffL );
- bsW ( s, 8, (u >> 16) & 0xffL );
- bsW ( s, 8, (u >> 8) & 0xffL );
- bsW ( s, 8, u & 0xffL );
-}
-
-
-/*---------------------------------------------------*/
-static
-void bsPutUChar ( EState* s, UChar c )
-{
- bsW( s, 8, (UInt32)c );
-}
-
-
-/*---------------------------------------------------*/
-/*--- The back end proper ---*/
-/*---------------------------------------------------*/
-
-/*---------------------------------------------------*/
-static
-void makeMaps_e ( EState* s )
-{
- Int32 i;
- s->nInUse = 0;
- for (i = 0; i < 256; i++)
- if (s->inUse[i]) {
- s->unseqToSeq[i] = s->nInUse;
- s->nInUse++;
- }
-}
-
-
-/*---------------------------------------------------*/
-static
-void generateMTFValues ( EState* s )
-{
- UChar yy[256];
- Int32 i, j;
- Int32 zPend;
- Int32 wr;
- Int32 EOB;
-
- /*
- After sorting (eg, here),
- s->arr1 [ 0 .. s->nblock-1 ] holds sorted order,
- and
- ((UChar*)s->arr2) [ 0 .. s->nblock-1 ]
- holds the original block data.
-
- The first thing to do is generate the MTF values,
- and put them in
- ((UInt16*)s->arr1) [ 0 .. s->nblock-1 ].
- Because there are strictly fewer or equal MTF values
- than block values, ptr values in this area are overwritten
- with MTF values only when they are no longer needed.
-
- The final compressed bitstream is generated into the
- area starting at
- (UChar*) (&((UChar*)s->arr2)[s->nblock])
-
- These storage aliases are set up in bzCompressInit(),
- except for the last one, which is arranged in
- compressBlock().
- */
- UInt32* ptr = s->ptr;
- UChar* block = s->block;
- UInt16* mtfv = s->mtfv;
-
- makeMaps_e ( s );
- EOB = s->nInUse+1;
-
- for (i = 0; i <= EOB; i++) s->mtfFreq[i] = 0;
-
- wr = 0;
- zPend = 0;
- for (i = 0; i < s->nInUse; i++) yy[i] = (UChar) i;
-
- for (i = 0; i < s->nblock; i++) {
- UChar ll_i;
- AssertD ( wr <= i, "generateMTFValues(1)" );
- j = ptr[i]-1; if (j < 0) j += s->nblock;
- ll_i = s->unseqToSeq[block[j]];
- AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" );
-
- if (yy[0] == ll_i) {
- zPend++;
- } else {
-
- if (zPend > 0) {
- zPend--;
- while (True) {
- if (zPend & 1) {
- mtfv[wr] = BZ_RUNB; wr++;
- s->mtfFreq[BZ_RUNB]++;
- } else {
- mtfv[wr] = BZ_RUNA; wr++;
- s->mtfFreq[BZ_RUNA]++;
- }
- if (zPend < 2) break;
- zPend = (zPend - 2) / 2;
- };
- zPend = 0;
- }
- {
- register UChar rtmp;
- register UChar* ryy_j;
- register UChar rll_i;
- rtmp = yy[1];
- yy[1] = yy[0];
- ryy_j = &(yy[1]);
- rll_i = ll_i;
- while ( rll_i != rtmp ) {
- register UChar rtmp2;
- ryy_j++;
- rtmp2 = rtmp;
- rtmp = *ryy_j;
- *ryy_j = rtmp2;
- };
- yy[0] = rtmp;
- j = ryy_j - &(yy[0]);
- mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++;
- }
-
- }
- }
-
- if (zPend > 0) {
- zPend--;
- while (True) {
- if (zPend & 1) {
- mtfv[wr] = BZ_RUNB; wr++;
- s->mtfFreq[BZ_RUNB]++;
- } else {
- mtfv[wr] = BZ_RUNA; wr++;
- s->mtfFreq[BZ_RUNA]++;
- }
- if (zPend < 2) break;
- zPend = (zPend - 2) / 2;
- };
- zPend = 0;
- }
-
- mtfv[wr] = EOB; wr++; s->mtfFreq[EOB]++;
-
- s->nMTF = wr;
-}
-
-
-/*---------------------------------------------------*/
-#define BZ_LESSER_ICOST 0
-#define BZ_GREATER_ICOST 15
-
-static
-void sendMTFValues ( EState* s )
-{
- Int32 v, t, i, j, gs, ge, totc, bt, bc, iter;
- Int32 nSelectors, alphaSize, minLen, maxLen, selCtr;
- Int32 nGroups, nBytes;
-
- /*--
- UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- is a global since the decoder also needs it.
-
- Int32 code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- Int32 rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
- are also globals only used in this proc.
- Made global to keep stack frame size small.
- --*/
-
-
- UInt16 cost[BZ_N_GROUPS];
- Int32 fave[BZ_N_GROUPS];
-
- UInt16* mtfv = s->mtfv;
-
- if (s->verbosity >= 3)
- VPrintf3( " %d in block, %d after MTF & 1-2 coding, "
- "%d+2 syms in use\n",
- s->nblock, s->nMTF, s->nInUse );
-
- alphaSize = s->nInUse+2;
- for (t = 0; t < BZ_N_GROUPS; t++)
- for (v = 0; v < alphaSize; v++)
- s->len[t][v] = BZ_GREATER_ICOST;
-
- /*--- Decide how many coding tables to use ---*/
- AssertH ( s->nMTF > 0, 3001 );
- if (s->nMTF < 200) nGroups = 2; else
- if (s->nMTF < 600) nGroups = 3; else
- if (s->nMTF < 1200) nGroups = 4; else
- if (s->nMTF < 2400) nGroups = 5; else
- nGroups = 6;
-
- /*--- Generate an initial set of coding tables ---*/
- {
- Int32 nPart, remF, tFreq, aFreq;
-
- nPart = nGroups;
- remF = s->nMTF;
- gs = 0;
- while (nPart > 0) {
- tFreq = remF / nPart;
- ge = gs-1;
- aFreq = 0;
- while (aFreq < tFreq && ge < alphaSize-1) {
- ge++;
- aFreq += s->mtfFreq[ge];
- }
-
- if (ge > gs
- && nPart != nGroups && nPart != 1
- && ((nGroups-nPart) % 2 == 1)) {
- aFreq -= s->mtfFreq[ge];
- ge--;
- }
-
- if (s->verbosity >= 3)
- VPrintf5( " initial group %d, [%d .. %d], "
- "has %d syms (%4.1f%%)\n",
- nPart, gs, ge, aFreq,
- (100.0 * (float)aFreq) / (float)(s->nMTF) );
-
- for (v = 0; v < alphaSize; v++)
- if (v >= gs && v <= ge)
- s->len[nPart-1][v] = BZ_LESSER_ICOST; else
- s->len[nPart-1][v] = BZ_GREATER_ICOST;
-
- nPart--;
- gs = ge+1;
- remF -= aFreq;
- }
- }
-
- /*---
- Iterate up to BZ_N_ITERS times to improve the tables.
- ---*/
- for (iter = 0; iter < BZ_N_ITERS; iter++) {
-
- for (t = 0; t < nGroups; t++) fave[t] = 0;
-
- for (t = 0; t < nGroups; t++)
- for (v = 0; v < alphaSize; v++)
- s->rfreq[t][v] = 0;
-
- /*---
- Set up an auxiliary length table which is used to fast-track
- the common case (nGroups == 6).
- ---*/
- if (nGroups == 6) {
- for (v = 0; v < alphaSize; v++) {
- s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v];
- s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v];
- s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v];
- }
- }
-
- nSelectors = 0;
- totc = 0;
- gs = 0;
- while (True) {
-
- /*--- Set group start & end marks. --*/
- if (gs >= s->nMTF) break;
- ge = gs + BZ_G_SIZE - 1;
- if (ge >= s->nMTF) ge = s->nMTF-1;
-
- /*--
- Calculate the cost of this group as coded
- by each of the coding tables.
- --*/
- for (t = 0; t < nGroups; t++) cost[t] = 0;
-
- if (nGroups == 6 && 50 == ge-gs+1) {
- /*--- fast track the common case ---*/
- register UInt32 cost01, cost23, cost45;
- register UInt16 icv;
- cost01 = cost23 = cost45 = 0;
-
-# define BZ_ITER(nn) \
- icv = mtfv[gs+(nn)]; \
- cost01 += s->len_pack[icv][0]; \
- cost23 += s->len_pack[icv][1]; \
- cost45 += s->len_pack[icv][2]; \
-
- BZ_ITER(0); BZ_ITER(1); BZ_ITER(2); BZ_ITER(3); BZ_ITER(4);
- BZ_ITER(5); BZ_ITER(6); BZ_ITER(7); BZ_ITER(8); BZ_ITER(9);
- BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14);
- BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19);
- BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24);
- BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29);
- BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34);
- BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39);
- BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44);
- BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49);
-
-# undef BZ_ITER
-
- cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16;
- cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16;
- cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16;
-
- } else {
- /*--- slow version which correctly handles all situations ---*/
- for (i = gs; i <= ge; i++) {
- UInt16 icv = mtfv[i];
- for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv];
- }
- }
-
- /*--
- Find the coding table which is best for this group,
- and record its identity in the selector table.
- --*/
- bc = 999999999; bt = -1;
- for (t = 0; t < nGroups; t++)
- if (cost[t] < bc) { bc = cost[t]; bt = t; };
- totc += bc;
- fave[bt]++;
- s->selector[nSelectors] = bt;
- nSelectors++;
-
- /*--
- Increment the symbol frequencies for the selected table.
- --*/
- if (nGroups == 6 && 50 == ge-gs+1) {
- /*--- fast track the common case ---*/
-
-# define BZ_ITUR(nn) s->rfreq[bt][ mtfv[gs+(nn)] ]++
-
- BZ_ITUR(0); BZ_ITUR(1); BZ_ITUR(2); BZ_ITUR(3); BZ_ITUR(4);
- BZ_ITUR(5); BZ_ITUR(6); BZ_ITUR(7); BZ_ITUR(8); BZ_ITUR(9);
- BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14);
- BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19);
- BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24);
- BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29);
- BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34);
- BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39);
- BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44);
- BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49);
-
-# undef BZ_ITUR
-
- } else {
- /*--- slow version which correctly handles all situations ---*/
- for (i = gs; i <= ge; i++)
- s->rfreq[bt][ mtfv[i] ]++;
- }
-
- gs = ge+1;
- }
- if (s->verbosity >= 3) {
- VPrintf2 ( " pass %d: size is %d, grp uses are ",
- iter+1, totc/8 );
- for (t = 0; t < nGroups; t++)
- VPrintf1 ( "%d ", fave[t] );
- VPrintf0 ( "\n" );
- }
-
- /*--
- Recompute the tables based on the accumulated frequencies.
- --*/
- /* maxLen was changed from 20 to 17 in bzip2-1.0.3. See
- comment in huffman.c for details. */
- for (t = 0; t < nGroups; t++)
- BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]),
- alphaSize, 17 /*20*/ );
- }
-
-
- AssertH( nGroups < 8, 3002 );
- AssertH( nSelectors < 32768 &&
- nSelectors <= (2 + (900000 / BZ_G_SIZE)),
- 3003 );
-
-
- /*--- Compute MTF values for the selectors. ---*/
- {
- UChar pos[BZ_N_GROUPS], ll_i, tmp2, tmp;
- for (i = 0; i < nGroups; i++) pos[i] = i;
- for (i = 0; i < nSelectors; i++) {
- ll_i = s->selector[i];
- j = 0;
- tmp = pos[j];
- while ( ll_i != tmp ) {
- j++;
- tmp2 = tmp;
- tmp = pos[j];
- pos[j] = tmp2;
- };
- pos[0] = tmp;
- s->selectorMtf[i] = j;
- }
- };
-
- /*--- Assign actual codes for the tables. --*/
- for (t = 0; t < nGroups; t++) {
- minLen = 32;
- maxLen = 0;
- for (i = 0; i < alphaSize; i++) {
- if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
- if (s->len[t][i] < minLen) minLen = s->len[t][i];
- }
- AssertH ( !(maxLen > 17 /*20*/ ), 3004 );
- AssertH ( !(minLen < 1), 3005 );
- BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]),
- minLen, maxLen, alphaSize );
- }
-
- /*--- Transmit the mapping table. ---*/
- {
- Bool inUse16[16];
- for (i = 0; i < 16; i++) {
- inUse16[i] = False;
- for (j = 0; j < 16; j++)
- if (s->inUse[i * 16 + j]) inUse16[i] = True;
- }
-
- nBytes = s->numZ;
- for (i = 0; i < 16; i++)
- if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0);
-
- for (i = 0; i < 16; i++)
- if (inUse16[i])
- for (j = 0; j < 16; j++) {
- if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0);
- }
-
- if (s->verbosity >= 3)
- VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes );
- }
-
- /*--- Now the selectors. ---*/
- nBytes = s->numZ;
- bsW ( s, 3, nGroups );
- bsW ( s, 15, nSelectors );
- for (i = 0; i < nSelectors; i++) {
- for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1);
- bsW(s,1,0);
- }
- if (s->verbosity >= 3)
- VPrintf1( "selectors %d, ", s->numZ-nBytes );
-
- /*--- Now the coding tables. ---*/
- nBytes = s->numZ;
-
- for (t = 0; t < nGroups; t++) {
- Int32 curr = s->len[t][0];
- bsW ( s, 5, curr );
- for (i = 0; i < alphaSize; i++) {
- while (curr < s->len[t][i]) { bsW(s,2,2); curr++; /* 10 */ };
- while (curr > s->len[t][i]) { bsW(s,2,3); curr--; /* 11 */ };
- bsW ( s, 1, 0 );
- }
- }
-
- if (s->verbosity >= 3)
- VPrintf1 ( "code lengths %d, ", s->numZ-nBytes );
-
- /*--- And finally, the block data proper ---*/
- nBytes = s->numZ;
- selCtr = 0;
- gs = 0;
- while (True) {
- if (gs >= s->nMTF) break;
- ge = gs + BZ_G_SIZE - 1;
- if (ge >= s->nMTF) ge = s->nMTF-1;
- AssertH ( s->selector[selCtr] < nGroups, 3006 );
-
- if (nGroups == 6 && 50 == ge-gs+1) {
- /*--- fast track the common case ---*/
- UInt16 mtfv_i;
- UChar* s_len_sel_selCtr
- = &(s->len[s->selector[selCtr]][0]);
- Int32* s_code_sel_selCtr
- = &(s->code[s->selector[selCtr]][0]);
-
-# define BZ_ITAH(nn) \
- mtfv_i = mtfv[gs+(nn)]; \
- bsW ( s, \
- s_len_sel_selCtr[mtfv_i], \
- s_code_sel_selCtr[mtfv_i] )
-
- BZ_ITAH(0); BZ_ITAH(1); BZ_ITAH(2); BZ_ITAH(3); BZ_ITAH(4);
- BZ_ITAH(5); BZ_ITAH(6); BZ_ITAH(7); BZ_ITAH(8); BZ_ITAH(9);
- BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14);
- BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19);
- BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24);
- BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29);
- BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34);
- BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39);
- BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44);
- BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49);
-
-# undef BZ_ITAH
-
- } else {
- /*--- slow version which correctly handles all situations ---*/
- for (i = gs; i <= ge; i++) {
- bsW ( s,
- s->len [s->selector[selCtr]] [mtfv[i]],
- s->code [s->selector[selCtr]] [mtfv[i]] );
- }
- }
-
-
- gs = ge+1;
- selCtr++;
- }
- AssertH( selCtr == nSelectors, 3007 );
-
- if (s->verbosity >= 3)
- VPrintf1( "codes %d\n", s->numZ-nBytes );
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_compressBlock ( EState* s, Bool is_last_block )
-{
- if (s->nblock > 0) {
-
- BZ_FINALISE_CRC ( s->blockCRC );
- s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31);
- s->combinedCRC ^= s->blockCRC;
- if (s->blockNo > 1) s->numZ = 0;
-
- if (s->verbosity >= 2)
- VPrintf4( " block %d: crc = 0x%08x, "
- "combined CRC = 0x%08x, size = %d\n",
- s->blockNo, s->blockCRC, s->combinedCRC, s->nblock );
-
- BZ2_blockSort ( s );
- }
-
- s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]);
-
- /*-- If this is the first block, create the stream header. --*/
- if (s->blockNo == 1) {
- BZ2_bsInitWrite ( s );
- bsPutUChar ( s, BZ_HDR_B );
- bsPutUChar ( s, BZ_HDR_Z );
- bsPutUChar ( s, BZ_HDR_h );
- bsPutUChar ( s, (UChar)(BZ_HDR_0 + s->blockSize100k) );
- }
-
- if (s->nblock > 0) {
-
- bsPutUChar ( s, 0x31 ); bsPutUChar ( s, 0x41 );
- bsPutUChar ( s, 0x59 ); bsPutUChar ( s, 0x26 );
- bsPutUChar ( s, 0x53 ); bsPutUChar ( s, 0x59 );
-
- /*-- Now the block's CRC, so it is in a known place. --*/
- bsPutUInt32 ( s, s->blockCRC );
-
- /*--
- Now a single bit indicating (non-)randomisation.
- As of version 0.9.5, we use a better sorting algorithm
- which makes randomisation unnecessary. So always set
- the randomised bit to 'no'. Of course, the decoder
- still needs to be able to handle randomised blocks
- so as to maintain backwards compatibility with
- older versions of bzip2.
- --*/
- bsW(s,1,0);
-
- bsW ( s, 24, s->origPtr );
- generateMTFValues ( s );
- sendMTFValues ( s );
- }
-
-
- /*-- If this is the last block, add the stream trailer. --*/
- if (is_last_block) {
-
- bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 );
- bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 );
- bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 );
- bsPutUInt32 ( s, s->combinedCRC );
- if (s->verbosity >= 2)
- VPrintf1( " final combined CRC = 0x%08x\n ", s->combinedCRC );
- bsFinishWrite ( s );
- }
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end compress.c ---*/
-/*-------------------------------------------------------------*/
diff -Nru r-base-3.2.3/src/extra/bzip2/crctable.c r-base-3.3.1/src/extra/bzip2/crctable.c
--- r-base-3.2.3/src/extra/bzip2/crctable.c 2010-09-27 22:05:02.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/crctable.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,104 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Table for doing CRCs ---*/
-/*--- crctable.c ---*/
-/*-------------------------------------------------------------*/
-
-/* ------------------------------------------------------------------
- This file is part of bzip2/libbzip2, a program and library for
- lossless, block-sorting data compression.
-
- bzip2/libbzip2 version 1.0.6 of 6 September 2010
- Copyright (C) 1996-2010 Julian Seward
-
- Please read the WARNING, DISCLAIMER and PATENTS sections in the
- README file.
-
- This program is released under the terms of the license contained
- in the file LICENSE.
- ------------------------------------------------------------------ */
-
-
-#include "bzlib_private.h"
-
-/*--
- I think this is an implementation of the AUTODIN-II,
- Ethernet & FDDI 32-bit CRC standard. Vaguely derived
- from code by Rob Warnock, in Section 51 of the
- comp.compression FAQ.
---*/
-
-UInt32 BZ2_crc32Table[256] = {
-
- /*-- Ugly, innit? --*/
-
- 0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L,
- 0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L,
- 0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L,
- 0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL,
- 0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L,
- 0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L,
- 0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L,
- 0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL,
- 0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L,
- 0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L,
- 0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L,
- 0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL,
- 0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L,
- 0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L,
- 0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L,
- 0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL,
- 0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL,
- 0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L,
- 0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L,
- 0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL,
- 0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL,
- 0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L,
- 0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L,
- 0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL,
- 0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL,
- 0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L,
- 0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L,
- 0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL,
- 0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL,
- 0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L,
- 0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L,
- 0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL,
- 0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L,
- 0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL,
- 0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL,
- 0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L,
- 0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L,
- 0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL,
- 0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL,
- 0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L,
- 0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L,
- 0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL,
- 0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL,
- 0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L,
- 0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L,
- 0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL,
- 0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL,
- 0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L,
- 0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L,
- 0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL,
- 0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L,
- 0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L,
- 0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L,
- 0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL,
- 0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L,
- 0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L,
- 0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L,
- 0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL,
- 0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L,
- 0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L,
- 0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L,
- 0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL,
- 0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L,
- 0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L
-};
-
-
-/*-------------------------------------------------------------*/
-/*--- end crctable.c ---*/
-/*-------------------------------------------------------------*/
diff -Nru r-base-3.2.3/src/extra/bzip2/decompress.c r-base-3.3.1/src/extra/bzip2/decompress.c
--- r-base-3.2.3/src/extra/bzip2/decompress.c 2010-09-27 22:05:02.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/decompress.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,646 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Decompression machinery ---*/
-/*--- decompress.c ---*/
-/*-------------------------------------------------------------*/
-
-/* ------------------------------------------------------------------
- This file is part of bzip2/libbzip2, a program and library for
- lossless, block-sorting data compression.
-
- bzip2/libbzip2 version 1.0.6 of 6 September 2010
- Copyright (C) 1996-2010 Julian Seward
-
- Please read the WARNING, DISCLAIMER and PATENTS sections in the
- README file.
-
- This program is released under the terms of the license contained
- in the file LICENSE.
- ------------------------------------------------------------------ */
-
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------------*/
-static
-void makeMaps_d ( DState* s )
-{
- Int32 i;
- s->nInUse = 0;
- for (i = 0; i < 256; i++)
- if (s->inUse[i]) {
- s->seqToUnseq[s->nInUse] = i;
- s->nInUse++;
- }
-}
-
-
-/*---------------------------------------------------*/
-#define RETURN(rrr) \
- { retVal = rrr; goto save_state_and_return; };
-
-#define GET_BITS(lll,vvv,nnn) \
- case lll: s->state = lll; \
- while (True) { \
- if (s->bsLive >= nnn) { \
- UInt32 v; \
- v = (s->bsBuff >> \
- (s->bsLive-nnn)) & ((1 << nnn)-1); \
- s->bsLive -= nnn; \
- vvv = v; \
- break; \
- } \
- if (s->strm->avail_in == 0) RETURN(BZ_OK); \
- s->bsBuff \
- = (s->bsBuff << 8) | \
- ((UInt32) \
- (*((UChar*)(s->strm->next_in)))); \
- s->bsLive += 8; \
- s->strm->next_in++; \
- s->strm->avail_in--; \
- s->strm->total_in_lo32++; \
- if (s->strm->total_in_lo32 == 0) \
- s->strm->total_in_hi32++; \
- }
-
-#define GET_UCHAR(lll,uuu) \
- GET_BITS(lll,uuu,8)
-
-#define GET_BIT(lll,uuu) \
- GET_BITS(lll,uuu,1)
-
-/*---------------------------------------------------*/
-#define GET_MTF_VAL(label1,label2,lval) \
-{ \
- if (groupPos == 0) { \
- groupNo++; \
- if (groupNo >= nSelectors) \
- RETURN(BZ_DATA_ERROR); \
- groupPos = BZ_G_SIZE; \
- gSel = s->selector[groupNo]; \
- gMinlen = s->minLens[gSel]; \
- gLimit = &(s->limit[gSel][0]); \
- gPerm = &(s->perm[gSel][0]); \
- gBase = &(s->base[gSel][0]); \
- } \
- groupPos--; \
- zn = gMinlen; \
- GET_BITS(label1, zvec, zn); \
- while (1) { \
- if (zn > 20 /* the longest code */) \
- RETURN(BZ_DATA_ERROR); \
- if (zvec <= gLimit[zn]) break; \
- zn++; \
- GET_BIT(label2, zj); \
- zvec = (zvec << 1) | zj; \
- }; \
- if (zvec - gBase[zn] < 0 \
- || zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE) \
- RETURN(BZ_DATA_ERROR); \
- lval = gPerm[zvec - gBase[zn]]; \
-}
-
-
-/*---------------------------------------------------*/
-Int32 BZ2_decompress ( DState* s )
-{
- UChar uc;
- Int32 retVal;
- Int32 minLen, maxLen;
- bz_stream* strm = s->strm;
-
- /* stuff that needs to be saved/restored */
- Int32 i;
- Int32 j;
- Int32 t;
- Int32 alphaSize;
- Int32 nGroups;
- Int32 nSelectors;
- Int32 EOB;
- Int32 groupNo;
- Int32 groupPos;
- Int32 nextSym;
- Int32 nblockMAX;
- Int32 nblock;
- Int32 es;
- Int32 N;
- Int32 curr;
- Int32 zt;
- Int32 zn;
- Int32 zvec;
- Int32 zj;
- Int32 gSel;
- Int32 gMinlen;
- Int32* gLimit;
- Int32* gBase;
- Int32* gPerm;
-
- if (s->state == BZ_X_MAGIC_1) {
- /*initialise the save area*/
- s->save_i = 0;
- s->save_j = 0;
- s->save_t = 0;
- s->save_alphaSize = 0;
- s->save_nGroups = 0;
- s->save_nSelectors = 0;
- s->save_EOB = 0;
- s->save_groupNo = 0;
- s->save_groupPos = 0;
- s->save_nextSym = 0;
- s->save_nblockMAX = 0;
- s->save_nblock = 0;
- s->save_es = 0;
- s->save_N = 0;
- s->save_curr = 0;
- s->save_zt = 0;
- s->save_zn = 0;
- s->save_zvec = 0;
- s->save_zj = 0;
- s->save_gSel = 0;
- s->save_gMinlen = 0;
- s->save_gLimit = NULL;
- s->save_gBase = NULL;
- s->save_gPerm = NULL;
- }
-
- /*restore from the save area*/
- i = s->save_i;
- j = s->save_j;
- t = s->save_t;
- alphaSize = s->save_alphaSize;
- nGroups = s->save_nGroups;
- nSelectors = s->save_nSelectors;
- EOB = s->save_EOB;
- groupNo = s->save_groupNo;
- groupPos = s->save_groupPos;
- nextSym = s->save_nextSym;
- nblockMAX = s->save_nblockMAX;
- nblock = s->save_nblock;
- es = s->save_es;
- N = s->save_N;
- curr = s->save_curr;
- zt = s->save_zt;
- zn = s->save_zn;
- zvec = s->save_zvec;
- zj = s->save_zj;
- gSel = s->save_gSel;
- gMinlen = s->save_gMinlen;
- gLimit = s->save_gLimit;
- gBase = s->save_gBase;
- gPerm = s->save_gPerm;
-
- retVal = BZ_OK;
-
- switch (s->state) {
-
- GET_UCHAR(BZ_X_MAGIC_1, uc);
- if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC);
-
- GET_UCHAR(BZ_X_MAGIC_2, uc);
- if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC);
-
- GET_UCHAR(BZ_X_MAGIC_3, uc)
- if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC);
-
- GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8)
- if (s->blockSize100k < (BZ_HDR_0 + 1) ||
- s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC);
- s->blockSize100k -= BZ_HDR_0;
-
- if (s->smallDecompress) {
- s->ll16 = (UInt16*) BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
- s->ll4 = (UChar *) BZALLOC(
- ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
- );
- if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
- } else {
- s->tt = (UInt32 *) BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
- if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
- }
-
- GET_UCHAR(BZ_X_BLKHDR_1, uc);
-
- if (uc == 0x17) goto endhdr_2;
- if (uc != 0x31) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_BLKHDR_2, uc);
- if (uc != 0x41) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_BLKHDR_3, uc);
- if (uc != 0x59) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_BLKHDR_4, uc);
- if (uc != 0x26) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_BLKHDR_5, uc);
- if (uc != 0x53) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_BLKHDR_6, uc);
- if (uc != 0x59) RETURN(BZ_DATA_ERROR);
-
- s->currBlockNo++;
- if (s->verbosity >= 2)
- VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo );
-
- s->storedBlockCRC = 0;
- GET_UCHAR(BZ_X_BCRC_1, uc);
- s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_BCRC_2, uc);
- s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_BCRC_3, uc);
- s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_BCRC_4, uc);
- s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc);
-
- GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1);
-
- s->origPtr = 0;
- GET_UCHAR(BZ_X_ORIGPTR_1, uc);
- s->origPtr = (s->origPtr << 8) | ((Int32)uc);
- GET_UCHAR(BZ_X_ORIGPTR_2, uc);
- s->origPtr = (s->origPtr << 8) | ((Int32)uc);
- GET_UCHAR(BZ_X_ORIGPTR_3, uc);
- s->origPtr = (s->origPtr << 8) | ((Int32)uc);
-
- if (s->origPtr < 0)
- RETURN(BZ_DATA_ERROR);
- if (s->origPtr > 10 + 100000*s->blockSize100k)
- RETURN(BZ_DATA_ERROR);
-
- /*--- Receive the mapping table ---*/
- for (i = 0; i < 16; i++) {
- GET_BIT(BZ_X_MAPPING_1, uc);
- if (uc == 1)
- s->inUse16[i] = True; else
- s->inUse16[i] = False;
- }
-
- for (i = 0; i < 256; i++) s->inUse[i] = False;
-
- for (i = 0; i < 16; i++)
- if (s->inUse16[i])
- for (j = 0; j < 16; j++) {
- GET_BIT(BZ_X_MAPPING_2, uc);
- if (uc == 1) s->inUse[i * 16 + j] = True;
- }
- makeMaps_d ( s );
- if (s->nInUse == 0) RETURN(BZ_DATA_ERROR);
- alphaSize = s->nInUse+2;
-
- /*--- Now the selectors ---*/
- GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
- if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
- GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
- if (nSelectors < 1) RETURN(BZ_DATA_ERROR);
- for (i = 0; i < nSelectors; i++) {
- j = 0;
- while (True) {
- GET_BIT(BZ_X_SELECTOR_3, uc);
- if (uc == 0) break;
- j++;
- if (j >= nGroups) RETURN(BZ_DATA_ERROR);
- }
- s->selectorMtf[i] = j;
- }
-
- /*--- Undo the MTF values for the selectors. ---*/
- {
- UChar pos[BZ_N_GROUPS], tmp, v;
- for (v = 0; v < nGroups; v++) pos[v] = v;
-
- for (i = 0; i < nSelectors; i++) {
- v = s->selectorMtf[i];
- tmp = pos[v];
- while (v > 0) { pos[v] = pos[v-1]; v--; }
- pos[0] = tmp;
- s->selector[i] = tmp;
- }
- }
-
- /*--- Now the coding tables ---*/
- for (t = 0; t < nGroups; t++) {
- GET_BITS(BZ_X_CODING_1, curr, 5);
- for (i = 0; i < alphaSize; i++) {
- while (True) {
- if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR);
- GET_BIT(BZ_X_CODING_2, uc);
- if (uc == 0) break;
- GET_BIT(BZ_X_CODING_3, uc);
- if (uc == 0) curr++; else curr--;
- }
- s->len[t][i] = curr;
- }
- }
-
- /*--- Create the Huffman decoding tables ---*/
- for (t = 0; t < nGroups; t++) {
- minLen = 32;
- maxLen = 0;
- for (i = 0; i < alphaSize; i++) {
- if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
- if (s->len[t][i] < minLen) minLen = s->len[t][i];
- }
- BZ2_hbCreateDecodeTables (
- &(s->limit[t][0]),
- &(s->base[t][0]),
- &(s->perm[t][0]),
- &(s->len[t][0]),
- minLen, maxLen, alphaSize
- );
- s->minLens[t] = minLen;
- }
-
- /*--- Now the MTF values ---*/
-
- EOB = s->nInUse+1;
- nblockMAX = 100000 * s->blockSize100k;
- groupNo = -1;
- groupPos = 0;
-
- for (i = 0; i <= 255; i++) s->unzftab[i] = 0;
-
- /*-- MTF init --*/
- {
- Int32 ii, jj, kk;
- kk = MTFA_SIZE-1;
- for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) {
- for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
- s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj);
- kk--;
- }
- s->mtfbase[ii] = kk + 1;
- }
- }
- /*-- end MTF init --*/
-
- nblock = 0;
- GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym);
-
- while (True) {
-
- if (nextSym == EOB) break;
-
- if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) {
-
- es = -1;
- N = 1;
- do {
- /* Check that N doesn't get too big, so that es doesn't
- go negative. The maximum value that can be
- RUNA/RUNB encoded is equal to the block size (post
- the initial RLE), viz, 900k, so bounding N at 2
- million should guard against overflow without
- rejecting any legitimate inputs. */
- if (N >= 2*1024*1024) RETURN(BZ_DATA_ERROR);
- if (nextSym == BZ_RUNA) es = es + (0+1) * N; else
- if (nextSym == BZ_RUNB) es = es + (1+1) * N;
- N = N * 2;
- GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym);
- }
- while (nextSym == BZ_RUNA || nextSym == BZ_RUNB);
-
- es++;
- uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ];
- s->unzftab[uc] += es;
-
- if (s->smallDecompress)
- while (es > 0) {
- if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
- s->ll16[nblock] = (UInt16)uc;
- nblock++;
- es--;
- }
- else
- while (es > 0) {
- if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
- s->tt[nblock] = (UInt32)uc;
- nblock++;
- es--;
- };
-
- continue;
-
- } else {
-
- if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR);
-
- /*-- uc = MTF ( nextSym-1 ) --*/
- {
- Int32 ii, jj, kk, pp, lno, off;
- UInt32 nn;
- nn = (UInt32)(nextSym - 1);
-
- if (nn < MTFL_SIZE) {
- /* avoid general-case expense */
- pp = s->mtfbase[0];
- uc = s->mtfa[pp+nn];
- while (nn > 3) {
- Int32 z = pp+nn;
- s->mtfa[(z) ] = s->mtfa[(z)-1];
- s->mtfa[(z)-1] = s->mtfa[(z)-2];
- s->mtfa[(z)-2] = s->mtfa[(z)-3];
- s->mtfa[(z)-3] = s->mtfa[(z)-4];
- nn -= 4;
- }
- while (nn > 0) {
- s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--;
- };
- s->mtfa[pp] = uc;
- } else {
- /* general case */
- lno = nn / MTFL_SIZE;
- off = nn % MTFL_SIZE;
- pp = s->mtfbase[lno] + off;
- uc = s->mtfa[pp];
- while (pp > s->mtfbase[lno]) {
- s->mtfa[pp] = s->mtfa[pp-1]; pp--;
- };
- s->mtfbase[lno]++;
- while (lno > 0) {
- s->mtfbase[lno]--;
- s->mtfa[s->mtfbase[lno]]
- = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1];
- lno--;
- }
- s->mtfbase[0]--;
- s->mtfa[s->mtfbase[0]] = uc;
- if (s->mtfbase[0] == 0) {
- kk = MTFA_SIZE-1;
- for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) {
- for (jj = MTFL_SIZE-1; jj >= 0; jj--) {
- s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj];
- kk--;
- }
- s->mtfbase[ii] = kk + 1;
- }
- }
- }
- }
- /*-- end uc = MTF ( nextSym-1 ) --*/
-
- s->unzftab[s->seqToUnseq[uc]]++;
- if (s->smallDecompress)
- s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else
- s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]);
- nblock++;
-
- GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym);
- continue;
- }
- }
-
- /* Now we know what nblock is, we can do a better sanity
- check on s->origPtr.
- */
- if (s->origPtr < 0 || s->origPtr >= nblock)
- RETURN(BZ_DATA_ERROR);
-
- /*-- Set up cftab to facilitate generation of T^(-1) --*/
- /* Check: unzftab entries in range. */
- for (i = 0; i <= 255; i++) {
- if (s->unzftab[i] < 0 || s->unzftab[i] > nblock)
- RETURN(BZ_DATA_ERROR);
- }
- /* Actually generate cftab. */
- s->cftab[0] = 0;
- for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1];
- for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1];
- /* Check: cftab entries in range. */
- for (i = 0; i <= 256; i++) {
- if (s->cftab[i] < 0 || s->cftab[i] > nblock) {
- /* s->cftab[i] can legitimately be == nblock */
- RETURN(BZ_DATA_ERROR);
- }
- }
- /* Check: cftab entries non-descending. */
- for (i = 1; i <= 256; i++) {
- if (s->cftab[i-1] > s->cftab[i]) {
- RETURN(BZ_DATA_ERROR);
- }
- }
-
- s->state_out_len = 0;
- s->state_out_ch = 0;
- BZ_INITIALISE_CRC ( s->calculatedBlockCRC );
- s->state = BZ_X_OUTPUT;
- if (s->verbosity >= 2) VPrintf0 ( "rt+rld" );
-
- if (s->smallDecompress) {
-
- /*-- Make a copy of cftab, used in generation of T --*/
- for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i];
-
- /*-- compute the T vector --*/
- for (i = 0; i < nblock; i++) {
- uc = (UChar)(s->ll16[i]);
- SET_LL(i, s->cftabCopy[uc]);
- s->cftabCopy[uc]++;
- }
-
- /*-- Compute T^(-1) by pointer reversal on T --*/
- i = s->origPtr;
- j = GET_LL(i);
- do {
- Int32 tmp = GET_LL(j);
- SET_LL(j, i);
- i = j;
- j = tmp;
- }
- while (i != s->origPtr);
-
- s->tPos = s->origPtr;
- s->nblock_used = 0;
- if (s->blockRandomised) {
- BZ_RAND_INIT_MASK;
- BZ_GET_SMALL(s->k0); s->nblock_used++;
- BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
- } else {
- BZ_GET_SMALL(s->k0); s->nblock_used++;
- }
-
- } else {
-
- /*-- compute the T^(-1) vector --*/
- for (i = 0; i < nblock; i++) {
- uc = (UChar)(s->tt[i] & 0xff);
- s->tt[s->cftab[uc]] |= (i << 8);
- s->cftab[uc]++;
- }
-
- s->tPos = s->tt[s->origPtr] >> 8;
- s->nblock_used = 0;
- if (s->blockRandomised) {
- BZ_RAND_INIT_MASK;
- BZ_GET_FAST(s->k0); s->nblock_used++;
- BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK;
- } else {
- BZ_GET_FAST(s->k0); s->nblock_used++;
- }
-
- }
-
- RETURN(BZ_OK);
-
-
-
- endhdr_2:
-
- GET_UCHAR(BZ_X_ENDHDR_2, uc);
- if (uc != 0x72) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_ENDHDR_3, uc);
- if (uc != 0x45) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_ENDHDR_4, uc);
- if (uc != 0x38) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_ENDHDR_5, uc);
- if (uc != 0x50) RETURN(BZ_DATA_ERROR);
- GET_UCHAR(BZ_X_ENDHDR_6, uc);
- if (uc != 0x90) RETURN(BZ_DATA_ERROR);
-
- s->storedCombinedCRC = 0;
- GET_UCHAR(BZ_X_CCRC_1, uc);
- s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_CCRC_2, uc);
- s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_CCRC_3, uc);
- s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
- GET_UCHAR(BZ_X_CCRC_4, uc);
- s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc);
-
- s->state = BZ_X_IDLE;
- RETURN(BZ_STREAM_END);
-
- default: AssertH ( False, 4001 );
- }
-
- AssertH ( False, 4002 );
-
- save_state_and_return:
-
- s->save_i = i;
- s->save_j = j;
- s->save_t = t;
- s->save_alphaSize = alphaSize;
- s->save_nGroups = nGroups;
- s->save_nSelectors = nSelectors;
- s->save_EOB = EOB;
- s->save_groupNo = groupNo;
- s->save_groupPos = groupPos;
- s->save_nextSym = nextSym;
- s->save_nblockMAX = nblockMAX;
- s->save_nblock = nblock;
- s->save_es = es;
- s->save_N = N;
- s->save_curr = curr;
- s->save_zt = zt;
- s->save_zn = zn;
- s->save_zvec = zvec;
- s->save_zj = zj;
- s->save_gSel = gSel;
- s->save_gMinlen = gMinlen;
- s->save_gLimit = gLimit;
- s->save_gBase = gBase;
- s->save_gPerm = gPerm;
-
- return retVal;
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end decompress.c ---*/
-/*-------------------------------------------------------------*/
diff -Nru r-base-3.2.3/src/extra/bzip2/huffman.c r-base-3.3.1/src/extra/bzip2/huffman.c
--- r-base-3.2.3/src/extra/bzip2/huffman.c 2010-09-27 22:05:02.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/huffman.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,205 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Huffman coding low-level stuff ---*/
-/*--- huffman.c ---*/
-/*-------------------------------------------------------------*/
-
-/* ------------------------------------------------------------------
- This file is part of bzip2/libbzip2, a program and library for
- lossless, block-sorting data compression.
-
- bzip2/libbzip2 version 1.0.6 of 6 September 2010
- Copyright (C) 1996-2010 Julian Seward
-
- Please read the WARNING, DISCLAIMER and PATENTS sections in the
- README file.
-
- This program is released under the terms of the license contained
- in the file LICENSE.
- ------------------------------------------------------------------ */
-
-
-#include "bzlib_private.h"
-
-/*---------------------------------------------------*/
-#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
-#define DEPTHOF(zz1) ((zz1) & 0x000000ff)
-#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
-
-#define ADDWEIGHTS(zw1,zw2) \
- (WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \
- (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
-
-#define UPHEAP(z) \
-{ \
- Int32 zz, tmp; \
- zz = z; tmp = heap[zz]; \
- while (weight[tmp] < weight[heap[zz >> 1]]) { \
- heap[zz] = heap[zz >> 1]; \
- zz >>= 1; \
- } \
- heap[zz] = tmp; \
-}
-
-#define DOWNHEAP(z) \
-{ \
- Int32 zz, yy, tmp; \
- zz = z; tmp = heap[zz]; \
- while (True) { \
- yy = zz << 1; \
- if (yy > nHeap) break; \
- if (yy < nHeap && \
- weight[heap[yy+1]] < weight[heap[yy]]) \
- yy++; \
- if (weight[tmp] < weight[heap[yy]]) break; \
- heap[zz] = heap[yy]; \
- zz = yy; \
- } \
- heap[zz] = tmp; \
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbMakeCodeLengths ( UChar *len,
- Int32 *freq,
- Int32 alphaSize,
- Int32 maxLen )
-{
- /*--
- Nodes and heap entries run from 1. Entry 0
- for both the heap and nodes is a sentinel.
- --*/
- Int32 nNodes, nHeap, n1, n2, i, j, k;
- Bool tooLong;
-
- Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ];
- Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ];
- Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ];
-
- for (i = 0; i < alphaSize; i++)
- weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
-
- while (True) {
-
- nNodes = alphaSize;
- nHeap = 0;
-
- heap[0] = 0;
- weight[0] = 0;
- parent[0] = -2;
-
- for (i = 1; i <= alphaSize; i++) {
- parent[i] = -1;
- nHeap++;
- heap[nHeap] = i;
- UPHEAP(nHeap);
- }
-
- AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 );
-
- while (nHeap > 1) {
- n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
- n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1);
- nNodes++;
- parent[n1] = parent[n2] = nNodes;
- weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
- parent[nNodes] = -1;
- nHeap++;
- heap[nHeap] = nNodes;
- UPHEAP(nHeap);
- }
-
- AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 );
-
- tooLong = False;
- for (i = 1; i <= alphaSize; i++) {
- j = 0;
- k = i;
- while (parent[k] >= 0) { k = parent[k]; j++; }
- len[i-1] = j;
- if (j > maxLen) tooLong = True;
- }
-
- if (! tooLong) break;
-
- /* 17 Oct 04: keep-going condition for the following loop used
- to be 'i < alphaSize', which missed the last element,
- theoretically leading to the possibility of the compressor
- looping. However, this count-scaling step is only needed if
- one of the generated Huffman code words is longer than
- maxLen, which up to and including version 1.0.2 was 20 bits,
- which is extremely unlikely. In version 1.0.3 maxLen was
- changed to 17 bits, which has minimal effect on compression
- ratio, but does mean this scaling step is used from time to
- time, enough to verify that it works.
-
- This means that bzip2-1.0.3 and later will only produce
- Huffman codes with a maximum length of 17 bits. However, in
- order to preserve backwards compatibility with bitstreams
- produced by versions pre-1.0.3, the decompressor must still
- handle lengths of up to 20. */
-
- for (i = 1; i <= alphaSize; i++) {
- j = weight[i] >> 8;
- j = 1 + (j / 2);
- weight[i] = j << 8;
- }
- }
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbAssignCodes ( Int32 *code,
- UChar *length,
- Int32 minLen,
- Int32 maxLen,
- Int32 alphaSize )
-{
- Int32 n, vec, i;
-
- vec = 0;
- for (n = minLen; n <= maxLen; n++) {
- for (i = 0; i < alphaSize; i++)
- if (length[i] == n) { code[i] = vec; vec++; };
- vec <<= 1;
- }
-}
-
-
-/*---------------------------------------------------*/
-void BZ2_hbCreateDecodeTables ( Int32 *limit,
- Int32 *base,
- Int32 *perm,
- UChar *length,
- Int32 minLen,
- Int32 maxLen,
- Int32 alphaSize )
-{
- Int32 pp, i, j, vec;
-
- pp = 0;
- for (i = minLen; i <= maxLen; i++)
- for (j = 0; j < alphaSize; j++)
- if (length[j] == i) { perm[pp] = j; pp++; };
-
- for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0;
- for (i = 0; i < alphaSize; i++) base[length[i]+1]++;
-
- for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1];
-
- for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0;
- vec = 0;
-
- for (i = minLen; i <= maxLen; i++) {
- vec += (base[i+1] - base[i]);
- limit[i] = vec-1;
- vec <<= 1;
- }
- for (i = minLen + 1; i <= maxLen; i++)
- base[i] = ((limit[i-1] + 1) << 1) - base[i];
-}
-
-
-/*-------------------------------------------------------------*/
-/*--- end huffman.c ---*/
-/*-------------------------------------------------------------*/
diff -Nru r-base-3.2.3/src/extra/bzip2/LICENSE r-base-3.3.1/src/extra/bzip2/LICENSE
--- r-base-3.2.3/src/extra/bzip2/LICENSE 2010-09-27 22:05:02.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/LICENSE 1970-01-01 00:00:00.000000000 +0000
@@ -1,42 +0,0 @@
-
---------------------------------------------------------------------------
-
-This program, "bzip2", the associated library "libbzip2", and all
-documentation, are copyright (C) 1996-2010 Julian R Seward. All
-rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
-2. The origin of this software must not be misrepresented; you must
- not claim that you wrote the original software. If you use this
- software in a product, an acknowledgment in the product
- documentation would be appreciated but is not required.
-
-3. Altered source versions must be plainly marked as such, and must
- not be misrepresented as being the original software.
-
-4. The name of the author may not be used to endorse or promote
- products derived from this software without specific prior written
- permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
-OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
-GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Julian Seward, jseward@bzip.org
-bzip2/libbzip2 version 1.0.6 of 6 September 2010
-
---------------------------------------------------------------------------
diff -Nru r-base-3.2.3/src/extra/bzip2/Makefile.in r-base-3.3.1/src/extra/bzip2/Makefile.in
--- r-base-3.2.3/src/extra/bzip2/Makefile.in 2015-03-18 23:02:09.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/Makefile.in 1970-01-01 00:00:00.000000000 +0000
@@ -1,70 +0,0 @@
-#
-# ${R_HOME}/src/extra/bzip2/Makefile
-
-VPATH = @srcdir@
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-
-top_builddir = ../../..
-subdir = src/extra/bzip2
-R_HOME = $(top_builddir)
-
-include $(top_builddir)/Makeconf
-
-BZIP2_CPPFLAGS = -I$(srcdir)
-ALL_CPPFLAGS = $(BZIP2_CPPFLAGS) $(R_XTRA_CPPFLAGS) $(CPPFLAGS) $(DEFS)
-
-SOURCES = blocksort.c bzlib.c compress.c crctable.c decompress.c \
- huffman.c randtable.c
-HEADERS = bzlib.h bzlib_private.h
-DEPENDS = $(SOURCES:.c=.d)
-OBJECTS = $(SOURCES:.c=.o)
-@WANT_R_SHLIB_TRUE@ALL_CFLAGS = $(ALL_CFLAGS_LO) @C_VISIBILITY@
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-DISTFILES = LICENSE Makefile.in Makefile.win R_changes \
- $(SOURCES) $(HEADERS)
-noinst_LIBRARIES = libbz2.a
-#noinst_LIBRARIES = @BUILD_BZLIB_TRUE@ libbz2.a
-libbz2_a_SOURCES = $(SOURCES)
-libbz2_a_OBJECTS = $(OBJECTS)
-
-
-all: R
-
-Makefile: $(srcdir)/Makefile.in \
- $(top_builddir)/config.status \
- $(SOURCES)
- @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
-
-Makedeps: Makefile $(DEPENDS)
- @cat $(DEPENDS) >> Makefile
- @touch $@
-
-R: Makedeps
- @$(MAKE) $(noinst_LIBRARIES)
-
-libbz2.a: $(libbz2_a_OBJECTS)
- rm -f $@
- $(AR) cr $@ $(libbz2_a_OBJECTS)
- $(RANLIB) $@
-
-
-mostlyclean: clean
-clean:
- @-rm -f Makedeps *.d *.o *.lo *.a
-distclean: clean
- @-rm -f Makefile
-maintainer-clean: distclean
-
-install install-strip uninstall TAGS info dvi check:
-
-distdir: $(DISTFILES)
- @for f in $(DISTFILES); do \
- test -f $(distdir)/$${f} \
- || ln $(srcdir)/$${f} $(distdir)/$${f} 2>/dev/null \
- || cp -p $(srcdir)/$${f} $(distdir)/$${f}; \
- done
-
-## Automagically generated dependencies:
-
diff -Nru r-base-3.2.3/src/extra/bzip2/Makefile.win r-base-3.3.1/src/extra/bzip2/Makefile.win
--- r-base-3.2.3/src/extra/bzip2/Makefile.win 2015-03-18 23:02:09.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/Makefile.win 1970-01-01 00:00:00.000000000 +0000
@@ -1,27 +0,0 @@
-#-*- Makefile -*-
-
-include ../../gnuwin32/MkRules
-
-all: makeMakedeps libbz2.a
-
-CPPFLAGS = -I../../include
-
-CSOURCES = blocksort.c huffman.c crctable.c randtable.c compress.c \
- decompress.c bzlib.c
-OBJS = $(CSOURCES:.c=.o)
-
-libbz2.a: $(OBJS)
-
-clean:
- $(RM) *.o *~ *.d Makedeps
-distclean: clean
- @$(RM) libbz2.a
-
-# Dependencies
-DEPS = $(CSOURCES:.c=.d)
-
-makeMakedeps: $(DEPS)
- @$(RM) Makedeps
- @cat $(DEPS) >> Makedeps
-
--include Makedeps
diff -Nru r-base-3.2.3/src/extra/bzip2/randtable.c r-base-3.3.1/src/extra/bzip2/randtable.c
--- r-base-3.2.3/src/extra/bzip2/randtable.c 2010-09-27 22:05:02.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/randtable.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,84 +0,0 @@
-
-/*-------------------------------------------------------------*/
-/*--- Table for randomising repetitive blocks ---*/
-/*--- randtable.c ---*/
-/*-------------------------------------------------------------*/
-
-/* ------------------------------------------------------------------
- This file is part of bzip2/libbzip2, a program and library for
- lossless, block-sorting data compression.
-
- bzip2/libbzip2 version 1.0.6 of 6 September 2010
- Copyright (C) 1996-2010 Julian Seward
-
- Please read the WARNING, DISCLAIMER and PATENTS sections in the
- README file.
-
- This program is released under the terms of the license contained
- in the file LICENSE.
- ------------------------------------------------------------------ */
-
-
-#include "bzlib_private.h"
-
-
-/*---------------------------------------------*/
-Int32 BZ2_rNums[512] = {
- 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
- 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
- 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
- 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
- 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
- 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
- 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
- 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
- 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
- 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
- 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
- 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
- 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
- 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
- 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
- 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
- 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
- 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
- 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
- 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
- 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
- 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
- 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
- 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
- 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
- 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
- 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
- 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
- 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
- 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
- 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
- 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
- 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
- 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
- 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
- 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
- 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
- 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
- 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
- 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
- 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
- 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
- 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
- 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
- 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
- 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
- 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
- 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
- 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
- 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
- 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
- 936, 638
-};
-
-
-/*-------------------------------------------------------------*/
-/*--- end randtable.c ---*/
-/*-------------------------------------------------------------*/
diff -Nru r-base-3.2.3/src/extra/bzip2/R_changes r-base-3.3.1/src/extra/bzip2/R_changes
--- r-base-3.2.3/src/extra/bzip2/R_changes 2015-03-18 23:02:09.000000000 +0000
+++ r-base-3.3.1/src/extra/bzip2/R_changes 1970-01-01 00:00:00.000000000 +0000
@@ -1,330 +0,0 @@
-The changes for R are all to do with portability:
-
-Only files which are needed for the interface used are included.
-File compress.c was renamed to bzcompress.c to avoid clashes.
-
-__inline__ is not portable. We make use of static inlining in the
-file bzlib.c and decompress.c to avoid issues with semantics of
-'extern inline'.
-
-fdopen is POSIX but not C89 nor C99.
-Solaris' cc at one time objected to inlining functions with names
-starting with 'main'.
-C character strings are limited to ca 500 chars.
-Various casts were missing.
-Solaris cc complained about unused code, hence the use of UNREACHED.
-The shifts on signed ints are undefined behaviour (this has been
-reported upstream with no response).
-
-
-diff -ru bzip2-1.0.6/blocksort.c bzip2/blocksort.c
---- bzip2-1.0.6/blocksort.c 2010-09-10 23:37:02.000000000 +0100
-+++ bzip2/blocksort.c 2014-11-22 22:18:15.000000000 +0000
-@@ -28,7 +28,7 @@
-
- /*---------------------------------------------*/
- static
--__inline__
-+R_INLINE
- void fallbackSimpleSort ( UInt32* fmap,
- UInt32* eclass,
- Int32 lo,
-@@ -202,9 +202,10 @@
- bhtab [ 0 .. 2+(nblock/32) ] destroyed
- */
-
--#define SET_BH(zz) bhtab[(zz) >> 5] |= (1 << ((zz) & 31))
--#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~(1 << ((zz) & 31))
--#define ISSET_BH(zz) (bhtab[(zz) >> 5] & (1 << ((zz) & 31)))
-+// R_change: these shifts on signed ints are undefined behaviour.
-+#define SET_BH(zz) bhtab[(zz) >> 5] |= (1U << ((zz) & 31))
-+#define CLEAR_BH(zz) bhtab[(zz) >> 5] &= ~(1U << ((zz) & 31))
-+#define ISSET_BH(zz) (bhtab[(zz) >> 5] & (1U << ((zz) & 31)))
- #define WORD_BH(zz) bhtab[(zz) >> 5]
- #define UNALIGNED_BH(zz) ((zz) & 0x01f)
-
-@@ -342,8 +343,12 @@
- /*---------------------------------------------*/
-
- /*---------------------------------------------*/
-+/* Solaris cc objects to inlining functions whose names start with `main' */
-+#ifdef __SUNPRO_C
-+# define mainGtU BZmainGtU
-+#endif
- static
--__inline__
-+R_INLINE
- Bool mainGtU ( UInt32 i1,
- UInt32 i2,
- UChar* block,
-@@ -579,7 +584,7 @@
- }
-
- static
--__inline__
-+R_INLINE
- UChar mmed3 ( UChar a, UChar b, UChar c )
- {
- UChar t;
-diff -ru bzip2-1.0.6/bzlib.c bzip2/bzlib.c
---- bzip2-1.0.6/bzlib.c 2010-09-10 23:38:23.000000000 +0100
-+++ bzip2/bzlib.c 2014-11-23 07:43:39.000000000 +0000
-@@ -53,8 +53,9 @@
- BZ2_bzlibVersion()
- );
-
-+ /* split up over-long message */
- if (errcode == 1007) {
-- fprintf(stderr,
-+ fprintf(stderr, "%s%s%s",
- "\n*** A special note about internal error number 1007 ***\n"
- "\n"
- "Experience suggests that a common cause of i.e. 1007\n"
-@@ -62,7 +63,7 @@
- "just happens to cross-check the results of huge numbers of\n"
- "memory reads/writes, and so acts (unintendedly) as a stress\n"
- "test of your memory system.\n"
-- "\n"
-+ "\n",
- "I suggest the following: try compressing the file again,\n"
- "possibly monitoring progress in detail with the -vv flag.\n"
- "\n"
-@@ -72,7 +73,7 @@
- " (www.memtest86.com). At the time of writing it is free (GPLd).\n"
- " Memtest86 tests memory much more thorougly than your BIOSs\n"
- " power-on test, and may find failures that the BIOS doesn't.\n"
-- "\n"
-+ "\n",
- "* If the error can be repeatably reproduced, this is a bug in\n"
- " bzip2, and I would very much like to hear about it. Please\n"
- " let me know, and, ideally, save a copy of the file causing the\n"
-@@ -165,7 +166,7 @@
- if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
- if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
-
-- s = BZALLOC( sizeof(EState) );
-+ s = (EState *) BZALLOC( sizeof(EState) );
- if (s == NULL) return BZ_MEM_ERROR;
- s->strm = strm;
-
-@@ -174,9 +175,9 @@
- s->ftab = NULL;
-
- n = 100000 * blockSize100k;
-- s->arr1 = BZALLOC( n * sizeof(UInt32) );
-- s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
-- s->ftab = BZALLOC( 65537 * sizeof(UInt32) );
-+ s->arr1 = (UInt32 *) BZALLOC( n * sizeof(UInt32) );
-+ s->arr2 = (UInt32 *) BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) );
-+ s->ftab = (UInt32 *) BZALLOC( 65537 * sizeof(UInt32) );
-
- if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) {
- if (s->arr1 != NULL) BZFREE(s->arr1);
-@@ -362,7 +363,7 @@
- {
- Bool progress_in = False;
- Bool progress_out = False;
-- EState* s = strm->state;
-+ EState* s = (EState *) strm->state;
-
- while (True) {
-
-@@ -409,7 +410,7 @@
- Bool progress;
- EState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
-- s = strm->state;
-+ s = (EState *) strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
-@@ -469,7 +470,7 @@
- {
- EState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
-- s = strm->state;
-+ s = (EState *) strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
-@@ -505,7 +506,7 @@
- if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc;
- if (strm->bzfree == NULL) strm->bzfree = default_bzfree;
-
-- s = BZALLOC( sizeof(DState) );
-+ s = (DState *) BZALLOC( sizeof(DState) );
- if (s == NULL) return BZ_MEM_ERROR;
- s->strm = strm;
- strm->state = s;
-@@ -684,7 +685,7 @@
-
-
- /*---------------------------------------------------*/
--__inline__ Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
-+Int32 BZ2_indexIntoF ( Int32 indx, Int32 *cftab )
- {
- Int32 nb, na, mid;
- nb = 0;
-@@ -810,7 +811,7 @@
- Bool corrupt;
- DState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
-- s = strm->state;
-+ s = (DState *) strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
-@@ -852,9 +853,11 @@
- }
- }
-
-+#ifdef UNREACHED
- AssertH ( 0, 6001 );
-
- return 0; /*NOTREACHED*/
-+#endif
- }
-
-
-@@ -863,7 +866,7 @@
- {
- DState* s;
- if (strm == NULL) return BZ_PARAM_ERROR;
-- s = strm->state;
-+ s = (DState *) strm->state;
- if (s == NULL) return BZ_PARAM_ERROR;
- if (s->strm != strm) return BZ_PARAM_ERROR;
-
-@@ -934,7 +937,7 @@
- if (ferror(f))
- { BZ_SETERR(BZ_IO_ERROR); return NULL; };
-
-- bzf = malloc ( sizeof(bzFile) );
-+ bzf = (bzFile *) malloc ( sizeof(bzFile) );
- if (bzf == NULL)
- { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
-
-@@ -982,7 +985,7 @@
- { BZ_SETERR(BZ_OK); return; };
-
- bzf->strm.avail_in = len;
-- bzf->strm.next_in = buf;
-+ bzf->strm.next_in = (char *) buf;
-
- while (True) {
- bzf->strm.avail_out = BZ_MAX_UNUSED;
-@@ -1107,7 +1110,7 @@
- if (ferror(f))
- { BZ_SETERR(BZ_IO_ERROR); return NULL; };
-
-- bzf = malloc ( sizeof(bzFile) );
-+ bzf = (bzFile *) malloc ( sizeof(bzFile) );
- if (bzf == NULL)
- { BZ_SETERR(BZ_MEM_ERROR); return NULL; };
-
-@@ -1179,7 +1182,7 @@
- { BZ_SETERR(BZ_OK); return 0; };
-
- bzf->strm.avail_out = len;
-- bzf->strm.next_out = buf;
-+ bzf->strm.next_out = (char *) buf;
-
- while (True) {
-
-@@ -1213,7 +1216,9 @@
-
- }
-
-+#ifdef UNREACHED
- return 0; /*not reached*/
-+#endif
- }
-
-
-@@ -1379,6 +1384,15 @@
- #else
- # define SET_BINARY_MODE(file)
- #endif
-+
-+#if !defined(fdopen) && defined(HAVE_FDOPEN)
-+ FILE *fdopen(int fildes, const char *mode)
-+#ifdef __cplusplus
-+ throw ()
-+#endif
-+ ;
-+#endif
-+
- static
- BZFILE * bzopen_or_bzdopen
- ( const char *path, /* no use when bzdopen */
-@@ -1425,7 +1439,7 @@
- fp = fopen(path,mode2);
- }
- } else {
--#ifdef BZ_STRICT_ANSI
-+#ifndef HAVE_FDOPEN
- fp = NULL;
- #else
- fp = fdopen(fd,mode2);
-@@ -1513,11 +1527,11 @@
- /*---------------------------------------------------*/
- void BZ_API(BZ2_bzclose) (BZFILE* b)
- {
-+ if (b==NULL) return;
-+
- int bzerr;
-- FILE *fp;
-+ FILE *fp = ((bzFile *)b)->handle;
-
-- if (b==NULL) {return;}
-- fp = ((bzFile *)b)->handle;
- if(((bzFile*)b)->writing){
- BZ2_bzWriteClose(&bzerr,b,0,NULL,NULL);
- if(bzerr != BZ_OK){
-diff -ru bzip2-1.0.6/bzlib_private.h bzip2/bzlib_private.h
---- bzip2-1.0.6/bzlib_private.h 2010-09-10 23:41:55.000000000 +0100
-+++ bzip2/bzlib_private.h 2011-03-30 14:00:46.000000000 +0100
-@@ -22,6 +22,9 @@
- #ifndef _BZLIB_PRIVATE_H
- #define _BZLIB_PRIVATE_H
-
-+#include /* for R_INLINE */
-+#undef HAVE_FDOPEN /* we may have, but this re-declares it and
-+ we don't use BZ2_bzdopen */
- #include
-
- #ifndef BZ_NO_STDIO
-diff -ru bzip2-1.0.6/compress.c bzip2/compress.c
---- bzip2-1.0.6/compress.c 2014-11-21 10:38:37.000000000 +0000
-+++ bzip2/compress.c 2011-03-30 14:00:46.000000000 +0100
-@@ -69,7 +69,7 @@
-
- /*---------------------------------------------------*/
- static
--__inline__
-+R_INLINE
- void bsW ( EState* s, Int32 n, UInt32 v )
- {
- bsNEEDW ( n );
-diff -ru bzip2-1.0.6/decompress.c bzip2/decompress.c
---- bzip2-1.0.6/decompress.c 2010-09-10 23:43:17.000000000 +0100
-+++ bzip2/decompress.c 2011-03-30 14:00:46.000000000 +0100
-@@ -209,13 +209,13 @@
- s->blockSize100k -= BZ_HDR_0;
-
- if (s->smallDecompress) {
-- s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
-- s->ll4 = BZALLOC(
-- ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
-- );
-+ s->ll16 = (UInt16*) BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) );
-+ s->ll4 = (UChar *) BZALLOC(
-+ ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar)
-+ );
- if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR);
- } else {
-- s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
-+ s->tt = (UInt32 *) BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) );
- if (s->tt == NULL) RETURN(BZ_MEM_ERROR);
- }
-
diff -Nru r-base-3.2.3/src/extra/intl/Makefile.in r-base-3.3.1/src/extra/intl/Makefile.in
--- r-base-3.2.3/src/extra/intl/Makefile.in 2010-03-17 14:43:05.000000000 +0000
+++ r-base-3.3.1/src/extra/intl/Makefile.in 2015-12-10 23:15:13.000000000 +0000
@@ -56,8 +56,8 @@
@touch $@
libintl.a: $(libintl_a_OBJECTS)
- rm -f $@
- $(AR) cr $@ $(libintl_a_OBJECTS)
+ @rm -f $@
+ $(AR) -cr $@ $(libintl_a_OBJECTS)
$(RANLIB) $@
headers: libgnuintl.h
diff -Nru r-base-3.2.3/src/extra/Makefile.in r-base-3.3.1/src/extra/Makefile.in
--- r-base-3.2.3/src/extra/Makefile.in 2015-03-23 16:16:55.000000000 +0000
+++ r-base-3.3.1/src/extra/Makefile.in 2016-03-16 23:02:11.000000000 +0000
@@ -13,20 +13,15 @@
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
DISTFILES = Makefile.in
-SUBDIRS = blas bzip2 pcre tre xdr xz zlib @USE_NLS_TRUE@ intl
+SUBDIRS = blas tre xdr @USE_NLS_TRUE@ intl
SUBDIRS_WITH_NO_BUILD = graphapp trio tzone win_iconv @USE_NLS_FALSE@ intl
RBLAS =@BLAS_SHLIB_TRUE@ make.blas
-LIBBZ2 =@BUILD_BZLIB_TRUE@ make.bzip2
-LIBPCRE =@BUILD_PCRE_TRUE@ make.pcre
-LIBZ =@BUILD_ZLIB_TRUE@ make.zlib
LIBXDR =@BUILD_XDR_TRUE@ make.xdr
LIBINTL =@BUILD_LIBINTL_TRUE@ make.intl
LIBTRE =@BUILD_TRE_TRUE@ make.tre
-LIBTZONE = @BUILD_TZONE_TRUE@make.tzone
-LIBXZ =@BUILD_XZ_TRUE@ make.xz
-EXTRAS = $(RBLAS) $(LIBBZ2) $(LIBPCRE) $(LIBZ) $(LIBXDR) $(LIBINTL) \
- $(LIBTRE) $(LIBTZONE) $(LIBXZ)
+LIBTZONE =@BUILD_TZONE_TRUE@make.tzone
+EXTRAS = $(RBLAS) $(LIBXDR) $(LIBINTL) $(LIBTRE) $(LIBTZONE)
all: Makefile R
@@ -39,24 +34,12 @@
make.blas: Makefile
@(cd blas; $(MAKE))
-make.bzip2: Makefile
- @(cd bzip2; $(MAKE))
-
-make.pcre: Makefile
- @(cd pcre; $(MAKE))
-
-make.zlib: Makefile
- @(cd zlib; $(MAKE))
-
make.tre: Makefile
@(cd tre; $(MAKE))
make.xdr: Makefile
@(cd xdr; $(MAKE))
-make.xz: Makefile
- @(cd xz; $(MAKE))
-
make.intl: Makefile
@(cd intl; $(MAKE))
diff -Nru r-base-3.2.3/src/extra/pcre/LICENCE r-base-3.3.1/src/extra/pcre/LICENCE
--- r-base-3.2.3/src/extra/pcre/LICENCE 2015-05-13 22:15:08.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/LICENCE 1970-01-01 00:00:00.000000000 +0000
@@ -1,93 +0,0 @@
-PCRE LICENCE
-------------
-
-PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
-Release 8 of PCRE is distributed under the terms of the "BSD" licence, as
-specified below. The documentation for PCRE, supplied in the "doc"
-directory, is distributed under the same terms as the software itself. The data
-in the testdata directory is not copyrighted and is in the public domain.
-
-The basic library functions are written in C and are freestanding. Also
-included in the distribution is a set of C++ wrapper functions, and a
-just-in-time compiler that can be used to optimize pattern matching. These
-are both optional features that can be omitted when the library is built.
-
-
-THE BASIC LIBRARY FUNCTIONS
----------------------------
-
-Written by: Philip Hazel
-Email local part: ph10
-Email domain: cam.ac.uk
-
-University of Cambridge Computing Service,
-Cambridge, England.
-
-Copyright (c) 1997-2015 University of Cambridge
-All rights reserved.
-
-
-PCRE JUST-IN-TIME COMPILATION SUPPORT
--------------------------------------
-
-Written by: Zoltan Herczeg
-Email local part: hzmester
-Emain domain: freemail.hu
-
-Copyright(c) 2010-2015 Zoltan Herczeg
-All rights reserved.
-
-
-STACK-LESS JUST-IN-TIME COMPILER
---------------------------------
-
-Written by: Zoltan Herczeg
-Email local part: hzmester
-Emain domain: freemail.hu
-
-Copyright(c) 2009-2015 Zoltan Herczeg
-All rights reserved.
-
-
-THE C++ WRAPPER FUNCTIONS
--------------------------
-
-Contributed by: Google Inc.
-
-Copyright (c) 2007-2012, Google Inc.
-All rights reserved.
-
-
-THE "BSD" LICENCE
------------------
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the name of Google
- Inc. nor the names of their contributors may be used to endorse or
- promote products derived from this software without specific prior
- written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
-
-End
diff -Nru r-base-3.2.3/src/extra/pcre/Makefile.in r-base-3.3.1/src/extra/pcre/Makefile.in
--- r-base-3.2.3/src/extra/pcre/Makefile.in 2015-03-18 23:02:10.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/Makefile.in 1970-01-01 00:00:00.000000000 +0000
@@ -1,82 +0,0 @@
-#
-# ${R_HOME}/src/extra/pcre/Makefile
-
-VPATH = @srcdir@
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-
-top_builddir = ../../..
-subdir = src/extra/pcre
-R_HOME = $(top_builddir)
-
-include $(top_builddir)/Makeconf
-
-PCRE_CPPFLAGS = -I$(srcdir) -DLINK_SIZE=2
-ALL_CPPFLAGS = $(PCRE_CPPFLAGS) $(R_XTRA_CPPFLAGS) $(CPPFLAGS) $(DEFS)
-
-SOURCES = pcre_chartables.c pcre_compile.c pcre_config.c pcre_exec.c \
- pcre_fullinfo.c pcre_get.c pcre_globals.c pcre_jit_compile.c \
- pcre_maketables.c pcre_newline.c pcre_ord2utf8.c pcre_refcount.c \
- pcre_study.c pcre_tables.c pcre_ucd.c \
- pcre_valid_utf8.c pcre_version.c pcre_xclass.c
-
-HEADERS = pcre_internal.h pcre.h ucp.h
-DEPENDS = $(SOURCES:.c=.d)
-OBJECTS = $(SOURCES:.c=.o)
-@WANT_R_SHLIB_TRUE@ALL_CFLAGS = $(ALL_CFLAGS_LO) @C_VISIBILITY@
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-DISTFILES = LICENCE Makefile.in Makefile.win R_changes \
- $(SOURCES) $(HEADERS)
-
-SUBDIRS_WITH_NO_BUILD = sljit
-
-
-noinst_LIBRARIES = @BUILD_PCRE_TRUE@ libpcre.a
-libpcre_a_SOURCES = $(SOURCES)
-libpcre_a_OBJECTS = $(OBJECTS)
-
-
-all: R
-
-Makefile: $(srcdir)/Makefile.in \
- $(top_builddir)/config.status \
- $(SOURCES)
- @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
-
-Makedeps: Makefile $(DEPENDS)
- @cat $(DEPENDS) >> Makefile
- @touch $@
-
-R: Makefile
- @$(MAKE) Makedeps
- @BUILD_PCRE_TRUE@ @$(MAKE) $(noinst_LIBRARIES)
-
-libpcre.a: $(libpcre_a_OBJECTS)
- rm -f $@
- $(AR) cr $@ $(libpcre_a_OBJECTS)
- $(RANLIB) $@
-
-mostlyclean: clean
-clean:
- @-rm -f Makedeps *.d *.o *.lo *.a
-distclean: clean
- @-rm -f Makefile
-maintainer-clean: distclean
-
-install install-strip uninstall TAGS info dvi check:
-
-distdir: $(DISTFILES)
- @for f in $(DISTFILES); do \
- test -f $(distdir)/$${f} \
- || ln $(srcdir)/$${f} $(distdir)/$${f} 2>/dev/null \
- || cp -p $(srcdir)/$${f} $(distdir)/$${f}; \
- done
- @for d in $(SUBDIRS_WITH_NO_BUILD); do \
- ((cd $(srcdir); $(TAR) -c -f - --exclude=.svn --exclude=CVS $${d}) \
- | (cd $(distdir); $(TAR) -x -f -)) \
- || exit 1; \
- done
-
-## Automagically generated dependencies:
-
diff -Nru r-base-3.2.3/src/extra/pcre/Makefile.win r-base-3.3.1/src/extra/pcre/Makefile.win
--- r-base-3.2.3/src/extra/pcre/Makefile.win 2015-03-18 23:02:11.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/Makefile.win 1970-01-01 00:00:00.000000000 +0000
@@ -1,34 +0,0 @@
-#-*- Makefile -*-
-include ../../gnuwin32/MkRules
-
-DEFS = -DWIN32 -DPCRE_STATIC -DLINK_SIZE=2
-
-CPPFLAGS = -I../../include -I. $(DEFS)
-
-## done this way for parallel make
-all:
- $(MAKE) -f Makefile.win makeMakedeps
- $(MAKE) -f Makefile.win libpcre.a
-
-CSOURCES = pcre_chartables.c pcre_compile.c pcre_config.c pcre_exec.c \
- pcre_fullinfo.c pcre_get.c pcre_globals.c pcre_jit_compile.c \
- pcre_maketables.c pcre_newline.c pcre_ord2utf8.c pcre_refcount.c \
- pcre_study.c pcre_tables.c pcre_ucd.c \
- pcre_valid_utf8.c pcre_version.c pcre_xclass.c
-OBJS = $(CSOURCES:.c=.o)
-libpcre.a: $(OBJS)
-
-clean:
- @$(RM) *.o *~ *.d Makedeps
-
-distclean: clean
- @$(RM) libpcre.a
-
-# Dependencies
-DEPS = $(CSOURCES:.c=.d)
-
-makeMakedeps: $(DEPS)
- @$(RM) Makedeps
- @cat $(DEPS) >> Makedeps
-
--include Makedeps
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_chartables.c r-base-3.3.1/src/extra/pcre/pcre_chartables.c
--- r-base-3.2.3/src/extra/pcre/pcre_chartables.c 2015-11-26 23:15:13.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_chartables.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,198 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* This file contains character tables that are used when no external tables
-are passed to PCRE by the application that calls it. The tables are used only
-for characters whose code values are less than 256.
-
-This is a default version of the tables that assumes ASCII encoding. A program
-called dftables (which is distributed with PCRE) can be used to build
-alternative versions of this file. This is necessary if you are running in an
-EBCDIC environment, or if you want to default to a different encoding, for
-example ISO-8859-1. When dftables is run, it creates these tables in the
-current locale. If PCRE is configured with --enable-rebuild-chartables, this
-happens automatically.
-
-The following #includes are present because without them gcc 4.x may remove the
-array definition from the final binary if PCRE is built into a static library
-and dead code stripping is activated. This leads to link errors. Pulling in the
-header ensures that the array gets flagged as "someone outside this compilation
-unit might reference this" and so it will always be supplied to the linker. */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pcre_internal.h"
-
-const pcre_uint8 PRIV(default_tables)[] = {
-
-/* This table is a lower casing table. */
-
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 97, 98, 99,100,101,102,103,
- 104,105,106,107,108,109,110,111,
- 112,113,114,115,116,117,118,119,
- 120,121,122, 91, 92, 93, 94, 95,
- 96, 97, 98, 99,100,101,102,103,
- 104,105,106,107,108,109,110,111,
- 112,113,114,115,116,117,118,119,
- 120,121,122,123,124,125,126,127,
- 128,129,130,131,132,133,134,135,
- 136,137,138,139,140,141,142,143,
- 144,145,146,147,148,149,150,151,
- 152,153,154,155,156,157,158,159,
- 160,161,162,163,164,165,166,167,
- 168,169,170,171,172,173,174,175,
- 176,177,178,179,180,181,182,183,
- 184,185,186,187,188,189,190,191,
- 192,193,194,195,196,197,198,199,
- 200,201,202,203,204,205,206,207,
- 208,209,210,211,212,213,214,215,
- 216,217,218,219,220,221,222,223,
- 224,225,226,227,228,229,230,231,
- 232,233,234,235,236,237,238,239,
- 240,241,242,243,244,245,246,247,
- 248,249,250,251,252,253,254,255,
-
-/* This table is a case flipping table. */
-
- 0, 1, 2, 3, 4, 5, 6, 7,
- 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23,
- 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39,
- 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 97, 98, 99,100,101,102,103,
- 104,105,106,107,108,109,110,111,
- 112,113,114,115,116,117,118,119,
- 120,121,122, 91, 92, 93, 94, 95,
- 96, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87,
- 88, 89, 90,123,124,125,126,127,
- 128,129,130,131,132,133,134,135,
- 136,137,138,139,140,141,142,143,
- 144,145,146,147,148,149,150,151,
- 152,153,154,155,156,157,158,159,
- 160,161,162,163,164,165,166,167,
- 168,169,170,171,172,173,174,175,
- 176,177,178,179,180,181,182,183,
- 184,185,186,187,188,189,190,191,
- 192,193,194,195,196,197,198,199,
- 200,201,202,203,204,205,206,207,
- 208,209,210,211,212,213,214,215,
- 216,217,218,219,220,221,222,223,
- 224,225,226,227,228,229,230,231,
- 232,233,234,235,236,237,238,239,
- 240,241,242,243,244,245,246,247,
- 248,249,250,251,252,253,254,255,
-
-/* This table contains bit maps for various character classes. Each map is 32
-bytes long and the bits run from the least significant end of each byte. The
-classes that have their own maps are: space, xdigit, digit, upper, lower, word,
-graph, print, punct, and cntrl. Other classes are built from combinations. */
-
- 0x00,0x3e,0x00,0x00,0x01,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
- 0x7e,0x00,0x00,0x00,0x7e,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xfe,0xff,0xff,0x07,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0x07,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,
- 0xfe,0xff,0xff,0x87,0xfe,0xff,0xff,0x07,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0x00,0x00,0x00,0x00,0xfe,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
- 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0x00,0x00,0x00,0x00,0xfe,0xff,0x00,0xfc,
- 0x01,0x00,0x00,0xf8,0x01,0x00,0x00,0x78,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
- 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-
-/* This table identifies various classes of character by individual bits:
- 0x01 white space character
- 0x02 letter
- 0x04 decimal digit
- 0x08 hexadecimal digit
- 0x10 alphanumeric or '_'
- 0x80 regular expression metacharacter or binary zero
-*/
-
- 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */
- 0x00,0x01,0x01,0x01,0x01,0x01,0x00,0x00, /* 8- 15 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 16- 23 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */
- 0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00, /* - ' */
- 0x80,0x80,0x80,0x80,0x00,0x00,0x80,0x00, /* ( - / */
- 0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /* 0 - 7 */
- 0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x80, /* 8 - ? */
- 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* @ - G */
- 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* H - O */
- 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* P - W */
- 0x12,0x12,0x12,0x80,0x80,0x00,0x80,0x10, /* X - _ */
- 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* ` - g */
- 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* h - o */
- 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* p - w */
- 0x12,0x12,0x12,0x80,0x80,0x00,0x00,0x00, /* x -127 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
-
-/* End of pcre_chartables.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_compile.c r-base-3.3.1/src/extra/pcre/pcre_compile.c
--- r-base-3.2.3/src/extra/pcre/pcre_compile.c 2015-11-26 23:15:10.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_compile.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,9732 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2014 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains the external function pcre_compile(), along with
-supporting internal functions that are not used by other modules. */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#define NLBLOCK cd /* Block containing newline information */
-#define PSSTART start_pattern /* Field containing pattern start */
-#define PSEND end_pattern /* Field containing pattern end */
-
-#include "pcre_internal.h"
-
-
-/* When PCRE_DEBUG is defined, we need the pcre(16|32)_printint() function, which
-is also used by pcretest. PCRE_DEBUG is not defined when building a production
-library. We do not need to select pcre16_printint.c specially, because the
-COMPILE_PCREx macro will already be appropriately set. */
-
-#ifdef PCRE_DEBUG
-/* pcre_printint.c should not include any headers */
-#define PCRE_INCLUDED
-#include "pcre_printint.c"
-#undef PCRE_INCLUDED
-#endif
-
-
-/* Macro for setting individual bits in class bitmaps. */
-
-#define SETBIT(a,b) a[(b)/8] |= (1 << ((b)&7))
-
-/* Maximum length value to check against when making sure that the integer that
-holds the compiled pattern length does not overflow. We make it a bit less than
-INT_MAX to allow for adding in group terminating bytes, so that we don't have
-to check them every time. */
-
-#define OFLOW_MAX (INT_MAX - 20)
-
-/* Definitions to allow mutual recursion */
-
-static int
- add_list_to_class(pcre_uint8 *, pcre_uchar **, int, compile_data *,
- const pcre_uint32 *, unsigned int);
-
-static BOOL
- compile_regex(int, pcre_uchar **, const pcre_uchar **, int *, BOOL, BOOL, int, int,
- pcre_uint32 *, pcre_int32 *, pcre_uint32 *, pcre_int32 *, branch_chain *,
- compile_data *, int *);
-
-
-
-/*************************************************
-* Code parameters and static tables *
-*************************************************/
-
-/* This value specifies the size of stack workspace that is used during the
-first pre-compile phase that determines how much memory is required. The regex
-is partly compiled into this space, but the compiled parts are discarded as
-soon as they can be, so that hopefully there will never be an overrun. The code
-does, however, check for an overrun. The largest amount I've seen used is 218,
-so this number is very generous.
-
-The same workspace is used during the second, actual compile phase for
-remembering forward references to groups so that they can be filled in at the
-end. Each entry in this list occupies LINK_SIZE bytes, so even when LINK_SIZE
-is 4 there is plenty of room for most patterns. However, the memory can get
-filled up by repetitions of forward references, for example patterns like
-/(?1){0,1999}(b)/, and one user did hit the limit. The code has been changed so
-that the workspace is expanded using malloc() in this situation. The value
-below is therefore a minimum, and we put a maximum on it for safety. The
-minimum is now also defined in terms of LINK_SIZE so that the use of malloc()
-kicks in at the same number of forward references in all cases. */
-
-#define COMPILE_WORK_SIZE (2048*LINK_SIZE)
-#define COMPILE_WORK_SIZE_MAX (100*COMPILE_WORK_SIZE)
-
-/* This value determines the size of the initial vector that is used for
-remembering named groups during the pre-compile. It is allocated on the stack,
-but if it is too small, it is expanded using malloc(), in a similar way to the
-workspace. The value is the number of slots in the list. */
-
-#define NAMED_GROUP_LIST_SIZE 20
-
-/* The overrun tests check for a slightly smaller size so that they detect the
-overrun before it actually does run off the end of the data block. */
-
-#define WORK_SIZE_SAFETY_MARGIN (100)
-
-/* Private flags added to firstchar and reqchar. */
-
-#define REQ_CASELESS (1 << 0) /* Indicates caselessness */
-#define REQ_VARY (1 << 1) /* Reqchar followed non-literal item */
-/* Negative values for the firstchar and reqchar flags */
-#define REQ_UNSET (-2)
-#define REQ_NONE (-1)
-
-/* Repeated character flags. */
-
-#define UTF_LENGTH 0x10000000l /* The char contains its length. */
-
-/* Table for handling escaped characters in the range '0'-'z'. Positive returns
-are simple data values; negative values are for special things like \d and so
-on. Zero means further processing is needed (for things like \x), or the escape
-is invalid. */
-
-#ifndef EBCDIC
-
-/* This is the "normal" table for ASCII systems or for EBCDIC systems running
-in UTF-8 mode. */
-
-static const short int escapes[] = {
- 0, 0,
- 0, 0,
- 0, 0,
- 0, 0,
- 0, 0,
- CHAR_COLON, CHAR_SEMICOLON,
- CHAR_LESS_THAN_SIGN, CHAR_EQUALS_SIGN,
- CHAR_GREATER_THAN_SIGN, CHAR_QUESTION_MARK,
- CHAR_COMMERCIAL_AT, -ESC_A,
- -ESC_B, -ESC_C,
- -ESC_D, -ESC_E,
- 0, -ESC_G,
- -ESC_H, 0,
- 0, -ESC_K,
- 0, 0,
- -ESC_N, 0,
- -ESC_P, -ESC_Q,
- -ESC_R, -ESC_S,
- 0, 0,
- -ESC_V, -ESC_W,
- -ESC_X, 0,
- -ESC_Z, CHAR_LEFT_SQUARE_BRACKET,
- CHAR_BACKSLASH, CHAR_RIGHT_SQUARE_BRACKET,
- CHAR_CIRCUMFLEX_ACCENT, CHAR_UNDERSCORE,
- CHAR_GRAVE_ACCENT, ESC_a,
- -ESC_b, 0,
- -ESC_d, ESC_e,
- ESC_f, 0,
- -ESC_h, 0,
- 0, -ESC_k,
- 0, 0,
- ESC_n, 0,
- -ESC_p, 0,
- ESC_r, -ESC_s,
- ESC_tee, 0,
- -ESC_v, -ESC_w,
- 0, 0,
- -ESC_z
-};
-
-#else
-
-/* This is the "abnormal" table for EBCDIC systems without UTF-8 support. */
-
-static const short int escapes[] = {
-/* 48 */ 0, 0, 0, '.', '<', '(', '+', '|',
-/* 50 */ '&', 0, 0, 0, 0, 0, 0, 0,
-/* 58 */ 0, 0, '!', '$', '*', ')', ';', '~',
-/* 60 */ '-', '/', 0, 0, 0, 0, 0, 0,
-/* 68 */ 0, 0, '|', ',', '%', '_', '>', '?',
-/* 70 */ 0, 0, 0, 0, 0, 0, 0, 0,
-/* 78 */ 0, '`', ':', '#', '@', '\'', '=', '"',
-/* 80 */ 0, ESC_a, -ESC_b, 0, -ESC_d, ESC_e, ESC_f, 0,
-/* 88 */-ESC_h, 0, 0, '{', 0, 0, 0, 0,
-/* 90 */ 0, 0, -ESC_k, 0, 0, ESC_n, 0, -ESC_p,
-/* 98 */ 0, ESC_r, 0, '}', 0, 0, 0, 0,
-/* A0 */ 0, '~', -ESC_s, ESC_tee, 0,-ESC_v, -ESC_w, 0,
-/* A8 */ 0,-ESC_z, 0, 0, 0, '[', 0, 0,
-/* B0 */ 0, 0, 0, 0, 0, 0, 0, 0,
-/* B8 */ 0, 0, 0, 0, 0, ']', '=', '-',
-/* C0 */ '{',-ESC_A, -ESC_B, -ESC_C, -ESC_D,-ESC_E, 0, -ESC_G,
-/* C8 */-ESC_H, 0, 0, 0, 0, 0, 0, 0,
-/* D0 */ '}', 0, -ESC_K, 0, 0,-ESC_N, 0, -ESC_P,
-/* D8 */-ESC_Q,-ESC_R, 0, 0, 0, 0, 0, 0,
-/* E0 */ '\\', 0, -ESC_S, 0, 0,-ESC_V, -ESC_W, -ESC_X,
-/* E8 */ 0,-ESC_Z, 0, 0, 0, 0, 0, 0,
-/* F0 */ 0, 0, 0, 0, 0, 0, 0, 0,
-/* F8 */ 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-/* We also need a table of characters that may follow \c in an EBCDIC
-environment for characters 0-31. */
-
-static unsigned char ebcdic_escape_c[] = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
-
-#endif
-
-
-/* Table of special "verbs" like (*PRUNE). This is a short table, so it is
-searched linearly. Put all the names into a single string, in order to reduce
-the number of relocations when a shared library is dynamically linked. The
-string is built from string macros so that it works in UTF-8 mode on EBCDIC
-platforms. */
-
-typedef struct verbitem {
- int len; /* Length of verb name */
- int op; /* Op when no arg, or -1 if arg mandatory */
- int op_arg; /* Op when arg present, or -1 if not allowed */
-} verbitem;
-
-static const char verbnames[] =
- "\0" /* Empty name is a shorthand for MARK */
- STRING_MARK0
- STRING_ACCEPT0
- STRING_COMMIT0
- STRING_F0
- STRING_FAIL0
- STRING_PRUNE0
- STRING_SKIP0
- STRING_THEN;
-
-static const verbitem verbs[] = {
- { 0, -1, OP_MARK },
- { 4, -1, OP_MARK },
- { 6, OP_ACCEPT, -1 },
- { 6, OP_COMMIT, -1 },
- { 1, OP_FAIL, -1 },
- { 4, OP_FAIL, -1 },
- { 5, OP_PRUNE, OP_PRUNE_ARG },
- { 4, OP_SKIP, OP_SKIP_ARG },
- { 4, OP_THEN, OP_THEN_ARG }
-};
-
-static const int verbcount = sizeof(verbs)/sizeof(verbitem);
-
-
-/* Substitutes for [[:<:]] and [[:>:]], which mean start and end of word in
-another regex library. */
-
-static const pcre_uchar sub_start_of_word[] = {
- CHAR_BACKSLASH, CHAR_b, CHAR_LEFT_PARENTHESIS, CHAR_QUESTION_MARK,
- CHAR_EQUALS_SIGN, CHAR_BACKSLASH, CHAR_w, CHAR_RIGHT_PARENTHESIS, '\0' };
-
-static const pcre_uchar sub_end_of_word[] = {
- CHAR_BACKSLASH, CHAR_b, CHAR_LEFT_PARENTHESIS, CHAR_QUESTION_MARK,
- CHAR_LESS_THAN_SIGN, CHAR_EQUALS_SIGN, CHAR_BACKSLASH, CHAR_w,
- CHAR_RIGHT_PARENTHESIS, '\0' };
-
-
-/* Tables of names of POSIX character classes and their lengths. The names are
-now all in a single string, to reduce the number of relocations when a shared
-library is dynamically loaded. The list of lengths is terminated by a zero
-length entry. The first three must be alpha, lower, upper, as this is assumed
-for handling case independence. The indices for graph, print, and punct are
-needed, so identify them. */
-
-static const char posix_names[] =
- STRING_alpha0 STRING_lower0 STRING_upper0 STRING_alnum0
- STRING_ascii0 STRING_blank0 STRING_cntrl0 STRING_digit0
- STRING_graph0 STRING_print0 STRING_punct0 STRING_space0
- STRING_word0 STRING_xdigit;
-
-static const pcre_uint8 posix_name_lengths[] = {
- 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 0 };
-
-#define PC_GRAPH 8
-#define PC_PRINT 9
-#define PC_PUNCT 10
-
-
-/* Table of class bit maps for each POSIX class. Each class is formed from a
-base map, with an optional addition or removal of another map. Then, for some
-classes, there is some additional tweaking: for [:blank:] the vertical space
-characters are removed, and for [:alpha:] and [:alnum:] the underscore
-character is removed. The triples in the table consist of the base map offset,
-second map offset or -1 if no second map, and a non-negative value for map
-addition or a negative value for map subtraction (if there are two maps). The
-absolute value of the third field has these meanings: 0 => no tweaking, 1 =>
-remove vertical space characters, 2 => remove underscore. */
-
-static const int posix_class_maps[] = {
- cbit_word, cbit_digit, -2, /* alpha */
- cbit_lower, -1, 0, /* lower */
- cbit_upper, -1, 0, /* upper */
- cbit_word, -1, 2, /* alnum - word without underscore */
- cbit_print, cbit_cntrl, 0, /* ascii */
- cbit_space, -1, 1, /* blank - a GNU extension */
- cbit_cntrl, -1, 0, /* cntrl */
- cbit_digit, -1, 0, /* digit */
- cbit_graph, -1, 0, /* graph */
- cbit_print, -1, 0, /* print */
- cbit_punct, -1, 0, /* punct */
- cbit_space, -1, 0, /* space */
- cbit_word, -1, 0, /* word - a Perl extension */
- cbit_xdigit,-1, 0 /* xdigit */
-};
-
-/* Table of substitutes for \d etc when PCRE_UCP is set. They are replaced by
-Unicode property escapes. */
-
-#ifdef SUPPORT_UCP
-static const pcre_uchar string_PNd[] = {
- CHAR_BACKSLASH, CHAR_P, CHAR_LEFT_CURLY_BRACKET,
- CHAR_N, CHAR_d, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_pNd[] = {
- CHAR_BACKSLASH, CHAR_p, CHAR_LEFT_CURLY_BRACKET,
- CHAR_N, CHAR_d, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_PXsp[] = {
- CHAR_BACKSLASH, CHAR_P, CHAR_LEFT_CURLY_BRACKET,
- CHAR_X, CHAR_s, CHAR_p, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_pXsp[] = {
- CHAR_BACKSLASH, CHAR_p, CHAR_LEFT_CURLY_BRACKET,
- CHAR_X, CHAR_s, CHAR_p, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_PXwd[] = {
- CHAR_BACKSLASH, CHAR_P, CHAR_LEFT_CURLY_BRACKET,
- CHAR_X, CHAR_w, CHAR_d, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_pXwd[] = {
- CHAR_BACKSLASH, CHAR_p, CHAR_LEFT_CURLY_BRACKET,
- CHAR_X, CHAR_w, CHAR_d, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-
-static const pcre_uchar *substitutes[] = {
- string_PNd, /* \D */
- string_pNd, /* \d */
- string_PXsp, /* \S */ /* Xsp is Perl space, but from 8.34, Perl */
- string_pXsp, /* \s */ /* space and POSIX space are the same. */
- string_PXwd, /* \W */
- string_pXwd /* \w */
-};
-
-/* The POSIX class substitutes must be in the order of the POSIX class names,
-defined above, and there are both positive and negative cases. NULL means no
-general substitute of a Unicode property escape (\p or \P). However, for some
-POSIX classes (e.g. graph, print, punct) a special property code is compiled
-directly. */
-
-static const pcre_uchar string_pL[] = {
- CHAR_BACKSLASH, CHAR_p, CHAR_LEFT_CURLY_BRACKET,
- CHAR_L, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_pLl[] = {
- CHAR_BACKSLASH, CHAR_p, CHAR_LEFT_CURLY_BRACKET,
- CHAR_L, CHAR_l, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_pLu[] = {
- CHAR_BACKSLASH, CHAR_p, CHAR_LEFT_CURLY_BRACKET,
- CHAR_L, CHAR_u, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_pXan[] = {
- CHAR_BACKSLASH, CHAR_p, CHAR_LEFT_CURLY_BRACKET,
- CHAR_X, CHAR_a, CHAR_n, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_h[] = {
- CHAR_BACKSLASH, CHAR_h, '\0' };
-static const pcre_uchar string_pXps[] = {
- CHAR_BACKSLASH, CHAR_p, CHAR_LEFT_CURLY_BRACKET,
- CHAR_X, CHAR_p, CHAR_s, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_PL[] = {
- CHAR_BACKSLASH, CHAR_P, CHAR_LEFT_CURLY_BRACKET,
- CHAR_L, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_PLl[] = {
- CHAR_BACKSLASH, CHAR_P, CHAR_LEFT_CURLY_BRACKET,
- CHAR_L, CHAR_l, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_PLu[] = {
- CHAR_BACKSLASH, CHAR_P, CHAR_LEFT_CURLY_BRACKET,
- CHAR_L, CHAR_u, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_PXan[] = {
- CHAR_BACKSLASH, CHAR_P, CHAR_LEFT_CURLY_BRACKET,
- CHAR_X, CHAR_a, CHAR_n, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-static const pcre_uchar string_H[] = {
- CHAR_BACKSLASH, CHAR_H, '\0' };
-static const pcre_uchar string_PXps[] = {
- CHAR_BACKSLASH, CHAR_P, CHAR_LEFT_CURLY_BRACKET,
- CHAR_X, CHAR_p, CHAR_s, CHAR_RIGHT_CURLY_BRACKET, '\0' };
-
-static const pcre_uchar *posix_substitutes[] = {
- string_pL, /* alpha */
- string_pLl, /* lower */
- string_pLu, /* upper */
- string_pXan, /* alnum */
- NULL, /* ascii */
- string_h, /* blank */
- NULL, /* cntrl */
- string_pNd, /* digit */
- NULL, /* graph */
- NULL, /* print */
- NULL, /* punct */
- string_pXps, /* space */ /* Xps is POSIX space, but from 8.34 */
- string_pXwd, /* word */ /* Perl and POSIX space are the same */
- NULL, /* xdigit */
- /* Negated cases */
- string_PL, /* ^alpha */
- string_PLl, /* ^lower */
- string_PLu, /* ^upper */
- string_PXan, /* ^alnum */
- NULL, /* ^ascii */
- string_H, /* ^blank */
- NULL, /* ^cntrl */
- string_PNd, /* ^digit */
- NULL, /* ^graph */
- NULL, /* ^print */
- NULL, /* ^punct */
- string_PXps, /* ^space */ /* Xps is POSIX space, but from 8.34 */
- string_PXwd, /* ^word */ /* Perl and POSIX space are the same */
- NULL /* ^xdigit */
-};
-#define POSIX_SUBSIZE (sizeof(posix_substitutes) / sizeof(pcre_uchar *))
-#endif
-
-#define STRING(a) # a
-#define XSTRING(s) STRING(s)
-
-/* The texts of compile-time error messages. These are "char *" because they
-are passed to the outside world. Do not ever re-use any error number, because
-they are documented. Always add a new error instead. Messages marked DEAD below
-are no longer used. This used to be a table of strings, but in order to reduce
-the number of relocations needed when a shared library is loaded dynamically,
-it is now one long string. We cannot use a table of offsets, because the
-lengths of inserts such as XSTRING(MAX_NAME_SIZE) are not known. Instead, we
-simply count through to the one we want - this isn't a performance issue
-because these strings are used only when there is a compilation error.
-
-Each substring ends with \0 to insert a null character. This includes the final
-substring, so that the whole string ends with \0\0, which can be detected when
-counting through. */
-
-static const char error_texts[] =
- "no error\0"
- "\\ at end of pattern\0"
- "\\c at end of pattern\0"
- "unrecognized character follows \\\0"
- "numbers out of order in {} quantifier\0"
- /* 5 */
- "number too big in {} quantifier\0"
- "missing terminating ] for character class\0"
- "invalid escape sequence in character class\0"
- "range out of order in character class\0"
- "nothing to repeat\0"
- /* 10 */
- "internal error: invalid forward reference offset\0"
- "internal error: unexpected repeat\0"
- "unrecognized character after (? or (?-\0"
- "POSIX named classes are supported only within a class\0"
- "missing )\0"
- /* 15 */
- "reference to non-existent subpattern\0"
- "erroffset passed as NULL\0"
- "unknown option bit(s) set\0"
- "missing ) after comment\0"
- "parentheses nested too deeply\0" /** DEAD **/
- /* 20 */
- "regular expression is too large\0"
- "failed to get memory\0"
- "unmatched parentheses\0"
- "internal error: code overflow\0"
- "unrecognized character after (?<\0"
- /* 25 */
- "lookbehind assertion is not fixed length\0"
- "malformed number or name after (?(\0"
- "conditional group contains more than two branches\0"
- "assertion expected after (?(\0"
- "(?R or (?[+-]digits must be followed by )\0"
- /* 30 */
- "unknown POSIX class name\0"
- "POSIX collating elements are not supported\0"
- "this version of PCRE is compiled without UTF support\0"
- "spare error\0" /** DEAD **/
- "character value in \\x{} or \\o{} is too large\0"
- /* 35 */
- "invalid condition (?(0)\0"
- "\\C not allowed in lookbehind assertion\0"
- "PCRE does not support \\L, \\l, \\N{name}, \\U, or \\u\0"
- "number after (?C is > 255\0"
- "closing ) for (?C expected\0"
- /* 40 */
- "recursive call could loop indefinitely\0"
- "unrecognized character after (?P\0"
- "syntax error in subpattern name (missing terminator)\0"
- "two named subpatterns have the same name\0"
- "invalid UTF-8 string\0"
- /* 45 */
- "support for \\P, \\p, and \\X has not been compiled\0"
- "malformed \\P or \\p sequence\0"
- "unknown property name after \\P or \\p\0"
- "subpattern name is too long (maximum " XSTRING(MAX_NAME_SIZE) " characters)\0"
- "too many named subpatterns (maximum " XSTRING(MAX_NAME_COUNT) ")\0"
- /* 50 */
- "repeated subpattern is too long\0" /** DEAD **/
- "octal value is greater than \\377 in 8-bit non-UTF-8 mode\0"
- "internal error: overran compiling workspace\0"
- "internal error: previously-checked referenced subpattern not found\0"
- "DEFINE group contains more than one branch\0"
- /* 55 */
- "repeating a DEFINE group is not allowed\0" /** DEAD **/
- "inconsistent NEWLINE options\0"
- "\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number\0"
- "a numbered reference must not be zero\0"
- "an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT)\0"
- /* 60 */
- "(*VERB) not recognized or malformed\0"
- "number is too big\0"
- "subpattern name expected\0"
- "digit expected after (?+\0"
- "] is an invalid data character in JavaScript compatibility mode\0"
- /* 65 */
- "different names for subpatterns of the same number are not allowed\0"
- "(*MARK) must have an argument\0"
- "this version of PCRE is not compiled with Unicode property support\0"
-#ifndef EBCDIC
- "\\c must be followed by an ASCII character\0"
-#else
- "\\c must be followed by a letter or one of [\\]^_?\0"
-#endif
- "\\k is not followed by a braced, angle-bracketed, or quoted name\0"
- /* 70 */
- "internal error: unknown opcode in find_fixedlength()\0"
- "\\N is not supported in a class\0"
- "too many forward references\0"
- "disallowed Unicode code point (>= 0xd800 && <= 0xdfff)\0"
- "invalid UTF-16 string\0"
- /* 75 */
- "name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)\0"
- "character value in \\u.... sequence is too large\0"
- "invalid UTF-32 string\0"
- "setting UTF is disabled by the application\0"
- "non-hex character in \\x{} (closing brace missing?)\0"
- /* 80 */
- "non-octal character in \\o{} (closing brace missing?)\0"
- "missing opening brace after \\o\0"
- "parentheses are too deeply nested\0"
- "invalid range in character class\0"
- "group name must start with a non-digit\0"
- /* 85 */
- "parentheses are too deeply nested (stack check)\0"
- "digits missing in \\x{} or \\o{}\0"
- ;
-
-/* Table to identify digits and hex digits. This is used when compiling
-patterns. Note that the tables in chartables are dependent on the locale, and
-may mark arbitrary characters as digits - but the PCRE compiling code expects
-to handle only 0-9, a-z, and A-Z as digits when compiling. That is why we have
-a private table here. It costs 256 bytes, but it is a lot faster than doing
-character value tests (at least in some simple cases I timed), and in some
-applications one wants PCRE to compile efficiently as well as match
-efficiently.
-
-For convenience, we use the same bit definitions as in chartables:
-
- 0x04 decimal digit
- 0x08 hexadecimal digit
-
-Then we can use ctype_digit and ctype_xdigit in the code. */
-
-/* Using a simple comparison for decimal numbers rather than a memory read
-is much faster, and the resulting code is simpler (the compiler turns it
-into a subtraction and unsigned comparison). */
-
-#define IS_DIGIT(x) ((x) >= CHAR_0 && (x) <= CHAR_9)
-
-#ifndef EBCDIC
-
-/* This is the "normal" case, for ASCII systems, and EBCDIC systems running in
-UTF-8 mode. */
-
-static const pcre_uint8 digitab[] =
- {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 8- 15 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 16- 23 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - ' */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* ( - / */
- 0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c, /* 0 - 7 */
- 0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, /* 8 - ? */
- 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /* @ - G */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* H - O */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* P - W */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* X - _ */
- 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /* ` - g */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* h - o */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* p - w */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* x -127 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 128-135 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 136-143 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144-151 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 152-159 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160-167 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 168-175 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 176-183 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 192-199 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 200-207 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 208-215 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 216-223 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 224-231 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 232-239 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 240-247 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/* 248-255 */
-
-#else
-
-/* This is the "abnormal" case, for EBCDIC systems not running in UTF-8 mode. */
-
-static const pcre_uint8 digitab[] =
- {
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0- 7 0 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 8- 15 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 16- 23 10 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 32- 39 20 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 40- 47 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 48- 55 30 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 56- 63 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - 71 40 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 72- | */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* & - 87 50 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 88- 95 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - -103 60 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 104- ? */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 70 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 120- " */
- 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /* 128- g 80 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* h -143 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 144- p 90 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* q -159 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 160- x A0 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* y -175 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* ^ -183 B0 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
- 0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x00, /* { - G C0 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* H -207 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* } - P D0 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* Q -223 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* \ - X E0 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* Y -239 */
- 0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c,0x0c, /* 0 - 7 F0 */
- 0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00};/* 8 -255 */
-
-static const pcre_uint8 ebcdic_chartab[] = { /* chartable partial dup */
- 0x80,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /* 0- 7 */
- 0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00, /* 8- 15 */
- 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /* 16- 23 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 24- 31 */
- 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /* 32- 39 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 40- 47 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 48- 55 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 56- 63 */
- 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - 71 */
- 0x00,0x00,0x00,0x80,0x00,0x80,0x80,0x80, /* 72- | */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* & - 87 */
- 0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00, /* 88- 95 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* - -103 */
- 0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x80, /* 104- ? */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 112-119 */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 120- " */
- 0x00,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* 128- g */
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* h -143 */
- 0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* 144- p */
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* q -159 */
- 0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12, /* 160- x */
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* y -175 */
- 0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* ^ -183 */
- 0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00, /* 184-191 */
- 0x80,0x1a,0x1a,0x1a,0x1a,0x1a,0x1a,0x12, /* { - G */
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* H -207 */
- 0x00,0x12,0x12,0x12,0x12,0x12,0x12,0x12, /* } - P */
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* Q -223 */
- 0x00,0x00,0x12,0x12,0x12,0x12,0x12,0x12, /* \ - X */
- 0x12,0x12,0x00,0x00,0x00,0x00,0x00,0x00, /* Y -239 */
- 0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c,0x1c, /* 0 - 7 */
- 0x1c,0x1c,0x00,0x00,0x00,0x00,0x00,0x00};/* 8 -255 */
-#endif
-
-
-/* This table is used to check whether auto-possessification is possible
-between adjacent character-type opcodes. The left-hand (repeated) opcode is
-used to select the row, and the right-hand opcode is use to select the column.
-A value of 1 means that auto-possessification is OK. For example, the second
-value in the first row means that \D+\d can be turned into \D++\d.
-
-The Unicode property types (\P and \p) have to be present to fill out the table
-because of what their opcode values are, but the table values should always be
-zero because property types are handled separately in the code. The last four
-columns apply to items that cannot be repeated, so there is no need to have
-rows for them. Note that OP_DIGIT etc. are generated only when PCRE_UCP is
-*not* set. When it is set, \d etc. are converted into OP_(NOT_)PROP codes. */
-
-#define APTROWS (LAST_AUTOTAB_LEFT_OP - FIRST_AUTOTAB_OP + 1)
-#define APTCOLS (LAST_AUTOTAB_RIGHT_OP - FIRST_AUTOTAB_OP + 1)
-
-static const pcre_uint8 autoposstab[APTROWS][APTCOLS] = {
-/* \D \d \S \s \W \w . .+ \C \P \p \R \H \h \V \v \X \Z \z $ $M */
- { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }, /* \D */
- { 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1 }, /* \d */
- { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1 }, /* \S */
- { 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }, /* \s */
- { 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }, /* \W */
- { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1 }, /* \w */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0 }, /* . */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }, /* .+ */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }, /* \C */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* \P */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* \p */
- { 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, /* \R */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0 }, /* \H */
- { 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0 }, /* \h */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0 }, /* \V */
- { 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0 }, /* \v */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 } /* \X */
-};
-
-
-/* This table is used to check whether auto-possessification is possible
-between adjacent Unicode property opcodes (OP_PROP and OP_NOTPROP). The
-left-hand (repeated) opcode is used to select the row, and the right-hand
-opcode is used to select the column. The values are as follows:
-
- 0 Always return FALSE (never auto-possessify)
- 1 Character groups are distinct (possessify if both are OP_PROP)
- 2 Check character categories in the same group (general or particular)
- 3 TRUE if the two opcodes are not the same (PROP vs NOTPROP)
-
- 4 Check left general category vs right particular category
- 5 Check right general category vs left particular category
-
- 6 Left alphanum vs right general category
- 7 Left space vs right general category
- 8 Left word vs right general category
-
- 9 Right alphanum vs left general category
- 10 Right space vs left general category
- 11 Right word vs left general category
-
- 12 Left alphanum vs right particular category
- 13 Left space vs right particular category
- 14 Left word vs right particular category
-
- 15 Right alphanum vs left particular category
- 16 Right space vs left particular category
- 17 Right word vs left particular category
-*/
-
-static const pcre_uint8 propposstab[PT_TABSIZE][PT_TABSIZE] = {
-/* ANY LAMP GC PC SC ALNUM SPACE PXSPACE WORD CLIST UCNC */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* PT_ANY */
- { 0, 3, 0, 0, 0, 3, 1, 1, 0, 0, 0 }, /* PT_LAMP */
- { 0, 0, 2, 4, 0, 9, 10, 10, 11, 0, 0 }, /* PT_GC */
- { 0, 0, 5, 2, 0, 15, 16, 16, 17, 0, 0 }, /* PT_PC */
- { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0 }, /* PT_SC */
- { 0, 3, 6, 12, 0, 3, 1, 1, 0, 0, 0 }, /* PT_ALNUM */
- { 0, 1, 7, 13, 0, 1, 3, 3, 1, 0, 0 }, /* PT_SPACE */
- { 0, 1, 7, 13, 0, 1, 3, 3, 1, 0, 0 }, /* PT_PXSPACE */
- { 0, 0, 8, 14, 0, 0, 1, 1, 3, 0, 0 }, /* PT_WORD */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* PT_CLIST */
- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3 } /* PT_UCNC */
-};
-
-/* This table is used to check whether auto-possessification is possible
-between adjacent Unicode property opcodes (OP_PROP and OP_NOTPROP) when one
-specifies a general category and the other specifies a particular category. The
-row is selected by the general category and the column by the particular
-category. The value is 1 if the particular category is not part of the general
-category. */
-
-static const pcre_uint8 catposstab[7][30] = {
-/* Cc Cf Cn Co Cs Ll Lm Lo Lt Lu Mc Me Mn Nd Nl No Pc Pd Pe Pf Pi Po Ps Sc Sk Sm So Zl Zp Zs */
- { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* C */
- { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* L */
- { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* M */
- { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, /* N */
- { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1 }, /* P */
- { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1 }, /* S */
- { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 } /* Z */
-};
-
-/* This table is used when checking ALNUM, (PX)SPACE, SPACE, and WORD against
-a general or particular category. The properties in each row are those
-that apply to the character set in question. Duplication means that a little
-unnecessary work is done when checking, but this keeps things much simpler
-because they can all use the same code. For more details see the comment where
-this table is used.
-
-Note: SPACE and PXSPACE used to be different because Perl excluded VT from
-"space", but from Perl 5.18 it's included, so both categories are treated the
-same here. */
-
-static const pcre_uint8 posspropstab[3][4] = {
- { ucp_L, ucp_N, ucp_N, ucp_Nl }, /* ALNUM, 3rd and 4th values redundant */
- { ucp_Z, ucp_Z, ucp_C, ucp_Cc }, /* SPACE and PXSPACE, 2nd value redundant */
- { ucp_L, ucp_N, ucp_P, ucp_Po } /* WORD */
-};
-
-/* This table is used when converting repeating opcodes into possessified
-versions as a result of an explicit possessive quantifier such as ++. A zero
-value means there is no possessified version - in those cases the item in
-question must be wrapped in ONCE brackets. The table is truncated at OP_CALLOUT
-because all relevant opcodes are less than that. */
-
-static const pcre_uint8 opcode_possessify[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 15 */
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16 - 31 */
-
- 0, /* NOTI */
- OP_POSSTAR, 0, /* STAR, MINSTAR */
- OP_POSPLUS, 0, /* PLUS, MINPLUS */
- OP_POSQUERY, 0, /* QUERY, MINQUERY */
- OP_POSUPTO, 0, /* UPTO, MINUPTO */
- 0, /* EXACT */
- 0, 0, 0, 0, /* POS{STAR,PLUS,QUERY,UPTO} */
-
- OP_POSSTARI, 0, /* STARI, MINSTARI */
- OP_POSPLUSI, 0, /* PLUSI, MINPLUSI */
- OP_POSQUERYI, 0, /* QUERYI, MINQUERYI */
- OP_POSUPTOI, 0, /* UPTOI, MINUPTOI */
- 0, /* EXACTI */
- 0, 0, 0, 0, /* POS{STARI,PLUSI,QUERYI,UPTOI} */
-
- OP_NOTPOSSTAR, 0, /* NOTSTAR, NOTMINSTAR */
- OP_NOTPOSPLUS, 0, /* NOTPLUS, NOTMINPLUS */
- OP_NOTPOSQUERY, 0, /* NOTQUERY, NOTMINQUERY */
- OP_NOTPOSUPTO, 0, /* NOTUPTO, NOTMINUPTO */
- 0, /* NOTEXACT */
- 0, 0, 0, 0, /* NOTPOS{STAR,PLUS,QUERY,UPTO} */
-
- OP_NOTPOSSTARI, 0, /* NOTSTARI, NOTMINSTARI */
- OP_NOTPOSPLUSI, 0, /* NOTPLUSI, NOTMINPLUSI */
- OP_NOTPOSQUERYI, 0, /* NOTQUERYI, NOTMINQUERYI */
- OP_NOTPOSUPTOI, 0, /* NOTUPTOI, NOTMINUPTOI */
- 0, /* NOTEXACTI */
- 0, 0, 0, 0, /* NOTPOS{STARI,PLUSI,QUERYI,UPTOI} */
-
- OP_TYPEPOSSTAR, 0, /* TYPESTAR, TYPEMINSTAR */
- OP_TYPEPOSPLUS, 0, /* TYPEPLUS, TYPEMINPLUS */
- OP_TYPEPOSQUERY, 0, /* TYPEQUERY, TYPEMINQUERY */
- OP_TYPEPOSUPTO, 0, /* TYPEUPTO, TYPEMINUPTO */
- 0, /* TYPEEXACT */
- 0, 0, 0, 0, /* TYPEPOS{STAR,PLUS,QUERY,UPTO} */
-
- OP_CRPOSSTAR, 0, /* CRSTAR, CRMINSTAR */
- OP_CRPOSPLUS, 0, /* CRPLUS, CRMINPLUS */
- OP_CRPOSQUERY, 0, /* CRQUERY, CRMINQUERY */
- OP_CRPOSRANGE, 0, /* CRRANGE, CRMINRANGE */
- 0, 0, 0, 0, /* CRPOS{STAR,PLUS,QUERY,RANGE} */
-
- 0, 0, 0, /* CLASS, NCLASS, XCLASS */
- 0, 0, /* REF, REFI */
- 0, 0, /* DNREF, DNREFI */
- 0, 0 /* RECURSE, CALLOUT */
-};
-
-
-
-/*************************************************
-* Find an error text *
-*************************************************/
-
-/* The error texts are now all in one long string, to save on relocations. As
-some of the text is of unknown length, we can't use a table of offsets.
-Instead, just count through the strings. This is not a performance issue
-because it happens only when there has been a compilation error.
-
-Argument: the error number
-Returns: pointer to the error string
-*/
-
-static const char *
-find_error_text(int n)
-{
-const char *s = error_texts;
-for (; n > 0; n--)
- {
- while (*s++ != CHAR_NULL) {};
- if (*s == CHAR_NULL) return "Error text not found (please report)";
- }
-return s;
-}
-
-
-
-/*************************************************
-* Expand the workspace *
-*************************************************/
-
-/* This function is called during the second compiling phase, if the number of
-forward references fills the existing workspace, which is originally a block on
-the stack. A larger block is obtained from malloc() unless the ultimate limit
-has been reached or the increase will be rather small.
-
-Argument: pointer to the compile data block
-Returns: 0 if all went well, else an error number
-*/
-
-static int
-expand_workspace(compile_data *cd)
-{
-pcre_uchar *newspace;
-int newsize = cd->workspace_size * 2;
-
-if (newsize > COMPILE_WORK_SIZE_MAX) newsize = COMPILE_WORK_SIZE_MAX;
-if (cd->workspace_size >= COMPILE_WORK_SIZE_MAX ||
- newsize - cd->workspace_size < WORK_SIZE_SAFETY_MARGIN)
- return ERR72;
-
-newspace = (PUBL(malloc))(IN_UCHARS(newsize));
-if (newspace == NULL) return ERR21;
-memcpy(newspace, cd->start_workspace, cd->workspace_size * sizeof(pcre_uchar));
-cd->hwm = (pcre_uchar *)newspace + (cd->hwm - cd->start_workspace);
-if (cd->workspace_size > COMPILE_WORK_SIZE)
- (PUBL(free))((void *)cd->start_workspace);
-cd->start_workspace = newspace;
-cd->workspace_size = newsize;
-return 0;
-}
-
-
-
-/*************************************************
-* Check for counted repeat *
-*************************************************/
-
-/* This function is called when a '{' is encountered in a place where it might
-start a quantifier. It looks ahead to see if it really is a quantifier or not.
-It is only a quantifier if it is one of the forms {ddd} {ddd,} or {ddd,ddd}
-where the ddds are digits.
-
-Arguments:
- p pointer to the first char after '{'
-
-Returns: TRUE or FALSE
-*/
-
-static BOOL
-is_counted_repeat(const pcre_uchar *p)
-{
-if (!IS_DIGIT(*p)) return FALSE;
-p++;
-while (IS_DIGIT(*p)) p++;
-if (*p == CHAR_RIGHT_CURLY_BRACKET) return TRUE;
-
-if (*p++ != CHAR_COMMA) return FALSE;
-if (*p == CHAR_RIGHT_CURLY_BRACKET) return TRUE;
-
-if (!IS_DIGIT(*p)) return FALSE;
-p++;
-while (IS_DIGIT(*p)) p++;
-
-return (*p == CHAR_RIGHT_CURLY_BRACKET);
-}
-
-
-
-/*************************************************
-* Handle escapes *
-*************************************************/
-
-/* This function is called when a \ has been encountered. It either returns a
-positive value for a simple escape such as \n, or 0 for a data character which
-will be placed in chptr. A backreference to group n is returned as negative n.
-When UTF-8 is enabled, a positive value greater than 255 may be returned in
-chptr. On entry, ptr is pointing at the \. On exit, it is on the final
-character of the escape sequence.
-
-Arguments:
- ptrptr points to the pattern position pointer
- chptr points to a returned data character
- errorcodeptr points to the errorcode variable
- bracount number of previous extracting brackets
- options the options bits
- isclass TRUE if inside a character class
-
-Returns: zero => a data character
- positive => a special escape sequence
- negative => a back reference
- on error, errorcodeptr is set
-*/
-
-static int
-check_escape(const pcre_uchar **ptrptr, pcre_uint32 *chptr, int *errorcodeptr,
- int bracount, int options, BOOL isclass)
-{
-/* PCRE_UTF16 has the same value as PCRE_UTF8. */
-BOOL utf = (options & PCRE_UTF8) != 0;
-const pcre_uchar *ptr = *ptrptr + 1;
-pcre_uint32 c;
-int escape = 0;
-int i;
-
-GETCHARINCTEST(c, ptr); /* Get character value, increment pointer */
-ptr--; /* Set pointer back to the last byte */
-
-/* If backslash is at the end of the pattern, it's an error. */
-
-if (c == CHAR_NULL) *errorcodeptr = ERR1;
-
-/* Non-alphanumerics are literals. For digits or letters, do an initial lookup
-in a table. A non-zero result is something that can be returned immediately.
-Otherwise further processing may be required. */
-
-#ifndef EBCDIC /* ASCII/UTF-8 coding */
-/* Not alphanumeric */
-else if (c < CHAR_0 || c > CHAR_z) {}
-else if ((i = escapes[c - CHAR_0]) != 0)
- { if (i > 0) c = (pcre_uint32)i; else escape = -i; }
-
-#else /* EBCDIC coding */
-/* Not alphanumeric */
-else if (c < CHAR_a || (!MAX_255(c) || (ebcdic_chartab[c] & 0x0E) == 0)) {}
-else if ((i = escapes[c - 0x48]) != 0) { if (i > 0) c = (pcre_uint32)i; else escape = -i; }
-#endif
-
-/* Escapes that need further processing, or are illegal. */
-
-else
- {
- const pcre_uchar *oldptr;
- BOOL braced, negated, overflow;
- int s;
-
- switch (c)
- {
- /* A number of Perl escapes are not handled by PCRE. We give an explicit
- error. */
-
- case CHAR_l:
- case CHAR_L:
- *errorcodeptr = ERR37;
- break;
-
- case CHAR_u:
- if ((options & PCRE_JAVASCRIPT_COMPAT) != 0)
- {
- /* In JavaScript, \u must be followed by four hexadecimal numbers.
- Otherwise it is a lowercase u letter. */
- if (MAX_255(ptr[1]) && (digitab[ptr[1]] & ctype_xdigit) != 0
- && MAX_255(ptr[2]) && (digitab[ptr[2]] & ctype_xdigit) != 0
- && MAX_255(ptr[3]) && (digitab[ptr[3]] & ctype_xdigit) != 0
- && MAX_255(ptr[4]) && (digitab[ptr[4]] & ctype_xdigit) != 0)
- {
- c = 0;
- for (i = 0; i < 4; ++i)
- {
- register pcre_uint32 cc = *(++ptr);
-#ifndef EBCDIC /* ASCII/UTF-8 coding */
- if (cc >= CHAR_a) cc -= 32; /* Convert to upper case */
- c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));
-#else /* EBCDIC coding */
- if (cc >= CHAR_a && cc <= CHAR_z) cc += 64; /* Convert to upper case */
- c = (c << 4) + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));
-#endif
- }
-
-#if defined COMPILE_PCRE8
- if (c > (utf ? 0x10ffffU : 0xffU))
-#elif defined COMPILE_PCRE16
- if (c > (utf ? 0x10ffffU : 0xffffU))
-#elif defined COMPILE_PCRE32
- if (utf && c > 0x10ffffU)
-#endif
- {
- *errorcodeptr = ERR76;
- }
- else if (utf && c >= 0xd800 && c <= 0xdfff) *errorcodeptr = ERR73;
- }
- }
- else
- *errorcodeptr = ERR37;
- break;
-
- case CHAR_U:
- /* In JavaScript, \U is an uppercase U letter. */
- if ((options & PCRE_JAVASCRIPT_COMPAT) == 0) *errorcodeptr = ERR37;
- break;
-
- /* In a character class, \g is just a literal "g". Outside a character
- class, \g must be followed by one of a number of specific things:
-
- (1) A number, either plain or braced. If positive, it is an absolute
- backreference. If negative, it is a relative backreference. This is a Perl
- 5.10 feature.
-
- (2) Perl 5.10 also supports \g{name} as a reference to a named group. This
- is part of Perl's movement towards a unified syntax for back references. As
- this is synonymous with \k{name}, we fudge it up by pretending it really
- was \k.
-
- (3) For Oniguruma compatibility we also support \g followed by a name or a
- number either in angle brackets or in single quotes. However, these are
- (possibly recursive) subroutine calls, _not_ backreferences. Just return
- the ESC_g code (cf \k). */
-
- case CHAR_g:
- if (isclass) break;
- if (ptr[1] == CHAR_LESS_THAN_SIGN || ptr[1] == CHAR_APOSTROPHE)
- {
- escape = ESC_g;
- break;
- }
-
- /* Handle the Perl-compatible cases */
-
- if (ptr[1] == CHAR_LEFT_CURLY_BRACKET)
- {
- const pcre_uchar *p;
- for (p = ptr+2; *p != CHAR_NULL && *p != CHAR_RIGHT_CURLY_BRACKET; p++)
- if (*p != CHAR_MINUS && !IS_DIGIT(*p)) break;
- if (*p != CHAR_NULL && *p != CHAR_RIGHT_CURLY_BRACKET)
- {
- escape = ESC_k;
- break;
- }
- braced = TRUE;
- ptr++;
- }
- else braced = FALSE;
-
- if (ptr[1] == CHAR_MINUS)
- {
- negated = TRUE;
- ptr++;
- }
- else negated = FALSE;
-
- /* The integer range is limited by the machine's int representation. */
- s = 0;
- overflow = FALSE;
- while (IS_DIGIT(ptr[1]))
- {
- if (s > INT_MAX / 10 - 1) /* Integer overflow */
- {
- overflow = TRUE;
- break;
- }
- s = s * 10 + (int)(*(++ptr) - CHAR_0);
- }
- if (overflow) /* Integer overflow */
- {
- while (IS_DIGIT(ptr[1]))
- ptr++;
- *errorcodeptr = ERR61;
- break;
- }
-
- if (braced && *(++ptr) != CHAR_RIGHT_CURLY_BRACKET)
- {
- *errorcodeptr = ERR57;
- break;
- }
-
- if (s == 0)
- {
- *errorcodeptr = ERR58;
- break;
- }
-
- if (negated)
- {
- if (s > bracount)
- {
- *errorcodeptr = ERR15;
- break;
- }
- s = bracount - (s - 1);
- }
-
- escape = -s;
- break;
-
- /* The handling of escape sequences consisting of a string of digits
- starting with one that is not zero is not straightforward. Perl has changed
- over the years. Nowadays \g{} for backreferences and \o{} for octal are
- recommended to avoid the ambiguities in the old syntax.
-
- Outside a character class, the digits are read as a decimal number. If the
- number is less than 8 (used to be 10), or if there are that many previous
- extracting left brackets, then it is a back reference. Otherwise, up to
- three octal digits are read to form an escaped byte. Thus \123 is likely to
- be octal 123 (cf \0123, which is octal 012 followed by the literal 3). If
- the octal value is greater than 377, the least significant 8 bits are
- taken. \8 and \9 are treated as the literal characters 8 and 9.
-
- Inside a character class, \ followed by a digit is always either a literal
- 8 or 9 or an octal number. */
-
- case CHAR_1: case CHAR_2: case CHAR_3: case CHAR_4: case CHAR_5:
- case CHAR_6: case CHAR_7: case CHAR_8: case CHAR_9:
-
- if (!isclass)
- {
- oldptr = ptr;
- /* The integer range is limited by the machine's int representation. */
- s = (int)(c -CHAR_0);
- overflow = FALSE;
- while (IS_DIGIT(ptr[1]))
- {
- if (s > INT_MAX / 10 - 1) /* Integer overflow */
- {
- overflow = TRUE;
- break;
- }
- s = s * 10 + (int)(*(++ptr) - CHAR_0);
- }
- if (overflow) /* Integer overflow */
- {
- while (IS_DIGIT(ptr[1]))
- ptr++;
- *errorcodeptr = ERR61;
- break;
- }
- if (s < 8 || s <= bracount) /* Check for back reference */
- {
- escape = -s;
- break;
- }
- ptr = oldptr; /* Put the pointer back and fall through */
- }
-
- /* Handle a digit following \ when the number is not a back reference. If
- the first digit is 8 or 9, Perl used to generate a binary zero byte and
- then treat the digit as a following literal. At least by Perl 5.18 this
- changed so as not to insert the binary zero. */
-
- if ((c = *ptr) >= CHAR_8) break;
-
- /* Fall through with a digit less than 8 */
-
- /* \0 always starts an octal number, but we may drop through to here with a
- larger first octal digit. The original code used just to take the least
- significant 8 bits of octal numbers (I think this is what early Perls used
- to do). Nowadays we allow for larger numbers in UTF-8 mode and 16-bit mode,
- but no more than 3 octal digits. */
-
- case CHAR_0:
- c -= CHAR_0;
- while(i++ < 2 && ptr[1] >= CHAR_0 && ptr[1] <= CHAR_7)
- c = c * 8 + *(++ptr) - CHAR_0;
-#ifdef COMPILE_PCRE8
- if (!utf && c > 0xff) *errorcodeptr = ERR51;
-#endif
- break;
-
- /* \o is a relatively new Perl feature, supporting a more general way of
- specifying character codes in octal. The only supported form is \o{ddd}. */
-
- case CHAR_o:
- if (ptr[1] != CHAR_LEFT_CURLY_BRACKET) *errorcodeptr = ERR81; else
- if (ptr[2] == CHAR_RIGHT_CURLY_BRACKET) *errorcodeptr = ERR86; else
- {
- ptr += 2;
- c = 0;
- overflow = FALSE;
- while (*ptr >= CHAR_0 && *ptr <= CHAR_7)
- {
- register pcre_uint32 cc = *ptr++;
- if (c == 0 && cc == CHAR_0) continue; /* Leading zeroes */
-#ifdef COMPILE_PCRE32
- if (c >= 0x20000000l) { overflow = TRUE; break; }
-#endif
- c = (c << 3) + cc - CHAR_0 ;
-#if defined COMPILE_PCRE8
- if (c > (utf ? 0x10ffffU : 0xffU)) { overflow = TRUE; break; }
-#elif defined COMPILE_PCRE16
- if (c > (utf ? 0x10ffffU : 0xffffU)) { overflow = TRUE; break; }
-#elif defined COMPILE_PCRE32
- if (utf && c > 0x10ffffU) { overflow = TRUE; break; }
-#endif
- }
- if (overflow)
- {
- while (*ptr >= CHAR_0 && *ptr <= CHAR_7) ptr++;
- *errorcodeptr = ERR34;
- }
- else if (*ptr == CHAR_RIGHT_CURLY_BRACKET)
- {
- if (utf && c >= 0xd800 && c <= 0xdfff) *errorcodeptr = ERR73;
- }
- else *errorcodeptr = ERR80;
- }
- break;
-
- /* \x is complicated. In JavaScript, \x must be followed by two hexadecimal
- numbers. Otherwise it is a lowercase x letter. */
-
- case CHAR_x:
- if ((options & PCRE_JAVASCRIPT_COMPAT) != 0)
- {
- if (MAX_255(ptr[1]) && (digitab[ptr[1]] & ctype_xdigit) != 0
- && MAX_255(ptr[2]) && (digitab[ptr[2]] & ctype_xdigit) != 0)
- {
- c = 0;
- for (i = 0; i < 2; ++i)
- {
- register pcre_uint32 cc = *(++ptr);
-#ifndef EBCDIC /* ASCII/UTF-8 coding */
- if (cc >= CHAR_a) cc -= 32; /* Convert to upper case */
- c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));
-#else /* EBCDIC coding */
- if (cc >= CHAR_a && cc <= CHAR_z) cc += 64; /* Convert to upper case */
- c = (c << 4) + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));
-#endif
- }
- }
- } /* End JavaScript handling */
-
- /* Handle \x in Perl's style. \x{ddd} is a character number which can be
- greater than 0xff in utf or non-8bit mode, but only if the ddd are hex
- digits. If not, { used to be treated as a data character. However, Perl
- seems to read hex digits up to the first non-such, and ignore the rest, so
- that, for example \x{zz} matches a binary zero. This seems crazy, so PCRE
- now gives an error. */
-
- else
- {
- if (ptr[1] == CHAR_LEFT_CURLY_BRACKET)
- {
- ptr += 2;
- if (*ptr == CHAR_RIGHT_CURLY_BRACKET)
- {
- *errorcodeptr = ERR86;
- break;
- }
- c = 0;
- overflow = FALSE;
- while (MAX_255(*ptr) && (digitab[*ptr] & ctype_xdigit) != 0)
- {
- register pcre_uint32 cc = *ptr++;
- if (c == 0 && cc == CHAR_0) continue; /* Leading zeroes */
-
-#ifdef COMPILE_PCRE32
- if (c >= 0x10000000l) { overflow = TRUE; break; }
-#endif
-
-#ifndef EBCDIC /* ASCII/UTF-8 coding */
- if (cc >= CHAR_a) cc -= 32; /* Convert to upper case */
- c = (c << 4) + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));
-#else /* EBCDIC coding */
- if (cc >= CHAR_a && cc <= CHAR_z) cc += 64; /* Convert to upper case */
- c = (c << 4) + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));
-#endif
-
-#if defined COMPILE_PCRE8
- if (c > (utf ? 0x10ffffU : 0xffU)) { overflow = TRUE; break; }
-#elif defined COMPILE_PCRE16
- if (c > (utf ? 0x10ffffU : 0xffffU)) { overflow = TRUE; break; }
-#elif defined COMPILE_PCRE32
- if (utf && c > 0x10ffffU) { overflow = TRUE; break; }
-#endif
- }
-
- if (overflow)
- {
- while (MAX_255(*ptr) && (digitab[*ptr] & ctype_xdigit) != 0) ptr++;
- *errorcodeptr = ERR34;
- }
-
- else if (*ptr == CHAR_RIGHT_CURLY_BRACKET)
- {
- if (utf && c >= 0xd800 && c <= 0xdfff) *errorcodeptr = ERR73;
- }
-
- /* If the sequence of hex digits does not end with '}', give an error.
- We used just to recognize this construct and fall through to the normal
- \x handling, but nowadays Perl gives an error, which seems much more
- sensible, so we do too. */
-
- else *errorcodeptr = ERR79;
- } /* End of \x{} processing */
-
- /* Read a single-byte hex-defined char (up to two hex digits after \x) */
-
- else
- {
- c = 0;
- while (i++ < 2 && MAX_255(ptr[1]) && (digitab[ptr[1]] & ctype_xdigit) != 0)
- {
- pcre_uint32 cc; /* Some compilers don't like */
- cc = *(++ptr); /* ++ in initializers */
-#ifndef EBCDIC /* ASCII/UTF-8 coding */
- if (cc >= CHAR_a) cc -= 32; /* Convert to upper case */
- c = c * 16 + cc - ((cc < CHAR_A)? CHAR_0 : (CHAR_A - 10));
-#else /* EBCDIC coding */
- if (cc <= CHAR_z) cc += 64; /* Convert to upper case */
- c = c * 16 + cc - ((cc >= CHAR_0)? CHAR_0 : (CHAR_A - 10));
-#endif
- }
- } /* End of \xdd handling */
- } /* End of Perl-style \x handling */
- break;
-
- /* For \c, a following letter is upper-cased; then the 0x40 bit is flipped.
- An error is given if the byte following \c is not an ASCII character. This
- coding is ASCII-specific, but then the whole concept of \cx is
- ASCII-specific. (However, an EBCDIC equivalent has now been added.) */
-
- case CHAR_c:
- c = *(++ptr);
- if (c == CHAR_NULL)
- {
- *errorcodeptr = ERR2;
- break;
- }
-#ifndef EBCDIC /* ASCII/UTF-8 coding */
- if (c > 127) /* Excludes all non-ASCII in either mode */
- {
- *errorcodeptr = ERR68;
- break;
- }
- if (c >= CHAR_a && c <= CHAR_z) c -= 32;
- c ^= 0x40;
-#else /* EBCDIC coding */
- if (c >= CHAR_a && c <= CHAR_z) c += 64;
- if (c == CHAR_QUESTION_MARK)
- c = ('\\' == 188 && '`' == 74)? 0x5f : 0xff;
- else
- {
- for (i = 0; i < 32; i++)
- {
- if (c == ebcdic_escape_c[i]) break;
- }
- if (i < 32) c = i; else *errorcodeptr = ERR68;
- }
-#endif
- break;
-
- /* PCRE_EXTRA enables extensions to Perl in the matter of escapes. Any
- other alphanumeric following \ is an error if PCRE_EXTRA was set;
- otherwise, for Perl compatibility, it is a literal. This code looks a bit
- odd, but there used to be some cases other than the default, and there may
- be again in future, so I haven't "optimized" it. */
-
- default:
- if ((options & PCRE_EXTRA) != 0) switch(c)
- {
- default:
- *errorcodeptr = ERR3;
- break;
- }
- break;
- }
- }
-
-/* Perl supports \N{name} for character names, as well as plain \N for "not
-newline". PCRE does not support \N{name}. However, it does support
-quantification such as \N{2,3}. */
-
-if (escape == ESC_N && ptr[1] == CHAR_LEFT_CURLY_BRACKET &&
- !is_counted_repeat(ptr+2))
- *errorcodeptr = ERR37;
-
-/* If PCRE_UCP is set, we change the values for \d etc. */
-
-if ((options & PCRE_UCP) != 0 && escape >= ESC_D && escape <= ESC_w)
- escape += (ESC_DU - ESC_D);
-
-/* Set the pointer to the final character before returning. */
-
-*ptrptr = ptr;
-*chptr = c;
-return escape;
-}
-
-
-
-#ifdef SUPPORT_UCP
-/*************************************************
-* Handle \P and \p *
-*************************************************/
-
-/* This function is called after \P or \p has been encountered, provided that
-PCRE is compiled with support for Unicode properties. On entry, ptrptr is
-pointing at the P or p. On exit, it is pointing at the final character of the
-escape sequence.
-
-Argument:
- ptrptr points to the pattern position pointer
- negptr points to a boolean that is set TRUE for negation else FALSE
- ptypeptr points to an unsigned int that is set to the type value
- pdataptr points to an unsigned int that is set to the detailed property value
- errorcodeptr points to the error code variable
-
-Returns: TRUE if the type value was found, or FALSE for an invalid type
-*/
-
-static BOOL
-get_ucp(const pcre_uchar **ptrptr, BOOL *negptr, unsigned int *ptypeptr,
- unsigned int *pdataptr, int *errorcodeptr)
-{
-pcre_uchar c;
-int i, bot, top;
-const pcre_uchar *ptr = *ptrptr;
-pcre_uchar name[32];
-
-c = *(++ptr);
-if (c == CHAR_NULL) goto ERROR_RETURN;
-
-*negptr = FALSE;
-
-/* \P or \p can be followed by a name in {}, optionally preceded by ^ for
-negation. */
-
-if (c == CHAR_LEFT_CURLY_BRACKET)
- {
- if (ptr[1] == CHAR_CIRCUMFLEX_ACCENT)
- {
- *negptr = TRUE;
- ptr++;
- }
- for (i = 0; i < (int)(sizeof(name) / sizeof(pcre_uchar)) - 1; i++)
- {
- c = *(++ptr);
- if (c == CHAR_NULL) goto ERROR_RETURN;
- if (c == CHAR_RIGHT_CURLY_BRACKET) break;
- name[i] = c;
- }
- if (c != CHAR_RIGHT_CURLY_BRACKET) goto ERROR_RETURN;
- name[i] = 0;
- }
-
-/* Otherwise there is just one following character */
-
-else
- {
- name[0] = c;
- name[1] = 0;
- }
-
-*ptrptr = ptr;
-
-/* Search for a recognized property name using binary chop */
-
-bot = 0;
-top = PRIV(utt_size);
-
-while (bot < top)
- {
- int r;
- i = (bot + top) >> 1;
- r = STRCMP_UC_C8(name, PRIV(utt_names) + PRIV(utt)[i].name_offset);
- if (r == 0)
- {
- *ptypeptr = PRIV(utt)[i].type;
- *pdataptr = PRIV(utt)[i].value;
- return TRUE;
- }
- if (r > 0) bot = i + 1; else top = i;
- }
-
-*errorcodeptr = ERR47;
-*ptrptr = ptr;
-return FALSE;
-
-ERROR_RETURN:
-*errorcodeptr = ERR46;
-*ptrptr = ptr;
-return FALSE;
-}
-#endif
-
-
-
-/*************************************************
-* Read repeat counts *
-*************************************************/
-
-/* Read an item of the form {n,m} and return the values. This is called only
-after is_counted_repeat() has confirmed that a repeat-count quantifier exists,
-so the syntax is guaranteed to be correct, but we need to check the values.
-
-Arguments:
- p pointer to first char after '{'
- minp pointer to int for min
- maxp pointer to int for max
- returned as -1 if no max
- errorcodeptr points to error code variable
-
-Returns: pointer to '}' on success;
- current ptr on error, with errorcodeptr set non-zero
-*/
-
-static const pcre_uchar *
-read_repeat_counts(const pcre_uchar *p, int *minp, int *maxp, int *errorcodeptr)
-{
-int min = 0;
-int max = -1;
-
-while (IS_DIGIT(*p))
- {
- min = min * 10 + (int)(*p++ - CHAR_0);
- if (min > 65535)
- {
- *errorcodeptr = ERR5;
- return p;
- }
- }
-
-if (*p == CHAR_RIGHT_CURLY_BRACKET) max = min; else
- {
- if (*(++p) != CHAR_RIGHT_CURLY_BRACKET)
- {
- max = 0;
- while(IS_DIGIT(*p))
- {
- max = max * 10 + (int)(*p++ - CHAR_0);
- if (max > 65535)
- {
- *errorcodeptr = ERR5;
- return p;
- }
- }
- if (max < min)
- {
- *errorcodeptr = ERR4;
- return p;
- }
- }
- }
-
-*minp = min;
-*maxp = max;
-return p;
-}
-
-
-
-/*************************************************
-* Find first significant op code *
-*************************************************/
-
-/* This is called by several functions that scan a compiled expression looking
-for a fixed first character, or an anchoring op code etc. It skips over things
-that do not influence this. For some calls, it makes sense to skip negative
-forward and all backward assertions, and also the \b assertion; for others it
-does not.
-
-Arguments:
- code pointer to the start of the group
- skipassert TRUE if certain assertions are to be skipped
-
-Returns: pointer to the first significant opcode
-*/
-
-static const pcre_uchar*
-first_significant_code(const pcre_uchar *code, BOOL skipassert)
-{
-for (;;)
- {
- switch ((int)*code)
- {
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- if (!skipassert) return code;
- do code += GET(code, 1); while (*code == OP_ALT);
- code += PRIV(OP_lengths)[*code];
- break;
-
- case OP_WORD_BOUNDARY:
- case OP_NOT_WORD_BOUNDARY:
- if (!skipassert) return code;
- /* Fall through */
-
- case OP_CALLOUT:
- case OP_CREF:
- case OP_DNCREF:
- case OP_RREF:
- case OP_DNRREF:
- case OP_DEF:
- code += PRIV(OP_lengths)[*code];
- break;
-
- default:
- return code;
- }
- }
-/* Control never reaches here */
-}
-
-
-
-/*************************************************
-* Find the fixed length of a branch *
-*************************************************/
-
-/* Scan a branch and compute the fixed length of subject that will match it,
-if the length is fixed. This is needed for dealing with backward assertions.
-In UTF8 mode, the result is in characters rather than bytes. The branch is
-temporarily terminated with OP_END when this function is called.
-
-This function is called when a backward assertion is encountered, so that if it
-fails, the error message can point to the correct place in the pattern.
-However, we cannot do this when the assertion contains subroutine calls,
-because they can be forward references. We solve this by remembering this case
-and doing the check at the end; a flag specifies which mode we are running in.
-
-Arguments:
- code points to the start of the pattern (the bracket)
- utf TRUE in UTF-8 / UTF-16 / UTF-32 mode
- atend TRUE if called when the pattern is complete
- cd the "compile data" structure
- recurses chain of recurse_check to catch mutual recursion
-
-Returns: the fixed length,
- or -1 if there is no fixed length,
- or -2 if \C was encountered (in UTF-8 mode only)
- or -3 if an OP_RECURSE item was encountered and atend is FALSE
- or -4 if an unknown opcode was encountered (internal error)
-*/
-
-static int
-find_fixedlength(pcre_uchar *code, BOOL utf, BOOL atend, compile_data *cd,
- recurse_check *recurses)
-{
-int length = -1;
-recurse_check this_recurse;
-register int branchlength = 0;
-register pcre_uchar *cc = code + 1 + LINK_SIZE;
-
-/* Scan along the opcodes for this branch. If we get to the end of the
-branch, check the length against that of the other branches. */
-
-for (;;)
- {
- int d;
- pcre_uchar *ce, *cs;
- register pcre_uchar op = *cc;
-
- switch (op)
- {
- /* We only need to continue for OP_CBRA (normal capturing bracket) and
- OP_BRA (normal non-capturing bracket) because the other variants of these
- opcodes are all concerned with unlimited repeated groups, which of course
- are not of fixed length. */
-
- case OP_CBRA:
- case OP_BRA:
- case OP_ONCE:
- case OP_ONCE_NC:
- case OP_COND:
- d = find_fixedlength(cc + ((op == OP_CBRA)? IMM2_SIZE : 0), utf, atend, cd,
- recurses);
- if (d < 0) return d;
- branchlength += d;
- do cc += GET(cc, 1); while (*cc == OP_ALT);
- cc += 1 + LINK_SIZE;
- break;
-
- /* Reached end of a branch; if it's a ket it is the end of a nested call.
- If it's ALT it is an alternation in a nested call. An ACCEPT is effectively
- an ALT. If it is END it's the end of the outer call. All can be handled by
- the same code. Note that we must not include the OP_KETRxxx opcodes here,
- because they all imply an unlimited repeat. */
-
- case OP_ALT:
- case OP_KET:
- case OP_END:
- case OP_ACCEPT:
- case OP_ASSERT_ACCEPT:
- if (length < 0) length = branchlength;
- else if (length != branchlength) return -1;
- if (*cc != OP_ALT) return length;
- cc += 1 + LINK_SIZE;
- branchlength = 0;
- break;
-
- /* A true recursion implies not fixed length, but a subroutine call may
- be OK. If the subroutine is a forward reference, we can't deal with
- it until the end of the pattern, so return -3. */
-
- case OP_RECURSE:
- if (!atend) return -3;
- cs = ce = (pcre_uchar *)cd->start_code + GET(cc, 1); /* Start subpattern */
- do ce += GET(ce, 1); while (*ce == OP_ALT); /* End subpattern */
- if (cc > cs && cc < ce) return -1; /* Recursion */
- else /* Check for mutual recursion */
- {
- recurse_check *r = recurses;
- for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break;
- if (r != NULL) return -1; /* Mutual recursion */
- }
- this_recurse.prev = recurses;
- this_recurse.group = cs;
- d = find_fixedlength(cs + IMM2_SIZE, utf, atend, cd, &this_recurse);
- if (d < 0) return d;
- branchlength += d;
- cc += 1 + LINK_SIZE;
- break;
-
- /* Skip over assertive subpatterns */
-
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- do cc += GET(cc, 1); while (*cc == OP_ALT);
- cc += 1 + LINK_SIZE;
- break;
-
- /* Skip over things that don't match chars */
-
- case OP_MARK:
- case OP_PRUNE_ARG:
- case OP_SKIP_ARG:
- case OP_THEN_ARG:
- cc += cc[1] + PRIV(OP_lengths)[*cc];
- break;
-
- case OP_CALLOUT:
- case OP_CIRC:
- case OP_CIRCM:
- case OP_CLOSE:
- case OP_COMMIT:
- case OP_CREF:
- case OP_DEF:
- case OP_DNCREF:
- case OP_DNRREF:
- case OP_DOLL:
- case OP_DOLLM:
- case OP_EOD:
- case OP_EODN:
- case OP_FAIL:
- case OP_NOT_WORD_BOUNDARY:
- case OP_PRUNE:
- case OP_REVERSE:
- case OP_RREF:
- case OP_SET_SOM:
- case OP_SKIP:
- case OP_SOD:
- case OP_SOM:
- case OP_THEN:
- case OP_WORD_BOUNDARY:
- cc += PRIV(OP_lengths)[*cc];
- break;
-
- /* Handle literal characters */
-
- case OP_CHAR:
- case OP_CHARI:
- case OP_NOT:
- case OP_NOTI:
- branchlength++;
- cc += 2;
-#ifdef SUPPORT_UTF
- if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- break;
-
- /* Handle exact repetitions. The count is already in characters, but we
- need to skip over a multibyte character in UTF8 mode. */
-
- case OP_EXACT:
- case OP_EXACTI:
- case OP_NOTEXACT:
- case OP_NOTEXACTI:
- branchlength += (int)GET2(cc,1);
- cc += 2 + IMM2_SIZE;
-#ifdef SUPPORT_UTF
- if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- break;
-
- case OP_TYPEEXACT:
- branchlength += GET2(cc,1);
- if (cc[1 + IMM2_SIZE] == OP_PROP || cc[1 + IMM2_SIZE] == OP_NOTPROP)
- cc += 2;
- cc += 1 + IMM2_SIZE + 1;
- break;
-
- /* Handle single-char matchers */
-
- case OP_PROP:
- case OP_NOTPROP:
- cc += 2;
- /* Fall through */
-
- case OP_HSPACE:
- case OP_VSPACE:
- case OP_NOT_HSPACE:
- case OP_NOT_VSPACE:
- case OP_NOT_DIGIT:
- case OP_DIGIT:
- case OP_NOT_WHITESPACE:
- case OP_WHITESPACE:
- case OP_NOT_WORDCHAR:
- case OP_WORDCHAR:
- case OP_ANY:
- case OP_ALLANY:
- branchlength++;
- cc++;
- break;
-
- /* The single-byte matcher isn't allowed. This only happens in UTF-8 mode;
- otherwise \C is coded as OP_ALLANY. */
-
- case OP_ANYBYTE:
- return -2;
-
- /* Check a class for variable quantification */
-
- case OP_CLASS:
- case OP_NCLASS:
-#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- case OP_XCLASS:
- /* The original code caused an unsigned overflow in 64 bit systems,
- so now we use a conditional statement. */
- if (op == OP_XCLASS)
- cc += GET(cc, 1);
- else
- cc += PRIV(OP_lengths)[OP_CLASS];
-#else
- cc += PRIV(OP_lengths)[OP_CLASS];
-#endif
-
- switch (*cc)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- case OP_CRPOSSTAR:
- case OP_CRPOSPLUS:
- case OP_CRPOSQUERY:
- return -1;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- case OP_CRPOSRANGE:
- if (GET2(cc,1) != GET2(cc,1+IMM2_SIZE)) return -1;
- branchlength += (int)GET2(cc,1);
- cc += 1 + 2 * IMM2_SIZE;
- break;
-
- default:
- branchlength++;
- }
- break;
-
- /* Anything else is variable length */
-
- case OP_ANYNL:
- case OP_BRAMINZERO:
- case OP_BRAPOS:
- case OP_BRAPOSZERO:
- case OP_BRAZERO:
- case OP_CBRAPOS:
- case OP_EXTUNI:
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_KETRPOS:
- case OP_MINPLUS:
- case OP_MINPLUSI:
- case OP_MINQUERY:
- case OP_MINQUERYI:
- case OP_MINSTAR:
- case OP_MINSTARI:
- case OP_MINUPTO:
- case OP_MINUPTOI:
- case OP_NOTMINPLUS:
- case OP_NOTMINPLUSI:
- case OP_NOTMINQUERY:
- case OP_NOTMINQUERYI:
- case OP_NOTMINSTAR:
- case OP_NOTMINSTARI:
- case OP_NOTMINUPTO:
- case OP_NOTMINUPTOI:
- case OP_NOTPLUS:
- case OP_NOTPLUSI:
- case OP_NOTPOSPLUS:
- case OP_NOTPOSPLUSI:
- case OP_NOTPOSQUERY:
- case OP_NOTPOSQUERYI:
- case OP_NOTPOSSTAR:
- case OP_NOTPOSSTARI:
- case OP_NOTPOSUPTO:
- case OP_NOTPOSUPTOI:
- case OP_NOTQUERY:
- case OP_NOTQUERYI:
- case OP_NOTSTAR:
- case OP_NOTSTARI:
- case OP_NOTUPTO:
- case OP_NOTUPTOI:
- case OP_PLUS:
- case OP_PLUSI:
- case OP_POSPLUS:
- case OP_POSPLUSI:
- case OP_POSQUERY:
- case OP_POSQUERYI:
- case OP_POSSTAR:
- case OP_POSSTARI:
- case OP_POSUPTO:
- case OP_POSUPTOI:
- case OP_QUERY:
- case OP_QUERYI:
- case OP_REF:
- case OP_REFI:
- case OP_DNREF:
- case OP_DNREFI:
- case OP_SBRA:
- case OP_SBRAPOS:
- case OP_SCBRA:
- case OP_SCBRAPOS:
- case OP_SCOND:
- case OP_SKIPZERO:
- case OP_STAR:
- case OP_STARI:
- case OP_TYPEMINPLUS:
- case OP_TYPEMINQUERY:
- case OP_TYPEMINSTAR:
- case OP_TYPEMINUPTO:
- case OP_TYPEPLUS:
- case OP_TYPEPOSPLUS:
- case OP_TYPEPOSQUERY:
- case OP_TYPEPOSSTAR:
- case OP_TYPEPOSUPTO:
- case OP_TYPEQUERY:
- case OP_TYPESTAR:
- case OP_TYPEUPTO:
- case OP_UPTO:
- case OP_UPTOI:
- return -1;
-
- /* Catch unrecognized opcodes so that when new ones are added they
- are not forgotten, as has happened in the past. */
-
- default:
- return -4;
- }
- }
-/* Control never gets here */
-}
-
-
-
-/*************************************************
-* Scan compiled regex for specific bracket *
-*************************************************/
-
-/* This little function scans through a compiled pattern until it finds a
-capturing bracket with the given number, or, if the number is negative, an
-instance of OP_REVERSE for a lookbehind. The function is global in the C sense
-so that it can be called from pcre_study() when finding the minimum matching
-length.
-
-Arguments:
- code points to start of expression
- utf TRUE in UTF-8 / UTF-16 / UTF-32 mode
- number the required bracket number or negative to find a lookbehind
-
-Returns: pointer to the opcode for the bracket, or NULL if not found
-*/
-
-const pcre_uchar *
-PRIV(find_bracket)(const pcre_uchar *code, BOOL utf, int number)
-{
-for (;;)
- {
- register pcre_uchar c = *code;
-
- if (c == OP_END) return NULL;
-
- /* XCLASS is used for classes that cannot be represented just by a bit
- map. This includes negated single high-valued characters. The length in
- the table is zero; the actual length is stored in the compiled code. */
-
- if (c == OP_XCLASS) code += GET(code, 1);
-
- /* Handle recursion */
-
- else if (c == OP_REVERSE)
- {
- if (number < 0) return (pcre_uchar *)code;
- code += PRIV(OP_lengths)[c];
- }
-
- /* Handle capturing bracket */
-
- else if (c == OP_CBRA || c == OP_SCBRA ||
- c == OP_CBRAPOS || c == OP_SCBRAPOS)
- {
- int n = (int)GET2(code, 1+LINK_SIZE);
- if (n == number) return (pcre_uchar *)code;
- code += PRIV(OP_lengths)[c];
- }
-
- /* Otherwise, we can get the item's length from the table, except that for
- repeated character types, we have to test for \p and \P, which have an extra
- two bytes of parameters, and for MARK/PRUNE/SKIP/THEN with an argument, we
- must add in its length. */
-
- else
- {
- switch(c)
- {
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- case OP_TYPEPOSSTAR:
- case OP_TYPEPOSPLUS:
- case OP_TYPEPOSQUERY:
- if (code[1] == OP_PROP || code[1] == OP_NOTPROP) code += 2;
- break;
-
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- case OP_TYPEEXACT:
- case OP_TYPEPOSUPTO:
- if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
- code += 2;
- break;
-
- case OP_MARK:
- case OP_PRUNE_ARG:
- case OP_SKIP_ARG:
- case OP_THEN_ARG:
- code += code[1];
- break;
- }
-
- /* Add in the fixed length from the table */
-
- code += PRIV(OP_lengths)[c];
-
- /* In UTF-8 mode, opcodes that are followed by a character may be followed by
- a multi-byte character. The length in the table is a minimum, so we have to
- arrange to skip the extra bytes. */
-
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (utf) switch(c)
- {
- case OP_CHAR:
- case OP_CHARI:
- case OP_NOT:
- case OP_NOTI:
- case OP_EXACT:
- case OP_EXACTI:
- case OP_NOTEXACT:
- case OP_NOTEXACTI:
- case OP_UPTO:
- case OP_UPTOI:
- case OP_NOTUPTO:
- case OP_NOTUPTOI:
- case OP_MINUPTO:
- case OP_MINUPTOI:
- case OP_NOTMINUPTO:
- case OP_NOTMINUPTOI:
- case OP_POSUPTO:
- case OP_POSUPTOI:
- case OP_NOTPOSUPTO:
- case OP_NOTPOSUPTOI:
- case OP_STAR:
- case OP_STARI:
- case OP_NOTSTAR:
- case OP_NOTSTARI:
- case OP_MINSTAR:
- case OP_MINSTARI:
- case OP_NOTMINSTAR:
- case OP_NOTMINSTARI:
- case OP_POSSTAR:
- case OP_POSSTARI:
- case OP_NOTPOSSTAR:
- case OP_NOTPOSSTARI:
- case OP_PLUS:
- case OP_PLUSI:
- case OP_NOTPLUS:
- case OP_NOTPLUSI:
- case OP_MINPLUS:
- case OP_MINPLUSI:
- case OP_NOTMINPLUS:
- case OP_NOTMINPLUSI:
- case OP_POSPLUS:
- case OP_POSPLUSI:
- case OP_NOTPOSPLUS:
- case OP_NOTPOSPLUSI:
- case OP_QUERY:
- case OP_QUERYI:
- case OP_NOTQUERY:
- case OP_NOTQUERYI:
- case OP_MINQUERY:
- case OP_MINQUERYI:
- case OP_NOTMINQUERY:
- case OP_NOTMINQUERYI:
- case OP_POSQUERY:
- case OP_POSQUERYI:
- case OP_NOTPOSQUERY:
- case OP_NOTPOSQUERYI:
- if (HAS_EXTRALEN(code[-1])) code += GET_EXTRALEN(code[-1]);
- break;
- }
-#else
- (void)(utf); /* Keep compiler happy by referencing function argument */
-#endif
- }
- }
-}
-
-
-
-/*************************************************
-* Scan compiled regex for recursion reference *
-*************************************************/
-
-/* This little function scans through a compiled pattern until it finds an
-instance of OP_RECURSE.
-
-Arguments:
- code points to start of expression
- utf TRUE in UTF-8 / UTF-16 / UTF-32 mode
-
-Returns: pointer to the opcode for OP_RECURSE, or NULL if not found
-*/
-
-static const pcre_uchar *
-find_recurse(const pcre_uchar *code, BOOL utf)
-{
-for (;;)
- {
- register pcre_uchar c = *code;
- if (c == OP_END) return NULL;
- if (c == OP_RECURSE) return code;
-
- /* XCLASS is used for classes that cannot be represented just by a bit
- map. This includes negated single high-valued characters. The length in
- the table is zero; the actual length is stored in the compiled code. */
-
- if (c == OP_XCLASS) code += GET(code, 1);
-
- /* Otherwise, we can get the item's length from the table, except that for
- repeated character types, we have to test for \p and \P, which have an extra
- two bytes of parameters, and for MARK/PRUNE/SKIP/THEN with an argument, we
- must add in its length. */
-
- else
- {
- switch(c)
- {
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- case OP_TYPEPOSSTAR:
- case OP_TYPEPOSPLUS:
- case OP_TYPEPOSQUERY:
- if (code[1] == OP_PROP || code[1] == OP_NOTPROP) code += 2;
- break;
-
- case OP_TYPEPOSUPTO:
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- case OP_TYPEEXACT:
- if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
- code += 2;
- break;
-
- case OP_MARK:
- case OP_PRUNE_ARG:
- case OP_SKIP_ARG:
- case OP_THEN_ARG:
- code += code[1];
- break;
- }
-
- /* Add in the fixed length from the table */
-
- code += PRIV(OP_lengths)[c];
-
- /* In UTF-8 mode, opcodes that are followed by a character may be followed
- by a multi-byte character. The length in the table is a minimum, so we have
- to arrange to skip the extra bytes. */
-
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (utf) switch(c)
- {
- case OP_CHAR:
- case OP_CHARI:
- case OP_NOT:
- case OP_NOTI:
- case OP_EXACT:
- case OP_EXACTI:
- case OP_NOTEXACT:
- case OP_NOTEXACTI:
- case OP_UPTO:
- case OP_UPTOI:
- case OP_NOTUPTO:
- case OP_NOTUPTOI:
- case OP_MINUPTO:
- case OP_MINUPTOI:
- case OP_NOTMINUPTO:
- case OP_NOTMINUPTOI:
- case OP_POSUPTO:
- case OP_POSUPTOI:
- case OP_NOTPOSUPTO:
- case OP_NOTPOSUPTOI:
- case OP_STAR:
- case OP_STARI:
- case OP_NOTSTAR:
- case OP_NOTSTARI:
- case OP_MINSTAR:
- case OP_MINSTARI:
- case OP_NOTMINSTAR:
- case OP_NOTMINSTARI:
- case OP_POSSTAR:
- case OP_POSSTARI:
- case OP_NOTPOSSTAR:
- case OP_NOTPOSSTARI:
- case OP_PLUS:
- case OP_PLUSI:
- case OP_NOTPLUS:
- case OP_NOTPLUSI:
- case OP_MINPLUS:
- case OP_MINPLUSI:
- case OP_NOTMINPLUS:
- case OP_NOTMINPLUSI:
- case OP_POSPLUS:
- case OP_POSPLUSI:
- case OP_NOTPOSPLUS:
- case OP_NOTPOSPLUSI:
- case OP_QUERY:
- case OP_QUERYI:
- case OP_NOTQUERY:
- case OP_NOTQUERYI:
- case OP_MINQUERY:
- case OP_MINQUERYI:
- case OP_NOTMINQUERY:
- case OP_NOTMINQUERYI:
- case OP_POSQUERY:
- case OP_POSQUERYI:
- case OP_NOTPOSQUERY:
- case OP_NOTPOSQUERYI:
- if (HAS_EXTRALEN(code[-1])) code += GET_EXTRALEN(code[-1]);
- break;
- }
-#else
- (void)(utf); /* Keep compiler happy by referencing function argument */
-#endif
- }
- }
-}
-
-
-
-/*************************************************
-* Scan compiled branch for non-emptiness *
-*************************************************/
-
-/* This function scans through a branch of a compiled pattern to see whether it
-can match the empty string or not. It is called from could_be_empty()
-below and from compile_branch() when checking for an unlimited repeat of a
-group that can match nothing. Note that first_significant_code() skips over
-backward and negative forward assertions when its final argument is TRUE. If we
-hit an unclosed bracket, we return "empty" - this means we've struck an inner
-bracket whose current branch will already have been scanned.
-
-Arguments:
- code points to start of search
- endcode points to where to stop
- utf TRUE if in UTF-8 / UTF-16 / UTF-32 mode
- cd contains pointers to tables etc.
- recurses chain of recurse_check to catch mutual recursion
-
-Returns: TRUE if what is matched could be empty
-*/
-
-static BOOL
-could_be_empty_branch(const pcre_uchar *code, const pcre_uchar *endcode,
- BOOL utf, compile_data *cd, recurse_check *recurses)
-{
-register pcre_uchar c;
-recurse_check this_recurse;
-
-for (code = first_significant_code(code + PRIV(OP_lengths)[*code], TRUE);
- code < endcode;
- code = first_significant_code(code + PRIV(OP_lengths)[c], TRUE))
- {
- const pcre_uchar *ccode;
-
- c = *code;
-
- /* Skip over forward assertions; the other assertions are skipped by
- first_significant_code() with a TRUE final argument. */
-
- if (c == OP_ASSERT)
- {
- do code += GET(code, 1); while (*code == OP_ALT);
- c = *code;
- continue;
- }
-
- /* For a recursion/subroutine call, if its end has been reached, which
- implies a backward reference subroutine call, we can scan it. If it's a
- forward reference subroutine call, we can't. To detect forward reference
- we have to scan up the list that is kept in the workspace. This function is
- called only when doing the real compile, not during the pre-compile that
- measures the size of the compiled pattern. */
-
- if (c == OP_RECURSE)
- {
- const pcre_uchar *scode = cd->start_code + GET(code, 1);
- const pcre_uchar *endgroup = scode;
- BOOL empty_branch;
-
- /* Test for forward reference or uncompleted reference. This is disabled
- when called to scan a completed pattern by setting cd->start_workspace to
- NULL. */
-
- if (cd->start_workspace != NULL)
- {
- const pcre_uchar *tcode;
- for (tcode = cd->start_workspace; tcode < cd->hwm; tcode += LINK_SIZE)
- if ((int)GET(tcode, 0) == (int)(code + 1 - cd->start_code)) return TRUE;
- if (GET(scode, 1) == 0) return TRUE; /* Unclosed */
- }
-
- /* If the reference is to a completed group, we need to detect whether this
- is a recursive call, as otherwise there will be an infinite loop. If it is
- a recursion, just skip over it. Simple recursions are easily detected. For
- mutual recursions we keep a chain on the stack. */
-
- do endgroup += GET(endgroup, 1); while (*endgroup == OP_ALT);
- if (code >= scode && code <= endgroup) continue; /* Simple recursion */
- else
- {
- recurse_check *r = recurses;
- for (r = recurses; r != NULL; r = r->prev)
- if (r->group == scode) break;
- if (r != NULL) continue; /* Mutual recursion */
- }
-
- /* Completed reference; scan the referenced group, remembering it on the
- stack chain to detect mutual recursions. */
-
- empty_branch = FALSE;
- this_recurse.prev = recurses;
- this_recurse.group = scode;
-
- do
- {
- if (could_be_empty_branch(scode, endcode, utf, cd, &this_recurse))
- {
- empty_branch = TRUE;
- break;
- }
- scode += GET(scode, 1);
- }
- while (*scode == OP_ALT);
-
- if (!empty_branch) return FALSE; /* All branches are non-empty */
- continue;
- }
-
- /* Groups with zero repeats can of course be empty; skip them. */
-
- if (c == OP_BRAZERO || c == OP_BRAMINZERO || c == OP_SKIPZERO ||
- c == OP_BRAPOSZERO)
- {
- code += PRIV(OP_lengths)[c];
- do code += GET(code, 1); while (*code == OP_ALT);
- c = *code;
- continue;
- }
-
- /* A nested group that is already marked as "could be empty" can just be
- skipped. */
-
- if (c == OP_SBRA || c == OP_SBRAPOS ||
- c == OP_SCBRA || c == OP_SCBRAPOS)
- {
- do code += GET(code, 1); while (*code == OP_ALT);
- c = *code;
- continue;
- }
-
- /* For other groups, scan the branches. */
-
- if (c == OP_BRA || c == OP_BRAPOS ||
- c == OP_CBRA || c == OP_CBRAPOS ||
- c == OP_ONCE || c == OP_ONCE_NC ||
- c == OP_COND || c == OP_SCOND)
- {
- BOOL empty_branch;
- if (GET(code, 1) == 0) return TRUE; /* Hit unclosed bracket */
-
- /* If a conditional group has only one branch, there is a second, implied,
- empty branch, so just skip over the conditional, because it could be empty.
- Otherwise, scan the individual branches of the group. */
-
- if (c == OP_COND && code[GET(code, 1)] != OP_ALT)
- code += GET(code, 1);
- else
- {
- empty_branch = FALSE;
- do
- {
- if (!empty_branch && could_be_empty_branch(code, endcode, utf, cd,
- recurses)) empty_branch = TRUE;
- code += GET(code, 1);
- }
- while (*code == OP_ALT);
- if (!empty_branch) return FALSE; /* All branches are non-empty */
- }
-
- c = *code;
- continue;
- }
-
- /* Handle the other opcodes */
-
- switch (c)
- {
- /* Check for quantifiers after a class. XCLASS is used for classes that
- cannot be represented just by a bit map. This includes negated single
- high-valued characters. The length in PRIV(OP_lengths)[] is zero; the
- actual length is stored in the compiled code, so we must update "code"
- here. */
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- ccode = code += GET(code, 1);
- goto CHECK_CLASS_REPEAT;
-#endif
-
- case OP_CLASS:
- case OP_NCLASS:
- ccode = code + PRIV(OP_lengths)[OP_CLASS];
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- CHECK_CLASS_REPEAT:
-#endif
-
- switch (*ccode)
- {
- case OP_CRSTAR: /* These could be empty; continue */
- case OP_CRMINSTAR:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- case OP_CRPOSSTAR:
- case OP_CRPOSQUERY:
- break;
-
- default: /* Non-repeat => class must match */
- case OP_CRPLUS: /* These repeats aren't empty */
- case OP_CRMINPLUS:
- case OP_CRPOSPLUS:
- return FALSE;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- case OP_CRPOSRANGE:
- if (GET2(ccode, 1) > 0) return FALSE; /* Minimum > 0 */
- break;
- }
- break;
-
- /* Opcodes that must match a character */
-
- case OP_ANY:
- case OP_ALLANY:
- case OP_ANYBYTE:
-
- case OP_PROP:
- case OP_NOTPROP:
- case OP_ANYNL:
-
- case OP_NOT_HSPACE:
- case OP_HSPACE:
- case OP_NOT_VSPACE:
- case OP_VSPACE:
- case OP_EXTUNI:
-
- case OP_NOT_DIGIT:
- case OP_DIGIT:
- case OP_NOT_WHITESPACE:
- case OP_WHITESPACE:
- case OP_NOT_WORDCHAR:
- case OP_WORDCHAR:
-
- case OP_CHAR:
- case OP_CHARI:
- case OP_NOT:
- case OP_NOTI:
-
- case OP_PLUS:
- case OP_PLUSI:
- case OP_MINPLUS:
- case OP_MINPLUSI:
-
- case OP_NOTPLUS:
- case OP_NOTPLUSI:
- case OP_NOTMINPLUS:
- case OP_NOTMINPLUSI:
-
- case OP_POSPLUS:
- case OP_POSPLUSI:
- case OP_NOTPOSPLUS:
- case OP_NOTPOSPLUSI:
-
- case OP_EXACT:
- case OP_EXACTI:
- case OP_NOTEXACT:
- case OP_NOTEXACTI:
-
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEPOSPLUS:
- case OP_TYPEEXACT:
-
- return FALSE;
-
- /* These are going to continue, as they may be empty, but we have to
- fudge the length for the \p and \P cases. */
-
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPOSSTAR:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- case OP_TYPEPOSQUERY:
- if (code[1] == OP_PROP || code[1] == OP_NOTPROP) code += 2;
- break;
-
- /* Same for these */
-
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- case OP_TYPEPOSUPTO:
- if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
- code += 2;
- break;
-
- /* End of branch */
-
- case OP_KET:
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_KETRPOS:
- case OP_ALT:
- return TRUE;
-
- /* In UTF-8 mode, STAR, MINSTAR, POSSTAR, QUERY, MINQUERY, POSQUERY, UPTO,
- MINUPTO, and POSUPTO and their caseless and negative versions may be
- followed by a multibyte character. */
-
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- case OP_STAR:
- case OP_STARI:
- case OP_NOTSTAR:
- case OP_NOTSTARI:
-
- case OP_MINSTAR:
- case OP_MINSTARI:
- case OP_NOTMINSTAR:
- case OP_NOTMINSTARI:
-
- case OP_POSSTAR:
- case OP_POSSTARI:
- case OP_NOTPOSSTAR:
- case OP_NOTPOSSTARI:
-
- case OP_QUERY:
- case OP_QUERYI:
- case OP_NOTQUERY:
- case OP_NOTQUERYI:
-
- case OP_MINQUERY:
- case OP_MINQUERYI:
- case OP_NOTMINQUERY:
- case OP_NOTMINQUERYI:
-
- case OP_POSQUERY:
- case OP_POSQUERYI:
- case OP_NOTPOSQUERY:
- case OP_NOTPOSQUERYI:
-
- if (utf && HAS_EXTRALEN(code[1])) code += GET_EXTRALEN(code[1]);
- break;
-
- case OP_UPTO:
- case OP_UPTOI:
- case OP_NOTUPTO:
- case OP_NOTUPTOI:
-
- case OP_MINUPTO:
- case OP_MINUPTOI:
- case OP_NOTMINUPTO:
- case OP_NOTMINUPTOI:
-
- case OP_POSUPTO:
- case OP_POSUPTOI:
- case OP_NOTPOSUPTO:
- case OP_NOTPOSUPTOI:
-
- if (utf && HAS_EXTRALEN(code[1 + IMM2_SIZE])) code += GET_EXTRALEN(code[1 + IMM2_SIZE]);
- break;
-#endif
-
- /* MARK, and PRUNE/SKIP/THEN with an argument must skip over the argument
- string. */
-
- case OP_MARK:
- case OP_PRUNE_ARG:
- case OP_SKIP_ARG:
- case OP_THEN_ARG:
- code += code[1];
- break;
-
- /* None of the remaining opcodes are required to match a character. */
-
- default:
- break;
- }
- }
-
-return TRUE;
-}
-
-
-
-/*************************************************
-* Scan compiled regex for non-emptiness *
-*************************************************/
-
-/* This function is called to check for left recursive calls. We want to check
-the current branch of the current pattern to see if it could match the empty
-string. If it could, we must look outwards for branches at other levels,
-stopping when we pass beyond the bracket which is the subject of the recursion.
-This function is called only during the real compile, not during the
-pre-compile.
-
-Arguments:
- code points to start of the recursion
- endcode points to where to stop (current RECURSE item)
- bcptr points to the chain of current (unclosed) branch starts
- utf TRUE if in UTF-8 / UTF-16 / UTF-32 mode
- cd pointers to tables etc
-
-Returns: TRUE if what is matched could be empty
-*/
-
-static BOOL
-could_be_empty(const pcre_uchar *code, const pcre_uchar *endcode,
- branch_chain *bcptr, BOOL utf, compile_data *cd)
-{
-while (bcptr != NULL && bcptr->current_branch >= code)
- {
- if (!could_be_empty_branch(bcptr->current_branch, endcode, utf, cd, NULL))
- return FALSE;
- bcptr = bcptr->outer;
- }
-return TRUE;
-}
-
-
-
-/*************************************************
-* Base opcode of repeated opcodes *
-*************************************************/
-
-/* Returns the base opcode for repeated single character type opcodes. If the
-opcode is not a repeated character type, it returns with the original value.
-
-Arguments: c opcode
-Returns: base opcode for the type
-*/
-
-static pcre_uchar
-get_repeat_base(pcre_uchar c)
-{
-return (c > OP_TYPEPOSUPTO)? c :
- (c >= OP_TYPESTAR)? OP_TYPESTAR :
- (c >= OP_NOTSTARI)? OP_NOTSTARI :
- (c >= OP_NOTSTAR)? OP_NOTSTAR :
- (c >= OP_STARI)? OP_STARI :
- OP_STAR;
-}
-
-
-
-#ifdef SUPPORT_UCP
-/*************************************************
-* Check a character and a property *
-*************************************************/
-
-/* This function is called by check_auto_possessive() when a property item
-is adjacent to a fixed character.
-
-Arguments:
- c the character
- ptype the property type
- pdata the data for the type
- negated TRUE if it's a negated property (\P or \p{^)
-
-Returns: TRUE if auto-possessifying is OK
-*/
-
-static BOOL
-check_char_prop(pcre_uint32 c, unsigned int ptype, unsigned int pdata,
- BOOL negated)
-{
-const pcre_uint32 *p;
-const ucd_record *prop = GET_UCD(c);
-
-switch(ptype)
- {
- case PT_LAMP:
- return (prop->chartype == ucp_Lu ||
- prop->chartype == ucp_Ll ||
- prop->chartype == ucp_Lt) == negated;
-
- case PT_GC:
- return (pdata == PRIV(ucp_gentype)[prop->chartype]) == negated;
-
- case PT_PC:
- return (pdata == prop->chartype) == negated;
-
- case PT_SC:
- return (pdata == prop->script) == negated;
-
- /* These are specials */
-
- case PT_ALNUM:
- return (PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
- PRIV(ucp_gentype)[prop->chartype] == ucp_N) == negated;
-
- /* Perl space used to exclude VT, but from Perl 5.18 it is included, which
- means that Perl space and POSIX space are now identical. PCRE was changed
- at release 8.34. */
-
- case PT_SPACE: /* Perl space */
- case PT_PXSPACE: /* POSIX space */
- switch(c)
- {
- HSPACE_CASES:
- VSPACE_CASES:
- return negated;
-
- default:
- return (PRIV(ucp_gentype)[prop->chartype] == ucp_Z) == negated;
- }
- break; /* Control never reaches here */
-
- case PT_WORD:
- return (PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
- PRIV(ucp_gentype)[prop->chartype] == ucp_N ||
- c == CHAR_UNDERSCORE) == negated;
-
- case PT_CLIST:
- p = PRIV(ucd_caseless_sets) + prop->caseset;
- for (;;)
- {
- if (c < *p) return !negated;
- if (c == *p++) return negated;
- }
- break; /* Control never reaches here */
- }
-
-return FALSE;
-}
-#endif /* SUPPORT_UCP */
-
-
-
-/*************************************************
-* Fill the character property list *
-*************************************************/
-
-/* Checks whether the code points to an opcode that can take part in auto-
-possessification, and if so, fills a list with its properties.
-
-Arguments:
- code points to start of expression
- utf TRUE if in UTF-8 / UTF-16 / UTF-32 mode
- fcc points to case-flipping table
- list points to output list
- list[0] will be filled with the opcode
- list[1] will be non-zero if this opcode
- can match an empty character string
- list[2..7] depends on the opcode
-
-Returns: points to the start of the next opcode if *code is accepted
- NULL if *code is not accepted
-*/
-
-static const pcre_uchar *
-get_chr_property_list(const pcre_uchar *code, BOOL utf,
- const pcre_uint8 *fcc, pcre_uint32 *list)
-{
-pcre_uchar c = *code;
-pcre_uchar base;
-const pcre_uchar *end;
-pcre_uint32 chr;
-
-#ifdef SUPPORT_UCP
-pcre_uint32 *clist_dest;
-const pcre_uint32 *clist_src;
-#else
-utf = utf; /* Suppress "unused parameter" compiler warning */
-#endif
-
-list[0] = c;
-list[1] = FALSE;
-code++;
-
-if (c >= OP_STAR && c <= OP_TYPEPOSUPTO)
- {
- base = get_repeat_base(c);
- c -= (base - OP_STAR);
-
- if (c == OP_UPTO || c == OP_MINUPTO || c == OP_EXACT || c == OP_POSUPTO)
- code += IMM2_SIZE;
-
- list[1] = (c != OP_PLUS && c != OP_MINPLUS && c != OP_EXACT && c != OP_POSPLUS);
-
- switch(base)
- {
- case OP_STAR:
- list[0] = OP_CHAR;
- break;
-
- case OP_STARI:
- list[0] = OP_CHARI;
- break;
-
- case OP_NOTSTAR:
- list[0] = OP_NOT;
- break;
-
- case OP_NOTSTARI:
- list[0] = OP_NOTI;
- break;
-
- case OP_TYPESTAR:
- list[0] = *code;
- code++;
- break;
- }
- c = list[0];
- }
-
-switch(c)
- {
- case OP_NOT_DIGIT:
- case OP_DIGIT:
- case OP_NOT_WHITESPACE:
- case OP_WHITESPACE:
- case OP_NOT_WORDCHAR:
- case OP_WORDCHAR:
- case OP_ANY:
- case OP_ALLANY:
- case OP_ANYNL:
- case OP_NOT_HSPACE:
- case OP_HSPACE:
- case OP_NOT_VSPACE:
- case OP_VSPACE:
- case OP_EXTUNI:
- case OP_EODN:
- case OP_EOD:
- case OP_DOLL:
- case OP_DOLLM:
- return code;
-
- case OP_CHAR:
- case OP_NOT:
- GETCHARINCTEST(chr, code);
- list[2] = chr;
- list[3] = NOTACHAR;
- return code;
-
- case OP_CHARI:
- case OP_NOTI:
- list[0] = (c == OP_CHARI) ? OP_CHAR : OP_NOT;
- GETCHARINCTEST(chr, code);
- list[2] = chr;
-
-#ifdef SUPPORT_UCP
- if (chr < 128 || (chr < 256 && !utf))
- list[3] = fcc[chr];
- else
- list[3] = UCD_OTHERCASE(chr);
-#elif defined SUPPORT_UTF || !defined COMPILE_PCRE8
- list[3] = (chr < 256) ? fcc[chr] : chr;
-#else
- list[3] = fcc[chr];
-#endif
-
- /* The othercase might be the same value. */
-
- if (chr == list[3])
- list[3] = NOTACHAR;
- else
- list[4] = NOTACHAR;
- return code;
-
-#ifdef SUPPORT_UCP
- case OP_PROP:
- case OP_NOTPROP:
- if (code[0] != PT_CLIST)
- {
- list[2] = code[0];
- list[3] = code[1];
- return code + 2;
- }
-
- /* Convert only if we have enough space. */
-
- clist_src = PRIV(ucd_caseless_sets) + code[1];
- clist_dest = list + 2;
- code += 2;
-
- do {
- if (clist_dest >= list + 8)
- {
- /* Early return if there is not enough space. This should never
- happen, since all clists are shorter than 5 character now. */
- list[2] = code[0];
- list[3] = code[1];
- return code;
- }
- *clist_dest++ = *clist_src;
- }
- while(*clist_src++ != NOTACHAR);
-
- /* All characters are stored. The terminating NOTACHAR
- is copied form the clist itself. */
-
- list[0] = (c == OP_PROP) ? OP_CHAR : OP_NOT;
- return code;
-#endif
-
- case OP_NCLASS:
- case OP_CLASS:
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- if (c == OP_XCLASS)
- end = code + GET(code, 0) - 1;
- else
-#endif
- end = code + 32 / sizeof(pcre_uchar);
-
- switch(*end)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- case OP_CRPOSSTAR:
- case OP_CRPOSQUERY:
- list[1] = TRUE;
- end++;
- break;
-
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRPOSPLUS:
- end++;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- case OP_CRPOSRANGE:
- list[1] = (GET2(end, 1) == 0);
- end += 1 + 2 * IMM2_SIZE;
- break;
- }
- list[2] = (pcre_uint32)(end - code);
- return end;
- }
-return NULL; /* Opcode not accepted */
-}
-
-
-
-/*************************************************
-* Scan further character sets for match *
-*************************************************/
-
-/* Checks whether the base and the current opcode have a common character, in
-which case the base cannot be possessified.
-
-Arguments:
- code points to the byte code
- utf TRUE in UTF-8 / UTF-16 / UTF-32 mode
- cd static compile data
- base_list the data list of the base opcode
-
-Returns: TRUE if the auto-possessification is possible
-*/
-
-static BOOL
-compare_opcodes(const pcre_uchar *code, BOOL utf, const compile_data *cd,
- const pcre_uint32 *base_list, const pcre_uchar *base_end, int *rec_limit)
-{
-pcre_uchar c;
-pcre_uint32 list[8];
-const pcre_uint32 *chr_ptr;
-const pcre_uint32 *ochr_ptr;
-const pcre_uint32 *list_ptr;
-const pcre_uchar *next_code;
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
-const pcre_uchar *xclass_flags;
-#endif
-const pcre_uint8 *class_bitset;
-const pcre_uint8 *set1, *set2, *set_end;
-pcre_uint32 chr;
-BOOL accepted, invert_bits;
-BOOL entered_a_group = FALSE;
-
-if (*rec_limit == 0) return FALSE;
---(*rec_limit);
-
-/* Note: the base_list[1] contains whether the current opcode has greedy
-(represented by a non-zero value) quantifier. This is a different from
-other character type lists, which stores here that the character iterator
-matches to an empty string (also represented by a non-zero value). */
-
-for(;;)
- {
- /* All operations move the code pointer forward.
- Therefore infinite recursions are not possible. */
-
- c = *code;
-
- /* Skip over callouts */
-
- if (c == OP_CALLOUT)
- {
- code += PRIV(OP_lengths)[c];
- continue;
- }
-
- if (c == OP_ALT)
- {
- do code += GET(code, 1); while (*code == OP_ALT);
- c = *code;
- }
-
- switch(c)
- {
- case OP_END:
- case OP_KETRPOS:
- /* TRUE only in greedy case. The non-greedy case could be replaced by
- an OP_EXACT, but it is probably not worth it. (And note that OP_EXACT
- uses more memory, which we cannot get at this stage.) */
-
- return base_list[1] != 0;
-
- case OP_KET:
- /* If the bracket is capturing, and referenced by an OP_RECURSE, or
- it is an atomic sub-pattern (assert, once, etc.) the non-greedy case
- cannot be converted to a possessive form. */
-
- if (base_list[1] == 0) return FALSE;
-
- switch(*(code - GET(code, 1)))
- {
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- case OP_ONCE:
- case OP_ONCE_NC:
- /* Atomic sub-patterns and assertions can always auto-possessify their
- last iterator. However, if the group was entered as a result of checking
- a previous iterator, this is not possible. */
-
- return !entered_a_group;
- }
-
- code += PRIV(OP_lengths)[c];
- continue;
-
- case OP_ONCE:
- case OP_ONCE_NC:
- case OP_BRA:
- case OP_CBRA:
- next_code = code + GET(code, 1);
- code += PRIV(OP_lengths)[c];
-
- while (*next_code == OP_ALT)
- {
- if (!compare_opcodes(code, utf, cd, base_list, base_end, rec_limit))
- return FALSE;
- code = next_code + 1 + LINK_SIZE;
- next_code += GET(next_code, 1);
- }
-
- entered_a_group = TRUE;
- continue;
-
- case OP_BRAZERO:
- case OP_BRAMINZERO:
-
- next_code = code + 1;
- if (*next_code != OP_BRA && *next_code != OP_CBRA
- && *next_code != OP_ONCE && *next_code != OP_ONCE_NC) return FALSE;
-
- do next_code += GET(next_code, 1); while (*next_code == OP_ALT);
-
- /* The bracket content will be checked by the
- OP_BRA/OP_CBRA case above. */
- next_code += 1 + LINK_SIZE;
- if (!compare_opcodes(next_code, utf, cd, base_list, base_end, rec_limit))
- return FALSE;
-
- code += PRIV(OP_lengths)[c];
- continue;
-
- default:
- break;
- }
-
- /* Check for a supported opcode, and load its properties. */
-
- code = get_chr_property_list(code, utf, cd->fcc, list);
- if (code == NULL) return FALSE; /* Unsupported */
-
- /* If either opcode is a small character list, set pointers for comparing
- characters from that list with another list, or with a property. */
-
- if (base_list[0] == OP_CHAR)
- {
- chr_ptr = base_list + 2;
- list_ptr = list;
- }
- else if (list[0] == OP_CHAR)
- {
- chr_ptr = list + 2;
- list_ptr = base_list;
- }
-
- /* Character bitsets can also be compared to certain opcodes. */
-
- else if (base_list[0] == OP_CLASS || list[0] == OP_CLASS
-#ifdef COMPILE_PCRE8
- /* In 8 bit, non-UTF mode, OP_CLASS and OP_NCLASS are the same. */
- || (!utf && (base_list[0] == OP_NCLASS || list[0] == OP_NCLASS))
-#endif
- )
- {
-#ifdef COMPILE_PCRE8
- if (base_list[0] == OP_CLASS || (!utf && base_list[0] == OP_NCLASS))
-#else
- if (base_list[0] == OP_CLASS)
-#endif
- {
- set1 = (pcre_uint8 *)(base_end - base_list[2]);
- list_ptr = list;
- }
- else
- {
- set1 = (pcre_uint8 *)(code - list[2]);
- list_ptr = base_list;
- }
-
- invert_bits = FALSE;
- switch(list_ptr[0])
- {
- case OP_CLASS:
- case OP_NCLASS:
- set2 = (pcre_uint8 *)
- ((list_ptr == list ? code : base_end) - list_ptr[2]);
- break;
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- xclass_flags = (list_ptr == list ? code : base_end) - list_ptr[2] + LINK_SIZE;
- if ((*xclass_flags & XCL_HASPROP) != 0) return FALSE;
- if ((*xclass_flags & XCL_MAP) == 0)
- {
- /* No bits are set for characters < 256. */
- if (list[1] == 0) return TRUE;
- /* Might be an empty repeat. */
- continue;
- }
- set2 = (pcre_uint8 *)(xclass_flags + 1);
- break;
-#endif
-
- case OP_NOT_DIGIT:
- invert_bits = TRUE;
- /* Fall through */
- case OP_DIGIT:
- set2 = (pcre_uint8 *)(cd->cbits + cbit_digit);
- break;
-
- case OP_NOT_WHITESPACE:
- invert_bits = TRUE;
- /* Fall through */
- case OP_WHITESPACE:
- set2 = (pcre_uint8 *)(cd->cbits + cbit_space);
- break;
-
- case OP_NOT_WORDCHAR:
- invert_bits = TRUE;
- /* Fall through */
- case OP_WORDCHAR:
- set2 = (pcre_uint8 *)(cd->cbits + cbit_word);
- break;
-
- default:
- return FALSE;
- }
-
- /* Because the sets are unaligned, we need
- to perform byte comparison here. */
- set_end = set1 + 32;
- if (invert_bits)
- {
- do
- {
- if ((*set1++ & ~(*set2++)) != 0) return FALSE;
- }
- while (set1 < set_end);
- }
- else
- {
- do
- {
- if ((*set1++ & *set2++) != 0) return FALSE;
- }
- while (set1 < set_end);
- }
-
- if (list[1] == 0) return TRUE;
- /* Might be an empty repeat. */
- continue;
- }
-
- /* Some property combinations also acceptable. Unicode property opcodes are
- processed specially; the rest can be handled with a lookup table. */
-
- else
- {
- pcre_uint32 leftop, rightop;
-
- leftop = base_list[0];
- rightop = list[0];
-
-#ifdef SUPPORT_UCP
- accepted = FALSE; /* Always set in non-unicode case. */
- if (leftop == OP_PROP || leftop == OP_NOTPROP)
- {
- if (rightop == OP_EOD)
- accepted = TRUE;
- else if (rightop == OP_PROP || rightop == OP_NOTPROP)
- {
- int n;
- const pcre_uint8 *p;
- BOOL same = leftop == rightop;
- BOOL lisprop = leftop == OP_PROP;
- BOOL risprop = rightop == OP_PROP;
- BOOL bothprop = lisprop && risprop;
-
- /* There's a table that specifies how each combination is to be
- processed:
- 0 Always return FALSE (never auto-possessify)
- 1 Character groups are distinct (possessify if both are OP_PROP)
- 2 Check character categories in the same group (general or particular)
- 3 Return TRUE if the two opcodes are not the same
- ... see comments below
- */
-
- n = propposstab[base_list[2]][list[2]];
- switch(n)
- {
- case 0: break;
- case 1: accepted = bothprop; break;
- case 2: accepted = (base_list[3] == list[3]) != same; break;
- case 3: accepted = !same; break;
-
- case 4: /* Left general category, right particular category */
- accepted = risprop && catposstab[base_list[3]][list[3]] == same;
- break;
-
- case 5: /* Right general category, left particular category */
- accepted = lisprop && catposstab[list[3]][base_list[3]] == same;
- break;
-
- /* This code is logically tricky. Think hard before fiddling with it.
- The posspropstab table has four entries per row. Each row relates to
- one of PCRE's special properties such as ALNUM or SPACE or WORD.
- Only WORD actually needs all four entries, but using repeats for the
- others means they can all use the same code below.
-
- The first two entries in each row are Unicode general categories, and
- apply always, because all the characters they include are part of the
- PCRE character set. The third and fourth entries are a general and a
- particular category, respectively, that include one or more relevant
- characters. One or the other is used, depending on whether the check
- is for a general or a particular category. However, in both cases the
- category contains more characters than the specials that are defined
- for the property being tested against. Therefore, it cannot be used
- in a NOTPROP case.
-
- Example: the row for WORD contains ucp_L, ucp_N, ucp_P, ucp_Po.
- Underscore is covered by ucp_P or ucp_Po. */
-
- case 6: /* Left alphanum vs right general category */
- case 7: /* Left space vs right general category */
- case 8: /* Left word vs right general category */
- p = posspropstab[n-6];
- accepted = risprop && lisprop ==
- (list[3] != p[0] &&
- list[3] != p[1] &&
- (list[3] != p[2] || !lisprop));
- break;
-
- case 9: /* Right alphanum vs left general category */
- case 10: /* Right space vs left general category */
- case 11: /* Right word vs left general category */
- p = posspropstab[n-9];
- accepted = lisprop && risprop ==
- (base_list[3] != p[0] &&
- base_list[3] != p[1] &&
- (base_list[3] != p[2] || !risprop));
- break;
-
- case 12: /* Left alphanum vs right particular category */
- case 13: /* Left space vs right particular category */
- case 14: /* Left word vs right particular category */
- p = posspropstab[n-12];
- accepted = risprop && lisprop ==
- (catposstab[p[0]][list[3]] &&
- catposstab[p[1]][list[3]] &&
- (list[3] != p[3] || !lisprop));
- break;
-
- case 15: /* Right alphanum vs left particular category */
- case 16: /* Right space vs left particular category */
- case 17: /* Right word vs left particular category */
- p = posspropstab[n-15];
- accepted = lisprop && risprop ==
- (catposstab[p[0]][base_list[3]] &&
- catposstab[p[1]][base_list[3]] &&
- (base_list[3] != p[3] || !risprop));
- break;
- }
- }
- }
-
- else
-#endif /* SUPPORT_UCP */
-
- accepted = leftop >= FIRST_AUTOTAB_OP && leftop <= LAST_AUTOTAB_LEFT_OP &&
- rightop >= FIRST_AUTOTAB_OP && rightop <= LAST_AUTOTAB_RIGHT_OP &&
- autoposstab[leftop - FIRST_AUTOTAB_OP][rightop - FIRST_AUTOTAB_OP];
-
- if (!accepted) return FALSE;
-
- if (list[1] == 0) return TRUE;
- /* Might be an empty repeat. */
- continue;
- }
-
- /* Control reaches here only if one of the items is a small character list.
- All characters are checked against the other side. */
-
- do
- {
- chr = *chr_ptr;
-
- switch(list_ptr[0])
- {
- case OP_CHAR:
- ochr_ptr = list_ptr + 2;
- do
- {
- if (chr == *ochr_ptr) return FALSE;
- ochr_ptr++;
- }
- while(*ochr_ptr != NOTACHAR);
- break;
-
- case OP_NOT:
- ochr_ptr = list_ptr + 2;
- do
- {
- if (chr == *ochr_ptr)
- break;
- ochr_ptr++;
- }
- while(*ochr_ptr != NOTACHAR);
- if (*ochr_ptr == NOTACHAR) return FALSE; /* Not found */
- break;
-
- /* Note that OP_DIGIT etc. are generated only when PCRE_UCP is *not*
- set. When it is set, \d etc. are converted into OP_(NOT_)PROP codes. */
-
- case OP_DIGIT:
- if (chr < 256 && (cd->ctypes[chr] & ctype_digit) != 0) return FALSE;
- break;
-
- case OP_NOT_DIGIT:
- if (chr > 255 || (cd->ctypes[chr] & ctype_digit) == 0) return FALSE;
- break;
-
- case OP_WHITESPACE:
- if (chr < 256 && (cd->ctypes[chr] & ctype_space) != 0) return FALSE;
- break;
-
- case OP_NOT_WHITESPACE:
- if (chr > 255 || (cd->ctypes[chr] & ctype_space) == 0) return FALSE;
- break;
-
- case OP_WORDCHAR:
- if (chr < 255 && (cd->ctypes[chr] & ctype_word) != 0) return FALSE;
- break;
-
- case OP_NOT_WORDCHAR:
- if (chr > 255 || (cd->ctypes[chr] & ctype_word) == 0) return FALSE;
- break;
-
- case OP_HSPACE:
- switch(chr)
- {
- HSPACE_CASES: return FALSE;
- default: break;
- }
- break;
-
- case OP_NOT_HSPACE:
- switch(chr)
- {
- HSPACE_CASES: break;
- default: return FALSE;
- }
- break;
-
- case OP_ANYNL:
- case OP_VSPACE:
- switch(chr)
- {
- VSPACE_CASES: return FALSE;
- default: break;
- }
- break;
-
- case OP_NOT_VSPACE:
- switch(chr)
- {
- VSPACE_CASES: break;
- default: return FALSE;
- }
- break;
-
- case OP_DOLL:
- case OP_EODN:
- switch (chr)
- {
- case CHAR_CR:
- case CHAR_LF:
- case CHAR_VT:
- case CHAR_FF:
- case CHAR_NEL:
-#ifndef EBCDIC
- case 0x2028:
- case 0x2029:
-#endif /* Not EBCDIC */
- return FALSE;
- }
- break;
-
- case OP_EOD: /* Can always possessify before \z */
- break;
-
-#ifdef SUPPORT_UCP
- case OP_PROP:
- case OP_NOTPROP:
- if (!check_char_prop(chr, list_ptr[2], list_ptr[3],
- list_ptr[0] == OP_NOTPROP))
- return FALSE;
- break;
-#endif
-
- case OP_NCLASS:
- if (chr > 255) return FALSE;
- /* Fall through */
-
- case OP_CLASS:
- if (chr > 255) break;
- class_bitset = (pcre_uint8 *)
- ((list_ptr == list ? code : base_end) - list_ptr[2]);
- if ((class_bitset[chr >> 3] & (1 << (chr & 7))) != 0) return FALSE;
- break;
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- if (PRIV(xclass)(chr, (list_ptr == list ? code : base_end) -
- list_ptr[2] + LINK_SIZE, utf)) return FALSE;
- break;
-#endif
-
- default:
- return FALSE;
- }
-
- chr_ptr++;
- }
- while(*chr_ptr != NOTACHAR);
-
- /* At least one character must be matched from this opcode. */
-
- if (list[1] == 0) return TRUE;
- }
-
-/* Control never reaches here. There used to be a fail-save return FALSE; here,
-but some compilers complain about an unreachable statement. */
-
-}
-
-
-
-/*************************************************
-* Scan compiled regex for auto-possession *
-*************************************************/
-
-/* Replaces single character iterations with their possessive alternatives
-if appropriate. This function modifies the compiled opcode!
-
-Arguments:
- code points to start of the byte code
- utf TRUE in UTF-8 / UTF-16 / UTF-32 mode
- cd static compile data
-
-Returns: nothing
-*/
-
-static void
-auto_possessify(pcre_uchar *code, BOOL utf, const compile_data *cd)
-{
-register pcre_uchar c;
-const pcre_uchar *end;
-pcre_uchar *repeat_opcode;
-pcre_uint32 list[8];
-int rec_limit;
-
-for (;;)
- {
- c = *code;
-
- /* When a pattern with bad UTF-8 encoding is compiled with NO_UTF_CHECK,
- it may compile without complaining, but may get into a loop here if the code
- pointer points to a bad value. This is, of course a documentated possibility,
- when NO_UTF_CHECK is set, so it isn't a bug, but we can detect this case and
- just give up on this optimization. */
-
- if (c >= OP_TABLE_LENGTH) return;
-
- if (c >= OP_STAR && c <= OP_TYPEPOSUPTO)
- {
- c -= get_repeat_base(c) - OP_STAR;
- end = (c <= OP_MINUPTO) ?
- get_chr_property_list(code, utf, cd->fcc, list) : NULL;
- list[1] = c == OP_STAR || c == OP_PLUS || c == OP_QUERY || c == OP_UPTO;
-
- rec_limit = 1000;
- if (end != NULL && compare_opcodes(end, utf, cd, list, end, &rec_limit))
- {
- switch(c)
- {
- case OP_STAR:
- *code += OP_POSSTAR - OP_STAR;
- break;
-
- case OP_MINSTAR:
- *code += OP_POSSTAR - OP_MINSTAR;
- break;
-
- case OP_PLUS:
- *code += OP_POSPLUS - OP_PLUS;
- break;
-
- case OP_MINPLUS:
- *code += OP_POSPLUS - OP_MINPLUS;
- break;
-
- case OP_QUERY:
- *code += OP_POSQUERY - OP_QUERY;
- break;
-
- case OP_MINQUERY:
- *code += OP_POSQUERY - OP_MINQUERY;
- break;
-
- case OP_UPTO:
- *code += OP_POSUPTO - OP_UPTO;
- break;
-
- case OP_MINUPTO:
- *code += OP_POSUPTO - OP_MINUPTO;
- break;
- }
- }
- c = *code;
- }
- else if (c == OP_CLASS || c == OP_NCLASS || c == OP_XCLASS)
- {
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- if (c == OP_XCLASS)
- repeat_opcode = code + GET(code, 1);
- else
-#endif
- repeat_opcode = code + 1 + (32 / sizeof(pcre_uchar));
-
- c = *repeat_opcode;
- if (c >= OP_CRSTAR && c <= OP_CRMINRANGE)
- {
- /* end must not be NULL. */
- end = get_chr_property_list(code, utf, cd->fcc, list);
-
- list[1] = (c & 1) == 0;
-
- rec_limit = 1000;
- if (compare_opcodes(end, utf, cd, list, end, &rec_limit))
- {
- switch (c)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- *repeat_opcode = OP_CRPOSSTAR;
- break;
-
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- *repeat_opcode = OP_CRPOSPLUS;
- break;
-
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- *repeat_opcode = OP_CRPOSQUERY;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- *repeat_opcode = OP_CRPOSRANGE;
- break;
- }
- }
- }
- c = *code;
- }
-
- switch(c)
- {
- case OP_END:
- return;
-
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- case OP_TYPEPOSSTAR:
- case OP_TYPEPOSPLUS:
- case OP_TYPEPOSQUERY:
- if (code[1] == OP_PROP || code[1] == OP_NOTPROP) code += 2;
- break;
-
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- case OP_TYPEEXACT:
- case OP_TYPEPOSUPTO:
- if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
- code += 2;
- break;
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- code += GET(code, 1);
- break;
-#endif
-
- case OP_MARK:
- case OP_PRUNE_ARG:
- case OP_SKIP_ARG:
- case OP_THEN_ARG:
- code += code[1];
- break;
- }
-
- /* Add in the fixed length from the table */
-
- code += PRIV(OP_lengths)[c];
-
- /* In UTF-8 mode, opcodes that are followed by a character may be followed by
- a multi-byte character. The length in the table is a minimum, so we have to
- arrange to skip the extra bytes. */
-
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (utf) switch(c)
- {
- case OP_CHAR:
- case OP_CHARI:
- case OP_NOT:
- case OP_NOTI:
- case OP_STAR:
- case OP_MINSTAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_UPTO:
- case OP_MINUPTO:
- case OP_EXACT:
- case OP_POSSTAR:
- case OP_POSPLUS:
- case OP_POSQUERY:
- case OP_POSUPTO:
- case OP_STARI:
- case OP_MINSTARI:
- case OP_PLUSI:
- case OP_MINPLUSI:
- case OP_QUERYI:
- case OP_MINQUERYI:
- case OP_UPTOI:
- case OP_MINUPTOI:
- case OP_EXACTI:
- case OP_POSSTARI:
- case OP_POSPLUSI:
- case OP_POSQUERYI:
- case OP_POSUPTOI:
- case OP_NOTSTAR:
- case OP_NOTMINSTAR:
- case OP_NOTPLUS:
- case OP_NOTMINPLUS:
- case OP_NOTQUERY:
- case OP_NOTMINQUERY:
- case OP_NOTUPTO:
- case OP_NOTMINUPTO:
- case OP_NOTEXACT:
- case OP_NOTPOSSTAR:
- case OP_NOTPOSPLUS:
- case OP_NOTPOSQUERY:
- case OP_NOTPOSUPTO:
- case OP_NOTSTARI:
- case OP_NOTMINSTARI:
- case OP_NOTPLUSI:
- case OP_NOTMINPLUSI:
- case OP_NOTQUERYI:
- case OP_NOTMINQUERYI:
- case OP_NOTUPTOI:
- case OP_NOTMINUPTOI:
- case OP_NOTEXACTI:
- case OP_NOTPOSSTARI:
- case OP_NOTPOSPLUSI:
- case OP_NOTPOSQUERYI:
- case OP_NOTPOSUPTOI:
- if (HAS_EXTRALEN(code[-1])) code += GET_EXTRALEN(code[-1]);
- break;
- }
-#else
- (void)(utf); /* Keep compiler happy by referencing function argument */
-#endif
- }
-}
-
-
-
-/*************************************************
-* Check for POSIX class syntax *
-*************************************************/
-
-/* This function is called when the sequence "[:" or "[." or "[=" is
-encountered in a character class. It checks whether this is followed by a
-sequence of characters terminated by a matching ":]" or ".]" or "=]". If we
-reach an unescaped ']' without the special preceding character, return FALSE.
-
-Originally, this function only recognized a sequence of letters between the
-terminators, but it seems that Perl recognizes any sequence of characters,
-though of course unknown POSIX names are subsequently rejected. Perl gives an
-"Unknown POSIX class" error for [:f\oo:] for example, where previously PCRE
-didn't consider this to be a POSIX class. Likewise for [:1234:].
-
-The problem in trying to be exactly like Perl is in the handling of escapes. We
-have to be sure that [abc[:x\]pqr] is *not* treated as containing a POSIX
-class, but [abc[:x\]pqr:]] is (so that an error can be generated). The code
-below handles the special cases \\ and \], but does not try to do any other
-escape processing. This makes it different from Perl for cases such as
-[:l\ower:] where Perl recognizes it as the POSIX class "lower" but PCRE does
-not recognize "l\ower". This is a lesser evil than not diagnosing bad classes
-when Perl does, I think.
-
-A user pointed out that PCRE was rejecting [:a[:digit:]] whereas Perl was not.
-It seems that the appearance of a nested POSIX class supersedes an apparent
-external class. For example, [:a[:digit:]b:] matches "a", "b", ":", or
-a digit.
-
-In Perl, unescaped square brackets may also appear as part of class names. For
-example, [:a[:abc]b:] gives unknown POSIX class "[:abc]b:]". However, for
-[:a[:abc]b][b:] it gives unknown POSIX class "[:abc]b][b:]", which does not
-seem right at all. PCRE does not allow closing square brackets in POSIX class
-names.
-
-Arguments:
- ptr pointer to the initial [
- endptr where to return the end pointer
-
-Returns: TRUE or FALSE
-*/
-
-static BOOL
-check_posix_syntax(const pcre_uchar *ptr, const pcre_uchar **endptr)
-{
-pcre_uchar terminator; /* Don't combine these lines; the Solaris cc */
-terminator = *(++ptr); /* compiler warns about "non-constant" initializer. */
-for (++ptr; *ptr != CHAR_NULL; ptr++)
- {
- if (*ptr == CHAR_BACKSLASH &&
- (ptr[1] == CHAR_RIGHT_SQUARE_BRACKET ||
- ptr[1] == CHAR_BACKSLASH))
- ptr++;
- else if ((*ptr == CHAR_LEFT_SQUARE_BRACKET && ptr[1] == terminator) ||
- *ptr == CHAR_RIGHT_SQUARE_BRACKET) return FALSE;
- else if (*ptr == terminator && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
- {
- *endptr = ptr;
- return TRUE;
- }
- }
-return FALSE;
-}
-
-
-
-
-/*************************************************
-* Check POSIX class name *
-*************************************************/
-
-/* This function is called to check the name given in a POSIX-style class entry
-such as [:alnum:].
-
-Arguments:
- ptr points to the first letter
- len the length of the name
-
-Returns: a value representing the name, or -1 if unknown
-*/
-
-static int
-check_posix_name(const pcre_uchar *ptr, int len)
-{
-const char *pn = posix_names;
-register int yield = 0;
-while (posix_name_lengths[yield] != 0)
- {
- if (len == posix_name_lengths[yield] &&
- STRNCMP_UC_C8(ptr, pn, (unsigned int)len) == 0) return yield;
- pn += posix_name_lengths[yield] + 1;
- yield++;
- }
-return -1;
-}
-
-
-/*************************************************
-* Adjust OP_RECURSE items in repeated group *
-*************************************************/
-
-/* OP_RECURSE items contain an offset from the start of the regex to the group
-that is referenced. This means that groups can be replicated for fixed
-repetition simply by copying (because the recursion is allowed to refer to
-earlier groups that are outside the current group). However, when a group is
-optional (i.e. the minimum quantifier is zero), OP_BRAZERO or OP_SKIPZERO is
-inserted before it, after it has been compiled. This means that any OP_RECURSE
-items within it that refer to the group itself or any contained groups have to
-have their offsets adjusted. That one of the jobs of this function. Before it
-is called, the partially compiled regex must be temporarily terminated with
-OP_END.
-
-This function has been extended to cope with forward references for recursions
-and subroutine calls. It must check the list of such references for the
-group we are dealing with. If it finds that one of the recursions in the
-current group is on this list, it does not adjust the value in the reference
-(which is a group number). After the group has been scanned, all the offsets in
-the forward reference list for the group are adjusted.
-
-Arguments:
- group points to the start of the group
- adjust the amount by which the group is to be moved
- utf TRUE in UTF-8 / UTF-16 / UTF-32 mode
- cd contains pointers to tables etc.
- save_hwm_offset the hwm forward reference offset at the start of the group
-
-Returns: nothing
-*/
-
-static void
-adjust_recurse(pcre_uchar *group, int adjust, BOOL utf, compile_data *cd,
- size_t save_hwm_offset)
-{
-int offset;
-pcre_uchar *hc;
-pcre_uchar *ptr = group;
-
-while ((ptr = (pcre_uchar *)find_recurse(ptr, utf)) != NULL)
- {
- for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset; hc < cd->hwm;
- hc += LINK_SIZE)
- {
- offset = (int)GET(hc, 0);
- if (cd->start_code + offset == ptr + 1) break;
- }
-
- /* If we have not found this recursion on the forward reference list, adjust
- the recursion's offset if it's after the start of this group. */
-
- if (hc >= cd->hwm)
- {
- offset = (int)GET(ptr, 1);
- if (cd->start_code + offset >= group) PUT(ptr, 1, offset + adjust);
- }
-
- ptr += 1 + LINK_SIZE;
- }
-
-/* Now adjust all forward reference offsets for the group. */
-
-for (hc = (pcre_uchar *)cd->start_workspace + save_hwm_offset; hc < cd->hwm;
- hc += LINK_SIZE)
- {
- offset = (int)GET(hc, 0);
- PUT(hc, 0, offset + adjust);
- }
-}
-
-
-
-/*************************************************
-* Insert an automatic callout point *
-*************************************************/
-
-/* This function is called when the PCRE_AUTO_CALLOUT option is set, to insert
-callout points before each pattern item.
-
-Arguments:
- code current code pointer
- ptr current pattern pointer
- cd pointers to tables etc
-
-Returns: new code pointer
-*/
-
-static pcre_uchar *
-auto_callout(pcre_uchar *code, const pcre_uchar *ptr, compile_data *cd)
-{
-*code++ = OP_CALLOUT;
-*code++ = 255;
-PUT(code, 0, (int)(ptr - cd->start_pattern)); /* Pattern offset */
-PUT(code, LINK_SIZE, 0); /* Default length */
-return code + 2 * LINK_SIZE;
-}
-
-
-
-/*************************************************
-* Complete a callout item *
-*************************************************/
-
-/* A callout item contains the length of the next item in the pattern, which
-we can't fill in till after we have reached the relevant point. This is used
-for both automatic and manual callouts.
-
-Arguments:
- previous_callout points to previous callout item
- ptr current pattern pointer
- cd pointers to tables etc
-
-Returns: nothing
-*/
-
-static void
-complete_callout(pcre_uchar *previous_callout, const pcre_uchar *ptr, compile_data *cd)
-{
-int length = (int)(ptr - cd->start_pattern - GET(previous_callout, 2));
-PUT(previous_callout, 2 + LINK_SIZE, length);
-}
-
-
-
-#ifdef SUPPORT_UCP
-/*************************************************
-* Get othercase range *
-*************************************************/
-
-/* This function is passed the start and end of a class range, in UTF-8 mode
-with UCP support. It searches up the characters, looking for ranges of
-characters in the "other" case. Each call returns the next one, updating the
-start address. A character with multiple other cases is returned on its own
-with a special return value.
-
-Arguments:
- cptr points to starting character value; updated
- d end value
- ocptr where to put start of othercase range
- odptr where to put end of othercase range
-
-Yield: -1 when no more
- 0 when a range is returned
- >0 the CASESET offset for char with multiple other cases
- in this case, ocptr contains the original
-*/
-
-static int
-get_othercase_range(pcre_uint32 *cptr, pcre_uint32 d, pcre_uint32 *ocptr,
- pcre_uint32 *odptr)
-{
-pcre_uint32 c, othercase, next;
-unsigned int co;
-
-/* Find the first character that has an other case. If it has multiple other
-cases, return its case offset value. */
-
-for (c = *cptr; c <= d; c++)
- {
- if ((co = UCD_CASESET(c)) != 0)
- {
- *ocptr = c++; /* Character that has the set */
- *cptr = c; /* Rest of input range */
- return (int)co;
- }
- if ((othercase = UCD_OTHERCASE(c)) != c) break;
- }
-
-if (c > d) return -1; /* Reached end of range */
-
-/* Found a character that has a single other case. Search for the end of the
-range, which is either the end of the input range, or a character that has zero
-or more than one other cases. */
-
-*ocptr = othercase;
-next = othercase + 1;
-
-for (++c; c <= d; c++)
- {
- if ((co = UCD_CASESET(c)) != 0 || UCD_OTHERCASE(c) != next) break;
- next++;
- }
-
-*odptr = next - 1; /* End of othercase range */
-*cptr = c; /* Rest of input range */
-return 0;
-}
-#endif /* SUPPORT_UCP */
-
-
-
-/*************************************************
-* Add a character or range to a class *
-*************************************************/
-
-/* This function packages up the logic of adding a character or range of
-characters to a class. The character values in the arguments will be within the
-valid values for the current mode (8-bit, 16-bit, UTF, etc). This function is
-mutually recursive with the function immediately below.
-
-Arguments:
- classbits the bit map for characters < 256
- uchardptr points to the pointer for extra data
- options the options word
- cd contains pointers to tables etc.
- start start of range character
- end end of range character
-
-Returns: the number of < 256 characters added
- the pointer to extra data is updated
-*/
-
-static int
-add_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr, int options,
- compile_data *cd, pcre_uint32 start, pcre_uint32 end)
-{
-pcre_uint32 c;
-pcre_uint32 classbits_end = (end <= 0xff ? end : 0xff);
-int n8 = 0;
-
-/* If caseless matching is required, scan the range and process alternate
-cases. In Unicode, there are 8-bit characters that have alternate cases that
-are greater than 255 and vice-versa. Sometimes we can just extend the original
-range. */
-
-if ((options & PCRE_CASELESS) != 0)
- {
-#ifdef SUPPORT_UCP
- if ((options & PCRE_UTF8) != 0)
- {
- int rc;
- pcre_uint32 oc, od;
-
- options &= ~PCRE_CASELESS; /* Remove for recursive calls */
- c = start;
-
- while ((rc = get_othercase_range(&c, end, &oc, &od)) >= 0)
- {
- /* Handle a single character that has more than one other case. */
-
- if (rc > 0) n8 += add_list_to_class(classbits, uchardptr, options, cd,
- PRIV(ucd_caseless_sets) + rc, oc);
-
- /* Do nothing if the other case range is within the original range. */
-
- else if (oc >= start && od <= end) continue;
-
- /* Extend the original range if there is overlap, noting that if oc < c, we
- can't have od > end because a subrange is always shorter than the basic
- range. Otherwise, use a recursive call to add the additional range. */
-
- else if (oc < start && od >= start - 1) start = oc; /* Extend downwards */
- else if (od > end && oc <= end + 1)
- {
- end = od; /* Extend upwards */
- if (end > classbits_end) classbits_end = (end <= 0xff ? end : 0xff);
- }
- else n8 += add_to_class(classbits, uchardptr, options, cd, oc, od);
- }
- }
- else
-#endif /* SUPPORT_UCP */
-
- /* Not UTF-mode, or no UCP */
-
- for (c = start; c <= classbits_end; c++)
- {
- SETBIT(classbits, cd->fcc[c]);
- n8++;
- }
- }
-
-/* Now handle the original range. Adjust the final value according to the bit
-length - this means that the same lists of (e.g.) horizontal spaces can be used
-in all cases. */
-
-#if defined COMPILE_PCRE8
-#ifdef SUPPORT_UTF
- if ((options & PCRE_UTF8) == 0)
-#endif
- if (end > 0xff) end = 0xff;
-
-#elif defined COMPILE_PCRE16
-#ifdef SUPPORT_UTF
- if ((options & PCRE_UTF16) == 0)
-#endif
- if (end > 0xffff) end = 0xffff;
-
-#endif /* COMPILE_PCRE[8|16] */
-
-/* Use the bitmap for characters < 256. Otherwise use extra data.*/
-
-for (c = start; c <= classbits_end; c++)
- {
- /* Regardless of start, c will always be <= 255. */
- SETBIT(classbits, c);
- n8++;
- }
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
-if (start <= 0xff) start = 0xff + 1;
-
-if (end >= start)
- {
- pcre_uchar *uchardata = *uchardptr;
-#ifdef SUPPORT_UTF
- if ((options & PCRE_UTF8) != 0) /* All UTFs use the same flag bit */
- {
- if (start < end)
- {
- *uchardata++ = XCL_RANGE;
- uchardata += PRIV(ord2utf)(start, uchardata);
- uchardata += PRIV(ord2utf)(end, uchardata);
- }
- else if (start == end)
- {
- *uchardata++ = XCL_SINGLE;
- uchardata += PRIV(ord2utf)(start, uchardata);
- }
- }
- else
-#endif /* SUPPORT_UTF */
-
- /* Without UTF support, character values are constrained by the bit length,
- and can only be > 256 for 16-bit and 32-bit libraries. */
-
-#ifdef COMPILE_PCRE8
- {}
-#else
- if (start < end)
- {
- *uchardata++ = XCL_RANGE;
- *uchardata++ = start;
- *uchardata++ = end;
- }
- else if (start == end)
- {
- *uchardata++ = XCL_SINGLE;
- *uchardata++ = start;
- }
-#endif
-
- *uchardptr = uchardata; /* Updata extra data pointer */
- }
-#endif /* SUPPORT_UTF || !COMPILE_PCRE8 */
-
-return n8; /* Number of 8-bit characters */
-}
-
-
-
-
-/*************************************************
-* Add a list of characters to a class *
-*************************************************/
-
-/* This function is used for adding a list of case-equivalent characters to a
-class, and also for adding a list of horizontal or vertical whitespace. If the
-list is in order (which it should be), ranges of characters are detected and
-handled appropriately. This function is mutually recursive with the function
-above.
-
-Arguments:
- classbits the bit map for characters < 256
- uchardptr points to the pointer for extra data
- options the options word
- cd contains pointers to tables etc.
- p points to row of 32-bit values, terminated by NOTACHAR
- except character to omit; this is used when adding lists of
- case-equivalent characters to avoid including the one we
- already know about
-
-Returns: the number of < 256 characters added
- the pointer to extra data is updated
-*/
-
-static int
-add_list_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr, int options,
- compile_data *cd, const pcre_uint32 *p, unsigned int except)
-{
-int n8 = 0;
-while (p[0] < NOTACHAR)
- {
- int n = 0;
- if (p[0] != except)
- {
- while(p[n+1] == p[0] + n + 1) n++;
- n8 += add_to_class(classbits, uchardptr, options, cd, p[0], p[n]);
- }
- p += n + 1;
- }
-return n8;
-}
-
-
-
-/*************************************************
-* Add characters not in a list to a class *
-*************************************************/
-
-/* This function is used for adding the complement of a list of horizontal or
-vertical whitespace to a class. The list must be in order.
-
-Arguments:
- classbits the bit map for characters < 256
- uchardptr points to the pointer for extra data
- options the options word
- cd contains pointers to tables etc.
- p points to row of 32-bit values, terminated by NOTACHAR
-
-Returns: the number of < 256 characters added
- the pointer to extra data is updated
-*/
-
-static int
-add_not_list_to_class(pcre_uint8 *classbits, pcre_uchar **uchardptr,
- int options, compile_data *cd, const pcre_uint32 *p)
-{
-BOOL utf = (options & PCRE_UTF8) != 0;
-int n8 = 0;
-if (p[0] > 0)
- n8 += add_to_class(classbits, uchardptr, options, cd, 0, p[0] - 1);
-while (p[0] < NOTACHAR)
- {
- while (p[1] == p[0] + 1) p++;
- n8 += add_to_class(classbits, uchardptr, options, cd, p[0] + 1,
- (p[1] == NOTACHAR) ? (utf ? 0x10ffffu : 0xffffffffu) : p[1] - 1);
- p++;
- }
-return n8;
-}
-
-
-
-/*************************************************
-* Compile one branch *
-*************************************************/
-
-/* Scan the pattern, compiling it into the a vector. If the options are
-changed during the branch, the pointer is used to change the external options
-bits. This function is used during the pre-compile phase when we are trying
-to find out the amount of memory needed, as well as during the real compile
-phase. The value of lengthptr distinguishes the two phases.
-
-Arguments:
- optionsptr pointer to the option bits
- codeptr points to the pointer to the current code point
- ptrptr points to the current pattern pointer
- errorcodeptr points to error code variable
- firstcharptr place to put the first required character
- firstcharflagsptr place to put the first character flags, or a negative number
- reqcharptr place to put the last required character
- reqcharflagsptr place to put the last required character flags, or a negative number
- bcptr points to current branch chain
- cond_depth conditional nesting depth
- cd contains pointers to tables etc.
- lengthptr NULL during the real compile phase
- points to length accumulator during pre-compile phase
-
-Returns: TRUE on success
- FALSE, with *errorcodeptr set non-zero on error
-*/
-
-static BOOL
-compile_branch(int *optionsptr, pcre_uchar **codeptr,
- const pcre_uchar **ptrptr, int *errorcodeptr,
- pcre_uint32 *firstcharptr, pcre_int32 *firstcharflagsptr,
- pcre_uint32 *reqcharptr, pcre_int32 *reqcharflagsptr,
- branch_chain *bcptr, int cond_depth,
- compile_data *cd, int *lengthptr)
-{
-int repeat_type, op_type;
-int repeat_min = 0, repeat_max = 0; /* To please picky compilers */
-int bravalue = 0;
-int greedy_default, greedy_non_default;
-pcre_uint32 firstchar, reqchar;
-pcre_int32 firstcharflags, reqcharflags;
-pcre_uint32 zeroreqchar, zerofirstchar;
-pcre_int32 zeroreqcharflags, zerofirstcharflags;
-pcre_int32 req_caseopt, reqvary, tempreqvary;
-int options = *optionsptr; /* May change dynamically */
-int after_manual_callout = 0;
-int length_prevgroup = 0;
-register pcre_uint32 c;
-int escape;
-register pcre_uchar *code = *codeptr;
-pcre_uchar *last_code = code;
-pcre_uchar *orig_code = code;
-pcre_uchar *tempcode;
-BOOL inescq = FALSE;
-BOOL groupsetfirstchar = FALSE;
-const pcre_uchar *ptr = *ptrptr;
-const pcre_uchar *tempptr;
-const pcre_uchar *nestptr = NULL;
-pcre_uchar *previous = NULL;
-pcre_uchar *previous_callout = NULL;
-size_t item_hwm_offset = 0;
-pcre_uint8 classbits[32];
-
-/* We can fish out the UTF-8 setting once and for all into a BOOL, but we
-must not do this for other options (e.g. PCRE_EXTENDED) because they may change
-dynamically as we process the pattern. */
-
-#ifdef SUPPORT_UTF
-/* PCRE_UTF[16|32] have the same value as PCRE_UTF8. */
-BOOL utf = (options & PCRE_UTF8) != 0;
-#ifndef COMPILE_PCRE32
-pcre_uchar utf_chars[6];
-#endif
-#else
-BOOL utf = FALSE;
-#endif
-
-/* Helper variables for OP_XCLASS opcode (for characters > 255). We define
-class_uchardata always so that it can be passed to add_to_class() always,
-though it will not be used in non-UTF 8-bit cases. This avoids having to supply
-alternative calls for the different cases. */
-
-pcre_uchar *class_uchardata;
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
-BOOL xclass;
-pcre_uchar *class_uchardata_base;
-#endif
-
-#ifdef PCRE_DEBUG
-if (lengthptr != NULL) DPRINTF((">> start branch\n"));
-#endif
-
-/* Set up the default and non-default settings for greediness */
-
-greedy_default = ((options & PCRE_UNGREEDY) != 0);
-greedy_non_default = greedy_default ^ 1;
-
-/* Initialize no first byte, no required byte. REQ_UNSET means "no char
-matching encountered yet". It gets changed to REQ_NONE if we hit something that
-matches a non-fixed char first char; reqchar just remains unset if we never
-find one.
-
-When we hit a repeat whose minimum is zero, we may have to adjust these values
-to take the zero repeat into account. This is implemented by setting them to
-zerofirstbyte and zeroreqchar when such a repeat is encountered. The individual
-item types that can be repeated set these backoff variables appropriately. */
-
-firstchar = reqchar = zerofirstchar = zeroreqchar = 0;
-firstcharflags = reqcharflags = zerofirstcharflags = zeroreqcharflags = REQ_UNSET;
-
-/* The variable req_caseopt contains either the REQ_CASELESS value
-or zero, according to the current setting of the caseless flag. The
-REQ_CASELESS leaves the lower 28 bit empty. It is added into the
-firstchar or reqchar variables to record the case status of the
-value. This is used only for ASCII characters. */
-
-req_caseopt = ((options & PCRE_CASELESS) != 0)? REQ_CASELESS:0;
-
-/* Switch on next character until the end of the branch */
-
-for (;; ptr++)
- {
- BOOL negate_class;
- BOOL should_flip_negation;
- BOOL possessive_quantifier;
- BOOL is_quantifier;
- BOOL is_recurse;
- BOOL reset_bracount;
- int class_has_8bitchar;
- int class_one_char;
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- BOOL xclass_has_prop;
-#endif
- int newoptions;
- int recno;
- int refsign;
- int skipbytes;
- pcre_uint32 subreqchar, subfirstchar;
- pcre_int32 subreqcharflags, subfirstcharflags;
- int terminator;
- unsigned int mclength;
- unsigned int tempbracount;
- pcre_uint32 ec;
- pcre_uchar mcbuffer[8];
-
- /* Get next character in the pattern */
-
- c = *ptr;
-
- /* If we are at the end of a nested substitution, revert to the outer level
- string. Nesting only happens one level deep. */
-
- if (c == CHAR_NULL && nestptr != NULL)
- {
- ptr = nestptr;
- nestptr = NULL;
- c = *ptr;
- }
-
- /* If we are in the pre-compile phase, accumulate the length used for the
- previous cycle of this loop. */
-
- if (lengthptr != NULL)
- {
-#ifdef PCRE_DEBUG
- if (code > cd->hwm) cd->hwm = code; /* High water info */
-#endif
- if (code > cd->start_workspace + cd->workspace_size -
- WORK_SIZE_SAFETY_MARGIN) /* Check for overrun */
- {
- *errorcodeptr = ERR52;
- goto FAILED;
- }
-
- /* There is at least one situation where code goes backwards: this is the
- case of a zero quantifier after a class (e.g. [ab]{0}). At compile time,
- the class is simply eliminated. However, it is created first, so we have to
- allow memory for it. Therefore, don't ever reduce the length at this point.
- */
-
- if (code < last_code) code = last_code;
-
- /* Paranoid check for integer overflow */
-
- if (OFLOW_MAX - *lengthptr < code - last_code)
- {
- *errorcodeptr = ERR20;
- goto FAILED;
- }
-
- *lengthptr += (int)(code - last_code);
- DPRINTF(("length=%d added %d c=%c (0x%x)\n", *lengthptr,
- (int)(code - last_code), c, c));
-
- /* If "previous" is set and it is not at the start of the work space, move
- it back to there, in order to avoid filling up the work space. Otherwise,
- if "previous" is NULL, reset the current code pointer to the start. */
-
- if (previous != NULL)
- {
- if (previous > orig_code)
- {
- memmove(orig_code, previous, IN_UCHARS(code - previous));
- code -= previous - orig_code;
- previous = orig_code;
- }
- }
- else code = orig_code;
-
- /* Remember where this code item starts so we can pick up the length
- next time round. */
-
- last_code = code;
- }
-
- /* In the real compile phase, just check the workspace used by the forward
- reference list. */
-
- else if (cd->hwm > cd->start_workspace + cd->workspace_size)
- {
- *errorcodeptr = ERR52;
- goto FAILED;
- }
-
- /* If in \Q...\E, check for the end; if not, we have a literal */
-
- if (inescq && c != CHAR_NULL)
- {
- if (c == CHAR_BACKSLASH && ptr[1] == CHAR_E)
- {
- inescq = FALSE;
- ptr++;
- continue;
- }
- else
- {
- if (previous_callout != NULL)
- {
- if (lengthptr == NULL) /* Don't attempt in pre-compile phase */
- complete_callout(previous_callout, ptr, cd);
- previous_callout = NULL;
- }
- if ((options & PCRE_AUTO_CALLOUT) != 0)
- {
- previous_callout = code;
- code = auto_callout(code, ptr, cd);
- }
- goto NORMAL_CHAR;
- }
- /* Control does not reach here. */
- }
-
- /* In extended mode, skip white space and comments. We need a loop in order
- to check for more white space and more comments after a comment. */
-
- if ((options & PCRE_EXTENDED) != 0)
- {
- for (;;)
- {
- while (MAX_255(c) && (cd->ctypes[c] & ctype_space) != 0) c = *(++ptr);
- if (c != CHAR_NUMBER_SIGN) break;
- ptr++;
- while (*ptr != CHAR_NULL)
- {
- if (IS_NEWLINE(ptr)) /* For non-fixed-length newline cases, */
- { /* IS_NEWLINE sets cd->nllen. */
- ptr += cd->nllen;
- break;
- }
- ptr++;
-#ifdef SUPPORT_UTF
- if (utf) FORWARDCHAR(ptr);
-#endif
- }
- c = *ptr; /* Either NULL or the char after a newline */
- }
- }
-
- /* See if the next thing is a quantifier. */
-
- is_quantifier =
- c == CHAR_ASTERISK || c == CHAR_PLUS || c == CHAR_QUESTION_MARK ||
- (c == CHAR_LEFT_CURLY_BRACKET && is_counted_repeat(ptr+1));
-
- /* Fill in length of a previous callout, except when the next thing is a
- quantifier or when processing a property substitution string in UCP mode. */
-
- if (!is_quantifier && previous_callout != NULL && nestptr == NULL &&
- after_manual_callout-- <= 0)
- {
- if (lengthptr == NULL) /* Don't attempt in pre-compile phase */
- complete_callout(previous_callout, ptr, cd);
- previous_callout = NULL;
- }
-
- /* Create auto callout, except for quantifiers, or while processing property
- strings that are substituted for \w etc in UCP mode. */
-
- if ((options & PCRE_AUTO_CALLOUT) != 0 && !is_quantifier && nestptr == NULL)
- {
- previous_callout = code;
- code = auto_callout(code, ptr, cd);
- }
-
- /* Process the next pattern item. */
-
- switch(c)
- {
- /* ===================================================================*/
- case CHAR_NULL: /* The branch terminates at string end */
- case CHAR_VERTICAL_LINE: /* or | or ) */
- case CHAR_RIGHT_PARENTHESIS:
- *firstcharptr = firstchar;
- *firstcharflagsptr = firstcharflags;
- *reqcharptr = reqchar;
- *reqcharflagsptr = reqcharflags;
- *codeptr = code;
- *ptrptr = ptr;
- if (lengthptr != NULL)
- {
- if (OFLOW_MAX - *lengthptr < code - last_code)
- {
- *errorcodeptr = ERR20;
- goto FAILED;
- }
- *lengthptr += (int)(code - last_code); /* To include callout length */
- DPRINTF((">> end branch\n"));
- }
- return TRUE;
-
-
- /* ===================================================================*/
- /* Handle single-character metacharacters. In multiline mode, ^ disables
- the setting of any following char as a first character. */
-
- case CHAR_CIRCUMFLEX_ACCENT:
- previous = NULL;
- if ((options & PCRE_MULTILINE) != 0)
- {
- if (firstcharflags == REQ_UNSET)
- zerofirstcharflags = firstcharflags = REQ_NONE;
- *code++ = OP_CIRCM;
- }
- else *code++ = OP_CIRC;
- break;
-
- case CHAR_DOLLAR_SIGN:
- previous = NULL;
- *code++ = ((options & PCRE_MULTILINE) != 0)? OP_DOLLM : OP_DOLL;
- break;
-
- /* There can never be a first char if '.' is first, whatever happens about
- repeats. The value of reqchar doesn't change either. */
-
- case CHAR_DOT:
- if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
- zerofirstchar = firstchar;
- zerofirstcharflags = firstcharflags;
- zeroreqchar = reqchar;
- zeroreqcharflags = reqcharflags;
- previous = code;
- item_hwm_offset = cd->hwm - cd->start_workspace;
- *code++ = ((options & PCRE_DOTALL) != 0)? OP_ALLANY: OP_ANY;
- break;
-
-
- /* ===================================================================*/
- /* Character classes. If the included characters are all < 256, we build a
- 32-byte bitmap of the permitted characters, except in the special case
- where there is only one such character. For negated classes, we build the
- map as usual, then invert it at the end. However, we use a different opcode
- so that data characters > 255 can be handled correctly.
-
- If the class contains characters outside the 0-255 range, a different
- opcode is compiled. It may optionally have a bit map for characters < 256,
- but those above are are explicitly listed afterwards. A flag byte tells
- whether the bitmap is present, and whether this is a negated class or not.
-
- In JavaScript compatibility mode, an isolated ']' causes an error. In
- default (Perl) mode, it is treated as a data character. */
-
- case CHAR_RIGHT_SQUARE_BRACKET:
- if ((cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0)
- {
- *errorcodeptr = ERR64;
- goto FAILED;
- }
- goto NORMAL_CHAR;
-
- /* In another (POSIX) regex library, the ugly syntax [[:<:]] and [[:>:]] is
- used for "start of word" and "end of word". As these are otherwise illegal
- sequences, we don't break anything by recognizing them. They are replaced
- by \b(?=\w) and \b(?<=\w) respectively. Sequences like [a[:<:]] are
- erroneous and are handled by the normal code below. */
-
- case CHAR_LEFT_SQUARE_BRACKET:
- if (STRNCMP_UC_C8(ptr+1, STRING_WEIRD_STARTWORD, 6) == 0)
- {
- nestptr = ptr + 7;
- ptr = sub_start_of_word - 1;
- continue;
- }
-
- if (STRNCMP_UC_C8(ptr+1, STRING_WEIRD_ENDWORD, 6) == 0)
- {
- nestptr = ptr + 7;
- ptr = sub_end_of_word - 1;
- continue;
- }
-
- /* Handle a real character class. */
-
- previous = code;
- item_hwm_offset = cd->hwm - cd->start_workspace;
-
- /* PCRE supports POSIX class stuff inside a class. Perl gives an error if
- they are encountered at the top level, so we'll do that too. */
-
- if ((ptr[1] == CHAR_COLON || ptr[1] == CHAR_DOT ||
- ptr[1] == CHAR_EQUALS_SIGN) &&
- check_posix_syntax(ptr, &tempptr))
- {
- *errorcodeptr = (ptr[1] == CHAR_COLON)? ERR13 : ERR31;
- goto FAILED;
- }
-
- /* If the first character is '^', set the negation flag and skip it. Also,
- if the first few characters (either before or after ^) are \Q\E or \E we
- skip them too. This makes for compatibility with Perl. */
-
- negate_class = FALSE;
- for (;;)
- {
- c = *(++ptr);
- if (c == CHAR_BACKSLASH)
- {
- if (ptr[1] == CHAR_E)
- ptr++;
- else if (STRNCMP_UC_C8(ptr + 1, STR_Q STR_BACKSLASH STR_E, 3) == 0)
- ptr += 3;
- else
- break;
- }
- else if (!negate_class && c == CHAR_CIRCUMFLEX_ACCENT)
- negate_class = TRUE;
- else break;
- }
-
- /* Empty classes are allowed in JavaScript compatibility mode. Otherwise,
- an initial ']' is taken as a data character -- the code below handles
- that. In JS mode, [] must always fail, so generate OP_FAIL, whereas
- [^] must match any character, so generate OP_ALLANY. */
-
- if (c == CHAR_RIGHT_SQUARE_BRACKET &&
- (cd->external_options & PCRE_JAVASCRIPT_COMPAT) != 0)
- {
- *code++ = negate_class? OP_ALLANY : OP_FAIL;
- if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
- zerofirstchar = firstchar;
- zerofirstcharflags = firstcharflags;
- break;
- }
-
- /* If a class contains a negative special such as \S, we need to flip the
- negation flag at the end, so that support for characters > 255 works
- correctly (they are all included in the class). */
-
- should_flip_negation = FALSE;
-
- /* Extended class (xclass) will be used when characters > 255
- might match. */
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- xclass = FALSE;
- class_uchardata = code + LINK_SIZE + 2; /* For XCLASS items */
- class_uchardata_base = class_uchardata; /* Save the start */
-#endif
-
- /* For optimization purposes, we track some properties of the class:
- class_has_8bitchar will be non-zero if the class contains at least one <
- 256 character; class_one_char will be 1 if the class contains just one
- character; xclass_has_prop will be TRUE if unicode property checks
- are present in the class. */
-
- class_has_8bitchar = 0;
- class_one_char = 0;
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- xclass_has_prop = FALSE;
-#endif
-
- /* Initialize the 32-char bit map to all zeros. We build the map in a
- temporary bit of memory, in case the class contains fewer than two
- 8-bit characters because in that case the compiled code doesn't use the bit
- map. */
-
- memset(classbits, 0, 32 * sizeof(pcre_uint8));
-
- /* Process characters until ] is reached. By writing this as a "do" it
- means that an initial ] is taken as a data character. At the start of the
- loop, c contains the first byte of the character. */
-
- if (c != CHAR_NULL) do
- {
- const pcre_uchar *oldptr;
-
-#ifdef SUPPORT_UTF
- if (utf && HAS_EXTRALEN(c))
- { /* Braces are required because the */
- GETCHARLEN(c, ptr, ptr); /* macro generates multiple statements */
- }
-#endif
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- /* In the pre-compile phase, accumulate the length of any extra
- data and reset the pointer. This is so that very large classes that
- contain a zillion > 255 characters no longer overwrite the work space
- (which is on the stack). We have to remember that there was XCLASS data,
- however. */
-
- if (class_uchardata > class_uchardata_base) xclass = TRUE;
-
- if (lengthptr != NULL && class_uchardata > class_uchardata_base)
- {
- *lengthptr += (int)(class_uchardata - class_uchardata_base);
- class_uchardata = class_uchardata_base;
- }
-#endif
-
- /* Inside \Q...\E everything is literal except \E */
-
- if (inescq)
- {
- if (c == CHAR_BACKSLASH && ptr[1] == CHAR_E) /* If we are at \E */
- {
- inescq = FALSE; /* Reset literal state */
- ptr++; /* Skip the 'E' */
- continue; /* Carry on with next */
- }
- goto CHECK_RANGE; /* Could be range if \E follows */
- }
-
- /* Handle POSIX class names. Perl allows a negation extension of the
- form [:^name:]. A square bracket that doesn't match the syntax is
- treated as a literal. We also recognize the POSIX constructions
- [.ch.] and [=ch=] ("collating elements") and fault them, as Perl
- 5.6 and 5.8 do. */
-
- if (c == CHAR_LEFT_SQUARE_BRACKET &&
- (ptr[1] == CHAR_COLON || ptr[1] == CHAR_DOT ||
- ptr[1] == CHAR_EQUALS_SIGN) && check_posix_syntax(ptr, &tempptr))
- {
- BOOL local_negate = FALSE;
- int posix_class, taboffset, tabopt;
- register const pcre_uint8 *cbits = cd->cbits;
- pcre_uint8 pbits[32];
-
- if (ptr[1] != CHAR_COLON)
- {
- *errorcodeptr = ERR31;
- goto FAILED;
- }
-
- ptr += 2;
- if (*ptr == CHAR_CIRCUMFLEX_ACCENT)
- {
- local_negate = TRUE;
- should_flip_negation = TRUE; /* Note negative special */
- ptr++;
- }
-
- posix_class = check_posix_name(ptr, (int)(tempptr - ptr));
- if (posix_class < 0)
- {
- *errorcodeptr = ERR30;
- goto FAILED;
- }
-
- /* If matching is caseless, upper and lower are converted to
- alpha. This relies on the fact that the class table starts with
- alpha, lower, upper as the first 3 entries. */
-
- if ((options & PCRE_CASELESS) != 0 && posix_class <= 2)
- posix_class = 0;
-
- /* When PCRE_UCP is set, some of the POSIX classes are converted to
- different escape sequences that use Unicode properties \p or \P. Others
- that are not available via \p or \P generate XCL_PROP/XCL_NOTPROP
- directly. */
-
-#ifdef SUPPORT_UCP
- if ((options & PCRE_UCP) != 0)
- {
- unsigned int ptype = 0;
- int pc = posix_class + ((local_negate)? POSIX_SUBSIZE/2 : 0);
-
- /* The posix_substitutes table specifies which POSIX classes can be
- converted to \p or \P items. */
-
- if (posix_substitutes[pc] != NULL)
- {
- nestptr = tempptr + 1;
- ptr = posix_substitutes[pc] - 1;
- continue;
- }
-
- /* There are three other classes that generate special property calls
- that are recognized only in an XCLASS. */
-
- else switch(posix_class)
- {
- case PC_GRAPH:
- ptype = PT_PXGRAPH;
- /* Fall through */
- case PC_PRINT:
- if (ptype == 0) ptype = PT_PXPRINT;
- /* Fall through */
- case PC_PUNCT:
- if (ptype == 0) ptype = PT_PXPUNCT;
- *class_uchardata++ = local_negate? XCL_NOTPROP : XCL_PROP;
- *class_uchardata++ = ptype;
- *class_uchardata++ = 0;
- xclass_has_prop = TRUE;
- ptr = tempptr + 1;
- continue;
-
- /* For the other POSIX classes (ascii, xdigit) we are going to fall
- through to the non-UCP case and build a bit map for characters with
- code points less than 256. If we are in a negated POSIX class
- within a non-negated overall class, characters with code points
- greater than 255 must all match. In the special case where we have
- not yet generated any xclass data, and this is the final item in
- the overall class, we need do nothing: later on, the opcode
- OP_NCLASS will be used to indicate that characters greater than 255
- are acceptable. If we have already seen an xclass item or one may
- follow (we have to assume that it might if this is not the end of
- the class), explicitly match all wide codepoints. */
-
- default:
- if (!negate_class && local_negate &&
- (xclass || tempptr[2] != CHAR_RIGHT_SQUARE_BRACKET))
- {
- *class_uchardata++ = XCL_RANGE;
- class_uchardata += PRIV(ord2utf)(0x100, class_uchardata);
- class_uchardata += PRIV(ord2utf)(0x10ffff, class_uchardata);
- }
- break;
- }
- }
-#endif
- /* In the non-UCP case, or when UCP makes no difference, we build the
- bit map for the POSIX class in a chunk of local store because we may be
- adding and subtracting from it, and we don't want to subtract bits that
- may be in the main map already. At the end we or the result into the
- bit map that is being built. */
-
- posix_class *= 3;
-
- /* Copy in the first table (always present) */
-
- memcpy(pbits, cbits + posix_class_maps[posix_class],
- 32 * sizeof(pcre_uint8));
-
- /* If there is a second table, add or remove it as required. */
-
- taboffset = posix_class_maps[posix_class + 1];
- tabopt = posix_class_maps[posix_class + 2];
-
- if (taboffset >= 0)
- {
- if (tabopt >= 0)
- for (c = 0; c < 32; c++) pbits[c] |= cbits[c + taboffset];
- else
- for (c = 0; c < 32; c++) pbits[c] &= ~cbits[c + taboffset];
- }
-
- /* Now see if we need to remove any special characters. An option
- value of 1 removes vertical space and 2 removes underscore. */
-
- if (tabopt < 0) tabopt = -tabopt;
- if (tabopt == 1) pbits[1] &= ~0x3c;
- else if (tabopt == 2) pbits[11] &= 0x7f;
-
- /* Add the POSIX table or its complement into the main table that is
- being built and we are done. */
-
- if (local_negate)
- for (c = 0; c < 32; c++) classbits[c] |= ~pbits[c];
- else
- for (c = 0; c < 32; c++) classbits[c] |= pbits[c];
-
- ptr = tempptr + 1;
- /* Every class contains at least one < 256 character. */
- class_has_8bitchar = 1;
- /* Every class contains at least two characters. */
- class_one_char = 2;
- continue; /* End of POSIX syntax handling */
- }
-
- /* Backslash may introduce a single character, or it may introduce one
- of the specials, which just set a flag. The sequence \b is a special
- case. Inside a class (and only there) it is treated as backspace. We
- assume that other escapes have more than one character in them, so
- speculatively set both class_has_8bitchar and class_one_char bigger
- than one. Unrecognized escapes fall through and are either treated
- as literal characters (by default), or are faulted if
- PCRE_EXTRA is set. */
-
- if (c == CHAR_BACKSLASH)
- {
- escape = check_escape(&ptr, &ec, errorcodeptr, cd->bracount, options,
- TRUE);
- if (*errorcodeptr != 0) goto FAILED;
- if (escape == 0) c = ec;
- else if (escape == ESC_b) c = CHAR_BS; /* \b is backspace in a class */
- else if (escape == ESC_N) /* \N is not supported in a class */
- {
- *errorcodeptr = ERR71;
- goto FAILED;
- }
- else if (escape == ESC_Q) /* Handle start of quoted string */
- {
- if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)
- {
- ptr += 2; /* avoid empty string */
- }
- else inescq = TRUE;
- continue;
- }
- else if (escape == ESC_E) continue; /* Ignore orphan \E */
-
- else
- {
- register const pcre_uint8 *cbits = cd->cbits;
- /* Every class contains at least two < 256 characters. */
- class_has_8bitchar++;
- /* Every class contains at least two characters. */
- class_one_char += 2;
-
- switch (escape)
- {
-#ifdef SUPPORT_UCP
- case ESC_du: /* These are the values given for \d etc */
- case ESC_DU: /* when PCRE_UCP is set. We replace the */
- case ESC_wu: /* escape sequence with an appropriate \p */
- case ESC_WU: /* or \P to test Unicode properties instead */
- case ESC_su: /* of the default ASCII testing. */
- case ESC_SU:
- nestptr = ptr;
- ptr = substitutes[escape - ESC_DU] - 1; /* Just before substitute */
- class_has_8bitchar--; /* Undo! */
- continue;
-#endif
- case ESC_d:
- for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_digit];
- continue;
-
- case ESC_D:
- should_flip_negation = TRUE;
- for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_digit];
- continue;
-
- case ESC_w:
- for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_word];
- continue;
-
- case ESC_W:
- should_flip_negation = TRUE;
- for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_word];
- continue;
-
- /* Perl 5.004 onwards omitted VT from \s, but restored it at Perl
- 5.18. Before PCRE 8.34, we had to preserve the VT bit if it was
- previously set by something earlier in the character class.
- Luckily, the value of CHAR_VT is 0x0b in both ASCII and EBCDIC, so
- we could just adjust the appropriate bit. From PCRE 8.34 we no
- longer treat \s and \S specially. */
-
- case ESC_s:
- for (c = 0; c < 32; c++) classbits[c] |= cbits[c+cbit_space];
- continue;
-
- case ESC_S:
- should_flip_negation = TRUE;
- for (c = 0; c < 32; c++) classbits[c] |= ~cbits[c+cbit_space];
- continue;
-
- /* The rest apply in both UCP and non-UCP cases. */
-
- case ESC_h:
- (void)add_list_to_class(classbits, &class_uchardata, options, cd,
- PRIV(hspace_list), NOTACHAR);
- continue;
-
- case ESC_H:
- (void)add_not_list_to_class(classbits, &class_uchardata, options,
- cd, PRIV(hspace_list));
- continue;
-
- case ESC_v:
- (void)add_list_to_class(classbits, &class_uchardata, options, cd,
- PRIV(vspace_list), NOTACHAR);
- continue;
-
- case ESC_V:
- (void)add_not_list_to_class(classbits, &class_uchardata, options,
- cd, PRIV(vspace_list));
- continue;
-
- case ESC_p:
- case ESC_P:
-#ifdef SUPPORT_UCP
- {
- BOOL negated;
- unsigned int ptype = 0, pdata = 0;
- if (!get_ucp(&ptr, &negated, &ptype, &pdata, errorcodeptr))
- goto FAILED;
- *class_uchardata++ = ((escape == ESC_p) != negated)?
- XCL_PROP : XCL_NOTPROP;
- *class_uchardata++ = ptype;
- *class_uchardata++ = pdata;
- xclass_has_prop = TRUE;
- class_has_8bitchar--; /* Undo! */
- continue;
- }
-#else
- *errorcodeptr = ERR45;
- goto FAILED;
-#endif
- /* Unrecognized escapes are faulted if PCRE is running in its
- strict mode. By default, for compatibility with Perl, they are
- treated as literals. */
-
- default:
- if ((options & PCRE_EXTRA) != 0)
- {
- *errorcodeptr = ERR7;
- goto FAILED;
- }
- class_has_8bitchar--; /* Undo the speculative increase. */
- class_one_char -= 2; /* Undo the speculative increase. */
- c = *ptr; /* Get the final character and fall through */
- break;
- }
- }
-
- /* Fall through if the escape just defined a single character (c >= 0).
- This may be greater than 256. */
-
- escape = 0;
-
- } /* End of backslash handling */
-
- /* A character may be followed by '-' to form a range. However, Perl does
- not permit ']' to be the end of the range. A '-' character at the end is
- treated as a literal. Perl ignores orphaned \E sequences entirely. The
- code for handling \Q and \E is messy. */
-
- CHECK_RANGE:
- while (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)
- {
- inescq = FALSE;
- ptr += 2;
- }
- oldptr = ptr;
-
- /* Remember if \r or \n were explicitly used */
-
- if (c == CHAR_CR || c == CHAR_NL) cd->external_flags |= PCRE_HASCRORLF;
-
- /* Check for range */
-
- if (!inescq && ptr[1] == CHAR_MINUS)
- {
- pcre_uint32 d;
- ptr += 2;
- while (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_E) ptr += 2;
-
- /* If we hit \Q (not followed by \E) at this point, go into escaped
- mode. */
-
- while (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_Q)
- {
- ptr += 2;
- if (*ptr == CHAR_BACKSLASH && ptr[1] == CHAR_E)
- { ptr += 2; continue; }
- inescq = TRUE;
- break;
- }
-
- /* Minus (hyphen) at the end of a class is treated as a literal, so put
- back the pointer and jump to handle the character that preceded it. */
-
- if (*ptr == CHAR_NULL || (!inescq && *ptr == CHAR_RIGHT_SQUARE_BRACKET))
- {
- ptr = oldptr;
- goto CLASS_SINGLE_CHARACTER;
- }
-
- /* Otherwise, we have a potential range; pick up the next character */
-
-#ifdef SUPPORT_UTF
- if (utf)
- { /* Braces are required because the */
- GETCHARLEN(d, ptr, ptr); /* macro generates multiple statements */
- }
- else
-#endif
- d = *ptr; /* Not UTF-8 mode */
-
- /* The second part of a range can be a single-character escape
- sequence, but not any of the other escapes. Perl treats a hyphen as a
- literal in such circumstances. However, in Perl's warning mode, a
- warning is given, so PCRE now faults it as it is almost certainly a
- mistake on the user's part. */
-
- if (!inescq)
- {
- if (d == CHAR_BACKSLASH)
- {
- int descape;
- descape = check_escape(&ptr, &d, errorcodeptr, cd->bracount, options, TRUE);
- if (*errorcodeptr != 0) goto FAILED;
-
- /* 0 means a character was put into d; \b is backspace; any other
- special causes an error. */
-
- if (descape != 0)
- {
- if (descape == ESC_b) d = CHAR_BS; else
- {
- *errorcodeptr = ERR83;
- goto FAILED;
- }
- }
- }
-
- /* A hyphen followed by a POSIX class is treated in the same way. */
-
- else if (d == CHAR_LEFT_SQUARE_BRACKET &&
- (ptr[1] == CHAR_COLON || ptr[1] == CHAR_DOT ||
- ptr[1] == CHAR_EQUALS_SIGN) &&
- check_posix_syntax(ptr, &tempptr))
- {
- *errorcodeptr = ERR83;
- goto FAILED;
- }
- }
-
- /* Check that the two values are in the correct order. Optimize
- one-character ranges. */
-
- if (d < c)
- {
- *errorcodeptr = ERR8;
- goto FAILED;
- }
- if (d == c) goto CLASS_SINGLE_CHARACTER; /* A few lines below */
-
- /* We have found a character range, so single character optimizations
- cannot be done anymore. Any value greater than 1 indicates that there
- is more than one character. */
-
- class_one_char = 2;
-
- /* Remember an explicit \r or \n, and add the range to the class. */
-
- if (d == CHAR_CR || d == CHAR_NL) cd->external_flags |= PCRE_HASCRORLF;
-
- class_has_8bitchar +=
- add_to_class(classbits, &class_uchardata, options, cd, c, d);
-
- continue; /* Go get the next char in the class */
- }
-
- /* Handle a single character - we can get here for a normal non-escape
- char, or after \ that introduces a single character or for an apparent
- range that isn't. Only the value 1 matters for class_one_char, so don't
- increase it if it is already 2 or more ... just in case there's a class
- with a zillion characters in it. */
-
- CLASS_SINGLE_CHARACTER:
- if (class_one_char < 2) class_one_char++;
-
- /* If xclass_has_prop is false and class_one_char is 1, we have the first
- single character in the class, and there have been no prior ranges, or
- XCLASS items generated by escapes. If this is the final character in the
- class, we can optimize by turning the item into a 1-character OP_CHAR[I]
- if it's positive, or OP_NOT[I] if it's negative. In the positive case, it
- can cause firstchar to be set. Otherwise, there can be no first char if
- this item is first, whatever repeat count may follow. In the case of
- reqchar, save the previous value for reinstating. */
-
- if (!inescq &&
-#ifdef SUPPORT_UCP
- !xclass_has_prop &&
-#endif
- class_one_char == 1 && ptr[1] == CHAR_RIGHT_SQUARE_BRACKET)
- {
- ptr++;
- zeroreqchar = reqchar;
- zeroreqcharflags = reqcharflags;
-
- if (negate_class)
- {
-#ifdef SUPPORT_UCP
- int d;
-#endif
- if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
- zerofirstchar = firstchar;
- zerofirstcharflags = firstcharflags;
-
- /* For caseless UTF-8 mode when UCP support is available, check
- whether this character has more than one other case. If so, generate
- a special OP_NOTPROP item instead of OP_NOTI. */
-
-#ifdef SUPPORT_UCP
- if (utf && (options & PCRE_CASELESS) != 0 &&
- (d = UCD_CASESET(c)) != 0)
- {
- *code++ = OP_NOTPROP;
- *code++ = PT_CLIST;
- *code++ = d;
- }
- else
-#endif
- /* Char has only one other case, or UCP not available */
-
- {
- *code++ = ((options & PCRE_CASELESS) != 0)? OP_NOTI: OP_NOT;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
- code += PRIV(ord2utf)(c, code);
- else
-#endif
- *code++ = c;
- }
-
- /* We are finished with this character class */
-
- goto END_CLASS;
- }
-
- /* For a single, positive character, get the value into mcbuffer, and
- then we can handle this with the normal one-character code. */
-
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
- mclength = PRIV(ord2utf)(c, mcbuffer);
- else
-#endif
- {
- mcbuffer[0] = c;
- mclength = 1;
- }
- goto ONE_CHAR;
- } /* End of 1-char optimization */
-
- /* There is more than one character in the class, or an XCLASS item
- has been generated. Add this character to the class. */
-
- class_has_8bitchar +=
- add_to_class(classbits, &class_uchardata, options, cd, c, c);
- }
-
- /* Loop until ']' reached. This "while" is the end of the "do" far above.
- If we are at the end of an internal nested string, revert to the outer
- string. */
-
- while (((c = *(++ptr)) != CHAR_NULL ||
- (nestptr != NULL &&
- (ptr = nestptr, nestptr = NULL, c = *(++ptr)) != CHAR_NULL)) &&
- (c != CHAR_RIGHT_SQUARE_BRACKET || inescq));
-
- /* Check for missing terminating ']' */
-
- if (c == CHAR_NULL)
- {
- *errorcodeptr = ERR6;
- goto FAILED;
- }
-
- /* We will need an XCLASS if data has been placed in class_uchardata. In
- the second phase this is a sufficient test. However, in the pre-compile
- phase, class_uchardata gets emptied to prevent workspace overflow, so it
- only if the very last character in the class needs XCLASS will it contain
- anything at this point. For this reason, xclass gets set TRUE above when
- uchar_classdata is emptied, and that's why this code is the way it is here
- instead of just doing a test on class_uchardata below. */
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- if (class_uchardata > class_uchardata_base) xclass = TRUE;
-#endif
-
- /* If this is the first thing in the branch, there can be no first char
- setting, whatever the repeat count. Any reqchar setting must remain
- unchanged after any kind of repeat. */
-
- if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
- zerofirstchar = firstchar;
- zerofirstcharflags = firstcharflags;
- zeroreqchar = reqchar;
- zeroreqcharflags = reqcharflags;
-
- /* If there are characters with values > 255, we have to compile an
- extended class, with its own opcode, unless there was a negated special
- such as \S in the class, and PCRE_UCP is not set, because in that case all
- characters > 255 are in the class, so any that were explicitly given as
- well can be ignored. If (when there are explicit characters > 255 that must
- be listed) there are no characters < 256, we can omit the bitmap in the
- actual compiled code. */
-
-#ifdef SUPPORT_UTF
- if (xclass && (xclass_has_prop || !should_flip_negation ||
- (options & PCRE_UCP) != 0))
-#elif !defined COMPILE_PCRE8
- if (xclass && (xclass_has_prop || !should_flip_negation))
-#endif
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- {
- *class_uchardata++ = XCL_END; /* Marks the end of extra data */
- *code++ = OP_XCLASS;
- code += LINK_SIZE;
- *code = negate_class? XCL_NOT:0;
- if (xclass_has_prop) *code |= XCL_HASPROP;
-
- /* If the map is required, move up the extra data to make room for it;
- otherwise just move the code pointer to the end of the extra data. */
-
- if (class_has_8bitchar > 0)
- {
- *code++ |= XCL_MAP;
- memmove(code + (32 / sizeof(pcre_uchar)), code,
- IN_UCHARS(class_uchardata - code));
- if (negate_class && !xclass_has_prop)
- for (c = 0; c < 32; c++) classbits[c] = ~classbits[c];
- memcpy(code, classbits, 32);
- code = class_uchardata + (32 / sizeof(pcre_uchar));
- }
- else code = class_uchardata;
-
- /* Now fill in the complete length of the item */
-
- PUT(previous, 1, (int)(code - previous));
- break; /* End of class handling */
- }
-
- /* Even though any XCLASS list is now discarded, we must allow for
- its memory. */
-
- if (lengthptr != NULL)
- *lengthptr += (int)(class_uchardata - class_uchardata_base);
-#endif
-
- /* If there are no characters > 255, or they are all to be included or
- excluded, set the opcode to OP_CLASS or OP_NCLASS, depending on whether the
- whole class was negated and whether there were negative specials such as \S
- (non-UCP) in the class. Then copy the 32-byte map into the code vector,
- negating it if necessary. */
-
- *code++ = (negate_class == should_flip_negation) ? OP_CLASS : OP_NCLASS;
- if (lengthptr == NULL) /* Save time in the pre-compile phase */
- {
- if (negate_class)
- for (c = 0; c < 32; c++) classbits[c] = ~classbits[c];
- memcpy(code, classbits, 32);
- }
- code += 32 / sizeof(pcre_uchar);
-
- END_CLASS:
- break;
-
-
- /* ===================================================================*/
- /* Various kinds of repeat; '{' is not necessarily a quantifier, but this
- has been tested above. */
-
- case CHAR_LEFT_CURLY_BRACKET:
- if (!is_quantifier) goto NORMAL_CHAR;
- ptr = read_repeat_counts(ptr+1, &repeat_min, &repeat_max, errorcodeptr);
- if (*errorcodeptr != 0) goto FAILED;
- goto REPEAT;
-
- case CHAR_ASTERISK:
- repeat_min = 0;
- repeat_max = -1;
- goto REPEAT;
-
- case CHAR_PLUS:
- repeat_min = 1;
- repeat_max = -1;
- goto REPEAT;
-
- case CHAR_QUESTION_MARK:
- repeat_min = 0;
- repeat_max = 1;
-
- REPEAT:
- if (previous == NULL)
- {
- *errorcodeptr = ERR9;
- goto FAILED;
- }
-
- if (repeat_min == 0)
- {
- firstchar = zerofirstchar; /* Adjust for zero repeat */
- firstcharflags = zerofirstcharflags;
- reqchar = zeroreqchar; /* Ditto */
- reqcharflags = zeroreqcharflags;
- }
-
- /* Remember whether this is a variable length repeat */
-
- reqvary = (repeat_min == repeat_max)? 0 : REQ_VARY;
-
- op_type = 0; /* Default single-char op codes */
- possessive_quantifier = FALSE; /* Default not possessive quantifier */
-
- /* Save start of previous item, in case we have to move it up in order to
- insert something before it. */
-
- tempcode = previous;
-
- /* Before checking for a possessive quantifier, we must skip over
- whitespace and comments in extended mode because Perl allows white space at
- this point. */
-
- if ((options & PCRE_EXTENDED) != 0)
- {
- const pcre_uchar *p = ptr + 1;
- for (;;)
- {
- while (MAX_255(*p) && (cd->ctypes[*p] & ctype_space) != 0) p++;
- if (*p != CHAR_NUMBER_SIGN) break;
- p++;
- while (*p != CHAR_NULL)
- {
- if (IS_NEWLINE(p)) /* For non-fixed-length newline cases, */
- { /* IS_NEWLINE sets cd->nllen. */
- p += cd->nllen;
- break;
- }
- p++;
-#ifdef SUPPORT_UTF
- if (utf) FORWARDCHAR(p);
-#endif
- } /* Loop for comment characters */
- } /* Loop for multiple comments */
- ptr = p - 1; /* Character before the next significant one. */
- }
-
- /* If the next character is '+', we have a possessive quantifier. This
- implies greediness, whatever the setting of the PCRE_UNGREEDY option.
- If the next character is '?' this is a minimizing repeat, by default,
- but if PCRE_UNGREEDY is set, it works the other way round. We change the
- repeat type to the non-default. */
-
- if (ptr[1] == CHAR_PLUS)
- {
- repeat_type = 0; /* Force greedy */
- possessive_quantifier = TRUE;
- ptr++;
- }
- else if (ptr[1] == CHAR_QUESTION_MARK)
- {
- repeat_type = greedy_non_default;
- ptr++;
- }
- else repeat_type = greedy_default;
-
- /* If previous was a recursion call, wrap it in atomic brackets so that
- previous becomes the atomic group. All recursions were so wrapped in the
- past, but it no longer happens for non-repeated recursions. In fact, the
- repeated ones could be re-implemented independently so as not to need this,
- but for the moment we rely on the code for repeating groups. */
-
- if (*previous == OP_RECURSE)
- {
- memmove(previous + 1 + LINK_SIZE, previous, IN_UCHARS(1 + LINK_SIZE));
- *previous = OP_ONCE;
- PUT(previous, 1, 2 + 2*LINK_SIZE);
- previous[2 + 2*LINK_SIZE] = OP_KET;
- PUT(previous, 3 + 2*LINK_SIZE, 2 + 2*LINK_SIZE);
- code += 2 + 2 * LINK_SIZE;
- length_prevgroup = 3 + 3*LINK_SIZE;
-
- /* When actually compiling, we need to check whether this was a forward
- reference, and if so, adjust the offset. */
-
- if (lengthptr == NULL && cd->hwm >= cd->start_workspace + LINK_SIZE)
- {
- int offset = GET(cd->hwm, -LINK_SIZE);
- if (offset == previous + 1 - cd->start_code)
- PUT(cd->hwm, -LINK_SIZE, offset + 1 + LINK_SIZE);
- }
- }
-
- /* Now handle repetition for the different types of item. */
-
- /* If previous was a character or negated character match, abolish the item
- and generate a repeat item instead. If a char item has a minimum of more
- than one, ensure that it is set in reqchar - it might not be if a sequence
- such as x{3} is the first thing in a branch because the x will have gone
- into firstchar instead. */
-
- if (*previous == OP_CHAR || *previous == OP_CHARI
- || *previous == OP_NOT || *previous == OP_NOTI)
- {
- switch (*previous)
- {
- default: /* Make compiler happy. */
- case OP_CHAR: op_type = OP_STAR - OP_STAR; break;
- case OP_CHARI: op_type = OP_STARI - OP_STAR; break;
- case OP_NOT: op_type = OP_NOTSTAR - OP_STAR; break;
- case OP_NOTI: op_type = OP_NOTSTARI - OP_STAR; break;
- }
-
- /* Deal with UTF characters that take up more than one character. It's
- easier to write this out separately than try to macrify it. Use c to
- hold the length of the character in bytes, plus UTF_LENGTH to flag that
- it's a length rather than a small character. */
-
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (utf && NOT_FIRSTCHAR(code[-1]))
- {
- pcre_uchar *lastchar = code - 1;
- BACKCHAR(lastchar);
- c = (int)(code - lastchar); /* Length of UTF-8 character */
- memcpy(utf_chars, lastchar, IN_UCHARS(c)); /* Save the char */
- c |= UTF_LENGTH; /* Flag c as a length */
- }
- else
-#endif /* SUPPORT_UTF */
-
- /* Handle the case of a single charater - either with no UTF support, or
- with UTF disabled, or for a single character UTF character. */
- {
- c = code[-1];
- if (*previous <= OP_CHARI && repeat_min > 1)
- {
- reqchar = c;
- reqcharflags = req_caseopt | cd->req_varyopt;
- }
- }
-
- goto OUTPUT_SINGLE_REPEAT; /* Code shared with single character types */
- }
-
- /* If previous was a character type match (\d or similar), abolish it and
- create a suitable repeat item. The code is shared with single-character
- repeats by setting op_type to add a suitable offset into repeat_type. Note
- the the Unicode property types will be present only when SUPPORT_UCP is
- defined, but we don't wrap the little bits of code here because it just
- makes it horribly messy. */
-
- else if (*previous < OP_EODN)
- {
- pcre_uchar *oldcode;
- int prop_type, prop_value;
- op_type = OP_TYPESTAR - OP_STAR; /* Use type opcodes */
- c = *previous;
-
- OUTPUT_SINGLE_REPEAT:
- if (*previous == OP_PROP || *previous == OP_NOTPROP)
- {
- prop_type = previous[1];
- prop_value = previous[2];
- }
- else prop_type = prop_value = -1;
-
- oldcode = code;
- code = previous; /* Usually overwrite previous item */
-
- /* If the maximum is zero then the minimum must also be zero; Perl allows
- this case, so we do too - by simply omitting the item altogether. */
-
- if (repeat_max == 0) goto END_REPEAT;
-
- /* Combine the op_type with the repeat_type */
-
- repeat_type += op_type;
-
- /* A minimum of zero is handled either as the special case * or ?, or as
- an UPTO, with the maximum given. */
-
- if (repeat_min == 0)
- {
- if (repeat_max == -1) *code++ = OP_STAR + repeat_type;
- else if (repeat_max == 1) *code++ = OP_QUERY + repeat_type;
- else
- {
- *code++ = OP_UPTO + repeat_type;
- PUT2INC(code, 0, repeat_max);
- }
- }
-
- /* A repeat minimum of 1 is optimized into some special cases. If the
- maximum is unlimited, we use OP_PLUS. Otherwise, the original item is
- left in place and, if the maximum is greater than 1, we use OP_UPTO with
- one less than the maximum. */
-
- else if (repeat_min == 1)
- {
- if (repeat_max == -1)
- *code++ = OP_PLUS + repeat_type;
- else
- {
- code = oldcode; /* leave previous item in place */
- if (repeat_max == 1) goto END_REPEAT;
- *code++ = OP_UPTO + repeat_type;
- PUT2INC(code, 0, repeat_max - 1);
- }
- }
-
- /* The case {n,n} is just an EXACT, while the general case {n,m} is
- handled as an EXACT followed by an UPTO. */
-
- else
- {
- *code++ = OP_EXACT + op_type; /* NB EXACT doesn't have repeat_type */
- PUT2INC(code, 0, repeat_min);
-
- /* If the maximum is unlimited, insert an OP_STAR. Before doing so,
- we have to insert the character for the previous code. For a repeated
- Unicode property match, there are two extra bytes that define the
- required property. In UTF-8 mode, long characters have their length in
- c, with the UTF_LENGTH bit as a flag. */
-
- if (repeat_max < 0)
- {
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (utf && (c & UTF_LENGTH) != 0)
- {
- memcpy(code, utf_chars, IN_UCHARS(c & 7));
- code += c & 7;
- }
- else
-#endif
- {
- *code++ = c;
- if (prop_type >= 0)
- {
- *code++ = prop_type;
- *code++ = prop_value;
- }
- }
- *code++ = OP_STAR + repeat_type;
- }
-
- /* Else insert an UPTO if the max is greater than the min, again
- preceded by the character, for the previously inserted code. If the
- UPTO is just for 1 instance, we can use QUERY instead. */
-
- else if (repeat_max != repeat_min)
- {
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (utf && (c & UTF_LENGTH) != 0)
- {
- memcpy(code, utf_chars, IN_UCHARS(c & 7));
- code += c & 7;
- }
- else
-#endif
- *code++ = c;
- if (prop_type >= 0)
- {
- *code++ = prop_type;
- *code++ = prop_value;
- }
- repeat_max -= repeat_min;
-
- if (repeat_max == 1)
- {
- *code++ = OP_QUERY + repeat_type;
- }
- else
- {
- *code++ = OP_UPTO + repeat_type;
- PUT2INC(code, 0, repeat_max);
- }
- }
- }
-
- /* The character or character type itself comes last in all cases. */
-
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (utf && (c & UTF_LENGTH) != 0)
- {
- memcpy(code, utf_chars, IN_UCHARS(c & 7));
- code += c & 7;
- }
- else
-#endif
- *code++ = c;
-
- /* For a repeated Unicode property match, there are two extra bytes that
- define the required property. */
-
-#ifdef SUPPORT_UCP
- if (prop_type >= 0)
- {
- *code++ = prop_type;
- *code++ = prop_value;
- }
-#endif
- }
-
- /* If previous was a character class or a back reference, we put the repeat
- stuff after it, but just skip the item if the repeat was {0,0}. */
-
- else if (*previous == OP_CLASS || *previous == OP_NCLASS ||
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- *previous == OP_XCLASS ||
-#endif
- *previous == OP_REF || *previous == OP_REFI ||
- *previous == OP_DNREF || *previous == OP_DNREFI)
- {
- if (repeat_max == 0)
- {
- code = previous;
- goto END_REPEAT;
- }
-
- if (repeat_min == 0 && repeat_max == -1)
- *code++ = OP_CRSTAR + repeat_type;
- else if (repeat_min == 1 && repeat_max == -1)
- *code++ = OP_CRPLUS + repeat_type;
- else if (repeat_min == 0 && repeat_max == 1)
- *code++ = OP_CRQUERY + repeat_type;
- else
- {
- *code++ = OP_CRRANGE + repeat_type;
- PUT2INC(code, 0, repeat_min);
- if (repeat_max == -1) repeat_max = 0; /* 2-byte encoding for max */
- PUT2INC(code, 0, repeat_max);
- }
- }
-
- /* If previous was a bracket group, we may have to replicate it in certain
- cases. Note that at this point we can encounter only the "basic" bracket
- opcodes such as BRA and CBRA, as this is the place where they get converted
- into the more special varieties such as BRAPOS and SBRA. A test for >=
- OP_ASSERT and <= OP_COND includes ASSERT, ASSERT_NOT, ASSERTBACK,
- ASSERTBACK_NOT, ONCE, ONCE_NC, BRA, BRAPOS, CBRA, CBRAPOS, and COND.
- Originally, PCRE did not allow repetition of assertions, but now it does,
- for Perl compatibility. */
-
- else if (*previous >= OP_ASSERT && *previous <= OP_COND)
- {
- register int i;
- int len = (int)(code - previous);
- size_t base_hwm_offset = item_hwm_offset;
- pcre_uchar *bralink = NULL;
- pcre_uchar *brazeroptr = NULL;
-
- /* Repeating a DEFINE group is pointless, but Perl allows the syntax, so
- we just ignore the repeat. */
-
- if (*previous == OP_COND && previous[LINK_SIZE+1] == OP_DEF)
- goto END_REPEAT;
-
- /* There is no sense in actually repeating assertions. The only potential
- use of repetition is in cases when the assertion is optional. Therefore,
- if the minimum is greater than zero, just ignore the repeat. If the
- maximum is not zero or one, set it to 1. */
-
- if (*previous < OP_ONCE) /* Assertion */
- {
- if (repeat_min > 0) goto END_REPEAT;
- if (repeat_max < 0 || repeat_max > 1) repeat_max = 1;
- }
-
- /* The case of a zero minimum is special because of the need to stick
- OP_BRAZERO in front of it, and because the group appears once in the
- data, whereas in other cases it appears the minimum number of times. For
- this reason, it is simplest to treat this case separately, as otherwise
- the code gets far too messy. There are several special subcases when the
- minimum is zero. */
-
- if (repeat_min == 0)
- {
- /* If the maximum is also zero, we used to just omit the group from the
- output altogether, like this:
-
- ** if (repeat_max == 0)
- ** {
- ** code = previous;
- ** goto END_REPEAT;
- ** }
-
- However, that fails when a group or a subgroup within it is referenced
- as a subroutine from elsewhere in the pattern, so now we stick in
- OP_SKIPZERO in front of it so that it is skipped on execution. As we
- don't have a list of which groups are referenced, we cannot do this
- selectively.
-
- If the maximum is 1 or unlimited, we just have to stick in the BRAZERO
- and do no more at this point. However, we do need to adjust any
- OP_RECURSE calls inside the group that refer to the group itself or any
- internal or forward referenced group, because the offset is from the
- start of the whole regex. Temporarily terminate the pattern while doing
- this. */
-
- if (repeat_max <= 1) /* Covers 0, 1, and unlimited */
- {
- *code = OP_END;
- adjust_recurse(previous, 1, utf, cd, item_hwm_offset);
- memmove(previous + 1, previous, IN_UCHARS(len));
- code++;
- if (repeat_max == 0)
- {
- *previous++ = OP_SKIPZERO;
- goto END_REPEAT;
- }
- brazeroptr = previous; /* Save for possessive optimizing */
- *previous++ = OP_BRAZERO + repeat_type;
- }
-
- /* If the maximum is greater than 1 and limited, we have to replicate
- in a nested fashion, sticking OP_BRAZERO before each set of brackets.
- The first one has to be handled carefully because it's the original
- copy, which has to be moved up. The remainder can be handled by code
- that is common with the non-zero minimum case below. We have to
- adjust the value or repeat_max, since one less copy is required. Once
- again, we may have to adjust any OP_RECURSE calls inside the group. */
-
- else
- {
- int offset;
- *code = OP_END;
- adjust_recurse(previous, 2 + LINK_SIZE, utf, cd, item_hwm_offset);
- memmove(previous + 2 + LINK_SIZE, previous, IN_UCHARS(len));
- code += 2 + LINK_SIZE;
- *previous++ = OP_BRAZERO + repeat_type;
- *previous++ = OP_BRA;
-
- /* We chain together the bracket offset fields that have to be
- filled in later when the ends of the brackets are reached. */
-
- offset = (bralink == NULL)? 0 : (int)(previous - bralink);
- bralink = previous;
- PUTINC(previous, 0, offset);
- }
-
- repeat_max--;
- }
-
- /* If the minimum is greater than zero, replicate the group as many
- times as necessary, and adjust the maximum to the number of subsequent
- copies that we need. If we set a first char from the group, and didn't
- set a required char, copy the latter from the former. If there are any
- forward reference subroutine calls in the group, there will be entries on
- the workspace list; replicate these with an appropriate increment. */
-
- else
- {
- if (repeat_min > 1)
- {
- /* In the pre-compile phase, we don't actually do the replication. We
- just adjust the length as if we had. Do some paranoid checks for
- potential integer overflow. The INT64_OR_DOUBLE type is a 64-bit
- integer type when available, otherwise double. */
-
- if (lengthptr != NULL)
- {
- int delta = (repeat_min - 1)*length_prevgroup;
- if ((INT64_OR_DOUBLE)(repeat_min - 1)*
- (INT64_OR_DOUBLE)length_prevgroup >
- (INT64_OR_DOUBLE)INT_MAX ||
- OFLOW_MAX - *lengthptr < delta)
- {
- *errorcodeptr = ERR20;
- goto FAILED;
- }
- *lengthptr += delta;
- }
-
- /* This is compiling for real. If there is a set first byte for
- the group, and we have not yet set a "required byte", set it. Make
- sure there is enough workspace for copying forward references before
- doing the copy. */
-
- else
- {
- if (groupsetfirstchar && reqcharflags < 0)
- {
- reqchar = firstchar;
- reqcharflags = firstcharflags;
- }
-
- for (i = 1; i < repeat_min; i++)
- {
- pcre_uchar *hc;
- size_t this_hwm_offset = cd->hwm - cd->start_workspace;
- memcpy(code, previous, IN_UCHARS(len));
-
- while (cd->hwm > cd->start_workspace + cd->workspace_size -
- WORK_SIZE_SAFETY_MARGIN -
- (this_hwm_offset - base_hwm_offset))
- {
- *errorcodeptr = expand_workspace(cd);
- if (*errorcodeptr != 0) goto FAILED;
- }
-
- for (hc = (pcre_uchar *)cd->start_workspace + base_hwm_offset;
- hc < (pcre_uchar *)cd->start_workspace + this_hwm_offset;
- hc += LINK_SIZE)
- {
- PUT(cd->hwm, 0, GET(hc, 0) + len);
- cd->hwm += LINK_SIZE;
- }
- base_hwm_offset = this_hwm_offset;
- code += len;
- }
- }
- }
-
- if (repeat_max > 0) repeat_max -= repeat_min;
- }
-
- /* This code is common to both the zero and non-zero minimum cases. If
- the maximum is limited, it replicates the group in a nested fashion,
- remembering the bracket starts on a stack. In the case of a zero minimum,
- the first one was set up above. In all cases the repeat_max now specifies
- the number of additional copies needed. Again, we must remember to
- replicate entries on the forward reference list. */
-
- if (repeat_max >= 0)
- {
- /* In the pre-compile phase, we don't actually do the replication. We
- just adjust the length as if we had. For each repetition we must add 1
- to the length for BRAZERO and for all but the last repetition we must
- add 2 + 2*LINKSIZE to allow for the nesting that occurs. Do some
- paranoid checks to avoid integer overflow. The INT64_OR_DOUBLE type is
- a 64-bit integer type when available, otherwise double. */
-
- if (lengthptr != NULL && repeat_max > 0)
- {
- int delta = repeat_max * (length_prevgroup + 1 + 2 + 2*LINK_SIZE) -
- 2 - 2*LINK_SIZE; /* Last one doesn't nest */
- if ((INT64_OR_DOUBLE)repeat_max *
- (INT64_OR_DOUBLE)(length_prevgroup + 1 + 2 + 2*LINK_SIZE)
- > (INT64_OR_DOUBLE)INT_MAX ||
- OFLOW_MAX - *lengthptr < delta)
- {
- *errorcodeptr = ERR20;
- goto FAILED;
- }
- *lengthptr += delta;
- }
-
- /* This is compiling for real */
-
- else for (i = repeat_max - 1; i >= 0; i--)
- {
- pcre_uchar *hc;
- size_t this_hwm_offset = cd->hwm - cd->start_workspace;
-
- *code++ = OP_BRAZERO + repeat_type;
-
- /* All but the final copy start a new nesting, maintaining the
- chain of brackets outstanding. */
-
- if (i != 0)
- {
- int offset;
- *code++ = OP_BRA;
- offset = (bralink == NULL)? 0 : (int)(code - bralink);
- bralink = code;
- PUTINC(code, 0, offset);
- }
-
- memcpy(code, previous, IN_UCHARS(len));
-
- /* Ensure there is enough workspace for forward references before
- copying them. */
-
- while (cd->hwm > cd->start_workspace + cd->workspace_size -
- WORK_SIZE_SAFETY_MARGIN -
- (this_hwm_offset - base_hwm_offset))
- {
- *errorcodeptr = expand_workspace(cd);
- if (*errorcodeptr != 0) goto FAILED;
- }
-
- for (hc = (pcre_uchar *)cd->start_workspace + base_hwm_offset;
- hc < (pcre_uchar *)cd->start_workspace + this_hwm_offset;
- hc += LINK_SIZE)
- {
- PUT(cd->hwm, 0, GET(hc, 0) + len + ((i != 0)? 2+LINK_SIZE : 1));
- cd->hwm += LINK_SIZE;
- }
- base_hwm_offset = this_hwm_offset;
- code += len;
- }
-
- /* Now chain through the pending brackets, and fill in their length
- fields (which are holding the chain links pro tem). */
-
- while (bralink != NULL)
- {
- int oldlinkoffset;
- int offset = (int)(code - bralink + 1);
- pcre_uchar *bra = code - offset;
- oldlinkoffset = GET(bra, 1);
- bralink = (oldlinkoffset == 0)? NULL : bralink - oldlinkoffset;
- *code++ = OP_KET;
- PUTINC(code, 0, offset);
- PUT(bra, 1, offset);
- }
- }
-
- /* If the maximum is unlimited, set a repeater in the final copy. For
- ONCE brackets, that's all we need to do. However, possessively repeated
- ONCE brackets can be converted into non-capturing brackets, as the
- behaviour of (?:xx)++ is the same as (?>xx)++ and this saves having to
- deal with possessive ONCEs specially.
-
- Otherwise, when we are doing the actual compile phase, check to see
- whether this group is one that could match an empty string. If so,
- convert the initial operator to the S form (e.g. OP_BRA -> OP_SBRA) so
- that runtime checking can be done. [This check is also applied to ONCE
- groups at runtime, but in a different way.]
-
- Then, if the quantifier was possessive and the bracket is not a
- conditional, we convert the BRA code to the POS form, and the KET code to
- KETRPOS. (It turns out to be convenient at runtime to detect this kind of
- subpattern at both the start and at the end.) The use of special opcodes
- makes it possible to reduce greatly the stack usage in pcre_exec(). If
- the group is preceded by OP_BRAZERO, convert this to OP_BRAPOSZERO.
-
- Then, if the minimum number of matches is 1 or 0, cancel the possessive
- flag so that the default action below, of wrapping everything inside
- atomic brackets, does not happen. When the minimum is greater than 1,
- there will be earlier copies of the group, and so we still have to wrap
- the whole thing. */
-
- else
- {
- pcre_uchar *ketcode = code - 1 - LINK_SIZE;
- pcre_uchar *bracode = ketcode - GET(ketcode, 1);
-
- /* Convert possessive ONCE brackets to non-capturing */
-
- if ((*bracode == OP_ONCE || *bracode == OP_ONCE_NC) &&
- possessive_quantifier) *bracode = OP_BRA;
-
- /* For non-possessive ONCE brackets, all we need to do is to
- set the KET. */
-
- if (*bracode == OP_ONCE || *bracode == OP_ONCE_NC)
- *ketcode = OP_KETRMAX + repeat_type;
-
- /* Handle non-ONCE brackets and possessive ONCEs (which have been
- converted to non-capturing above). */
-
- else
- {
- /* In the compile phase, check for empty string matching. */
-
- if (lengthptr == NULL)
- {
- pcre_uchar *scode = bracode;
- do
- {
- if (could_be_empty_branch(scode, ketcode, utf, cd, NULL))
- {
- *bracode += OP_SBRA - OP_BRA;
- break;
- }
- scode += GET(scode, 1);
- }
- while (*scode == OP_ALT);
- }
-
- /* A conditional group with only one branch has an implicit empty
- alternative branch. */
-
- if (*bracode == OP_COND && bracode[GET(bracode,1)] != OP_ALT)
- *bracode = OP_SCOND;
-
- /* Handle possessive quantifiers. */
-
- if (possessive_quantifier)
- {
- /* For COND brackets, we wrap the whole thing in a possessively
- repeated non-capturing bracket, because we have not invented POS
- versions of the COND opcodes. Because we are moving code along, we
- must ensure that any pending recursive references are updated. */
-
- if (*bracode == OP_COND || *bracode == OP_SCOND)
- {
- int nlen = (int)(code - bracode);
- *code = OP_END;
- adjust_recurse(bracode, 1 + LINK_SIZE, utf, cd, item_hwm_offset);
- memmove(bracode + 1 + LINK_SIZE, bracode, IN_UCHARS(nlen));
- code += 1 + LINK_SIZE;
- nlen += 1 + LINK_SIZE;
- *bracode = (*bracode == OP_COND)? OP_BRAPOS : OP_SBRAPOS;
- *code++ = OP_KETRPOS;
- PUTINC(code, 0, nlen);
- PUT(bracode, 1, nlen);
- }
-
- /* For non-COND brackets, we modify the BRA code and use KETRPOS. */
-
- else
- {
- *bracode += 1; /* Switch to xxxPOS opcodes */
- *ketcode = OP_KETRPOS;
- }
-
- /* If the minimum is zero, mark it as possessive, then unset the
- possessive flag when the minimum is 0 or 1. */
-
- if (brazeroptr != NULL) *brazeroptr = OP_BRAPOSZERO;
- if (repeat_min < 2) possessive_quantifier = FALSE;
- }
-
- /* Non-possessive quantifier */
-
- else *ketcode = OP_KETRMAX + repeat_type;
- }
- }
- }
-
- /* If previous is OP_FAIL, it was generated by an empty class [] in
- JavaScript mode. The other ways in which OP_FAIL can be generated, that is
- by (*FAIL) or (?!) set previous to NULL, which gives a "nothing to repeat"
- error above. We can just ignore the repeat in JS case. */
-
- else if (*previous == OP_FAIL) goto END_REPEAT;
-
- /* Else there's some kind of shambles */
-
- else
- {
- *errorcodeptr = ERR11;
- goto FAILED;
- }
-
- /* If the character following a repeat is '+', possessive_quantifier is
- TRUE. For some opcodes, there are special alternative opcodes for this
- case. For anything else, we wrap the entire repeated item inside OP_ONCE
- brackets. Logically, the '+' notation is just syntactic sugar, taken from
- Sun's Java package, but the special opcodes can optimize it.
-
- Some (but not all) possessively repeated subpatterns have already been
- completely handled in the code just above. For them, possessive_quantifier
- is always FALSE at this stage. Note that the repeated item starts at
- tempcode, not at previous, which might be the first part of a string whose
- (former) last char we repeated. */
-
- if (possessive_quantifier)
- {
- int len;
-
- /* Possessifying an EXACT quantifier has no effect, so we can ignore it.
- However, QUERY, STAR, or UPTO may follow (for quantifiers such as {5,6},
- {5,}, or {5,10}). We skip over an EXACT item; if the length of what
- remains is greater than zero, there's a further opcode that can be
- handled. If not, do nothing, leaving the EXACT alone. */
-
- switch(*tempcode)
- {
- case OP_TYPEEXACT:
- tempcode += PRIV(OP_lengths)[*tempcode] +
- ((tempcode[1 + IMM2_SIZE] == OP_PROP
- || tempcode[1 + IMM2_SIZE] == OP_NOTPROP)? 2 : 0);
- break;
-
- /* CHAR opcodes are used for exacts whose count is 1. */
-
- case OP_CHAR:
- case OP_CHARI:
- case OP_NOT:
- case OP_NOTI:
- case OP_EXACT:
- case OP_EXACTI:
- case OP_NOTEXACT:
- case OP_NOTEXACTI:
- tempcode += PRIV(OP_lengths)[*tempcode];
-#ifdef SUPPORT_UTF
- if (utf && HAS_EXTRALEN(tempcode[-1]))
- tempcode += GET_EXTRALEN(tempcode[-1]);
-#endif
- break;
-
- /* For the class opcodes, the repeat operator appears at the end;
- adjust tempcode to point to it. */
-
- case OP_CLASS:
- case OP_NCLASS:
- tempcode += 1 + 32/sizeof(pcre_uchar);
- break;
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- tempcode += GET(tempcode, 1);
- break;
-#endif
- }
-
- /* If tempcode is equal to code (which points to the end of the repeated
- item), it means we have skipped an EXACT item but there is no following
- QUERY, STAR, or UPTO; the value of len will be 0, and we do nothing. In
- all other cases, tempcode will be pointing to the repeat opcode, and will
- be less than code, so the value of len will be greater than 0. */
-
- len = (int)(code - tempcode);
- if (len > 0)
- {
- unsigned int repcode = *tempcode;
-
- /* There is a table for possessifying opcodes, all of which are less
- than OP_CALLOUT. A zero entry means there is no possessified version.
- */
-
- if (repcode < OP_CALLOUT && opcode_possessify[repcode] > 0)
- *tempcode = opcode_possessify[repcode];
-
- /* For opcode without a special possessified version, wrap the item in
- ONCE brackets. Because we are moving code along, we must ensure that any
- pending recursive references are updated. */
-
- else
- {
- *code = OP_END;
- adjust_recurse(tempcode, 1 + LINK_SIZE, utf, cd, item_hwm_offset);
- memmove(tempcode + 1 + LINK_SIZE, tempcode, IN_UCHARS(len));
- code += 1 + LINK_SIZE;
- len += 1 + LINK_SIZE;
- tempcode[0] = OP_ONCE;
- *code++ = OP_KET;
- PUTINC(code, 0, len);
- PUT(tempcode, 1, len);
- }
- }
-
-#ifdef NEVER
- if (len > 0) switch (*tempcode)
- {
- case OP_STAR: *tempcode = OP_POSSTAR; break;
- case OP_PLUS: *tempcode = OP_POSPLUS; break;
- case OP_QUERY: *tempcode = OP_POSQUERY; break;
- case OP_UPTO: *tempcode = OP_POSUPTO; break;
-
- case OP_STARI: *tempcode = OP_POSSTARI; break;
- case OP_PLUSI: *tempcode = OP_POSPLUSI; break;
- case OP_QUERYI: *tempcode = OP_POSQUERYI; break;
- case OP_UPTOI: *tempcode = OP_POSUPTOI; break;
-
- case OP_NOTSTAR: *tempcode = OP_NOTPOSSTAR; break;
- case OP_NOTPLUS: *tempcode = OP_NOTPOSPLUS; break;
- case OP_NOTQUERY: *tempcode = OP_NOTPOSQUERY; break;
- case OP_NOTUPTO: *tempcode = OP_NOTPOSUPTO; break;
-
- case OP_NOTSTARI: *tempcode = OP_NOTPOSSTARI; break;
- case OP_NOTPLUSI: *tempcode = OP_NOTPOSPLUSI; break;
- case OP_NOTQUERYI: *tempcode = OP_NOTPOSQUERYI; break;
- case OP_NOTUPTOI: *tempcode = OP_NOTPOSUPTOI; break;
-
- case OP_TYPESTAR: *tempcode = OP_TYPEPOSSTAR; break;
- case OP_TYPEPLUS: *tempcode = OP_TYPEPOSPLUS; break;
- case OP_TYPEQUERY: *tempcode = OP_TYPEPOSQUERY; break;
- case OP_TYPEUPTO: *tempcode = OP_TYPEPOSUPTO; break;
-
- case OP_CRSTAR: *tempcode = OP_CRPOSSTAR; break;
- case OP_CRPLUS: *tempcode = OP_CRPOSPLUS; break;
- case OP_CRQUERY: *tempcode = OP_CRPOSQUERY; break;
- case OP_CRRANGE: *tempcode = OP_CRPOSRANGE; break;
-
- /* Because we are moving code along, we must ensure that any
- pending recursive references are updated. */
-
- default:
- *code = OP_END;
- adjust_recurse(tempcode, 1 + LINK_SIZE, utf, cd, item_hwm_offset);
- memmove(tempcode + 1 + LINK_SIZE, tempcode, IN_UCHARS(len));
- code += 1 + LINK_SIZE;
- len += 1 + LINK_SIZE;
- tempcode[0] = OP_ONCE;
- *code++ = OP_KET;
- PUTINC(code, 0, len);
- PUT(tempcode, 1, len);
- break;
- }
-#endif
- }
-
- /* In all case we no longer have a previous item. We also set the
- "follows varying string" flag for subsequently encountered reqchars if
- it isn't already set and we have just passed a varying length item. */
-
- END_REPEAT:
- previous = NULL;
- cd->req_varyopt |= reqvary;
- break;
-
-
- /* ===================================================================*/
- /* Start of nested parenthesized sub-expression, or comment or lookahead or
- lookbehind or option setting or condition or all the other extended
- parenthesis forms. */
-
- case CHAR_LEFT_PARENTHESIS:
- ptr++;
-
- /* First deal with comments. Putting this code right at the start ensures
- that comments have no bad side effects. */
-
- if (ptr[0] == CHAR_QUESTION_MARK && ptr[1] == CHAR_NUMBER_SIGN)
- {
- ptr += 2;
- while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
- if (*ptr == CHAR_NULL)
- {
- *errorcodeptr = ERR18;
- goto FAILED;
- }
- continue;
- }
-
- /* Now deal with various "verbs" that can be introduced by '*'. */
-
- if (ptr[0] == CHAR_ASTERISK && (ptr[1] == ':'
- || (MAX_255(ptr[1]) && ((cd->ctypes[ptr[1]] & ctype_letter) != 0))))
- {
- int i, namelen;
- int arglen = 0;
- const char *vn = verbnames;
- const pcre_uchar *name = ptr + 1;
- const pcre_uchar *arg = NULL;
- previous = NULL;
- ptr++;
- while (MAX_255(*ptr) && (cd->ctypes[*ptr] & ctype_letter) != 0) ptr++;
- namelen = (int)(ptr - name);
-
- /* It appears that Perl allows any characters whatsoever, other than
- a closing parenthesis, to appear in arguments, so we no longer insist on
- letters, digits, and underscores. */
-
- if (*ptr == CHAR_COLON)
- {
- arg = ++ptr;
- while (*ptr != CHAR_NULL && *ptr != CHAR_RIGHT_PARENTHESIS) ptr++;
- arglen = (int)(ptr - arg);
- if ((unsigned int)arglen > MAX_MARK)
- {
- *errorcodeptr = ERR75;
- goto FAILED;
- }
- }
-
- if (*ptr != CHAR_RIGHT_PARENTHESIS)
- {
- *errorcodeptr = ERR60;
- goto FAILED;
- }
-
- /* Scan the table of verb names */
-
- for (i = 0; i < verbcount; i++)
- {
- if (namelen == verbs[i].len &&
- STRNCMP_UC_C8(name, vn, namelen) == 0)
- {
- int setverb;
-
- /* Check for open captures before ACCEPT and convert it to
- ASSERT_ACCEPT if in an assertion. */
-
- if (verbs[i].op == OP_ACCEPT)
- {
- open_capitem *oc;
- if (arglen != 0)
- {
- *errorcodeptr = ERR59;
- goto FAILED;
- }
- cd->had_accept = TRUE;
- for (oc = cd->open_caps; oc != NULL; oc = oc->next)
- {
- *code++ = OP_CLOSE;
- PUT2INC(code, 0, oc->number);
- }
- setverb = *code++ =
- (cd->assert_depth > 0)? OP_ASSERT_ACCEPT : OP_ACCEPT;
-
- /* Do not set firstchar after *ACCEPT */
- if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
- }
-
- /* Handle other cases with/without an argument */
-
- else if (arglen == 0)
- {
- if (verbs[i].op < 0) /* Argument is mandatory */
- {
- *errorcodeptr = ERR66;
- goto FAILED;
- }
- setverb = *code++ = verbs[i].op;
- }
-
- else
- {
- if (verbs[i].op_arg < 0) /* Argument is forbidden */
- {
- *errorcodeptr = ERR59;
- goto FAILED;
- }
- setverb = *code++ = verbs[i].op_arg;
- if (lengthptr != NULL) /* In pass 1 just add in the length */
- { /* to avoid potential workspace */
- *lengthptr += arglen; /* overflow. */
- *code++ = 0;
- }
- else
- {
- *code++ = arglen;
- memcpy(code, arg, IN_UCHARS(arglen));
- code += arglen;
- }
- *code++ = 0;
- }
-
- switch (setverb)
- {
- case OP_THEN:
- case OP_THEN_ARG:
- cd->external_flags |= PCRE_HASTHEN;
- break;
-
- case OP_PRUNE:
- case OP_PRUNE_ARG:
- case OP_SKIP:
- case OP_SKIP_ARG:
- cd->had_pruneorskip = TRUE;
- break;
- }
-
- break; /* Found verb, exit loop */
- }
-
- vn += verbs[i].len + 1;
- }
-
- if (i < verbcount) continue; /* Successfully handled a verb */
- *errorcodeptr = ERR60; /* Verb not recognized */
- goto FAILED;
- }
-
- /* Initialize for "real" parentheses */
-
- newoptions = options;
- skipbytes = 0;
- bravalue = OP_CBRA;
- item_hwm_offset = cd->hwm - cd->start_workspace;
- reset_bracount = FALSE;
-
- /* Deal with the extended parentheses; all are introduced by '?', and the
- appearance of any of them means that this is not a capturing group. */
-
- if (*ptr == CHAR_QUESTION_MARK)
- {
- int i, set, unset, namelen;
- int *optset;
- const pcre_uchar *name;
- pcre_uchar *slot;
-
- switch (*(++ptr))
- {
- /* ------------------------------------------------------------ */
- case CHAR_VERTICAL_LINE: /* Reset capture count for each branch */
- reset_bracount = TRUE;
- cd->dupgroups = TRUE; /* Record (?| encountered */
- /* Fall through */
-
- /* ------------------------------------------------------------ */
- case CHAR_COLON: /* Non-capturing bracket */
- bravalue = OP_BRA;
- ptr++;
- break;
-
-
- /* ------------------------------------------------------------ */
- case CHAR_LEFT_PARENTHESIS:
- bravalue = OP_COND; /* Conditional group */
- tempptr = ptr;
-
- /* A condition can be an assertion, a number (referring to a numbered
- group's having been set), a name (referring to a named group), or 'R',
- referring to recursion. R and R&name are also permitted for
- recursion tests.
-
- There are ways of testing a named group: (?(name)) is used by Python;
- Perl 5.10 onwards uses (?() or (?('name')).
-
- There is one unfortunate ambiguity, caused by history. 'R' can be the
- recursive thing or the name 'R' (and similarly for 'R' followed by
- digits). We look for a name first; if not found, we try the other case.
-
- For compatibility with auto-callouts, we allow a callout to be
- specified before a condition that is an assertion. First, check for the
- syntax of a callout; if found, adjust the temporary pointer that is
- used to check for an assertion condition. That's all that is needed! */
-
- if (ptr[1] == CHAR_QUESTION_MARK && ptr[2] == CHAR_C)
- {
- for (i = 3;; i++) if (!IS_DIGIT(ptr[i])) break;
- if (ptr[i] == CHAR_RIGHT_PARENTHESIS)
- tempptr += i + 1;
- }
-
- /* For conditions that are assertions, check the syntax, and then exit
- the switch. This will take control down to where bracketed groups,
- including assertions, are processed. */
-
- if (tempptr[1] == CHAR_QUESTION_MARK &&
- (tempptr[2] == CHAR_EQUALS_SIGN ||
- tempptr[2] == CHAR_EXCLAMATION_MARK ||
- (tempptr[2] == CHAR_LESS_THAN_SIGN &&
- (tempptr[3] == CHAR_EQUALS_SIGN ||
- tempptr[3] == CHAR_EXCLAMATION_MARK))))
- {
- cd->iscondassert = TRUE;
- break;
- }
-
- /* Other conditions use OP_CREF/OP_DNCREF/OP_RREF/OP_DNRREF, and all
- need to skip at least 1+IMM2_SIZE bytes at the start of the group. */
-
- code[1+LINK_SIZE] = OP_CREF;
- skipbytes = 1+IMM2_SIZE;
- refsign = -1; /* => not a number */
- namelen = -1; /* => not a name; must set to avoid warning */
- name = NULL; /* Always set to avoid warning */
- recno = 0; /* Always set to avoid warning */
-
- /* Check for a test for recursion in a named group. */
-
- ptr++;
- if (*ptr == CHAR_R && ptr[1] == CHAR_AMPERSAND)
- {
- terminator = -1;
- ptr += 2;
- code[1+LINK_SIZE] = OP_RREF; /* Change the type of test */
- }
-
- /* Check for a test for a named group's having been set, using the Perl
- syntax (?() or (?('name'), and also allow for the original PCRE
- syntax of (?(name) or for (?(+n), (?(-n), and just (?(n). */
-
- else if (*ptr == CHAR_LESS_THAN_SIGN)
- {
- terminator = CHAR_GREATER_THAN_SIGN;
- ptr++;
- }
- else if (*ptr == CHAR_APOSTROPHE)
- {
- terminator = CHAR_APOSTROPHE;
- ptr++;
- }
- else
- {
- terminator = CHAR_NULL;
- if (*ptr == CHAR_MINUS || *ptr == CHAR_PLUS) refsign = *ptr++;
- else if (IS_DIGIT(*ptr)) refsign = 0;
- }
-
- /* Handle a number */
-
- if (refsign >= 0)
- {
- while (IS_DIGIT(*ptr))
- {
- if (recno > INT_MAX / 10 - 1) /* Integer overflow */
- {
- while (IS_DIGIT(*ptr)) ptr++;
- *errorcodeptr = ERR61;
- goto FAILED;
- }
- recno = recno * 10 + (int)(*ptr - CHAR_0);
- ptr++;
- }
- }
-
- /* Otherwise we expect to read a name; anything else is an error. When
- a name is one of a number of duplicates, a different opcode is used and
- it needs more memory. Unfortunately we cannot tell whether a name is a
- duplicate in the first pass, so we have to allow for more memory. */
-
- else
- {
- if (IS_DIGIT(*ptr))
- {
- *errorcodeptr = ERR84;
- goto FAILED;
- }
- if (!MAX_255(*ptr) || (cd->ctypes[*ptr] & ctype_word) == 0)
- {
- *errorcodeptr = ERR28; /* Assertion expected */
- goto FAILED;
- }
- name = ptr++;
- while (MAX_255(*ptr) && (cd->ctypes[*ptr] & ctype_word) != 0)
- {
- ptr++;
- }
- namelen = (int)(ptr - name);
- if (lengthptr != NULL) skipbytes += IMM2_SIZE;
- }
-
- /* Check the terminator */
-
- if ((terminator > 0 && *ptr++ != (pcre_uchar)terminator) ||
- *ptr++ != CHAR_RIGHT_PARENTHESIS)
- {
- ptr--; /* Error offset */
- *errorcodeptr = ERR26; /* Malformed number or name */
- goto FAILED;
- }
-
- /* Do no further checking in the pre-compile phase. */
-
- if (lengthptr != NULL) break;
-
- /* In the real compile we do the work of looking for the actual
- reference. If refsign is not negative, it means we have a number in
- recno. */
-
- if (refsign >= 0)
- {
- if (recno <= 0)
- {
- *errorcodeptr = ERR35;
- goto FAILED;
- }
- if (refsign != 0) recno = (refsign == CHAR_MINUS)?
- cd->bracount - recno + 1 : recno + cd->bracount;
- if (recno <= 0 || recno > cd->final_bracount)
- {
- *errorcodeptr = ERR15;
- goto FAILED;
- }
- PUT2(code, 2+LINK_SIZE, recno);
- if (recno > cd->top_backref) cd->top_backref = recno;
- break;
- }
-
- /* Otherwise look for the name. */
-
- slot = cd->name_table;
- for (i = 0; i < cd->names_found; i++)
- {
- if (STRNCMP_UC_UC(name, slot+IMM2_SIZE, namelen) == 0) break;
- slot += cd->name_entry_size;
- }
-
- /* Found the named subpattern. If the name is duplicated, add one to
- the opcode to change CREF/RREF into DNCREF/DNRREF and insert
- appropriate data values. Otherwise, just insert the unique subpattern
- number. */
-
- if (i < cd->names_found)
- {
- int offset = i++;
- int count = 1;
- recno = GET2(slot, 0); /* Number from first found */
- if (recno > cd->top_backref) cd->top_backref = recno;
- for (; i < cd->names_found; i++)
- {
- slot += cd->name_entry_size;
- if (STRNCMP_UC_UC(name, slot+IMM2_SIZE, namelen) != 0 ||
- (slot+IMM2_SIZE)[namelen] != 0) break;
- count++;
- }
-
- if (count > 1)
- {
- PUT2(code, 2+LINK_SIZE, offset);
- PUT2(code, 2+LINK_SIZE+IMM2_SIZE, count);
- skipbytes += IMM2_SIZE;
- code[1+LINK_SIZE]++;
- }
- else /* Not a duplicated name */
- {
- PUT2(code, 2+LINK_SIZE, recno);
- }
- }
-
- /* If terminator == CHAR_NULL it means that the name followed directly
- after the opening parenthesis [e.g. (?(abc)...] and in this case there
- are some further alternatives to try. For the cases where terminator !=
- CHAR_NULL [things like (?(... or (?('name')... or (?(R&name)... ]
- we have now checked all the possibilities, so give an error. */
-
- else if (terminator != CHAR_NULL)
- {
- *errorcodeptr = ERR15;
- goto FAILED;
- }
-
- /* Check for (?(R) for recursion. Allow digits after R to specify a
- specific group number. */
-
- else if (*name == CHAR_R)
- {
- recno = 0;
- for (i = 1; i < namelen; i++)
- {
- if (!IS_DIGIT(name[i]))
- {
- *errorcodeptr = ERR15;
- goto FAILED;
- }
- if (recno > INT_MAX / 10 - 1) /* Integer overflow */
- {
- *errorcodeptr = ERR61;
- goto FAILED;
- }
- recno = recno * 10 + name[i] - CHAR_0;
- }
- if (recno == 0) recno = RREF_ANY;
- code[1+LINK_SIZE] = OP_RREF; /* Change test type */
- PUT2(code, 2+LINK_SIZE, recno);
- }
-
- /* Similarly, check for the (?(DEFINE) "condition", which is always
- false. */
-
- else if (namelen == 6 && STRNCMP_UC_C8(name, STRING_DEFINE, 6) == 0)
- {
- code[1+LINK_SIZE] = OP_DEF;
- skipbytes = 1;
- }
-
- /* Reference to an unidentified subpattern. */
-
- else
- {
- *errorcodeptr = ERR15;
- goto FAILED;
- }
- break;
-
-
- /* ------------------------------------------------------------ */
- case CHAR_EQUALS_SIGN: /* Positive lookahead */
- bravalue = OP_ASSERT;
- cd->assert_depth += 1;
- ptr++;
- break;
-
- /* Optimize (?!) to (*FAIL) unless it is quantified - which is a weird
- thing to do, but Perl allows all assertions to be quantified, and when
- they contain capturing parentheses there may be a potential use for
- this feature. Not that that applies to a quantified (?!) but we allow
- it for uniformity. */
-
- /* ------------------------------------------------------------ */
- case CHAR_EXCLAMATION_MARK: /* Negative lookahead */
- ptr++;
- if (*ptr == CHAR_RIGHT_PARENTHESIS && ptr[1] != CHAR_ASTERISK &&
- ptr[1] != CHAR_PLUS && ptr[1] != CHAR_QUESTION_MARK &&
- (ptr[1] != CHAR_LEFT_CURLY_BRACKET || !is_counted_repeat(ptr+2)))
- {
- *code++ = OP_FAIL;
- previous = NULL;
- continue;
- }
- bravalue = OP_ASSERT_NOT;
- cd->assert_depth += 1;
- break;
-
-
- /* ------------------------------------------------------------ */
- case CHAR_LESS_THAN_SIGN: /* Lookbehind or named define */
- switch (ptr[1])
- {
- case CHAR_EQUALS_SIGN: /* Positive lookbehind */
- bravalue = OP_ASSERTBACK;
- cd->assert_depth += 1;
- ptr += 2;
- break;
-
- case CHAR_EXCLAMATION_MARK: /* Negative lookbehind */
- bravalue = OP_ASSERTBACK_NOT;
- cd->assert_depth += 1;
- ptr += 2;
- break;
-
- default: /* Could be name define, else bad */
- if (MAX_255(ptr[1]) && (cd->ctypes[ptr[1]] & ctype_word) != 0)
- goto DEFINE_NAME;
- ptr++; /* Correct offset for error */
- *errorcodeptr = ERR24;
- goto FAILED;
- }
- break;
-
-
- /* ------------------------------------------------------------ */
- case CHAR_GREATER_THAN_SIGN: /* One-time brackets */
- bravalue = OP_ONCE;
- ptr++;
- break;
-
-
- /* ------------------------------------------------------------ */
- case CHAR_C: /* Callout - may be followed by digits; */
- previous_callout = code; /* Save for later completion */
- after_manual_callout = 1; /* Skip one item before completing */
- *code++ = OP_CALLOUT;
- {
- int n = 0;
- ptr++;
- while(IS_DIGIT(*ptr))
- n = n * 10 + *ptr++ - CHAR_0;
- if (*ptr != CHAR_RIGHT_PARENTHESIS)
- {
- *errorcodeptr = ERR39;
- goto FAILED;
- }
- if (n > 255)
- {
- *errorcodeptr = ERR38;
- goto FAILED;
- }
- *code++ = n;
- PUT(code, 0, (int)(ptr - cd->start_pattern + 1)); /* Pattern offset */
- PUT(code, LINK_SIZE, 0); /* Default length */
- code += 2 * LINK_SIZE;
- }
- previous = NULL;
- continue;
-
-
- /* ------------------------------------------------------------ */
- case CHAR_P: /* Python-style named subpattern handling */
- if (*(++ptr) == CHAR_EQUALS_SIGN ||
- *ptr == CHAR_GREATER_THAN_SIGN) /* Reference or recursion */
- {
- is_recurse = *ptr == CHAR_GREATER_THAN_SIGN;
- terminator = CHAR_RIGHT_PARENTHESIS;
- goto NAMED_REF_OR_RECURSE;
- }
- else if (*ptr != CHAR_LESS_THAN_SIGN) /* Test for Python-style defn */
- {
- *errorcodeptr = ERR41;
- goto FAILED;
- }
- /* Fall through to handle (?P< as (?< is handled */
-
-
- /* ------------------------------------------------------------ */
- DEFINE_NAME: /* Come here from (?< handling */
- case CHAR_APOSTROPHE:
- terminator = (*ptr == CHAR_LESS_THAN_SIGN)?
- CHAR_GREATER_THAN_SIGN : CHAR_APOSTROPHE;
- name = ++ptr;
- if (IS_DIGIT(*ptr))
- {
- *errorcodeptr = ERR84; /* Group name must start with non-digit */
- goto FAILED;
- }
- while (MAX_255(*ptr) && (cd->ctypes[*ptr] & ctype_word) != 0) ptr++;
- namelen = (int)(ptr - name);
-
- /* In the pre-compile phase, do a syntax check, remember the longest
- name, and then remember the group in a vector, expanding it if
- necessary. Duplicates for the same number are skipped; other duplicates
- are checked for validity. In the actual compile, there is nothing to
- do. */
-
- if (lengthptr != NULL)
- {
- named_group *ng;
- pcre_uint32 number = cd->bracount + 1;
-
- if (*ptr != (pcre_uchar)terminator)
- {
- *errorcodeptr = ERR42;
- goto FAILED;
- }
-
- if (cd->names_found >= MAX_NAME_COUNT)
- {
- *errorcodeptr = ERR49;
- goto FAILED;
- }
-
- if (namelen + IMM2_SIZE + 1 > cd->name_entry_size)
- {
- cd->name_entry_size = namelen + IMM2_SIZE + 1;
- if (namelen > MAX_NAME_SIZE)
- {
- *errorcodeptr = ERR48;
- goto FAILED;
- }
- }
-
- /* Scan the list to check for duplicates. For duplicate names, if the
- number is the same, break the loop, which causes the name to be
- discarded; otherwise, if DUPNAMES is not set, give an error.
- If it is set, allow the name with a different number, but continue
- scanning in case this is a duplicate with the same number. For
- non-duplicate names, give an error if the number is duplicated. */
-
- ng = cd->named_groups;
- for (i = 0; i < cd->names_found; i++, ng++)
- {
- if (namelen == ng->length &&
- STRNCMP_UC_UC(name, ng->name, namelen) == 0)
- {
- if (ng->number == number) break;
- if ((options & PCRE_DUPNAMES) == 0)
- {
- *errorcodeptr = ERR43;
- goto FAILED;
- }
- cd->dupnames = TRUE; /* Duplicate names exist */
- }
- else if (ng->number == number)
- {
- *errorcodeptr = ERR65;
- goto FAILED;
- }
- }
-
- if (i >= cd->names_found) /* Not a duplicate with same number */
- {
- /* Increase the list size if necessary */
-
- if (cd->names_found >= cd->named_group_list_size)
- {
- int newsize = cd->named_group_list_size * 2;
- named_group *newspace = (PUBL(malloc))
- (newsize * sizeof(named_group));
-
- if (newspace == NULL)
- {
- *errorcodeptr = ERR21;
- goto FAILED;
- }
-
- memcpy(newspace, cd->named_groups,
- cd->named_group_list_size * sizeof(named_group));
- if (cd->named_group_list_size > NAMED_GROUP_LIST_SIZE)
- (PUBL(free))((void *)cd->named_groups);
- cd->named_groups = newspace;
- cd->named_group_list_size = newsize;
- }
-
- cd->named_groups[cd->names_found].name = name;
- cd->named_groups[cd->names_found].length = namelen;
- cd->named_groups[cd->names_found].number = number;
- cd->names_found++;
- }
- }
-
- ptr++; /* Move past > or ' in both passes. */
- goto NUMBERED_GROUP;
-
-
- /* ------------------------------------------------------------ */
- case CHAR_AMPERSAND: /* Perl recursion/subroutine syntax */
- terminator = CHAR_RIGHT_PARENTHESIS;
- is_recurse = TRUE;
- /* Fall through */
-
- /* We come here from the Python syntax above that handles both
- references (?P=name) and recursion (?P>name), as well as falling
- through from the Perl recursion syntax (?&name). We also come here from
- the Perl \k or \k'name' back reference syntax and the \k{name}
- .NET syntax, and the Oniguruma \g<...> and \g'...' subroutine syntax. */
-
- NAMED_REF_OR_RECURSE:
- name = ++ptr;
- if (IS_DIGIT(*ptr))
- {
- *errorcodeptr = ERR84; /* Group name must start with non-digit */
- goto FAILED;
- }
- while (MAX_255(*ptr) && (cd->ctypes[*ptr] & ctype_word) != 0) ptr++;
- namelen = (int)(ptr - name);
-
- /* In the pre-compile phase, do a syntax check. We used to just set
- a dummy reference number, because it was not used in the first pass.
- However, with the change of recursive back references to be atomic,
- we have to look for the number so that this state can be identified, as
- otherwise the incorrect length is computed. If it's not a backwards
- reference, the dummy number will do. */
-
- if (lengthptr != NULL)
- {
- named_group *ng;
- recno = 0;
-
- if (namelen == 0)
- {
- *errorcodeptr = ERR62;
- goto FAILED;
- }
- if (*ptr != (pcre_uchar)terminator)
- {
- *errorcodeptr = ERR42;
- goto FAILED;
- }
- if (namelen > MAX_NAME_SIZE)
- {
- *errorcodeptr = ERR48;
- goto FAILED;
- }
-
- /* Count named back references. */
-
- if (!is_recurse) cd->namedrefcount++;
-
- /* We have to allow for a named reference to a duplicated name (this
- cannot be determined until the second pass). This needs an extra
- 16-bit data item. */
-
- *lengthptr += IMM2_SIZE;
-
- /* If this is a forward reference and we are within a (?|...) group,
- the reference may end up as the number of a group which we are
- currently inside, that is, it could be a recursive reference. In the
- real compile this will be picked up and the reference wrapped with
- OP_ONCE to make it atomic, so we must space in case this occurs. */
-
- /* In fact, this can happen for a non-forward reference because
- another group with the same number might be created later. This
- issue is fixed "properly" in PCRE2. As PCRE1 is now in maintenance
- only mode, we finesse the bug by allowing more memory always. */
-
- *lengthptr += 2 + 2*LINK_SIZE;
-
- /* It is even worse than that. The current reference may be to an
- existing named group with a different number (so apparently not
- recursive) but which later on is also attached to a group with the
- current number. This can only happen if $(| has been previous
- encountered. In that case, we allow yet more memory, just in case.
- (Again, this is fixed "properly" in PCRE2. */
-
- if (cd->dupgroups) *lengthptr += 4 + 4*LINK_SIZE;
-
- /* Otherwise, check for recursion here. The name table does not exist
- in the first pass; instead we must scan the list of names encountered
- so far in order to get the number. If the name is not found, leave
- the value of recno as 0 for a forward reference. */
-
- else
- {
- ng = cd->named_groups;
- for (i = 0; i < cd->names_found; i++, ng++)
- {
- if (namelen == ng->length &&
- STRNCMP_UC_UC(name, ng->name, namelen) == 0)
- {
- open_capitem *oc;
- recno = ng->number;
- if (is_recurse) break;
- for (oc = cd->open_caps; oc != NULL; oc = oc->next)
- {
- if (oc->number == recno)
- {
- oc->flag = TRUE;
- break;
- }
- }
- }
- }
- }
- }
-
- /* In the real compile, search the name table. We check the name
- first, and then check that we have reached the end of the name in the
- table. That way, if the name is longer than any in the table, the
- comparison will fail without reading beyond the table entry. */
-
- else
- {
- slot = cd->name_table;
- for (i = 0; i < cd->names_found; i++)
- {
- if (STRNCMP_UC_UC(name, slot+IMM2_SIZE, namelen) == 0 &&
- slot[IMM2_SIZE+namelen] == 0)
- break;
- slot += cd->name_entry_size;
- }
-
- if (i < cd->names_found)
- {
- recno = GET2(slot, 0);
- }
- else
- {
- *errorcodeptr = ERR15;
- goto FAILED;
- }
- }
-
- /* In both phases, for recursions, we can now go to the code than
- handles numerical recursion. */
-
- if (is_recurse) goto HANDLE_RECURSION;
-
- /* In the second pass we must see if the name is duplicated. If so, we
- generate a different opcode. */
-
- if (lengthptr == NULL && cd->dupnames)
- {
- int count = 1;
- unsigned int index = i;
- pcre_uchar *cslot = slot + cd->name_entry_size;
-
- for (i++; i < cd->names_found; i++)
- {
- if (STRCMP_UC_UC(slot + IMM2_SIZE, cslot + IMM2_SIZE) != 0) break;
- count++;
- cslot += cd->name_entry_size;
- }
-
- if (count > 1)
- {
- if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
- previous = code;
- item_hwm_offset = cd->hwm - cd->start_workspace;
- *code++ = ((options & PCRE_CASELESS) != 0)? OP_DNREFI : OP_DNREF;
- PUT2INC(code, 0, index);
- PUT2INC(code, 0, count);
-
- /* Process each potentially referenced group. */
-
- for (; slot < cslot; slot += cd->name_entry_size)
- {
- open_capitem *oc;
- recno = GET2(slot, 0);
- cd->backref_map |= (recno < 32)? (1 << recno) : 1;
- if (recno > cd->top_backref) cd->top_backref = recno;
-
- /* Check to see if this back reference is recursive, that it, it
- is inside the group that it references. A flag is set so that the
- group can be made atomic. */
-
- for (oc = cd->open_caps; oc != NULL; oc = oc->next)
- {
- if (oc->number == recno)
- {
- oc->flag = TRUE;
- break;
- }
- }
- }
-
- continue; /* End of back ref handling */
- }
- }
-
- /* First pass, or a non-duplicated name. */
-
- goto HANDLE_REFERENCE;
-
-
- /* ------------------------------------------------------------ */
- case CHAR_R: /* Recursion, same as (?0) */
- recno = 0;
- if (*(++ptr) != CHAR_RIGHT_PARENTHESIS)
- {
- *errorcodeptr = ERR29;
- goto FAILED;
- }
- goto HANDLE_RECURSION;
-
-
- /* ------------------------------------------------------------ */
- case CHAR_MINUS: case CHAR_PLUS: /* Recursion or subroutine */
- case CHAR_0: case CHAR_1: case CHAR_2: case CHAR_3: case CHAR_4:
- case CHAR_5: case CHAR_6: case CHAR_7: case CHAR_8: case CHAR_9:
- {
- const pcre_uchar *called;
- terminator = CHAR_RIGHT_PARENTHESIS;
-
- /* Come here from the \g<...> and \g'...' code (Oniguruma
- compatibility). However, the syntax has been checked to ensure that
- the ... are a (signed) number, so that neither ERR63 nor ERR29 will
- be called on this path, nor with the jump to OTHER_CHAR_AFTER_QUERY
- ever be taken. */
-
- HANDLE_NUMERICAL_RECURSION:
-
- if ((refsign = *ptr) == CHAR_PLUS)
- {
- ptr++;
- if (!IS_DIGIT(*ptr))
- {
- *errorcodeptr = ERR63;
- goto FAILED;
- }
- }
- else if (refsign == CHAR_MINUS)
- {
- if (!IS_DIGIT(ptr[1]))
- goto OTHER_CHAR_AFTER_QUERY;
- ptr++;
- }
-
- recno = 0;
- while(IS_DIGIT(*ptr))
- {
- if (recno > INT_MAX / 10 - 1) /* Integer overflow */
- {
- while (IS_DIGIT(*ptr)) ptr++;
- *errorcodeptr = ERR61;
- goto FAILED;
- }
- recno = recno * 10 + *ptr++ - CHAR_0;
- }
-
- if (*ptr != (pcre_uchar)terminator)
- {
- *errorcodeptr = ERR29;
- goto FAILED;
- }
-
- if (refsign == CHAR_MINUS)
- {
- if (recno == 0)
- {
- *errorcodeptr = ERR58;
- goto FAILED;
- }
- recno = cd->bracount - recno + 1;
- if (recno <= 0)
- {
- *errorcodeptr = ERR15;
- goto FAILED;
- }
- }
- else if (refsign == CHAR_PLUS)
- {
- if (recno == 0)
- {
- *errorcodeptr = ERR58;
- goto FAILED;
- }
- recno += cd->bracount;
- }
-
- /* Come here from code above that handles a named recursion */
-
- HANDLE_RECURSION:
-
- previous = code;
- item_hwm_offset = cd->hwm - cd->start_workspace;
- called = cd->start_code;
-
- /* When we are actually compiling, find the bracket that is being
- referenced. Temporarily end the regex in case it doesn't exist before
- this point. If we end up with a forward reference, first check that
- the bracket does occur later so we can give the error (and position)
- now. Then remember this forward reference in the workspace so it can
- be filled in at the end. */
-
- if (lengthptr == NULL)
- {
- *code = OP_END;
- if (recno != 0)
- called = PRIV(find_bracket)(cd->start_code, utf, recno);
-
- /* Forward reference */
-
- if (called == NULL)
- {
- if (recno > cd->final_bracount)
- {
- *errorcodeptr = ERR15;
- goto FAILED;
- }
-
- /* Fudge the value of "called" so that when it is inserted as an
- offset below, what it actually inserted is the reference number
- of the group. Then remember the forward reference. */
-
- called = cd->start_code + recno;
- if (cd->hwm >= cd->start_workspace + cd->workspace_size -
- WORK_SIZE_SAFETY_MARGIN)
- {
- *errorcodeptr = expand_workspace(cd);
- if (*errorcodeptr != 0) goto FAILED;
- }
- PUTINC(cd->hwm, 0, (int)(code + 1 - cd->start_code));
- }
-
- /* If not a forward reference, and the subpattern is still open,
- this is a recursive call. We check to see if this is a left
- recursion that could loop for ever, and diagnose that case. We
- must not, however, do this check if we are in a conditional
- subpattern because the condition might be testing for recursion in
- a pattern such as /(?(R)a+|(?R)b)/, which is perfectly valid.
- Forever loops are also detected at runtime, so those that occur in
- conditional subpatterns will be picked up then. */
-
- else if (GET(called, 1) == 0 && cond_depth <= 0 &&
- could_be_empty(called, code, bcptr, utf, cd))
- {
- *errorcodeptr = ERR40;
- goto FAILED;
- }
- }
-
- /* Insert the recursion/subroutine item. It does not have a set first
- character (relevant if it is repeated, because it will then be
- wrapped with ONCE brackets). */
-
- *code = OP_RECURSE;
- PUT(code, 1, (int)(called - cd->start_code));
- code += 1 + LINK_SIZE;
- groupsetfirstchar = FALSE;
- }
-
- /* Can't determine a first byte now */
-
- if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
- continue;
-
-
- /* ------------------------------------------------------------ */
- default: /* Other characters: check option setting */
- OTHER_CHAR_AFTER_QUERY:
- set = unset = 0;
- optset = &set;
-
- while (*ptr != CHAR_RIGHT_PARENTHESIS && *ptr != CHAR_COLON)
- {
- switch (*ptr++)
- {
- case CHAR_MINUS: optset = &unset; break;
-
- case CHAR_J: /* Record that it changed in the external options */
- *optset |= PCRE_DUPNAMES;
- cd->external_flags |= PCRE_JCHANGED;
- break;
-
- case CHAR_i: *optset |= PCRE_CASELESS; break;
- case CHAR_m: *optset |= PCRE_MULTILINE; break;
- case CHAR_s: *optset |= PCRE_DOTALL; break;
- case CHAR_x: *optset |= PCRE_EXTENDED; break;
- case CHAR_U: *optset |= PCRE_UNGREEDY; break;
- case CHAR_X: *optset |= PCRE_EXTRA; break;
-
- default: *errorcodeptr = ERR12;
- ptr--; /* Correct the offset */
- goto FAILED;
- }
- }
-
- /* Set up the changed option bits, but don't change anything yet. */
-
- newoptions = (options | set) & (~unset);
-
- /* If the options ended with ')' this is not the start of a nested
- group with option changes, so the options change at this level. If this
- item is right at the start of the pattern, the options can be
- abstracted and made external in the pre-compile phase, and ignored in
- the compile phase. This can be helpful when matching -- for instance in
- caseless checking of required bytes.
-
- If the code pointer is not (cd->start_code + 1 + LINK_SIZE), we are
- definitely *not* at the start of the pattern because something has been
- compiled. In the pre-compile phase, however, the code pointer can have
- that value after the start, because it gets reset as code is discarded
- during the pre-compile. However, this can happen only at top level - if
- we are within parentheses, the starting BRA will still be present. At
- any parenthesis level, the length value can be used to test if anything
- has been compiled at that level. Thus, a test for both these conditions
- is necessary to ensure we correctly detect the start of the pattern in
- both phases.
-
- If we are not at the pattern start, reset the greedy defaults and the
- case value for firstchar and reqchar. */
-
- if (*ptr == CHAR_RIGHT_PARENTHESIS)
- {
- if (code == cd->start_code + 1 + LINK_SIZE &&
- (lengthptr == NULL || *lengthptr == 2 + 2*LINK_SIZE))
- {
- cd->external_options = newoptions;
- }
- else
- {
- greedy_default = ((newoptions & PCRE_UNGREEDY) != 0);
- greedy_non_default = greedy_default ^ 1;
- req_caseopt = ((newoptions & PCRE_CASELESS) != 0)? REQ_CASELESS:0;
- }
-
- /* Change options at this level, and pass them back for use
- in subsequent branches. */
-
- *optionsptr = options = newoptions;
- previous = NULL; /* This item can't be repeated */
- continue; /* It is complete */
- }
-
- /* If the options ended with ':' we are heading into a nested group
- with possible change of options. Such groups are non-capturing and are
- not assertions of any kind. All we need to do is skip over the ':';
- the newoptions value is handled below. */
-
- bravalue = OP_BRA;
- ptr++;
- } /* End of switch for character following (? */
- } /* End of (? handling */
-
- /* Opening parenthesis not followed by '*' or '?'. If PCRE_NO_AUTO_CAPTURE
- is set, all unadorned brackets become non-capturing and behave like (?:...)
- brackets. */
-
- else if ((options & PCRE_NO_AUTO_CAPTURE) != 0)
- {
- bravalue = OP_BRA;
- }
-
- /* Else we have a capturing group. */
-
- else
- {
- NUMBERED_GROUP:
- cd->bracount += 1;
- PUT2(code, 1+LINK_SIZE, cd->bracount);
- skipbytes = IMM2_SIZE;
- }
-
- /* Process nested bracketed regex. First check for parentheses nested too
- deeply. */
-
- if ((cd->parens_depth += 1) > PARENS_NEST_LIMIT)
- {
- *errorcodeptr = ERR82;
- goto FAILED;
- }
-
- /* All assertions used not to be repeatable, but this was changed for Perl
- compatibility. All kinds can now be repeated except for assertions that are
- conditions (Perl also forbids these to be repeated). We copy code into a
- non-register variable (tempcode) in order to be able to pass its address
- because some compilers complain otherwise. At the start of a conditional
- group whose condition is an assertion, cd->iscondassert is set. We unset it
- here so as to allow assertions later in the group to be quantified. */
-
- if (bravalue >= OP_ASSERT && bravalue <= OP_ASSERTBACK_NOT &&
- cd->iscondassert)
- {
- previous = NULL;
- cd->iscondassert = FALSE;
- }
- else
- {
- previous = code;
- item_hwm_offset = cd->hwm - cd->start_workspace;
- }
-
- *code = bravalue;
- tempcode = code;
- tempreqvary = cd->req_varyopt; /* Save value before bracket */
- tempbracount = cd->bracount; /* Save value before bracket */
- length_prevgroup = 0; /* Initialize for pre-compile phase */
-
- if (!compile_regex(
- newoptions, /* The complete new option state */
- &tempcode, /* Where to put code (updated) */
- &ptr, /* Input pointer (updated) */
- errorcodeptr, /* Where to put an error message */
- (bravalue == OP_ASSERTBACK ||
- bravalue == OP_ASSERTBACK_NOT), /* TRUE if back assert */
- reset_bracount, /* True if (?| group */
- skipbytes, /* Skip over bracket number */
- cond_depth +
- ((bravalue == OP_COND)?1:0), /* Depth of condition subpatterns */
- &subfirstchar, /* For possible first char */
- &subfirstcharflags,
- &subreqchar, /* For possible last char */
- &subreqcharflags,
- bcptr, /* Current branch chain */
- cd, /* Tables block */
- (lengthptr == NULL)? NULL : /* Actual compile phase */
- &length_prevgroup /* Pre-compile phase */
- ))
- goto FAILED;
-
- cd->parens_depth -= 1;
-
- /* If this was an atomic group and there are no capturing groups within it,
- generate OP_ONCE_NC instead of OP_ONCE. */
-
- if (bravalue == OP_ONCE && cd->bracount <= tempbracount)
- *code = OP_ONCE_NC;
-
- if (bravalue >= OP_ASSERT && bravalue <= OP_ASSERTBACK_NOT)
- cd->assert_depth -= 1;
-
- /* At the end of compiling, code is still pointing to the start of the
- group, while tempcode has been updated to point past the end of the group.
- The pattern pointer (ptr) is on the bracket.
-
- If this is a conditional bracket, check that there are no more than
- two branches in the group, or just one if it's a DEFINE group. We do this
- in the real compile phase, not in the pre-pass, where the whole group may
- not be available. */
-
- if (bravalue == OP_COND && lengthptr == NULL)
- {
- pcre_uchar *tc = code;
- int condcount = 0;
-
- do {
- condcount++;
- tc += GET(tc,1);
- }
- while (*tc != OP_KET);
-
- /* A DEFINE group is never obeyed inline (the "condition" is always
- false). It must have only one branch. */
-
- if (code[LINK_SIZE+1] == OP_DEF)
- {
- if (condcount > 1)
- {
- *errorcodeptr = ERR54;
- goto FAILED;
- }
- bravalue = OP_DEF; /* Just a flag to suppress char handling below */
- }
-
- /* A "normal" conditional group. If there is just one branch, we must not
- make use of its firstchar or reqchar, because this is equivalent to an
- empty second branch. */
-
- else
- {
- if (condcount > 2)
- {
- *errorcodeptr = ERR27;
- goto FAILED;
- }
- if (condcount == 1) subfirstcharflags = subreqcharflags = REQ_NONE;
- }
- }
-
- /* Error if hit end of pattern */
-
- if (*ptr != CHAR_RIGHT_PARENTHESIS)
- {
- *errorcodeptr = ERR14;
- goto FAILED;
- }
-
- /* In the pre-compile phase, update the length by the length of the group,
- less the brackets at either end. Then reduce the compiled code to just a
- set of non-capturing brackets so that it doesn't use much memory if it is
- duplicated by a quantifier.*/
-
- if (lengthptr != NULL)
- {
- if (OFLOW_MAX - *lengthptr < length_prevgroup - 2 - 2*LINK_SIZE)
- {
- *errorcodeptr = ERR20;
- goto FAILED;
- }
- *lengthptr += length_prevgroup - 2 - 2*LINK_SIZE;
- code++; /* This already contains bravalue */
- PUTINC(code, 0, 1 + LINK_SIZE);
- *code++ = OP_KET;
- PUTINC(code, 0, 1 + LINK_SIZE);
- break; /* No need to waste time with special character handling */
- }
-
- /* Otherwise update the main code pointer to the end of the group. */
-
- code = tempcode;
-
- /* For a DEFINE group, required and first character settings are not
- relevant. */
-
- if (bravalue == OP_DEF) break;
-
- /* Handle updating of the required and first characters for other types of
- group. Update for normal brackets of all kinds, and conditions with two
- branches (see code above). If the bracket is followed by a quantifier with
- zero repeat, we have to back off. Hence the definition of zeroreqchar and
- zerofirstchar outside the main loop so that they can be accessed for the
- back off. */
-
- zeroreqchar = reqchar;
- zeroreqcharflags = reqcharflags;
- zerofirstchar = firstchar;
- zerofirstcharflags = firstcharflags;
- groupsetfirstchar = FALSE;
-
- if (bravalue >= OP_ONCE)
- {
- /* If we have not yet set a firstchar in this branch, take it from the
- subpattern, remembering that it was set here so that a repeat of more
- than one can replicate it as reqchar if necessary. If the subpattern has
- no firstchar, set "none" for the whole branch. In both cases, a zero
- repeat forces firstchar to "none". */
-
- if (firstcharflags == REQ_UNSET)
- {
- if (subfirstcharflags >= 0)
- {
- firstchar = subfirstchar;
- firstcharflags = subfirstcharflags;
- groupsetfirstchar = TRUE;
- }
- else firstcharflags = REQ_NONE;
- zerofirstcharflags = REQ_NONE;
- }
-
- /* If firstchar was previously set, convert the subpattern's firstchar
- into reqchar if there wasn't one, using the vary flag that was in
- existence beforehand. */
-
- else if (subfirstcharflags >= 0 && subreqcharflags < 0)
- {
- subreqchar = subfirstchar;
- subreqcharflags = subfirstcharflags | tempreqvary;
- }
-
- /* If the subpattern set a required byte (or set a first byte that isn't
- really the first byte - see above), set it. */
-
- if (subreqcharflags >= 0)
- {
- reqchar = subreqchar;
- reqcharflags = subreqcharflags;
- }
- }
-
- /* For a forward assertion, we take the reqchar, if set. This can be
- helpful if the pattern that follows the assertion doesn't set a different
- char. For example, it's useful for /(?=abcde).+/. We can't set firstchar
- for an assertion, however because it leads to incorrect effect for patterns
- such as /(?=a)a.+/ when the "real" "a" would then become a reqchar instead
- of a firstchar. This is overcome by a scan at the end if there's no
- firstchar, looking for an asserted first char. */
-
- else if (bravalue == OP_ASSERT && subreqcharflags >= 0)
- {
- reqchar = subreqchar;
- reqcharflags = subreqcharflags;
- }
- break; /* End of processing '(' */
-
-
- /* ===================================================================*/
- /* Handle metasequences introduced by \. For ones like \d, the ESC_ values
- are arranged to be the negation of the corresponding OP_values in the
- default case when PCRE_UCP is not set. For the back references, the values
- are negative the reference number. Only back references and those types
- that consume a character may be repeated. We can test for values between
- ESC_b and ESC_Z for the latter; this may have to change if any new ones are
- ever created. */
-
- case CHAR_BACKSLASH:
- tempptr = ptr;
- escape = check_escape(&ptr, &ec, errorcodeptr, cd->bracount, options, FALSE);
- if (*errorcodeptr != 0) goto FAILED;
-
- if (escape == 0) /* The escape coded a single character */
- c = ec;
- else
- {
- if (escape == ESC_Q) /* Handle start of quoted string */
- {
- if (ptr[1] == CHAR_BACKSLASH && ptr[2] == CHAR_E)
- ptr += 2; /* avoid empty string */
- else inescq = TRUE;
- continue;
- }
-
- if (escape == ESC_E) continue; /* Perl ignores an orphan \E */
-
- /* For metasequences that actually match a character, we disable the
- setting of a first character if it hasn't already been set. */
-
- if (firstcharflags == REQ_UNSET && escape > ESC_b && escape < ESC_Z)
- firstcharflags = REQ_NONE;
-
- /* Set values to reset to if this is followed by a zero repeat. */
-
- zerofirstchar = firstchar;
- zerofirstcharflags = firstcharflags;
- zeroreqchar = reqchar;
- zeroreqcharflags = reqcharflags;
-
- /* \g or \g'name' is a subroutine call by name and \g or \g'n'
- is a subroutine call by number (Oniguruma syntax). In fact, the value
- ESC_g is returned only for these cases. So we don't need to check for <
- or ' if the value is ESC_g. For the Perl syntax \g{n} the value is
- -n, and for the Perl syntax \g{name} the result is ESC_k (as
- that is a synonym for a named back reference). */
-
- if (escape == ESC_g)
- {
- const pcre_uchar *p;
- pcre_uint32 cf;
-
- item_hwm_offset = cd->hwm - cd->start_workspace; /* Normally this is set when '(' is read */
- terminator = (*(++ptr) == CHAR_LESS_THAN_SIGN)?
- CHAR_GREATER_THAN_SIGN : CHAR_APOSTROPHE;
-
- /* These two statements stop the compiler for warning about possibly
- unset variables caused by the jump to HANDLE_NUMERICAL_RECURSION. In
- fact, because we do the check for a number below, the paths that
- would actually be in error are never taken. */
-
- skipbytes = 0;
- reset_bracount = FALSE;
-
- /* If it's not a signed or unsigned number, treat it as a name. */
-
- cf = ptr[1];
- if (cf != CHAR_PLUS && cf != CHAR_MINUS && !IS_DIGIT(cf))
- {
- is_recurse = TRUE;
- goto NAMED_REF_OR_RECURSE;
- }
-
- /* Signed or unsigned number (cf = ptr[1]) is known to be plus or minus
- or a digit. */
-
- p = ptr + 2;
- while (IS_DIGIT(*p)) p++;
- if (*p != (pcre_uchar)terminator)
- {
- *errorcodeptr = ERR57;
- goto FAILED;
- }
- ptr++;
- goto HANDLE_NUMERICAL_RECURSION;
- }
-
- /* \k or \k'name' is a back reference by name (Perl syntax).
- We also support \k{name} (.NET syntax). */
-
- if (escape == ESC_k)
- {
- if ((ptr[1] != CHAR_LESS_THAN_SIGN &&
- ptr[1] != CHAR_APOSTROPHE && ptr[1] != CHAR_LEFT_CURLY_BRACKET))
- {
- *errorcodeptr = ERR69;
- goto FAILED;
- }
- is_recurse = FALSE;
- terminator = (*(++ptr) == CHAR_LESS_THAN_SIGN)?
- CHAR_GREATER_THAN_SIGN : (*ptr == CHAR_APOSTROPHE)?
- CHAR_APOSTROPHE : CHAR_RIGHT_CURLY_BRACKET;
- goto NAMED_REF_OR_RECURSE;
- }
-
- /* Back references are handled specially; must disable firstchar if
- not set to cope with cases like (?=(\w+))\1: which would otherwise set
- ':' later. */
-
- if (escape < 0)
- {
- open_capitem *oc;
- recno = -escape;
-
- /* Come here from named backref handling when the reference is to a
- single group (i.e. not to a duplicated name. */
-
- HANDLE_REFERENCE:
- if (firstcharflags == REQ_UNSET) firstcharflags = REQ_NONE;
- previous = code;
- item_hwm_offset = cd->hwm - cd->start_workspace;
- *code++ = ((options & PCRE_CASELESS) != 0)? OP_REFI : OP_REF;
- PUT2INC(code, 0, recno);
- cd->backref_map |= (recno < 32)? (1 << recno) : 1;
- if (recno > cd->top_backref) cd->top_backref = recno;
-
- /* Check to see if this back reference is recursive, that it, it
- is inside the group that it references. A flag is set so that the
- group can be made atomic. */
-
- for (oc = cd->open_caps; oc != NULL; oc = oc->next)
- {
- if (oc->number == recno)
- {
- oc->flag = TRUE;
- break;
- }
- }
- }
-
- /* So are Unicode property matches, if supported. */
-
-#ifdef SUPPORT_UCP
- else if (escape == ESC_P || escape == ESC_p)
- {
- BOOL negated;
- unsigned int ptype = 0, pdata = 0;
- if (!get_ucp(&ptr, &negated, &ptype, &pdata, errorcodeptr))
- goto FAILED;
- previous = code;
- item_hwm_offset = cd->hwm - cd->start_workspace;
- *code++ = ((escape == ESC_p) != negated)? OP_PROP : OP_NOTPROP;
- *code++ = ptype;
- *code++ = pdata;
- }
-#else
-
- /* If Unicode properties are not supported, \X, \P, and \p are not
- allowed. */
-
- else if (escape == ESC_X || escape == ESC_P || escape == ESC_p)
- {
- *errorcodeptr = ERR45;
- goto FAILED;
- }
-#endif
-
- /* For the rest (including \X when Unicode properties are supported), we
- can obtain the OP value by negating the escape value in the default
- situation when PCRE_UCP is not set. When it *is* set, we substitute
- Unicode property tests. Note that \b and \B do a one-character
- lookbehind, and \A also behaves as if it does. */
-
- else
- {
- if ((escape == ESC_b || escape == ESC_B || escape == ESC_A) &&
- cd->max_lookbehind == 0)
- cd->max_lookbehind = 1;
-#ifdef SUPPORT_UCP
- if (escape >= ESC_DU && escape <= ESC_wu)
- {
- nestptr = ptr + 1; /* Where to resume */
- ptr = substitutes[escape - ESC_DU] - 1; /* Just before substitute */
- }
- else
-#endif
- /* In non-UTF-8 mode, we turn \C into OP_ALLANY instead of OP_ANYBYTE
- so that it works in DFA mode and in lookbehinds. */
-
- {
- previous = (escape > ESC_b && escape < ESC_Z)? code : NULL;
- item_hwm_offset = cd->hwm - cd->start_workspace;
- *code++ = (!utf && escape == ESC_C)? OP_ALLANY : escape;
- }
- }
- continue;
- }
-
- /* We have a data character whose value is in c. In UTF-8 mode it may have
- a value > 127. We set its representation in the length/buffer, and then
- handle it as a data character. */
-
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (utf && c > MAX_VALUE_FOR_SINGLE_CHAR)
- mclength = PRIV(ord2utf)(c, mcbuffer);
- else
-#endif
-
- {
- mcbuffer[0] = c;
- mclength = 1;
- }
- goto ONE_CHAR;
-
-
- /* ===================================================================*/
- /* Handle a literal character. It is guaranteed not to be whitespace or #
- when the extended flag is set. If we are in a UTF mode, it may be a
- multi-unit literal character. */
-
- default:
- NORMAL_CHAR:
- mclength = 1;
- mcbuffer[0] = c;
-
-#ifdef SUPPORT_UTF
- if (utf && HAS_EXTRALEN(c))
- ACROSSCHAR(TRUE, ptr[1], mcbuffer[mclength++] = *(++ptr));
-#endif
-
- /* At this point we have the character's bytes in mcbuffer, and the length
- in mclength. When not in UTF-8 mode, the length is always 1. */
-
- ONE_CHAR:
- previous = code;
- item_hwm_offset = cd->hwm - cd->start_workspace;
-
- /* For caseless UTF-8 mode when UCP support is available, check whether
- this character has more than one other case. If so, generate a special
- OP_PROP item instead of OP_CHARI. */
-
-#ifdef SUPPORT_UCP
- if (utf && (options & PCRE_CASELESS) != 0)
- {
- GETCHAR(c, mcbuffer);
- if ((c = UCD_CASESET(c)) != 0)
- {
- *code++ = OP_PROP;
- *code++ = PT_CLIST;
- *code++ = c;
- if (firstcharflags == REQ_UNSET)
- firstcharflags = zerofirstcharflags = REQ_NONE;
- break;
- }
- }
-#endif
-
- /* Caseful matches, or not one of the multicase characters. */
-
- *code++ = ((options & PCRE_CASELESS) != 0)? OP_CHARI : OP_CHAR;
- for (c = 0; c < mclength; c++) *code++ = mcbuffer[c];
-
- /* Remember if \r or \n were seen */
-
- if (mcbuffer[0] == CHAR_CR || mcbuffer[0] == CHAR_NL)
- cd->external_flags |= PCRE_HASCRORLF;
-
- /* Set the first and required bytes appropriately. If no previous first
- byte, set it from this character, but revert to none on a zero repeat.
- Otherwise, leave the firstchar value alone, and don't change it on a zero
- repeat. */
-
- if (firstcharflags == REQ_UNSET)
- {
- zerofirstcharflags = REQ_NONE;
- zeroreqchar = reqchar;
- zeroreqcharflags = reqcharflags;
-
- /* If the character is more than one byte long, we can set firstchar
- only if it is not to be matched caselessly. */
-
- if (mclength == 1 || req_caseopt == 0)
- {
- firstchar = mcbuffer[0] | req_caseopt;
- firstchar = mcbuffer[0];
- firstcharflags = req_caseopt;
-
- if (mclength != 1)
- {
- reqchar = code[-1];
- reqcharflags = cd->req_varyopt;
- }
- }
- else firstcharflags = reqcharflags = REQ_NONE;
- }
-
- /* firstchar was previously set; we can set reqchar only if the length is
- 1 or the matching is caseful. */
-
- else
- {
- zerofirstchar = firstchar;
- zerofirstcharflags = firstcharflags;
- zeroreqchar = reqchar;
- zeroreqcharflags = reqcharflags;
- if (mclength == 1 || req_caseopt == 0)
- {
- reqchar = code[-1];
- reqcharflags = req_caseopt | cd->req_varyopt;
- }
- }
-
- break; /* End of literal character handling */
- }
- } /* end of big loop */
-
-
-/* Control never reaches here by falling through, only by a goto for all the
-error states. Pass back the position in the pattern so that it can be displayed
-to the user for diagnosing the error. */
-
-FAILED:
-*ptrptr = ptr;
-return FALSE;
-}
-
-
-
-/*************************************************
-* Compile sequence of alternatives *
-*************************************************/
-
-/* On entry, ptr is pointing past the bracket character, but on return it
-points to the closing bracket, or vertical bar, or end of string. The code
-variable is pointing at the byte into which the BRA operator has been stored.
-This function is used during the pre-compile phase when we are trying to find
-out the amount of memory needed, as well as during the real compile phase. The
-value of lengthptr distinguishes the two phases.
-
-Arguments:
- options option bits, including any changes for this subpattern
- codeptr -> the address of the current code pointer
- ptrptr -> the address of the current pattern pointer
- errorcodeptr -> pointer to error code variable
- lookbehind TRUE if this is a lookbehind assertion
- reset_bracount TRUE to reset the count for each branch
- skipbytes skip this many bytes at start (for brackets and OP_COND)
- cond_depth depth of nesting for conditional subpatterns
- firstcharptr place to put the first required character
- firstcharflagsptr place to put the first character flags, or a negative number
- reqcharptr place to put the last required character
- reqcharflagsptr place to put the last required character flags, or a negative number
- bcptr pointer to the chain of currently open branches
- cd points to the data block with tables pointers etc.
- lengthptr NULL during the real compile phase
- points to length accumulator during pre-compile phase
-
-Returns: TRUE on success
-*/
-
-static BOOL
-compile_regex(int options, pcre_uchar **codeptr, const pcre_uchar **ptrptr,
- int *errorcodeptr, BOOL lookbehind, BOOL reset_bracount, int skipbytes,
- int cond_depth,
- pcre_uint32 *firstcharptr, pcre_int32 *firstcharflagsptr,
- pcre_uint32 *reqcharptr, pcre_int32 *reqcharflagsptr,
- branch_chain *bcptr, compile_data *cd, int *lengthptr)
-{
-const pcre_uchar *ptr = *ptrptr;
-pcre_uchar *code = *codeptr;
-pcre_uchar *last_branch = code;
-pcre_uchar *start_bracket = code;
-pcre_uchar *reverse_count = NULL;
-open_capitem capitem;
-int capnumber = 0;
-pcre_uint32 firstchar, reqchar;
-pcre_int32 firstcharflags, reqcharflags;
-pcre_uint32 branchfirstchar, branchreqchar;
-pcre_int32 branchfirstcharflags, branchreqcharflags;
-int length;
-unsigned int orig_bracount;
-unsigned int max_bracount;
-branch_chain bc;
-size_t save_hwm_offset;
-
-/* If set, call the external function that checks for stack availability. */
-
-if (PUBL(stack_guard) != NULL && PUBL(stack_guard)())
- {
- *errorcodeptr= ERR85;
- return FALSE;
- }
-
-/* Miscellaneous initialization */
-
-bc.outer = bcptr;
-bc.current_branch = code;
-
-firstchar = reqchar = 0;
-firstcharflags = reqcharflags = REQ_UNSET;
-
-save_hwm_offset = cd->hwm - cd->start_workspace;
-
-/* Accumulate the length for use in the pre-compile phase. Start with the
-length of the BRA and KET and any extra bytes that are required at the
-beginning. We accumulate in a local variable to save frequent testing of
-lenthptr for NULL. We cannot do this by looking at the value of code at the
-start and end of each alternative, because compiled items are discarded during
-the pre-compile phase so that the work space is not exceeded. */
-
-length = 2 + 2*LINK_SIZE + skipbytes;
-
-/* WARNING: If the above line is changed for any reason, you must also change
-the code that abstracts option settings at the start of the pattern and makes
-them global. It tests the value of length for (2 + 2*LINK_SIZE) in the
-pre-compile phase to find out whether anything has yet been compiled or not. */
-
-/* If this is a capturing subpattern, add to the chain of open capturing items
-so that we can detect them if (*ACCEPT) is encountered. This is also used to
-detect groups that contain recursive back references to themselves. Note that
-only OP_CBRA need be tested here; changing this opcode to one of its variants,
-e.g. OP_SCBRAPOS, happens later, after the group has been compiled. */
-
-if (*code == OP_CBRA)
- {
- capnumber = GET2(code, 1 + LINK_SIZE);
- capitem.number = capnumber;
- capitem.next = cd->open_caps;
- capitem.flag = FALSE;
- cd->open_caps = &capitem;
- }
-
-/* Offset is set zero to mark that this bracket is still open */
-
-PUT(code, 1, 0);
-code += 1 + LINK_SIZE + skipbytes;
-
-/* Loop for each alternative branch */
-
-orig_bracount = max_bracount = cd->bracount;
-for (;;)
- {
- /* For a (?| group, reset the capturing bracket count so that each branch
- uses the same numbers. */
-
- if (reset_bracount) cd->bracount = orig_bracount;
-
- /* Set up dummy OP_REVERSE if lookbehind assertion */
-
- if (lookbehind)
- {
- *code++ = OP_REVERSE;
- reverse_count = code;
- PUTINC(code, 0, 0);
- length += 1 + LINK_SIZE;
- }
-
- /* Now compile the branch; in the pre-compile phase its length gets added
- into the length. */
-
- if (!compile_branch(&options, &code, &ptr, errorcodeptr, &branchfirstchar,
- &branchfirstcharflags, &branchreqchar, &branchreqcharflags, &bc,
- cond_depth, cd, (lengthptr == NULL)? NULL : &length))
- {
- *ptrptr = ptr;
- return FALSE;
- }
-
- /* Keep the highest bracket count in case (?| was used and some branch
- has fewer than the rest. */
-
- if (cd->bracount > max_bracount) max_bracount = cd->bracount;
-
- /* In the real compile phase, there is some post-processing to be done. */
-
- if (lengthptr == NULL)
- {
- /* If this is the first branch, the firstchar and reqchar values for the
- branch become the values for the regex. */
-
- if (*last_branch != OP_ALT)
- {
- firstchar = branchfirstchar;
- firstcharflags = branchfirstcharflags;
- reqchar = branchreqchar;
- reqcharflags = branchreqcharflags;
- }
-
- /* If this is not the first branch, the first char and reqchar have to
- match the values from all the previous branches, except that if the
- previous value for reqchar didn't have REQ_VARY set, it can still match,
- and we set REQ_VARY for the regex. */
-
- else
- {
- /* If we previously had a firstchar, but it doesn't match the new branch,
- we have to abandon the firstchar for the regex, but if there was
- previously no reqchar, it takes on the value of the old firstchar. */
-
- if (firstcharflags >= 0 &&
- (firstcharflags != branchfirstcharflags || firstchar != branchfirstchar))
- {
- if (reqcharflags < 0)
- {
- reqchar = firstchar;
- reqcharflags = firstcharflags;
- }
- firstcharflags = REQ_NONE;
- }
-
- /* If we (now or from before) have no firstchar, a firstchar from the
- branch becomes a reqchar if there isn't a branch reqchar. */
-
- if (firstcharflags < 0 && branchfirstcharflags >= 0 && branchreqcharflags < 0)
- {
- branchreqchar = branchfirstchar;
- branchreqcharflags = branchfirstcharflags;
- }
-
- /* Now ensure that the reqchars match */
-
- if (((reqcharflags & ~REQ_VARY) != (branchreqcharflags & ~REQ_VARY)) ||
- reqchar != branchreqchar)
- reqcharflags = REQ_NONE;
- else
- {
- reqchar = branchreqchar;
- reqcharflags |= branchreqcharflags; /* To "or" REQ_VARY */
- }
- }
-
- /* If lookbehind, check that this branch matches a fixed-length string, and
- put the length into the OP_REVERSE item. Temporarily mark the end of the
- branch with OP_END. If the branch contains OP_RECURSE, the result is -3
- because there may be forward references that we can't check here. Set a
- flag to cause another lookbehind check at the end. Why not do it all at the
- end? Because common, erroneous checks are picked up here and the offset of
- the problem can be shown. */
-
- if (lookbehind)
- {
- int fixed_length;
- *code = OP_END;
- fixed_length = find_fixedlength(last_branch, (options & PCRE_UTF8) != 0,
- FALSE, cd, NULL);
- DPRINTF(("fixed length = %d\n", fixed_length));
- if (fixed_length == -3)
- {
- cd->check_lookbehind = TRUE;
- }
- else if (fixed_length < 0)
- {
- *errorcodeptr = (fixed_length == -2)? ERR36 :
- (fixed_length == -4)? ERR70: ERR25;
- *ptrptr = ptr;
- return FALSE;
- }
- else
- {
- if (fixed_length > cd->max_lookbehind)
- cd->max_lookbehind = fixed_length;
- PUT(reverse_count, 0, fixed_length);
- }
- }
- }
-
- /* Reached end of expression, either ')' or end of pattern. In the real
- compile phase, go back through the alternative branches and reverse the chain
- of offsets, with the field in the BRA item now becoming an offset to the
- first alternative. If there are no alternatives, it points to the end of the
- group. The length in the terminating ket is always the length of the whole
- bracketed item. Return leaving the pointer at the terminating char. */
-
- if (*ptr != CHAR_VERTICAL_LINE)
- {
- if (lengthptr == NULL)
- {
- int branch_length = (int)(code - last_branch);
- do
- {
- int prev_length = GET(last_branch, 1);
- PUT(last_branch, 1, branch_length);
- branch_length = prev_length;
- last_branch -= branch_length;
- }
- while (branch_length > 0);
- }
-
- /* Fill in the ket */
-
- *code = OP_KET;
- PUT(code, 1, (int)(code - start_bracket));
- code += 1 + LINK_SIZE;
-
- /* If it was a capturing subpattern, check to see if it contained any
- recursive back references. If so, we must wrap it in atomic brackets.
- Because we are moving code along, we must ensure that any pending recursive
- references are updated. In any event, remove the block from the chain. */
-
- if (capnumber > 0)
- {
- if (cd->open_caps->flag)
- {
- *code = OP_END;
- adjust_recurse(start_bracket, 1 + LINK_SIZE,
- (options & PCRE_UTF8) != 0, cd, save_hwm_offset);
- memmove(start_bracket + 1 + LINK_SIZE, start_bracket,
- IN_UCHARS(code - start_bracket));
- *start_bracket = OP_ONCE;
- code += 1 + LINK_SIZE;
- PUT(start_bracket, 1, (int)(code - start_bracket));
- *code = OP_KET;
- PUT(code, 1, (int)(code - start_bracket));
- code += 1 + LINK_SIZE;
- length += 2 + 2*LINK_SIZE;
- }
- cd->open_caps = cd->open_caps->next;
- }
-
- /* Retain the highest bracket number, in case resetting was used. */
-
- cd->bracount = max_bracount;
-
- /* Set values to pass back */
-
- *codeptr = code;
- *ptrptr = ptr;
- *firstcharptr = firstchar;
- *firstcharflagsptr = firstcharflags;
- *reqcharptr = reqchar;
- *reqcharflagsptr = reqcharflags;
- if (lengthptr != NULL)
- {
- if (OFLOW_MAX - *lengthptr < length)
- {
- *errorcodeptr = ERR20;
- return FALSE;
- }
- *lengthptr += length;
- }
- return TRUE;
- }
-
- /* Another branch follows. In the pre-compile phase, we can move the code
- pointer back to where it was for the start of the first branch. (That is,
- pretend that each branch is the only one.)
-
- In the real compile phase, insert an ALT node. Its length field points back
- to the previous branch while the bracket remains open. At the end the chain
- is reversed. It's done like this so that the start of the bracket has a
- zero offset until it is closed, making it possible to detect recursion. */
-
- if (lengthptr != NULL)
- {
- code = *codeptr + 1 + LINK_SIZE + skipbytes;
- length += 1 + LINK_SIZE;
- }
- else
- {
- *code = OP_ALT;
- PUT(code, 1, (int)(code - last_branch));
- bc.current_branch = last_branch = code;
- code += 1 + LINK_SIZE;
- }
-
- ptr++;
- }
-/* Control never reaches here */
-}
-
-
-
-
-/*************************************************
-* Check for anchored expression *
-*************************************************/
-
-/* Try to find out if this is an anchored regular expression. Consider each
-alternative branch. If they all start with OP_SOD or OP_CIRC, or with a bracket
-all of whose alternatives start with OP_SOD or OP_CIRC (recurse ad lib), then
-it's anchored. However, if this is a multiline pattern, then only OP_SOD will
-be found, because ^ generates OP_CIRCM in that mode.
-
-We can also consider a regex to be anchored if OP_SOM starts all its branches.
-This is the code for \G, which means "match at start of match position, taking
-into account the match offset".
-
-A branch is also implicitly anchored if it starts with .* and DOTALL is set,
-because that will try the rest of the pattern at all possible matching points,
-so there is no point trying again.... er ....
-
-.... except when the .* appears inside capturing parentheses, and there is a
-subsequent back reference to those parentheses. We haven't enough information
-to catch that case precisely.
-
-At first, the best we could do was to detect when .* was in capturing brackets
-and the highest back reference was greater than or equal to that level.
-However, by keeping a bitmap of the first 31 back references, we can catch some
-of the more common cases more precisely.
-
-... A second exception is when the .* appears inside an atomic group, because
-this prevents the number of characters it matches from being adjusted.
-
-Arguments:
- code points to start of expression (the bracket)
- bracket_map a bitmap of which brackets we are inside while testing; this
- handles up to substring 31; after that we just have to take
- the less precise approach
- cd points to the compile data block
- atomcount atomic group level
-
-Returns: TRUE or FALSE
-*/
-
-static BOOL
-is_anchored(register const pcre_uchar *code, unsigned int bracket_map,
- compile_data *cd, int atomcount)
-{
-do {
- const pcre_uchar *scode = first_significant_code(
- code + PRIV(OP_lengths)[*code], FALSE);
- register int op = *scode;
-
- /* Non-capturing brackets */
-
- if (op == OP_BRA || op == OP_BRAPOS ||
- op == OP_SBRA || op == OP_SBRAPOS)
- {
- if (!is_anchored(scode, bracket_map, cd, atomcount)) return FALSE;
- }
-
- /* Capturing brackets */
-
- else if (op == OP_CBRA || op == OP_CBRAPOS ||
- op == OP_SCBRA || op == OP_SCBRAPOS)
- {
- int n = GET2(scode, 1+LINK_SIZE);
- int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
- if (!is_anchored(scode, new_map, cd, atomcount)) return FALSE;
- }
-
- /* Positive forward assertions and conditions */
-
- else if (op == OP_ASSERT || op == OP_COND)
- {
- if (!is_anchored(scode, bracket_map, cd, atomcount)) return FALSE;
- }
-
- /* Atomic groups */
-
- else if (op == OP_ONCE || op == OP_ONCE_NC)
- {
- if (!is_anchored(scode, bracket_map, cd, atomcount + 1))
- return FALSE;
- }
-
- /* .* is not anchored unless DOTALL is set (which generates OP_ALLANY) and
- it isn't in brackets that are or may be referenced or inside an atomic
- group. */
-
- else if ((op == OP_TYPESTAR || op == OP_TYPEMINSTAR ||
- op == OP_TYPEPOSSTAR))
- {
- if (scode[1] != OP_ALLANY || (bracket_map & cd->backref_map) != 0 ||
- atomcount > 0 || cd->had_pruneorskip)
- return FALSE;
- }
-
- /* Check for explicit anchoring */
-
- else if (op != OP_SOD && op != OP_SOM && op != OP_CIRC) return FALSE;
-
- code += GET(code, 1);
- }
-while (*code == OP_ALT); /* Loop for each alternative */
-return TRUE;
-}
-
-
-
-/*************************************************
-* Check for starting with ^ or .* *
-*************************************************/
-
-/* This is called to find out if every branch starts with ^ or .* so that
-"first char" processing can be done to speed things up in multiline
-matching and for non-DOTALL patterns that start with .* (which must start at
-the beginning or after \n). As in the case of is_anchored() (see above), we
-have to take account of back references to capturing brackets that contain .*
-because in that case we can't make the assumption. Also, the appearance of .*
-inside atomic brackets or in a pattern that contains *PRUNE or *SKIP does not
-count, because once again the assumption no longer holds.
-
-Arguments:
- code points to start of expression (the bracket)
- bracket_map a bitmap of which brackets we are inside while testing; this
- handles up to substring 31; after that we just have to take
- the less precise approach
- cd points to the compile data
- atomcount atomic group level
-
-Returns: TRUE or FALSE
-*/
-
-static BOOL
-is_startline(const pcre_uchar *code, unsigned int bracket_map,
- compile_data *cd, int atomcount)
-{
-do {
- const pcre_uchar *scode = first_significant_code(
- code + PRIV(OP_lengths)[*code], FALSE);
- register int op = *scode;
-
- /* If we are at the start of a conditional assertion group, *both* the
- conditional assertion *and* what follows the condition must satisfy the test
- for start of line. Other kinds of condition fail. Note that there may be an
- auto-callout at the start of a condition. */
-
- if (op == OP_COND)
- {
- scode += 1 + LINK_SIZE;
- if (*scode == OP_CALLOUT) scode += PRIV(OP_lengths)[OP_CALLOUT];
- switch (*scode)
- {
- case OP_CREF:
- case OP_DNCREF:
- case OP_RREF:
- case OP_DNRREF:
- case OP_DEF:
- case OP_FAIL:
- return FALSE;
-
- default: /* Assertion */
- if (!is_startline(scode, bracket_map, cd, atomcount)) return FALSE;
- do scode += GET(scode, 1); while (*scode == OP_ALT);
- scode += 1 + LINK_SIZE;
- break;
- }
- scode = first_significant_code(scode, FALSE);
- op = *scode;
- }
-
- /* Non-capturing brackets */
-
- if (op == OP_BRA || op == OP_BRAPOS ||
- op == OP_SBRA || op == OP_SBRAPOS)
- {
- if (!is_startline(scode, bracket_map, cd, atomcount)) return FALSE;
- }
-
- /* Capturing brackets */
-
- else if (op == OP_CBRA || op == OP_CBRAPOS ||
- op == OP_SCBRA || op == OP_SCBRAPOS)
- {
- int n = GET2(scode, 1+LINK_SIZE);
- int new_map = bracket_map | ((n < 32)? (1 << n) : 1);
- if (!is_startline(scode, new_map, cd, atomcount)) return FALSE;
- }
-
- /* Positive forward assertions */
-
- else if (op == OP_ASSERT)
- {
- if (!is_startline(scode, bracket_map, cd, atomcount)) return FALSE;
- }
-
- /* Atomic brackets */
-
- else if (op == OP_ONCE || op == OP_ONCE_NC)
- {
- if (!is_startline(scode, bracket_map, cd, atomcount + 1)) return FALSE;
- }
-
- /* .* means "start at start or after \n" if it isn't in atomic brackets or
- brackets that may be referenced, as long as the pattern does not contain
- *PRUNE or *SKIP, because these break the feature. Consider, for example,
- /.*?a(*PRUNE)b/ with the subject "aab", which matches "ab", i.e. not at the
- start of a line. */
-
- else if (op == OP_TYPESTAR || op == OP_TYPEMINSTAR || op == OP_TYPEPOSSTAR)
- {
- if (scode[1] != OP_ANY || (bracket_map & cd->backref_map) != 0 ||
- atomcount > 0 || cd->had_pruneorskip)
- return FALSE;
- }
-
- /* Check for explicit circumflex; anything else gives a FALSE result. Note
- in particular that this includes atomic brackets OP_ONCE and OP_ONCE_NC
- because the number of characters matched by .* cannot be adjusted inside
- them. */
-
- else if (op != OP_CIRC && op != OP_CIRCM) return FALSE;
-
- /* Move on to the next alternative */
-
- code += GET(code, 1);
- }
-while (*code == OP_ALT); /* Loop for each alternative */
-return TRUE;
-}
-
-
-
-/*************************************************
-* Check for asserted fixed first char *
-*************************************************/
-
-/* During compilation, the "first char" settings from forward assertions are
-discarded, because they can cause conflicts with actual literals that follow.
-However, if we end up without a first char setting for an unanchored pattern,
-it is worth scanning the regex to see if there is an initial asserted first
-char. If all branches start with the same asserted char, or with a
-non-conditional bracket all of whose alternatives start with the same asserted
-char (recurse ad lib), then we return that char, with the flags set to zero or
-REQ_CASELESS; otherwise return zero with REQ_NONE in the flags.
-
-Arguments:
- code points to start of expression (the bracket)
- flags points to the first char flags, or to REQ_NONE
- inassert TRUE if in an assertion
-
-Returns: the fixed first char, or 0 with REQ_NONE in flags
-*/
-
-static pcre_uint32
-find_firstassertedchar(const pcre_uchar *code, pcre_int32 *flags,
- BOOL inassert)
-{
-register pcre_uint32 c = 0;
-int cflags = REQ_NONE;
-
-*flags = REQ_NONE;
-do {
- pcre_uint32 d;
- int dflags;
- int xl = (*code == OP_CBRA || *code == OP_SCBRA ||
- *code == OP_CBRAPOS || *code == OP_SCBRAPOS)? IMM2_SIZE:0;
- const pcre_uchar *scode = first_significant_code(code + 1+LINK_SIZE + xl,
- TRUE);
- register pcre_uchar op = *scode;
-
- switch(op)
- {
- default:
- return 0;
-
- case OP_BRA:
- case OP_BRAPOS:
- case OP_CBRA:
- case OP_SCBRA:
- case OP_CBRAPOS:
- case OP_SCBRAPOS:
- case OP_ASSERT:
- case OP_ONCE:
- case OP_ONCE_NC:
- d = find_firstassertedchar(scode, &dflags, op == OP_ASSERT);
- if (dflags < 0)
- return 0;
- if (cflags < 0) { c = d; cflags = dflags; } else if (c != d || cflags != dflags) return 0;
- break;
-
- case OP_EXACT:
- scode += IMM2_SIZE;
- /* Fall through */
-
- case OP_CHAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_POSPLUS:
- if (!inassert) return 0;
- if (cflags < 0) { c = scode[1]; cflags = 0; }
- else if (c != scode[1]) return 0;
- break;
-
- case OP_EXACTI:
- scode += IMM2_SIZE;
- /* Fall through */
-
- case OP_CHARI:
- case OP_PLUSI:
- case OP_MINPLUSI:
- case OP_POSPLUSI:
- if (!inassert) return 0;
- if (cflags < 0) { c = scode[1]; cflags = REQ_CASELESS; }
- else if (c != scode[1]) return 0;
- break;
- }
-
- code += GET(code, 1);
- }
-while (*code == OP_ALT);
-
-*flags = cflags;
-return c;
-}
-
-
-
-/*************************************************
-* Add an entry to the name/number table *
-*************************************************/
-
-/* This function is called between compiling passes to add an entry to the
-name/number table, maintaining alphabetical order. Checking for permitted
-and forbidden duplicates has already been done.
-
-Arguments:
- cd the compile data block
- name the name to add
- length the length of the name
- groupno the group number
-
-Returns: nothing
-*/
-
-static void
-add_name(compile_data *cd, const pcre_uchar *name, int length,
- unsigned int groupno)
-{
-int i;
-pcre_uchar *slot = cd->name_table;
-
-for (i = 0; i < cd->names_found; i++)
- {
- int crc = memcmp(name, slot+IMM2_SIZE, IN_UCHARS(length));
- if (crc == 0 && slot[IMM2_SIZE+length] != 0)
- crc = -1; /* Current name is a substring */
-
- /* Make space in the table and break the loop for an earlier name. For a
- duplicate or later name, carry on. We do this for duplicates so that in the
- simple case (when ?(| is not used) they are in order of their numbers. In all
- cases they are in the order in which they appear in the pattern. */
-
- if (crc < 0)
- {
- memmove(slot + cd->name_entry_size, slot,
- IN_UCHARS((cd->names_found - i) * cd->name_entry_size));
- break;
- }
-
- /* Continue the loop for a later or duplicate name */
-
- slot += cd->name_entry_size;
- }
-
-PUT2(slot, 0, groupno);
-memcpy(slot + IMM2_SIZE, name, IN_UCHARS(length));
-slot[IMM2_SIZE + length] = 0;
-cd->names_found++;
-}
-
-
-
-/*************************************************
-* Compile a Regular Expression *
-*************************************************/
-
-/* This function takes a string and returns a pointer to a block of store
-holding a compiled version of the expression. The original API for this
-function had no error code return variable; it is retained for backwards
-compatibility. The new function is given a new name.
-
-Arguments:
- pattern the regular expression
- options various option bits
- errorcodeptr pointer to error code variable (pcre_compile2() only)
- can be NULL if you don't want a code value
- errorptr pointer to pointer to error text
- erroroffset ptr offset in pattern where error was detected
- tables pointer to character tables or NULL
-
-Returns: pointer to compiled data block, or NULL on error,
- with errorptr and erroroffset set
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
-pcre_compile(const char *pattern, int options, const char **errorptr,
- int *erroroffset, const unsigned char *tables)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION
-pcre16_compile(PCRE_SPTR16 pattern, int options, const char **errorptr,
- int *erroroffset, const unsigned char *tables)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN pcre32 * PCRE_CALL_CONVENTION
-pcre32_compile(PCRE_SPTR32 pattern, int options, const char **errorptr,
- int *erroroffset, const unsigned char *tables)
-#endif
-{
-#if defined COMPILE_PCRE8
-return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
-#elif defined COMPILE_PCRE16
-return pcre16_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
-#elif defined COMPILE_PCRE32
-return pcre32_compile2(pattern, options, NULL, errorptr, erroroffset, tables);
-#endif
-}
-
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN pcre * PCRE_CALL_CONVENTION
-pcre_compile2(const char *pattern, int options, int *errorcodeptr,
- const char **errorptr, int *erroroffset, const unsigned char *tables)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN pcre16 * PCRE_CALL_CONVENTION
-pcre16_compile2(PCRE_SPTR16 pattern, int options, int *errorcodeptr,
- const char **errorptr, int *erroroffset, const unsigned char *tables)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN pcre32 * PCRE_CALL_CONVENTION
-pcre32_compile2(PCRE_SPTR32 pattern, int options, int *errorcodeptr,
- const char **errorptr, int *erroroffset, const unsigned char *tables)
-#endif
-{
-REAL_PCRE *re;
-int length = 1; /* For final END opcode */
-pcre_int32 firstcharflags, reqcharflags;
-pcre_uint32 firstchar, reqchar;
-pcre_uint32 limit_match = PCRE_UINT32_MAX;
-pcre_uint32 limit_recursion = PCRE_UINT32_MAX;
-int newline;
-int errorcode = 0;
-int skipatstart = 0;
-BOOL utf;
-BOOL never_utf = FALSE;
-size_t size;
-pcre_uchar *code;
-const pcre_uchar *codestart;
-const pcre_uchar *ptr;
-compile_data compile_block;
-compile_data *cd = &compile_block;
-
-/* This space is used for "compiling" into during the first phase, when we are
-computing the amount of memory that is needed. Compiled items are thrown away
-as soon as possible, so that a fairly large buffer should be sufficient for
-this purpose. The same space is used in the second phase for remembering where
-to fill in forward references to subpatterns. That may overflow, in which case
-new memory is obtained from malloc(). */
-
-pcre_uchar cworkspace[COMPILE_WORK_SIZE];
-
-/* This vector is used for remembering name groups during the pre-compile. In a
-similar way to cworkspace, it can be expanded using malloc() if necessary. */
-
-named_group named_groups[NAMED_GROUP_LIST_SIZE];
-
-/* Set this early so that early errors get offset 0. */
-
-ptr = (const pcre_uchar *)pattern;
-
-/* We can't pass back an error message if errorptr is NULL; I guess the best we
-can do is just return NULL, but we can set a code value if there is a code
-pointer. */
-
-if (errorptr == NULL)
- {
- if (errorcodeptr != NULL) *errorcodeptr = 99;
- return NULL;
- }
-
-*errorptr = NULL;
-if (errorcodeptr != NULL) *errorcodeptr = ERR0;
-
-/* However, we can give a message for this error */
-
-if (erroroffset == NULL)
- {
- errorcode = ERR16;
- goto PCRE_EARLY_ERROR_RETURN2;
- }
-
-*erroroffset = 0;
-
-/* Set up pointers to the individual character tables */
-
-if (tables == NULL) tables = PRIV(default_tables);
-cd->lcc = tables + lcc_offset;
-cd->fcc = tables + fcc_offset;
-cd->cbits = tables + cbits_offset;
-cd->ctypes = tables + ctypes_offset;
-
-/* Check that all undefined public option bits are zero */
-
-if ((options & ~PUBLIC_COMPILE_OPTIONS) != 0)
- {
- errorcode = ERR17;
- goto PCRE_EARLY_ERROR_RETURN;
- }
-
-/* If PCRE_NEVER_UTF is set, remember it. */
-
-if ((options & PCRE_NEVER_UTF) != 0) never_utf = TRUE;
-
-/* Check for global one-time settings at the start of the pattern, and remember
-the offset for later. */
-
-cd->external_flags = 0; /* Initialize here for LIMIT_MATCH/RECURSION */
-
-while (ptr[skipatstart] == CHAR_LEFT_PARENTHESIS &&
- ptr[skipatstart+1] == CHAR_ASTERISK)
- {
- int newnl = 0;
- int newbsr = 0;
-
-/* For completeness and backward compatibility, (*UTFn) is supported in the
-relevant libraries, but (*UTF) is generic and always supported. Note that
-PCRE_UTF8 == PCRE_UTF16 == PCRE_UTF32. */
-
-#ifdef COMPILE_PCRE8
- if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF8_RIGHTPAR, 5) == 0)
- { skipatstart += 7; options |= PCRE_UTF8; continue; }
-#endif
-#ifdef COMPILE_PCRE16
- if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF16_RIGHTPAR, 6) == 0)
- { skipatstart += 8; options |= PCRE_UTF16; continue; }
-#endif
-#ifdef COMPILE_PCRE32
- if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF32_RIGHTPAR, 6) == 0)
- { skipatstart += 8; options |= PCRE_UTF32; continue; }
-#endif
-
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UTF_RIGHTPAR, 4) == 0)
- { skipatstart += 6; options |= PCRE_UTF8; continue; }
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_UCP_RIGHTPAR, 4) == 0)
- { skipatstart += 6; options |= PCRE_UCP; continue; }
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_NO_AUTO_POSSESS_RIGHTPAR, 16) == 0)
- { skipatstart += 18; options |= PCRE_NO_AUTO_POSSESS; continue; }
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_NO_START_OPT_RIGHTPAR, 13) == 0)
- { skipatstart += 15; options |= PCRE_NO_START_OPTIMIZE; continue; }
-
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_LIMIT_MATCH_EQ, 12) == 0)
- {
- pcre_uint32 c = 0;
- int p = skipatstart + 14;
- while (isdigit(ptr[p]))
- {
- if (c > PCRE_UINT32_MAX / 10 - 1) break; /* Integer overflow */
- c = c*10 + ptr[p++] - CHAR_0;
- }
- if (ptr[p++] != CHAR_RIGHT_PARENTHESIS) break;
- if (c < limit_match)
- {
- limit_match = c;
- cd->external_flags |= PCRE_MLSET;
- }
- skipatstart = p;
- continue;
- }
-
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_LIMIT_RECURSION_EQ, 16) == 0)
- {
- pcre_uint32 c = 0;
- int p = skipatstart + 18;
- while (isdigit(ptr[p]))
- {
- if (c > PCRE_UINT32_MAX / 10 - 1) break; /* Integer overflow check */
- c = c*10 + ptr[p++] - CHAR_0;
- }
- if (ptr[p++] != CHAR_RIGHT_PARENTHESIS) break;
- if (c < limit_recursion)
- {
- limit_recursion = c;
- cd->external_flags |= PCRE_RLSET;
- }
- skipatstart = p;
- continue;
- }
-
- if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_CR_RIGHTPAR, 3) == 0)
- { skipatstart += 5; newnl = PCRE_NEWLINE_CR; }
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_LF_RIGHTPAR, 3) == 0)
- { skipatstart += 5; newnl = PCRE_NEWLINE_LF; }
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_CRLF_RIGHTPAR, 5) == 0)
- { skipatstart += 7; newnl = PCRE_NEWLINE_CR + PCRE_NEWLINE_LF; }
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_ANY_RIGHTPAR, 4) == 0)
- { skipatstart += 6; newnl = PCRE_NEWLINE_ANY; }
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_ANYCRLF_RIGHTPAR, 8) == 0)
- { skipatstart += 10; newnl = PCRE_NEWLINE_ANYCRLF; }
-
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_BSR_ANYCRLF_RIGHTPAR, 12) == 0)
- { skipatstart += 14; newbsr = PCRE_BSR_ANYCRLF; }
- else if (STRNCMP_UC_C8(ptr+skipatstart+2, STRING_BSR_UNICODE_RIGHTPAR, 12) == 0)
- { skipatstart += 14; newbsr = PCRE_BSR_UNICODE; }
-
- if (newnl != 0)
- options = (options & ~PCRE_NEWLINE_BITS) | newnl;
- else if (newbsr != 0)
- options = (options & ~(PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) | newbsr;
- else break;
- }
-
-/* PCRE_UTF(16|32) have the same value as PCRE_UTF8. */
-utf = (options & PCRE_UTF8) != 0;
-if (utf && never_utf)
- {
- errorcode = ERR78;
- goto PCRE_EARLY_ERROR_RETURN2;
- }
-
-/* Can't support UTF unless PCRE has been compiled to include the code. The
-return of an error code from PRIV(valid_utf)() is a new feature, introduced in
-release 8.13. It is passed back from pcre_[dfa_]exec(), but at the moment is
-not used here. */
-
-#ifdef SUPPORT_UTF
-if (utf && (options & PCRE_NO_UTF8_CHECK) == 0 &&
- (errorcode = PRIV(valid_utf)((PCRE_PUCHAR)pattern, -1, erroroffset)) != 0)
- {
-#if defined COMPILE_PCRE8
- errorcode = ERR44;
-#elif defined COMPILE_PCRE16
- errorcode = ERR74;
-#elif defined COMPILE_PCRE32
- errorcode = ERR77;
-#endif
- goto PCRE_EARLY_ERROR_RETURN2;
- }
-#else
-if (utf)
- {
- errorcode = ERR32;
- goto PCRE_EARLY_ERROR_RETURN;
- }
-#endif
-
-/* Can't support UCP unless PCRE has been compiled to include the code. */
-
-#ifndef SUPPORT_UCP
-if ((options & PCRE_UCP) != 0)
- {
- errorcode = ERR67;
- goto PCRE_EARLY_ERROR_RETURN;
- }
-#endif
-
-/* Check validity of \R options. */
-
-if ((options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) ==
- (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE))
- {
- errorcode = ERR56;
- goto PCRE_EARLY_ERROR_RETURN;
- }
-
-/* Handle different types of newline. The three bits give seven cases. The
-current code allows for fixed one- or two-byte sequences, plus "any" and
-"anycrlf". */
-
-switch (options & PCRE_NEWLINE_BITS)
- {
- case 0: newline = NEWLINE; break; /* Build-time default */
- case PCRE_NEWLINE_CR: newline = CHAR_CR; break;
- case PCRE_NEWLINE_LF: newline = CHAR_NL; break;
- case PCRE_NEWLINE_CR+
- PCRE_NEWLINE_LF: newline = (CHAR_CR << 8) | CHAR_NL; break;
- case PCRE_NEWLINE_ANY: newline = -1; break;
- case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
- default: errorcode = ERR56; goto PCRE_EARLY_ERROR_RETURN;
- }
-
-if (newline == -2)
- {
- cd->nltype = NLTYPE_ANYCRLF;
- }
-else if (newline < 0)
- {
- cd->nltype = NLTYPE_ANY;
- }
-else
- {
- cd->nltype = NLTYPE_FIXED;
- if (newline > 255)
- {
- cd->nllen = 2;
- cd->nl[0] = (newline >> 8) & 255;
- cd->nl[1] = newline & 255;
- }
- else
- {
- cd->nllen = 1;
- cd->nl[0] = newline;
- }
- }
-
-/* Maximum back reference and backref bitmap. The bitmap records up to 31 back
-references to help in deciding whether (.*) can be treated as anchored or not.
-*/
-
-cd->top_backref = 0;
-cd->backref_map = 0;
-
-/* Reflect pattern for debugging output */
-
-DPRINTF(("------------------------------------------------------------------\n"));
-#ifdef PCRE_DEBUG
-print_puchar(stdout, (PCRE_PUCHAR)pattern);
-#endif
-DPRINTF(("\n"));
-
-/* Pretend to compile the pattern while actually just accumulating the length
-of memory required. This behaviour is triggered by passing a non-NULL final
-argument to compile_regex(). We pass a block of workspace (cworkspace) for it
-to compile parts of the pattern into; the compiled code is discarded when it is
-no longer needed, so hopefully this workspace will never overflow, though there
-is a test for its doing so. */
-
-cd->bracount = cd->final_bracount = 0;
-cd->names_found = 0;
-cd->name_entry_size = 0;
-cd->name_table = NULL;
-cd->dupnames = FALSE;
-cd->dupgroups = FALSE;
-cd->namedrefcount = 0;
-cd->start_code = cworkspace;
-cd->hwm = cworkspace;
-cd->iscondassert = FALSE;
-cd->start_workspace = cworkspace;
-cd->workspace_size = COMPILE_WORK_SIZE;
-cd->named_groups = named_groups;
-cd->named_group_list_size = NAMED_GROUP_LIST_SIZE;
-cd->start_pattern = (const pcre_uchar *)pattern;
-cd->end_pattern = (const pcre_uchar *)(pattern + STRLEN_UC((const pcre_uchar *)pattern));
-cd->req_varyopt = 0;
-cd->parens_depth = 0;
-cd->assert_depth = 0;
-cd->max_lookbehind = 0;
-cd->external_options = options;
-cd->open_caps = NULL;
-
-/* Now do the pre-compile. On error, errorcode will be set non-zero, so we
-don't need to look at the result of the function here. The initial options have
-been put into the cd block so that they can be changed if an option setting is
-found within the regex right at the beginning. Bringing initial option settings
-outside can help speed up starting point checks. */
-
-ptr += skipatstart;
-code = cworkspace;
-*code = OP_BRA;
-
-(void)compile_regex(cd->external_options, &code, &ptr, &errorcode, FALSE,
- FALSE, 0, 0, &firstchar, &firstcharflags, &reqchar, &reqcharflags, NULL,
- cd, &length);
-if (errorcode != 0) goto PCRE_EARLY_ERROR_RETURN;
-
-DPRINTF(("end pre-compile: length=%d workspace=%d\n", length,
- (int)(cd->hwm - cworkspace)));
-
-if (length > MAX_PATTERN_SIZE)
- {
- errorcode = ERR20;
- goto PCRE_EARLY_ERROR_RETURN;
- }
-
-/* Compute the size of the data block for storing the compiled pattern. Integer
-overflow should no longer be possible because nowadays we limit the maximum
-value of cd->names_found and cd->name_entry_size. */
-
-size = sizeof(REAL_PCRE) +
- (length + cd->names_found * cd->name_entry_size) * sizeof(pcre_uchar);
-
-/* Get the memory. */
-
-re = (REAL_PCRE *)(PUBL(malloc))(size);
-if (re == NULL)
- {
- errorcode = ERR21;
- goto PCRE_EARLY_ERROR_RETURN;
- }
-
-/* Put in the magic number, and save the sizes, initial options, internal
-flags, and character table pointer. NULL is used for the default character
-tables. The nullpad field is at the end; it's there to help in the case when a
-regex compiled on a system with 4-byte pointers is run on another with 8-byte
-pointers. */
-
-re->magic_number = MAGIC_NUMBER;
-re->size = (int)size;
-re->options = cd->external_options;
-re->flags = cd->external_flags;
-re->limit_match = limit_match;
-re->limit_recursion = limit_recursion;
-re->first_char = 0;
-re->req_char = 0;
-re->name_table_offset = sizeof(REAL_PCRE) / sizeof(pcre_uchar);
-re->name_entry_size = cd->name_entry_size;
-re->name_count = cd->names_found;
-re->ref_count = 0;
-re->tables = (tables == PRIV(default_tables))? NULL : tables;
-re->nullpad = NULL;
-#ifdef COMPILE_PCRE32
-re->dummy = 0;
-#else
-re->dummy1 = re->dummy2 = re->dummy3 = 0;
-#endif
-
-/* The starting points of the name/number translation table and of the code are
-passed around in the compile data block. The start/end pattern and initial
-options are already set from the pre-compile phase, as is the name_entry_size
-field. Reset the bracket count and the names_found field. Also reset the hwm
-field; this time it's used for remembering forward references to subpatterns.
-*/
-
-cd->final_bracount = cd->bracount; /* Save for checking forward references */
-cd->parens_depth = 0;
-cd->assert_depth = 0;
-cd->bracount = 0;
-cd->max_lookbehind = 0;
-cd->name_table = (pcre_uchar *)re + re->name_table_offset;
-codestart = cd->name_table + re->name_entry_size * re->name_count;
-cd->start_code = codestart;
-cd->hwm = (pcre_uchar *)(cd->start_workspace);
-cd->iscondassert = FALSE;
-cd->req_varyopt = 0;
-cd->had_accept = FALSE;
-cd->had_pruneorskip = FALSE;
-cd->check_lookbehind = FALSE;
-cd->open_caps = NULL;
-
-/* If any named groups were found, create the name/number table from the list
-created in the first pass. */
-
-if (cd->names_found > 0)
- {
- int i = cd->names_found;
- named_group *ng = cd->named_groups;
- cd->names_found = 0;
- for (; i > 0; i--, ng++)
- add_name(cd, ng->name, ng->length, ng->number);
- if (cd->named_group_list_size > NAMED_GROUP_LIST_SIZE)
- (PUBL(free))((void *)cd->named_groups);
- }
-
-/* Set up a starting, non-extracting bracket, then compile the expression. On
-error, errorcode will be set non-zero, so we don't need to look at the result
-of the function here. */
-
-ptr = (const pcre_uchar *)pattern + skipatstart;
-code = (pcre_uchar *)codestart;
-*code = OP_BRA;
-(void)compile_regex(re->options, &code, &ptr, &errorcode, FALSE, FALSE, 0, 0,
- &firstchar, &firstcharflags, &reqchar, &reqcharflags, NULL, cd, NULL);
-re->top_bracket = cd->bracount;
-re->top_backref = cd->top_backref;
-re->max_lookbehind = cd->max_lookbehind;
-re->flags = cd->external_flags | PCRE_MODE;
-
-if (cd->had_accept)
- {
- reqchar = 0; /* Must disable after (*ACCEPT) */
- reqcharflags = REQ_NONE;
- }
-
-/* If not reached end of pattern on success, there's an excess bracket. */
-
-if (errorcode == 0 && *ptr != CHAR_NULL) errorcode = ERR22;
-
-/* Fill in the terminating state and check for disastrous overflow, but
-if debugging, leave the test till after things are printed out. */
-
-*code++ = OP_END;
-
-#ifndef PCRE_DEBUG
-if (code - codestart > length) errorcode = ERR23;
-#endif
-
-#ifdef SUPPORT_VALGRIND
-/* If the estimated length exceeds the really used length, mark the extra
-allocated memory as unaddressable, so that any out-of-bound reads can be
-detected. */
-VALGRIND_MAKE_MEM_NOACCESS(code, (length - (code - codestart)) * sizeof(pcre_uchar));
-#endif
-
-/* Fill in any forward references that are required. There may be repeated
-references; optimize for them, as searching a large regex takes time. */
-
-if (cd->hwm > cd->start_workspace)
- {
- int prev_recno = -1;
- const pcre_uchar *groupptr = NULL;
- while (errorcode == 0 && cd->hwm > cd->start_workspace)
- {
- int offset, recno;
- cd->hwm -= LINK_SIZE;
- offset = GET(cd->hwm, 0);
-
- /* Check that the hwm handling hasn't gone wrong. This whole area is
- rewritten in PCRE2 because there are some obscure cases. */
-
- if (offset == 0 || codestart[offset-1] != OP_RECURSE)
- {
- errorcode = ERR10;
- break;
- }
-
- recno = GET(codestart, offset);
- if (recno != prev_recno)
- {
- groupptr = PRIV(find_bracket)(codestart, utf, recno);
- prev_recno = recno;
- }
- if (groupptr == NULL) errorcode = ERR53;
- else PUT(((pcre_uchar *)codestart), offset, (int)(groupptr - codestart));
- }
- }
-
-/* If the workspace had to be expanded, free the new memory. Set the pointer to
-NULL to indicate that forward references have been filled in. */
-
-if (cd->workspace_size > COMPILE_WORK_SIZE)
- (PUBL(free))((void *)cd->start_workspace);
-cd->start_workspace = NULL;
-
-/* Give an error if there's back reference to a non-existent capturing
-subpattern. */
-
-if (errorcode == 0 && re->top_backref > re->top_bracket) errorcode = ERR15;
-
-/* Unless disabled, check whether any single character iterators can be
-auto-possessified. The function overwrites the appropriate opcode values, so
-the type of the pointer must be cast. NOTE: the intermediate variable "temp" is
-used in this code because at least one compiler gives a warning about loss of
-"const" attribute if the cast (pcre_uchar *)codestart is used directly in the
-function call. */
-
-if (errorcode == 0 && (options & PCRE_NO_AUTO_POSSESS) == 0)
- {
- pcre_uchar *temp = (pcre_uchar *)codestart;
- auto_possessify(temp, utf, cd);
- }
-
-/* If there were any lookbehind assertions that contained OP_RECURSE
-(recursions or subroutine calls), a flag is set for them to be checked here,
-because they may contain forward references. Actual recursions cannot be fixed
-length, but subroutine calls can. It is done like this so that those without
-OP_RECURSE that are not fixed length get a diagnosic with a useful offset. The
-exceptional ones forgo this. We scan the pattern to check that they are fixed
-length, and set their lengths. */
-
-if (errorcode == 0 && cd->check_lookbehind)
- {
- pcre_uchar *cc = (pcre_uchar *)codestart;
-
- /* Loop, searching for OP_REVERSE items, and process those that do not have
- their length set. (Actually, it will also re-process any that have a length
- of zero, but that is a pathological case, and it does no harm.) When we find
- one, we temporarily terminate the branch it is in while we scan it. */
-
- for (cc = (pcre_uchar *)PRIV(find_bracket)(codestart, utf, -1);
- cc != NULL;
- cc = (pcre_uchar *)PRIV(find_bracket)(cc, utf, -1))
- {
- if (GET(cc, 1) == 0)
- {
- int fixed_length;
- pcre_uchar *be = cc - 1 - LINK_SIZE + GET(cc, -LINK_SIZE);
- int end_op = *be;
- *be = OP_END;
- fixed_length = find_fixedlength(cc, (re->options & PCRE_UTF8) != 0, TRUE,
- cd, NULL);
- *be = end_op;
- DPRINTF(("fixed length = %d\n", fixed_length));
- if (fixed_length < 0)
- {
- errorcode = (fixed_length == -2)? ERR36 :
- (fixed_length == -4)? ERR70 : ERR25;
- break;
- }
- if (fixed_length > cd->max_lookbehind) cd->max_lookbehind = fixed_length;
- PUT(cc, 1, fixed_length);
- }
- cc += 1 + LINK_SIZE;
- }
- }
-
-/* Failed to compile, or error while post-processing */
-
-if (errorcode != 0)
- {
- (PUBL(free))(re);
- PCRE_EARLY_ERROR_RETURN:
- *erroroffset = (int)(ptr - (const pcre_uchar *)pattern);
- PCRE_EARLY_ERROR_RETURN2:
- *errorptr = find_error_text(errorcode);
- if (errorcodeptr != NULL) *errorcodeptr = errorcode;
- return NULL;
- }
-
-/* If the anchored option was not passed, set the flag if we can determine that
-the pattern is anchored by virtue of ^ characters or \A or anything else, such
-as starting with non-atomic .* when DOTALL is set and there are no occurrences
-of *PRUNE or *SKIP.
-
-Otherwise, if we know what the first byte has to be, save it, because that
-speeds up unanchored matches no end. If not, see if we can set the
-PCRE_STARTLINE flag. This is helpful for multiline matches when all branches
-start with ^. and also when all branches start with non-atomic .* for
-non-DOTALL matches when *PRUNE and SKIP are not present. */
-
-if ((re->options & PCRE_ANCHORED) == 0)
- {
- if (is_anchored(codestart, 0, cd, 0)) re->options |= PCRE_ANCHORED;
- else
- {
- if (firstcharflags < 0)
- firstchar = find_firstassertedchar(codestart, &firstcharflags, FALSE);
- if (firstcharflags >= 0) /* Remove caseless flag for non-caseable chars */
- {
-#if defined COMPILE_PCRE8
- re->first_char = firstchar & 0xff;
-#elif defined COMPILE_PCRE16
- re->first_char = firstchar & 0xffff;
-#elif defined COMPILE_PCRE32
- re->first_char = firstchar;
-#endif
- if ((firstcharflags & REQ_CASELESS) != 0)
- {
-#if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)
- /* We ignore non-ASCII first chars in 8 bit mode. */
- if (utf)
- {
- if (re->first_char < 128)
- {
- if (cd->fcc[re->first_char] != re->first_char)
- re->flags |= PCRE_FCH_CASELESS;
- }
- else if (UCD_OTHERCASE(re->first_char) != re->first_char)
- re->flags |= PCRE_FCH_CASELESS;
- }
- else
-#endif
- if (MAX_255(re->first_char)
- && cd->fcc[re->first_char] != re->first_char)
- re->flags |= PCRE_FCH_CASELESS;
- }
-
- re->flags |= PCRE_FIRSTSET;
- }
-
- else if (is_startline(codestart, 0, cd, 0)) re->flags |= PCRE_STARTLINE;
- }
- }
-
-/* For an anchored pattern, we use the "required byte" only if it follows a
-variable length item in the regex. Remove the caseless flag for non-caseable
-bytes. */
-
-if (reqcharflags >= 0 &&
- ((re->options & PCRE_ANCHORED) == 0 || (reqcharflags & REQ_VARY) != 0))
- {
-#if defined COMPILE_PCRE8
- re->req_char = reqchar & 0xff;
-#elif defined COMPILE_PCRE16
- re->req_char = reqchar & 0xffff;
-#elif defined COMPILE_PCRE32
- re->req_char = reqchar;
-#endif
- if ((reqcharflags & REQ_CASELESS) != 0)
- {
-#if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)
- /* We ignore non-ASCII first chars in 8 bit mode. */
- if (utf)
- {
- if (re->req_char < 128)
- {
- if (cd->fcc[re->req_char] != re->req_char)
- re->flags |= PCRE_RCH_CASELESS;
- }
- else if (UCD_OTHERCASE(re->req_char) != re->req_char)
- re->flags |= PCRE_RCH_CASELESS;
- }
- else
-#endif
- if (MAX_255(re->req_char) && cd->fcc[re->req_char] != re->req_char)
- re->flags |= PCRE_RCH_CASELESS;
- }
-
- re->flags |= PCRE_REQCHSET;
- }
-
-/* Print out the compiled data if debugging is enabled. This is never the
-case when building a production library. */
-
-#ifdef PCRE_DEBUG
-printf("Length = %d top_bracket = %d top_backref = %d\n",
- length, re->top_bracket, re->top_backref);
-
-printf("Options=%08x\n", re->options);
-
-if ((re->flags & PCRE_FIRSTSET) != 0)
- {
- pcre_uchar ch = re->first_char;
- const char *caseless =
- ((re->flags & PCRE_FCH_CASELESS) == 0)? "" : " (caseless)";
- if (PRINTABLE(ch)) printf("First char = %c%s\n", ch, caseless);
- else printf("First char = \\x%02x%s\n", ch, caseless);
- }
-
-if ((re->flags & PCRE_REQCHSET) != 0)
- {
- pcre_uchar ch = re->req_char;
- const char *caseless =
- ((re->flags & PCRE_RCH_CASELESS) == 0)? "" : " (caseless)";
- if (PRINTABLE(ch)) printf("Req char = %c%s\n", ch, caseless);
- else printf("Req char = \\x%02x%s\n", ch, caseless);
- }
-
-#if defined COMPILE_PCRE8
-pcre_printint((pcre *)re, stdout, TRUE);
-#elif defined COMPILE_PCRE16
-pcre16_printint((pcre *)re, stdout, TRUE);
-#elif defined COMPILE_PCRE32
-pcre32_printint((pcre *)re, stdout, TRUE);
-#endif
-
-/* This check is done here in the debugging case so that the code that
-was compiled can be seen. */
-
-if (code - codestart > length)
- {
- (PUBL(free))(re);
- *errorptr = find_error_text(ERR23);
- *erroroffset = ptr - (pcre_uchar *)pattern;
- if (errorcodeptr != NULL) *errorcodeptr = ERR23;
- return NULL;
- }
-#endif /* PCRE_DEBUG */
-
-/* Check for a pattern than can match an empty string, so that this information
-can be provided to applications. */
-
-do
- {
- if (could_be_empty_branch(codestart, code, utf, cd, NULL))
- {
- re->flags |= PCRE_MATCH_EMPTY;
- break;
- }
- codestart += GET(codestart, 1);
- }
-while (*codestart == OP_ALT);
-
-#if defined COMPILE_PCRE8
-return (pcre *)re;
-#elif defined COMPILE_PCRE16
-return (pcre16 *)re;
-#elif defined COMPILE_PCRE32
-return (pcre32 *)re;
-#endif
-}
-
-/* End of pcre_compile.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_config.c r-base-3.3.1/src/extra/pcre/pcre_config.c
--- r-base-3.2.3/src/extra/pcre/pcre_config.c 2015-03-18 23:02:11.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_config.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,190 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2012 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains the external function pcre_config(). */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-/* Keep the original link size. */
-static int real_link_size = LINK_SIZE;
-
-#include "pcre_internal.h"
-
-
-/*************************************************
-* Return info about what features are configured *
-*************************************************/
-
-/* This function has an extensible interface so that additional items can be
-added compatibly.
-
-Arguments:
- what what information is required
- where where to put the information
-
-Returns: 0 if data returned, negative on error
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_config(int what, void *where)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_config(int what, void *where)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_config(int what, void *where)
-#endif
-{
-switch (what)
- {
- case PCRE_CONFIG_UTF8:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- *((int *)where) = 0;
- return PCRE_ERROR_BADOPTION;
-#else
-#if defined SUPPORT_UTF
- *((int *)where) = 1;
-#else
- *((int *)where) = 0;
-#endif
- break;
-#endif
-
- case PCRE_CONFIG_UTF16:
-#if defined COMPILE_PCRE8 || defined COMPILE_PCRE32
- *((int *)where) = 0;
- return PCRE_ERROR_BADOPTION;
-#else
-#if defined SUPPORT_UTF
- *((int *)where) = 1;
-#else
- *((int *)where) = 0;
-#endif
- break;
-#endif
-
- case PCRE_CONFIG_UTF32:
-#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
- *((int *)where) = 0;
- return PCRE_ERROR_BADOPTION;
-#else
-#if defined SUPPORT_UTF
- *((int *)where) = 1;
-#else
- *((int *)where) = 0;
-#endif
- break;
-#endif
-
- case PCRE_CONFIG_UNICODE_PROPERTIES:
-#ifdef SUPPORT_UCP
- *((int *)where) = 1;
-#else
- *((int *)where) = 0;
-#endif
- break;
-
- case PCRE_CONFIG_JIT:
-#ifdef SUPPORT_JIT
- *((int *)where) = 1;
-#else
- *((int *)where) = 0;
-#endif
- break;
-
- case PCRE_CONFIG_JITTARGET:
-#ifdef SUPPORT_JIT
- *((const char **)where) = PRIV(jit_get_target)();
-#else
- *((const char **)where) = NULL;
-#endif
- break;
-
- case PCRE_CONFIG_NEWLINE:
- *((int *)where) = NEWLINE;
- break;
-
- case PCRE_CONFIG_BSR:
-#ifdef BSR_ANYCRLF
- *((int *)where) = 1;
-#else
- *((int *)where) = 0;
-#endif
- break;
-
- case PCRE_CONFIG_LINK_SIZE:
- *((int *)where) = real_link_size;
- break;
-
- case PCRE_CONFIG_POSIX_MALLOC_THRESHOLD:
- *((int *)where) = POSIX_MALLOC_THRESHOLD;
- break;
-
- case PCRE_CONFIG_PARENS_LIMIT:
- *((unsigned long int *)where) = PARENS_NEST_LIMIT;
- break;
-
- case PCRE_CONFIG_MATCH_LIMIT:
- *((unsigned long int *)where) = MATCH_LIMIT;
- break;
-
- case PCRE_CONFIG_MATCH_LIMIT_RECURSION:
- *((unsigned long int *)where) = MATCH_LIMIT_RECURSION;
- break;
-
- case PCRE_CONFIG_STACKRECURSE:
-#ifdef NO_RECURSE
- *((int *)where) = 0;
-#else
- *((int *)where) = 1;
-#endif
- break;
-
- default: return PCRE_ERROR_BADOPTION;
- }
-
-return 0;
-}
-
-/* End of pcre_config.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_exec.c r-base-3.3.1/src/extra/pcre/pcre_exec.c
--- r-base-3.2.3/src/extra/pcre/pcre_exec.c 2015-11-26 23:15:13.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_exec.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,7173 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2014 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-/* This module contains pcre_exec(), the externally visible function that does
-pattern matching using an NFA algorithm, trying to mimic Perl as closely as
-possible. There are also some static supporting functions. */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#define NLBLOCK md /* Block containing newline information */
-#define PSSTART start_subject /* Field containing processed string start */
-#define PSEND end_subject /* Field containing processed string end */
-
-#include "pcre_internal.h"
-
-/* Undefine some potentially clashing cpp symbols */
-
-#undef min
-#undef max
-
-/* The md->capture_last field uses the lower 16 bits for the last captured
-substring (which can never be greater than 65535) and a bit in the top half
-to mean "capture vector overflowed". This odd way of doing things was
-implemented when it was realized that preserving and restoring the overflow bit
-whenever the last capture number was saved/restored made for a neater
-interface, and doing it this way saved on (a) another variable, which would
-have increased the stack frame size (a big NO-NO in PCRE) and (b) another
-separate set of save/restore instructions. The following defines are used in
-implementing this. */
-
-#define CAPLMASK 0x0000ffff /* The bits used for last_capture */
-#define OVFLMASK 0xffff0000 /* The bits used for the overflow flag */
-#define OVFLBIT 0x00010000 /* The bit that is set for overflow */
-
-/* Values for setting in md->match_function_type to indicate two special types
-of call to match(). We do it this way to save on using another stack variable,
-as stack usage is to be discouraged. */
-
-#define MATCH_CONDASSERT 1 /* Called to check a condition assertion */
-#define MATCH_CBEGROUP 2 /* Could-be-empty unlimited repeat group */
-
-/* Non-error returns from the match() function. Error returns are externally
-defined PCRE_ERROR_xxx codes, which are all negative. */
-
-#define MATCH_MATCH 1
-#define MATCH_NOMATCH 0
-
-/* Special internal returns from the match() function. Make them sufficiently
-negative to avoid the external error codes. */
-
-#define MATCH_ACCEPT (-999)
-#define MATCH_KETRPOS (-998)
-#define MATCH_ONCE (-997)
-/* The next 5 must be kept together and in sequence so that a test that checks
-for any one of them can use a range. */
-#define MATCH_COMMIT (-996)
-#define MATCH_PRUNE (-995)
-#define MATCH_SKIP (-994)
-#define MATCH_SKIP_ARG (-993)
-#define MATCH_THEN (-992)
-#define MATCH_BACKTRACK_MAX MATCH_THEN
-#define MATCH_BACKTRACK_MIN MATCH_COMMIT
-
-/* Maximum number of ints of offset to save on the stack for recursive calls.
-If the offset vector is bigger, malloc is used. This should be a multiple of 3,
-because the offset vector is always a multiple of 3 long. */
-
-#define REC_STACK_SAVE_MAX 30
-
-/* Min and max values for the common repeats; for the maxima, 0 => infinity */
-
-static const char rep_min[] = { 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, };
-static const char rep_max[] = { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, };
-
-#ifdef PCRE_DEBUG
-/*************************************************
-* Debugging function to print chars *
-*************************************************/
-
-/* Print a sequence of chars in printable format, stopping at the end of the
-subject if the requested.
-
-Arguments:
- p points to characters
- length number to print
- is_subject TRUE if printing from within md->start_subject
- md pointer to matching data block, if is_subject is TRUE
-
-Returns: nothing
-*/
-
-static void
-pchars(const pcre_uchar *p, int length, BOOL is_subject, match_data *md)
-{
-pcre_uint32 c;
-BOOL utf = md->utf;
-if (is_subject && length > md->end_subject - p) length = md->end_subject - p;
-while (length-- > 0)
- if (isprint(c = UCHAR21INCTEST(p))) printf("%c", (char)c); else printf("\\x{%02x}", c);
-}
-#endif
-
-
-
-/*************************************************
-* Match a back-reference *
-*************************************************/
-
-/* Normally, if a back reference hasn't been set, the length that is passed is
-negative, so the match always fails. However, in JavaScript compatibility mode,
-the length passed is zero. Note that in caseless UTF-8 mode, the number of
-subject bytes matched may be different to the number of reference bytes.
-
-Arguments:
- offset index into the offset vector
- eptr pointer into the subject
- length length of reference to be matched (number of bytes)
- md points to match data block
- caseless TRUE if caseless
-
-Returns: >= 0 the number of subject bytes matched
- -1 no match
- -2 partial match; always given if at end subject
-*/
-
-static int
-match_ref(int offset, register PCRE_PUCHAR eptr, int length, match_data *md,
- BOOL caseless)
-{
-PCRE_PUCHAR eptr_start = eptr;
-register PCRE_PUCHAR p = md->start_subject + md->offset_vector[offset];
-#if defined SUPPORT_UTF && defined SUPPORT_UCP
-BOOL utf = md->utf;
-#endif
-
-#ifdef PCRE_DEBUG
-if (eptr >= md->end_subject)
- printf("matching subject ");
-else
- {
- printf("matching subject ");
- pchars(eptr, length, TRUE, md);
- }
-printf(" against backref ");
-pchars(p, length, FALSE, md);
-printf("\n");
-#endif
-
-/* Always fail if reference not set (and not JavaScript compatible - in that
-case the length is passed as zero). */
-
-if (length < 0) return -1;
-
-/* Separate the caseless case for speed. In UTF-8 mode we can only do this
-properly if Unicode properties are supported. Otherwise, we can check only
-ASCII characters. */
-
-if (caseless)
- {
-#if defined SUPPORT_UTF && defined SUPPORT_UCP
- if (utf)
- {
- /* Match characters up to the end of the reference. NOTE: the number of
- data units matched may differ, because in UTF-8 there are some characters
- whose upper and lower case versions code have different numbers of bytes.
- For example, U+023A (2 bytes in UTF-8) is the upper case version of U+2C65
- (3 bytes in UTF-8); a sequence of 3 of the former uses 6 bytes, as does a
- sequence of two of the latter. It is important, therefore, to check the
- length along the reference, not along the subject (earlier code did this
- wrong). */
-
- PCRE_PUCHAR endptr = p + length;
- while (p < endptr)
- {
- pcre_uint32 c, d;
- const ucd_record *ur;
- if (eptr >= md->end_subject) return -2; /* Partial match */
- GETCHARINC(c, eptr);
- GETCHARINC(d, p);
- ur = GET_UCD(d);
- if (c != d && c != d + ur->other_case)
- {
- const pcre_uint32 *pp = PRIV(ucd_caseless_sets) + ur->caseset;
- for (;;)
- {
- if (c < *pp) return -1;
- if (c == *pp++) break;
- }
- }
- }
- }
- else
-#endif
-
- /* The same code works when not in UTF-8 mode and in UTF-8 mode when there
- is no UCP support. */
- {
- while (length-- > 0)
- {
- pcre_uint32 cc, cp;
- if (eptr >= md->end_subject) return -2; /* Partial match */
- cc = UCHAR21TEST(eptr);
- cp = UCHAR21TEST(p);
- if (TABLE_GET(cp, md->lcc, cp) != TABLE_GET(cc, md->lcc, cc)) return -1;
- p++;
- eptr++;
- }
- }
- }
-
-/* In the caseful case, we can just compare the bytes, whether or not we
-are in UTF-8 mode. */
-
-else
- {
- while (length-- > 0)
- {
- if (eptr >= md->end_subject) return -2; /* Partial match */
- if (UCHAR21INCTEST(p) != UCHAR21INCTEST(eptr)) return -1;
- }
- }
-
-return (int)(eptr - eptr_start);
-}
-
-
-
-/***************************************************************************
-****************************************************************************
- RECURSION IN THE match() FUNCTION
-
-The match() function is highly recursive, though not every recursive call
-increases the recursive depth. Nevertheless, some regular expressions can cause
-it to recurse to a great depth. I was writing for Unix, so I just let it call
-itself recursively. This uses the stack for saving everything that has to be
-saved for a recursive call. On Unix, the stack can be large, and this works
-fine.
-
-It turns out that on some non-Unix-like systems there are problems with
-programs that use a lot of stack. (This despite the fact that every last chip
-has oodles of memory these days, and techniques for extending the stack have
-been known for decades.) So....
-
-There is a fudge, triggered by defining NO_RECURSE, which avoids recursive
-calls by keeping local variables that need to be preserved in blocks of memory
-obtained from malloc() instead instead of on the stack. Macros are used to
-achieve this so that the actual code doesn't look very different to what it
-always used to.
-
-The original heap-recursive code used longjmp(). However, it seems that this
-can be very slow on some operating systems. Following a suggestion from Stan
-Switzer, the use of longjmp() has been abolished, at the cost of having to
-provide a unique number for each call to RMATCH. There is no way of generating
-a sequence of numbers at compile time in C. I have given them names, to make
-them stand out more clearly.
-
-Crude tests on x86 Linux show a small speedup of around 5-8%. However, on
-FreeBSD, avoiding longjmp() more than halves the time taken to run the standard
-tests. Furthermore, not using longjmp() means that local dynamic variables
-don't have indeterminate values; this has meant that the frame size can be
-reduced because the result can be "passed back" by straight setting of the
-variable instead of being passed in the frame.
-****************************************************************************
-***************************************************************************/
-
-/* Numbers for RMATCH calls. When this list is changed, the code at HEAP_RETURN
-below must be updated in sync. */
-
-enum { RM1=1, RM2, RM3, RM4, RM5, RM6, RM7, RM8, RM9, RM10,
- RM11, RM12, RM13, RM14, RM15, RM16, RM17, RM18, RM19, RM20,
- RM21, RM22, RM23, RM24, RM25, RM26, RM27, RM28, RM29, RM30,
- RM31, RM32, RM33, RM34, RM35, RM36, RM37, RM38, RM39, RM40,
- RM41, RM42, RM43, RM44, RM45, RM46, RM47, RM48, RM49, RM50,
- RM51, RM52, RM53, RM54, RM55, RM56, RM57, RM58, RM59, RM60,
- RM61, RM62, RM63, RM64, RM65, RM66, RM67 };
-
-/* These versions of the macros use the stack, as normal. There are debugging
-versions and production versions. Note that the "rw" argument of RMATCH isn't
-actually used in this definition. */
-
-#ifndef NO_RECURSE
-#define REGISTER register
-
-#ifdef PCRE_DEBUG
-#define RMATCH(ra,rb,rc,rd,re,rw) \
- { \
- printf("match() called in line %d\n", __LINE__); \
- rrc = match(ra,rb,mstart,rc,rd,re,rdepth+1); \
- printf("to line %d\n", __LINE__); \
- }
-#define RRETURN(ra) \
- { \
- printf("match() returned %d from line %d\n", ra, __LINE__); \
- return ra; \
- }
-#else
-#define RMATCH(ra,rb,rc,rd,re,rw) \
- rrc = match(ra,rb,mstart,rc,rd,re,rdepth+1)
-#define RRETURN(ra) return ra
-#endif
-
-#else
-
-
-/* These versions of the macros manage a private stack on the heap. Note that
-the "rd" argument of RMATCH isn't actually used in this definition. It's the md
-argument of match(), which never changes. */
-
-#define REGISTER
-
-#define RMATCH(ra,rb,rc,rd,re,rw)\
- {\
- heapframe *newframe = frame->Xnextframe;\
- if (newframe == NULL)\
- {\
- newframe = (heapframe *)(PUBL(stack_malloc))(sizeof(heapframe));\
- if (newframe == NULL) RRETURN(PCRE_ERROR_NOMEMORY);\
- newframe->Xnextframe = NULL;\
- frame->Xnextframe = newframe;\
- }\
- frame->Xwhere = rw;\
- newframe->Xeptr = ra;\
- newframe->Xecode = rb;\
- newframe->Xmstart = mstart;\
- newframe->Xoffset_top = rc;\
- newframe->Xeptrb = re;\
- newframe->Xrdepth = frame->Xrdepth + 1;\
- newframe->Xprevframe = frame;\
- frame = newframe;\
- DPRINTF(("restarting from line %d\n", __LINE__));\
- goto HEAP_RECURSE;\
- L_##rw:\
- DPRINTF(("jumped back to line %d\n", __LINE__));\
- }
-
-#define RRETURN(ra)\
- {\
- heapframe *oldframe = frame;\
- frame = oldframe->Xprevframe;\
- if (frame != NULL)\
- {\
- rrc = ra;\
- goto HEAP_RETURN;\
- }\
- return ra;\
- }
-
-
-/* Structure for remembering the local variables in a private frame */
-
-typedef struct heapframe {
- struct heapframe *Xprevframe;
- struct heapframe *Xnextframe;
-
- /* Function arguments that may change */
-
- PCRE_PUCHAR Xeptr;
- const pcre_uchar *Xecode;
- PCRE_PUCHAR Xmstart;
- int Xoffset_top;
- eptrblock *Xeptrb;
- unsigned int Xrdepth;
-
- /* Function local variables */
-
- PCRE_PUCHAR Xcallpat;
-#ifdef SUPPORT_UTF
- PCRE_PUCHAR Xcharptr;
-#endif
- PCRE_PUCHAR Xdata;
- PCRE_PUCHAR Xnext;
- PCRE_PUCHAR Xpp;
- PCRE_PUCHAR Xprev;
- PCRE_PUCHAR Xsaved_eptr;
-
- recursion_info Xnew_recursive;
-
- BOOL Xcur_is_word;
- BOOL Xcondition;
- BOOL Xprev_is_word;
-
-#ifdef SUPPORT_UCP
- int Xprop_type;
- unsigned int Xprop_value;
- int Xprop_fail_result;
- int Xoclength;
- pcre_uchar Xocchars[6];
-#endif
-
- int Xcodelink;
- int Xctype;
- unsigned int Xfc;
- int Xfi;
- int Xlength;
- int Xmax;
- int Xmin;
- unsigned int Xnumber;
- int Xoffset;
- unsigned int Xop;
- pcre_int32 Xsave_capture_last;
- int Xsave_offset1, Xsave_offset2, Xsave_offset3;
- int Xstacksave[REC_STACK_SAVE_MAX];
-
- eptrblock Xnewptrb;
-
- /* Where to jump back to */
-
- int Xwhere;
-
-} heapframe;
-
-#endif
-
-
-/***************************************************************************
-***************************************************************************/
-
-
-
-/*************************************************
-* Match from current position *
-*************************************************/
-
-/* This function is called recursively in many circumstances. Whenever it
-returns a negative (error) response, the outer incarnation must also return the
-same response. */
-
-/* These macros pack up tests that are used for partial matching, and which
-appear several times in the code. We set the "hit end" flag if the pointer is
-at the end of the subject and also past the start of the subject (i.e.
-something has been matched). For hard partial matching, we then return
-immediately. The second one is used when we already know we are past the end of
-the subject. */
-
-#define CHECK_PARTIAL()\
- if (md->partial != 0 && eptr >= md->end_subject && \
- eptr > md->start_used_ptr) \
- { \
- md->hitend = TRUE; \
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); \
- }
-
-#define SCHECK_PARTIAL()\
- if (md->partial != 0 && eptr > md->start_used_ptr) \
- { \
- md->hitend = TRUE; \
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL); \
- }
-
-
-/* Performance note: It might be tempting to extract commonly used fields from
-the md structure (e.g. utf, end_subject) into individual variables to improve
-performance. Tests using gcc on a SPARC disproved this; in the first case, it
-made performance worse.
-
-Arguments:
- eptr pointer to current character in subject
- ecode pointer to current position in compiled code
- mstart pointer to the current match start position (can be modified
- by encountering \K)
- offset_top current top pointer
- md pointer to "static" info for the match
- eptrb pointer to chain of blocks containing eptr at start of
- brackets - for testing for empty matches
- rdepth the recursion depth
-
-Returns: MATCH_MATCH if matched ) these values are >= 0
- MATCH_NOMATCH if failed to match )
- a negative MATCH_xxx value for PRUNE, SKIP, etc
- a negative PCRE_ERROR_xxx value if aborted by an error condition
- (e.g. stopped by repeated call or recursion limit)
-*/
-
-static int
-match(REGISTER PCRE_PUCHAR eptr, REGISTER const pcre_uchar *ecode,
- PCRE_PUCHAR mstart, int offset_top, match_data *md, eptrblock *eptrb,
- unsigned int rdepth)
-{
-/* These variables do not need to be preserved over recursion in this function,
-so they can be ordinary variables in all cases. Mark some of them with
-"register" because they are used a lot in loops. */
-
-register int rrc; /* Returns from recursive calls */
-register int i; /* Used for loops not involving calls to RMATCH() */
-register pcre_uint32 c; /* Character values not kept over RMATCH() calls */
-register BOOL utf; /* Local copy of UTF flag for speed */
-
-BOOL minimize, possessive; /* Quantifier options */
-BOOL caseless;
-int condcode;
-
-/* When recursion is not being used, all "local" variables that have to be
-preserved over calls to RMATCH() are part of a "frame". We set up the top-level
-frame on the stack here; subsequent instantiations are obtained from the heap
-whenever RMATCH() does a "recursion". See the macro definitions above. Putting
-the top-level on the stack rather than malloc-ing them all gives a performance
-boost in many cases where there is not much "recursion". */
-
-#ifdef NO_RECURSE
-heapframe *frame = (heapframe *)md->match_frames_base;
-
-/* Copy in the original argument variables */
-
-frame->Xeptr = eptr;
-frame->Xecode = ecode;
-frame->Xmstart = mstart;
-frame->Xoffset_top = offset_top;
-frame->Xeptrb = eptrb;
-frame->Xrdepth = rdepth;
-
-/* This is where control jumps back to to effect "recursion" */
-
-HEAP_RECURSE:
-
-/* Macros make the argument variables come from the current frame */
-
-#define eptr frame->Xeptr
-#define ecode frame->Xecode
-#define mstart frame->Xmstart
-#define offset_top frame->Xoffset_top
-#define eptrb frame->Xeptrb
-#define rdepth frame->Xrdepth
-
-/* Ditto for the local variables */
-
-#ifdef SUPPORT_UTF
-#define charptr frame->Xcharptr
-#endif
-#define callpat frame->Xcallpat
-#define codelink frame->Xcodelink
-#define data frame->Xdata
-#define next frame->Xnext
-#define pp frame->Xpp
-#define prev frame->Xprev
-#define saved_eptr frame->Xsaved_eptr
-
-#define new_recursive frame->Xnew_recursive
-
-#define cur_is_word frame->Xcur_is_word
-#define condition frame->Xcondition
-#define prev_is_word frame->Xprev_is_word
-
-#ifdef SUPPORT_UCP
-#define prop_type frame->Xprop_type
-#define prop_value frame->Xprop_value
-#define prop_fail_result frame->Xprop_fail_result
-#define oclength frame->Xoclength
-#define occhars frame->Xocchars
-#endif
-
-#define ctype frame->Xctype
-#define fc frame->Xfc
-#define fi frame->Xfi
-#define length frame->Xlength
-#define max frame->Xmax
-#define min frame->Xmin
-#define number frame->Xnumber
-#define offset frame->Xoffset
-#define op frame->Xop
-#define save_capture_last frame->Xsave_capture_last
-#define save_offset1 frame->Xsave_offset1
-#define save_offset2 frame->Xsave_offset2
-#define save_offset3 frame->Xsave_offset3
-#define stacksave frame->Xstacksave
-
-#define newptrb frame->Xnewptrb
-
-/* When recursion is being used, local variables are allocated on the stack and
-get preserved during recursion in the normal way. In this environment, fi and
-i, and fc and c, can be the same variables. */
-
-#else /* NO_RECURSE not defined */
-#define fi i
-#define fc c
-
-/* Many of the following variables are used only in small blocks of the code.
-My normal style of coding would have declared them within each of those blocks.
-However, in order to accommodate the version of this code that uses an external
-"stack" implemented on the heap, it is easier to declare them all here, so the
-declarations can be cut out in a block. The only declarations within blocks
-below are for variables that do not have to be preserved over a recursive call
-to RMATCH(). */
-
-#ifdef SUPPORT_UTF
-const pcre_uchar *charptr;
-#endif
-const pcre_uchar *callpat;
-const pcre_uchar *data;
-const pcre_uchar *next;
-PCRE_PUCHAR pp;
-const pcre_uchar *prev;
-PCRE_PUCHAR saved_eptr;
-
-recursion_info new_recursive;
-
-BOOL cur_is_word;
-BOOL condition;
-BOOL prev_is_word;
-
-#ifdef SUPPORT_UCP
-int prop_type;
-unsigned int prop_value;
-int prop_fail_result;
-int oclength;
-pcre_uchar occhars[6];
-#endif
-
-int codelink;
-int ctype;
-int length;
-int max;
-int min;
-unsigned int number;
-int offset;
-unsigned int op;
-pcre_int32 save_capture_last;
-int save_offset1, save_offset2, save_offset3;
-int stacksave[REC_STACK_SAVE_MAX];
-
-eptrblock newptrb;
-
-/* There is a special fudge for calling match() in a way that causes it to
-measure the size of its basic stack frame when the stack is being used for
-recursion. The second argument (ecode) being NULL triggers this behaviour. It
-cannot normally ever be NULL. The return is the negated value of the frame
-size. */
-
-if (ecode == NULL)
- {
- if (rdepth == 0)
- return match((PCRE_PUCHAR)&rdepth, NULL, NULL, 0, NULL, NULL, 1);
- else
- {
- int len = (char *)&rdepth - (char *)eptr;
- return (len > 0)? -len : len;
- }
- }
-#endif /* NO_RECURSE */
-
-/* To save space on the stack and in the heap frame, I have doubled up on some
-of the local variables that are used only in localised parts of the code, but
-still need to be preserved over recursive calls of match(). These macros define
-the alternative names that are used. */
-
-#define allow_zero cur_is_word
-#define cbegroup condition
-#define code_offset codelink
-#define condassert condition
-#define matched_once prev_is_word
-#define foc number
-#define save_mark data
-
-/* These statements are here to stop the compiler complaining about unitialized
-variables. */
-
-#ifdef SUPPORT_UCP
-prop_value = 0;
-prop_fail_result = 0;
-#endif
-
-
-/* This label is used for tail recursion, which is used in a few cases even
-when NO_RECURSE is not defined, in order to reduce the amount of stack that is
-used. Thanks to Ian Taylor for noticing this possibility and sending the
-original patch. */
-
-TAIL_RECURSE:
-
-/* OK, now we can get on with the real code of the function. Recursive calls
-are specified by the macro RMATCH and RRETURN is used to return. When
-NO_RECURSE is *not* defined, these just turn into a recursive call to match()
-and a "return", respectively (possibly with some debugging if PCRE_DEBUG is
-defined). However, RMATCH isn't like a function call because it's quite a
-complicated macro. It has to be used in one particular way. This shouldn't,
-however, impact performance when true recursion is being used. */
-
-#ifdef SUPPORT_UTF
-utf = md->utf; /* Local copy of the flag */
-#else
-utf = FALSE;
-#endif
-
-/* First check that we haven't called match() too many times, or that we
-haven't exceeded the recursive call limit. */
-
-if (md->match_call_count++ >= md->match_limit) RRETURN(PCRE_ERROR_MATCHLIMIT);
-if (rdepth >= md->match_limit_recursion) RRETURN(PCRE_ERROR_RECURSIONLIMIT);
-
-/* At the start of a group with an unlimited repeat that may match an empty
-string, the variable md->match_function_type is set to MATCH_CBEGROUP. It is
-done this way to save having to use another function argument, which would take
-up space on the stack. See also MATCH_CONDASSERT below.
-
-When MATCH_CBEGROUP is set, add the current subject pointer to the chain of
-such remembered pointers, to be checked when we hit the closing ket, in order
-to break infinite loops that match no characters. When match() is called in
-other circumstances, don't add to the chain. The MATCH_CBEGROUP feature must
-NOT be used with tail recursion, because the memory block that is used is on
-the stack, so a new one may be required for each match(). */
-
-if (md->match_function_type == MATCH_CBEGROUP)
- {
- newptrb.epb_saved_eptr = eptr;
- newptrb.epb_prev = eptrb;
- eptrb = &newptrb;
- md->match_function_type = 0;
- }
-
-/* Now start processing the opcodes. */
-
-for (;;)
- {
- minimize = possessive = FALSE;
- op = *ecode;
-
- switch(op)
- {
- case OP_MARK:
- md->nomatch_mark = ecode + 2;
- md->mark = NULL; /* In case previously set by assertion */
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
- eptrb, RM55);
- if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
- md->mark == NULL) md->mark = ecode + 2;
-
- /* A return of MATCH_SKIP_ARG means that matching failed at SKIP with an
- argument, and we must check whether that argument matches this MARK's
- argument. It is passed back in md->start_match_ptr (an overloading of that
- variable). If it does match, we reset that variable to the current subject
- position and return MATCH_SKIP. Otherwise, pass back the return code
- unaltered. */
-
- else if (rrc == MATCH_SKIP_ARG &&
- STRCMP_UC_UC_TEST(ecode + 2, md->start_match_ptr) == 0)
- {
- md->start_match_ptr = eptr;
- RRETURN(MATCH_SKIP);
- }
- RRETURN(rrc);
-
- case OP_FAIL:
- RRETURN(MATCH_NOMATCH);
-
- case OP_COMMIT:
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
- eptrb, RM52);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- RRETURN(MATCH_COMMIT);
-
- case OP_PRUNE:
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
- eptrb, RM51);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- RRETURN(MATCH_PRUNE);
-
- case OP_PRUNE_ARG:
- md->nomatch_mark = ecode + 2;
- md->mark = NULL; /* In case previously set by assertion */
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
- eptrb, RM56);
- if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
- md->mark == NULL) md->mark = ecode + 2;
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- RRETURN(MATCH_PRUNE);
-
- case OP_SKIP:
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
- eptrb, RM53);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- md->start_match_ptr = eptr; /* Pass back current position */
- RRETURN(MATCH_SKIP);
-
- /* Note that, for Perl compatibility, SKIP with an argument does NOT set
- nomatch_mark. When a pattern match ends with a SKIP_ARG for which there was
- not a matching mark, we have to re-run the match, ignoring the SKIP_ARG
- that failed and any that precede it (either they also failed, or were not
- triggered). To do this, we maintain a count of executed SKIP_ARGs. If a
- SKIP_ARG gets to top level, the match is re-run with md->ignore_skip_arg
- set to the count of the one that failed. */
-
- case OP_SKIP_ARG:
- md->skip_arg_count++;
- if (md->skip_arg_count <= md->ignore_skip_arg)
- {
- ecode += PRIV(OP_lengths)[*ecode] + ecode[1];
- break;
- }
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top, md,
- eptrb, RM57);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-
- /* Pass back the current skip name by overloading md->start_match_ptr and
- returning the special MATCH_SKIP_ARG return code. This will either be
- caught by a matching MARK, or get to the top, where it causes a rematch
- with md->ignore_skip_arg set to the value of md->skip_arg_count. */
-
- md->start_match_ptr = ecode + 2;
- RRETURN(MATCH_SKIP_ARG);
-
- /* For THEN (and THEN_ARG) we pass back the address of the opcode, so that
- the branch in which it occurs can be determined. Overload the start of
- match pointer to do this. */
-
- case OP_THEN:
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
- eptrb, RM54);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- md->start_match_ptr = ecode;
- RRETURN(MATCH_THEN);
-
- case OP_THEN_ARG:
- md->nomatch_mark = ecode + 2;
- md->mark = NULL; /* In case previously set by assertion */
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode] + ecode[1], offset_top,
- md, eptrb, RM58);
- if ((rrc == MATCH_MATCH || rrc == MATCH_ACCEPT) &&
- md->mark == NULL) md->mark = ecode + 2;
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- md->start_match_ptr = ecode;
- RRETURN(MATCH_THEN);
-
- /* Handle an atomic group that does not contain any capturing parentheses.
- This can be handled like an assertion. Prior to 8.13, all atomic groups
- were handled this way. In 8.13, the code was changed as below for ONCE, so
- that backups pass through the group and thereby reset captured values.
- However, this uses a lot more stack, so in 8.20, atomic groups that do not
- contain any captures generate OP_ONCE_NC, which can be handled in the old,
- less stack intensive way.
-
- Check the alternative branches in turn - the matching won't pass the KET
- for this kind of subpattern. If any one branch matches, we carry on as at
- the end of a normal bracket, leaving the subject pointer, but resetting
- the start-of-match value in case it was changed by \K. */
-
- case OP_ONCE_NC:
- prev = ecode;
- saved_eptr = eptr;
- save_mark = md->mark;
- do
- {
- RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM64);
- if (rrc == MATCH_MATCH) /* Note: _not_ MATCH_ACCEPT */
- {
- mstart = md->start_match_ptr;
- break;
- }
- if (rrc == MATCH_THEN)
- {
- next = ecode + GET(ecode,1);
- if (md->start_match_ptr < next &&
- (*ecode == OP_ALT || *next == OP_ALT))
- rrc = MATCH_NOMATCH;
- }
-
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- ecode += GET(ecode,1);
- md->mark = save_mark;
- }
- while (*ecode == OP_ALT);
-
- /* If hit the end of the group (which could be repeated), fail */
-
- if (*ecode != OP_ONCE_NC && *ecode != OP_ALT) RRETURN(MATCH_NOMATCH);
-
- /* Continue as from after the group, updating the offsets high water
- mark, since extracts may have been taken. */
-
- do ecode += GET(ecode, 1); while (*ecode == OP_ALT);
-
- offset_top = md->end_offset_top;
- eptr = md->end_match_ptr;
-
- /* For a non-repeating ket, just continue at this level. This also
- happens for a repeating ket if no characters were matched in the group.
- This is the forcible breaking of infinite loops as implemented in Perl
- 5.005. */
-
- if (*ecode == OP_KET || eptr == saved_eptr)
- {
- ecode += 1+LINK_SIZE;
- break;
- }
-
- /* The repeating kets try the rest of the pattern or restart from the
- preceding bracket, in the appropriate order. The second "call" of match()
- uses tail recursion, to avoid using another stack frame. */
-
- if (*ecode == OP_KETRMIN)
- {
- RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM65);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- ecode = prev;
- goto TAIL_RECURSE;
- }
- else /* OP_KETRMAX */
- {
- RMATCH(eptr, prev, offset_top, md, eptrb, RM66);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- ecode += 1 + LINK_SIZE;
- goto TAIL_RECURSE;
- }
- /* Control never gets here */
-
- /* Handle a capturing bracket, other than those that are possessive with an
- unlimited repeat. If there is space in the offset vector, save the current
- subject position in the working slot at the top of the vector. We mustn't
- change the current values of the data slot, because they may be set from a
- previous iteration of this group, and be referred to by a reference inside
- the group. A failure to match might occur after the group has succeeded,
- if something later on doesn't match. For this reason, we need to restore
- the working value and also the values of the final offsets, in case they
- were set by a previous iteration of the same bracket.
-
- If there isn't enough space in the offset vector, treat this as if it were
- a non-capturing bracket. Don't worry about setting the flag for the error
- case here; that is handled in the code for KET. */
-
- case OP_CBRA:
- case OP_SCBRA:
- number = GET2(ecode, 1+LINK_SIZE);
- offset = number << 1;
-
-#ifdef PCRE_DEBUG
- printf("start bracket %d\n", number);
- printf("subject=");
- pchars(eptr, 16, TRUE, md);
- printf("\n");
-#endif
-
- if (offset < md->offset_max)
- {
- save_offset1 = md->offset_vector[offset];
- save_offset2 = md->offset_vector[offset+1];
- save_offset3 = md->offset_vector[md->offset_end - number];
- save_capture_last = md->capture_last;
- save_mark = md->mark;
-
- DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
- md->offset_vector[md->offset_end - number] =
- (int)(eptr - md->start_subject);
-
- for (;;)
- {
- if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
- eptrb, RM1);
- if (rrc == MATCH_ONCE) break; /* Backing up through an atomic group */
-
- /* If we backed up to a THEN, check whether it is within the current
- branch by comparing the address of the THEN that is passed back with
- the end of the branch. If it is within the current branch, and the
- branch is one of two or more alternatives (it either starts or ends
- with OP_ALT), we have reached the limit of THEN's action, so convert
- the return code to NOMATCH, which will cause normal backtracking to
- happen from now on. Otherwise, THEN is passed back to an outer
- alternative. This implements Perl's treatment of parenthesized groups,
- where a group not containing | does not affect the current alternative,
- that is, (X) is NOT the same as (X|(*F)). */
-
- if (rrc == MATCH_THEN)
- {
- next = ecode + GET(ecode,1);
- if (md->start_match_ptr < next &&
- (*ecode == OP_ALT || *next == OP_ALT))
- rrc = MATCH_NOMATCH;
- }
-
- /* Anything other than NOMATCH is passed back. */
-
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- md->capture_last = save_capture_last;
- ecode += GET(ecode, 1);
- md->mark = save_mark;
- if (*ecode != OP_ALT) break;
- }
-
- DPRINTF(("bracket %d failed\n", number));
- md->offset_vector[offset] = save_offset1;
- md->offset_vector[offset+1] = save_offset2;
- md->offset_vector[md->offset_end - number] = save_offset3;
-
- /* At this point, rrc will be one of MATCH_ONCE or MATCH_NOMATCH. */
-
- RRETURN(rrc);
- }
-
- /* FALL THROUGH ... Insufficient room for saving captured contents. Treat
- as a non-capturing bracket. */
-
- /* VVVVVVVVVVVVVVVVVVVVVVVVV */
- /* VVVVVVVVVVVVVVVVVVVVVVVVV */
-
- DPRINTF(("insufficient capture room: treat as non-capturing\n"));
-
- /* VVVVVVVVVVVVVVVVVVVVVVVVV */
- /* VVVVVVVVVVVVVVVVVVVVVVVVV */
-
- /* Non-capturing or atomic group, except for possessive with unlimited
- repeat and ONCE group with no captures. Loop for all the alternatives.
-
- When we get to the final alternative within the brackets, we used to return
- the result of a recursive call to match() whatever happened so it was
- possible to reduce stack usage by turning this into a tail recursion,
- except in the case of a possibly empty group. However, now that there is
- the possiblity of (*THEN) occurring in the final alternative, this
- optimization is no longer always possible.
-
- We can optimize if we know there are no (*THEN)s in the pattern; at present
- this is the best that can be done.
-
- MATCH_ONCE is returned when the end of an atomic group is successfully
- reached, but subsequent matching fails. It passes back up the tree (causing
- captured values to be reset) until the original atomic group level is
- reached. This is tested by comparing md->once_target with the start of the
- group. At this point, the return is converted into MATCH_NOMATCH so that
- previous backup points can be taken. */
-
- case OP_ONCE:
- case OP_BRA:
- case OP_SBRA:
- DPRINTF(("start non-capturing bracket\n"));
-
- for (;;)
- {
- if (op >= OP_SBRA || op == OP_ONCE)
- md->match_function_type = MATCH_CBEGROUP;
-
- /* If this is not a possibly empty group, and there are no (*THEN)s in
- the pattern, and this is the final alternative, optimize as described
- above. */
-
- else if (!md->hasthen && ecode[GET(ecode, 1)] != OP_ALT)
- {
- ecode += PRIV(OP_lengths)[*ecode];
- goto TAIL_RECURSE;
- }
-
- /* In all other cases, we have to make another call to match(). */
-
- save_mark = md->mark;
- save_capture_last = md->capture_last;
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md, eptrb,
- RM2);
-
- /* See comment in the code for capturing groups above about handling
- THEN. */
-
- if (rrc == MATCH_THEN)
- {
- next = ecode + GET(ecode,1);
- if (md->start_match_ptr < next &&
- (*ecode == OP_ALT || *next == OP_ALT))
- rrc = MATCH_NOMATCH;
- }
-
- if (rrc != MATCH_NOMATCH)
- {
- if (rrc == MATCH_ONCE)
- {
- const pcre_uchar *scode = ecode;
- if (*scode != OP_ONCE) /* If not at start, find it */
- {
- while (*scode == OP_ALT) scode += GET(scode, 1);
- scode -= GET(scode, 1);
- }
- if (md->once_target == scode) rrc = MATCH_NOMATCH;
- }
- RRETURN(rrc);
- }
- ecode += GET(ecode, 1);
- md->mark = save_mark;
- if (*ecode != OP_ALT) break;
- md->capture_last = save_capture_last;
- }
-
- RRETURN(MATCH_NOMATCH);
-
- /* Handle possessive capturing brackets with an unlimited repeat. We come
- here from BRAZERO with allow_zero set TRUE. The offset_vector values are
- handled similarly to the normal case above. However, the matching is
- different. The end of these brackets will always be OP_KETRPOS, which
- returns MATCH_KETRPOS without going further in the pattern. By this means
- we can handle the group by iteration rather than recursion, thereby
- reducing the amount of stack needed. */
-
- case OP_CBRAPOS:
- case OP_SCBRAPOS:
- allow_zero = FALSE;
-
- POSSESSIVE_CAPTURE:
- number = GET2(ecode, 1+LINK_SIZE);
- offset = number << 1;
-
-#ifdef PCRE_DEBUG
- printf("start possessive bracket %d\n", number);
- printf("subject=");
- pchars(eptr, 16, TRUE, md);
- printf("\n");
-#endif
-
- if (offset >= md->offset_max) goto POSSESSIVE_NON_CAPTURE;
-
- matched_once = FALSE;
- code_offset = (int)(ecode - md->start_code);
-
- save_offset1 = md->offset_vector[offset];
- save_offset2 = md->offset_vector[offset+1];
- save_offset3 = md->offset_vector[md->offset_end - number];
- save_capture_last = md->capture_last;
-
- DPRINTF(("saving %d %d %d\n", save_offset1, save_offset2, save_offset3));
-
- /* Each time round the loop, save the current subject position for use
- when the group matches. For MATCH_MATCH, the group has matched, so we
- restart it with a new subject starting position, remembering that we had
- at least one match. For MATCH_NOMATCH, carry on with the alternatives, as
- usual. If we haven't matched any alternatives in any iteration, check to
- see if a previous iteration matched. If so, the group has matched;
- continue from afterwards. Otherwise it has failed; restore the previous
- capture values before returning NOMATCH. */
-
- for (;;)
- {
- md->offset_vector[md->offset_end - number] =
- (int)(eptr - md->start_subject);
- if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
- eptrb, RM63);
- if (rrc == MATCH_KETRPOS)
- {
- offset_top = md->end_offset_top;
- ecode = md->start_code + code_offset;
- save_capture_last = md->capture_last;
- matched_once = TRUE;
- mstart = md->start_match_ptr; /* In case \K changed it */
- if (eptr == md->end_match_ptr) /* Matched an empty string */
- {
- do ecode += GET(ecode, 1); while (*ecode == OP_ALT);
- break;
- }
- eptr = md->end_match_ptr;
- continue;
- }
-
- /* See comment in the code for capturing groups above about handling
- THEN. */
-
- if (rrc == MATCH_THEN)
- {
- next = ecode + GET(ecode,1);
- if (md->start_match_ptr < next &&
- (*ecode == OP_ALT || *next == OP_ALT))
- rrc = MATCH_NOMATCH;
- }
-
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- md->capture_last = save_capture_last;
- ecode += GET(ecode, 1);
- if (*ecode != OP_ALT) break;
- }
-
- if (!matched_once)
- {
- md->offset_vector[offset] = save_offset1;
- md->offset_vector[offset+1] = save_offset2;
- md->offset_vector[md->offset_end - number] = save_offset3;
- }
-
- if (allow_zero || matched_once)
- {
- ecode += 1 + LINK_SIZE;
- break;
- }
-
- RRETURN(MATCH_NOMATCH);
-
- /* Non-capturing possessive bracket with unlimited repeat. We come here
- from BRAZERO with allow_zero = TRUE. The code is similar to the above,
- without the capturing complication. It is written out separately for speed
- and cleanliness. */
-
- case OP_BRAPOS:
- case OP_SBRAPOS:
- allow_zero = FALSE;
-
- POSSESSIVE_NON_CAPTURE:
- matched_once = FALSE;
- code_offset = (int)(ecode - md->start_code);
- save_capture_last = md->capture_last;
-
- for (;;)
- {
- if (op >= OP_SBRA) md->match_function_type = MATCH_CBEGROUP;
- RMATCH(eptr, ecode + PRIV(OP_lengths)[*ecode], offset_top, md,
- eptrb, RM48);
- if (rrc == MATCH_KETRPOS)
- {
- offset_top = md->end_offset_top;
- ecode = md->start_code + code_offset;
- matched_once = TRUE;
- mstart = md->start_match_ptr; /* In case \K reset it */
- if (eptr == md->end_match_ptr) /* Matched an empty string */
- {
- do ecode += GET(ecode, 1); while (*ecode == OP_ALT);
- break;
- }
- eptr = md->end_match_ptr;
- continue;
- }
-
- /* See comment in the code for capturing groups above about handling
- THEN. */
-
- if (rrc == MATCH_THEN)
- {
- next = ecode + GET(ecode,1);
- if (md->start_match_ptr < next &&
- (*ecode == OP_ALT || *next == OP_ALT))
- rrc = MATCH_NOMATCH;
- }
-
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- ecode += GET(ecode, 1);
- if (*ecode != OP_ALT) break;
- md->capture_last = save_capture_last;
- }
-
- if (matched_once || allow_zero)
- {
- ecode += 1 + LINK_SIZE;
- break;
- }
- RRETURN(MATCH_NOMATCH);
-
- /* Control never reaches here. */
-
- /* Conditional group: compilation checked that there are no more than two
- branches. If the condition is false, skipping the first branch takes us
- past the end of the item if there is only one branch, but that's exactly
- what we want. */
-
- case OP_COND:
- case OP_SCOND:
-
- /* The variable codelink will be added to ecode when the condition is
- false, to get to the second branch. Setting it to the offset to the ALT
- or KET, then incrementing ecode achieves this effect. We now have ecode
- pointing to the condition or callout. */
-
- codelink = GET(ecode, 1); /* Offset to the second branch */
- ecode += 1 + LINK_SIZE; /* From this opcode */
-
- /* Because of the way auto-callout works during compile, a callout item is
- inserted between OP_COND and an assertion condition. */
-
- if (*ecode == OP_CALLOUT)
- {
- if (PUBL(callout) != NULL)
- {
- PUBL(callout_block) cb;
- cb.version = 2; /* Version 1 of the callout block */
- cb.callout_number = ecode[1];
- cb.offset_vector = md->offset_vector;
-#if defined COMPILE_PCRE8
- cb.subject = (PCRE_SPTR)md->start_subject;
-#elif defined COMPILE_PCRE16
- cb.subject = (PCRE_SPTR16)md->start_subject;
-#elif defined COMPILE_PCRE32
- cb.subject = (PCRE_SPTR32)md->start_subject;
-#endif
- cb.subject_length = (int)(md->end_subject - md->start_subject);
- cb.start_match = (int)(mstart - md->start_subject);
- cb.current_position = (int)(eptr - md->start_subject);
- cb.pattern_position = GET(ecode, 2);
- cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
- cb.capture_top = offset_top/2;
- cb.capture_last = md->capture_last & CAPLMASK;
- /* Internal change requires this for API compatibility. */
- if (cb.capture_last == 0) cb.capture_last = -1;
- cb.callout_data = md->callout_data;
- cb.mark = md->nomatch_mark;
- if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
- if (rrc < 0) RRETURN(rrc);
- }
-
- /* Advance ecode past the callout, so it now points to the condition. We
- must adjust codelink so that the value of ecode+codelink is unchanged. */
-
- ecode += PRIV(OP_lengths)[OP_CALLOUT];
- codelink -= PRIV(OP_lengths)[OP_CALLOUT];
- }
-
- /* Test the various possible conditions */
-
- condition = FALSE;
- switch(condcode = *ecode)
- {
- case OP_RREF: /* Numbered group recursion test */
- if (md->recursive != NULL) /* Not recursing => FALSE */
- {
- unsigned int recno = GET2(ecode, 1); /* Recursion group number*/
- condition = (recno == RREF_ANY || recno == md->recursive->group_num);
- }
- break;
-
- case OP_DNRREF: /* Duplicate named group recursion test */
- if (md->recursive != NULL)
- {
- int count = GET2(ecode, 1 + IMM2_SIZE);
- pcre_uchar *slot = md->name_table + GET2(ecode, 1) * md->name_entry_size;
- while (count-- > 0)
- {
- unsigned int recno = GET2(slot, 0);
- condition = recno == md->recursive->group_num;
- if (condition) break;
- slot += md->name_entry_size;
- }
- }
- break;
-
- case OP_CREF: /* Numbered group used test */
- offset = GET2(ecode, 1) << 1; /* Doubled ref number */
- condition = offset < offset_top && md->offset_vector[offset] >= 0;
- break;
-
- case OP_DNCREF: /* Duplicate named group used test */
- {
- int count = GET2(ecode, 1 + IMM2_SIZE);
- pcre_uchar *slot = md->name_table + GET2(ecode, 1) * md->name_entry_size;
- while (count-- > 0)
- {
- offset = GET2(slot, 0) << 1;
- condition = offset < offset_top && md->offset_vector[offset] >= 0;
- if (condition) break;
- slot += md->name_entry_size;
- }
- }
- break;
-
- case OP_DEF: /* DEFINE - always false */
- case OP_FAIL: /* From optimized (?!) condition */
- break;
-
- /* The condition is an assertion. Call match() to evaluate it - setting
- md->match_function_type to MATCH_CONDASSERT causes it to stop at the end
- of an assertion. */
-
- default:
- md->match_function_type = MATCH_CONDASSERT;
- RMATCH(eptr, ecode, offset_top, md, NULL, RM3);
- if (rrc == MATCH_MATCH)
- {
- if (md->end_offset_top > offset_top)
- offset_top = md->end_offset_top; /* Captures may have happened */
- condition = TRUE;
-
- /* Advance ecode past the assertion to the start of the first branch,
- but adjust it so that the general choosing code below works. If the
- assertion has a quantifier that allows zero repeats we must skip over
- the BRAZERO. This is a lunatic thing to do, but somebody did! */
-
- if (*ecode == OP_BRAZERO) ecode++;
- ecode += GET(ecode, 1);
- while (*ecode == OP_ALT) ecode += GET(ecode, 1);
- ecode += 1 + LINK_SIZE - PRIV(OP_lengths)[condcode];
- }
-
- /* PCRE doesn't allow the effect of (*THEN) to escape beyond an
- assertion; it is therefore treated as NOMATCH. Any other return is an
- error. */
-
- else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
- {
- RRETURN(rrc); /* Need braces because of following else */
- }
- break;
- }
-
- /* Choose branch according to the condition */
-
- ecode += condition? PRIV(OP_lengths)[condcode] : codelink;
-
- /* We are now at the branch that is to be obeyed. As there is only one, we
- can use tail recursion to avoid using another stack frame, except when
- there is unlimited repeat of a possibly empty group. In the latter case, a
- recursive call to match() is always required, unless the second alternative
- doesn't exist, in which case we can just plough on. Note that, for
- compatibility with Perl, the | in a conditional group is NOT treated as
- creating two alternatives. If a THEN is encountered in the branch, it
- propagates out to the enclosing alternative (unless nested in a deeper set
- of alternatives, of course). */
-
- if (condition || ecode[-(1+LINK_SIZE)] == OP_ALT)
- {
- if (op != OP_SCOND)
- {
- goto TAIL_RECURSE;
- }
-
- md->match_function_type = MATCH_CBEGROUP;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM49);
- RRETURN(rrc);
- }
-
- /* Condition false & no alternative; continue after the group. */
-
- else
- {
- }
- break;
-
-
- /* Before OP_ACCEPT there may be any number of OP_CLOSE opcodes,
- to close any currently open capturing brackets. */
-
- case OP_CLOSE:
- number = GET2(ecode, 1); /* Must be less than 65536 */
- offset = number << 1;
-
-#ifdef PCRE_DEBUG
- printf("end bracket %d at *ACCEPT", number);
- printf("\n");
-#endif
-
- md->capture_last = (md->capture_last & OVFLMASK) | number;
- if (offset >= md->offset_max) md->capture_last |= OVFLBIT; else
- {
- md->offset_vector[offset] =
- md->offset_vector[md->offset_end - number];
- md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
-
- /* If this group is at or above the current highwater mark, ensure that
- any groups between the current high water mark and this group are marked
- unset and then update the high water mark. */
-
- if (offset >= offset_top)
- {
- register int *iptr = md->offset_vector + offset_top;
- register int *iend = md->offset_vector + offset;
- while (iptr < iend) *iptr++ = -1;
- offset_top = offset + 2;
- }
- }
- ecode += 1 + IMM2_SIZE;
- break;
-
-
- /* End of the pattern, either real or forced. */
-
- case OP_END:
- case OP_ACCEPT:
- case OP_ASSERT_ACCEPT:
-
- /* If we have matched an empty string, fail if not in an assertion and not
- in a recursion if either PCRE_NOTEMPTY is set, or if PCRE_NOTEMPTY_ATSTART
- is set and we have matched at the start of the subject. In both cases,
- backtracking will then try other alternatives, if any. */
-
- if (eptr == mstart && op != OP_ASSERT_ACCEPT &&
- md->recursive == NULL &&
- (md->notempty ||
- (md->notempty_atstart &&
- mstart == md->start_subject + md->start_offset)))
- RRETURN(MATCH_NOMATCH);
-
- /* Otherwise, we have a match. */
-
- md->end_match_ptr = eptr; /* Record where we ended */
- md->end_offset_top = offset_top; /* and how many extracts were taken */
- md->start_match_ptr = mstart; /* and the start (\K can modify) */
-
- /* For some reason, the macros don't work properly if an expression is
- given as the argument to RRETURN when the heap is in use. */
-
- rrc = (op == OP_END)? MATCH_MATCH : MATCH_ACCEPT;
- RRETURN(rrc);
-
- /* Assertion brackets. Check the alternative branches in turn - the
- matching won't pass the KET for an assertion. If any one branch matches,
- the assertion is true. Lookbehind assertions have an OP_REVERSE item at the
- start of each branch to move the current point backwards, so the code at
- this level is identical to the lookahead case. When the assertion is part
- of a condition, we want to return immediately afterwards. The caller of
- this incarnation of the match() function will have set MATCH_CONDASSERT in
- md->match_function type, and one of these opcodes will be the first opcode
- that is processed. We use a local variable that is preserved over calls to
- match() to remember this case. */
-
- case OP_ASSERT:
- case OP_ASSERTBACK:
- save_mark = md->mark;
- if (md->match_function_type == MATCH_CONDASSERT)
- {
- condassert = TRUE;
- md->match_function_type = 0;
- }
- else condassert = FALSE;
-
- /* Loop for each branch */
-
- do
- {
- RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM4);
-
- /* A match means that the assertion is true; break out of the loop
- that matches its alternatives. */
-
- if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
- {
- mstart = md->start_match_ptr; /* In case \K reset it */
- break;
- }
-
- /* If not matched, restore the previous mark setting. */
-
- md->mark = save_mark;
-
- /* See comment in the code for capturing groups above about handling
- THEN. */
-
- if (rrc == MATCH_THEN)
- {
- next = ecode + GET(ecode,1);
- if (md->start_match_ptr < next &&
- (*ecode == OP_ALT || *next == OP_ALT))
- rrc = MATCH_NOMATCH;
- }
-
- /* Anything other than NOMATCH causes the entire assertion to fail,
- passing back the return code. This includes COMMIT, SKIP, PRUNE and an
- uncaptured THEN, which means they take their normal effect. This
- consistent approach does not always have exactly the same effect as in
- Perl. */
-
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- ecode += GET(ecode, 1);
- }
- while (*ecode == OP_ALT); /* Continue for next alternative */
-
- /* If we have tried all the alternative branches, the assertion has
- failed. If not, we broke out after a match. */
-
- if (*ecode == OP_KET) RRETURN(MATCH_NOMATCH);
-
- /* If checking an assertion for a condition, return MATCH_MATCH. */
-
- if (condassert) RRETURN(MATCH_MATCH);
-
- /* Continue from after a successful assertion, updating the offsets high
- water mark, since extracts may have been taken during the assertion. */
-
- do ecode += GET(ecode,1); while (*ecode == OP_ALT);
- ecode += 1 + LINK_SIZE;
- offset_top = md->end_offset_top;
- continue;
-
- /* Negative assertion: all branches must fail to match for the assertion to
- succeed. */
-
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK_NOT:
- save_mark = md->mark;
- if (md->match_function_type == MATCH_CONDASSERT)
- {
- condassert = TRUE;
- md->match_function_type = 0;
- }
- else condassert = FALSE;
-
- /* Loop for each alternative branch. */
-
- do
- {
- RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, NULL, RM5);
- md->mark = save_mark; /* Always restore the mark setting */
-
- switch(rrc)
- {
- case MATCH_MATCH: /* A successful match means */
- case MATCH_ACCEPT: /* the assertion has failed. */
- RRETURN(MATCH_NOMATCH);
-
- case MATCH_NOMATCH: /* Carry on with next branch */
- break;
-
- /* See comment in the code for capturing groups above about handling
- THEN. */
-
- case MATCH_THEN:
- next = ecode + GET(ecode,1);
- if (md->start_match_ptr < next &&
- (*ecode == OP_ALT || *next == OP_ALT))
- {
- rrc = MATCH_NOMATCH;
- break;
- }
- /* Otherwise fall through. */
-
- /* COMMIT, SKIP, PRUNE, and an uncaptured THEN cause the whole
- assertion to fail to match, without considering any more alternatives.
- Failing to match means the assertion is true. This is a consistent
- approach, but does not always have the same effect as in Perl. */
-
- case MATCH_COMMIT:
- case MATCH_SKIP:
- case MATCH_SKIP_ARG:
- case MATCH_PRUNE:
- do ecode += GET(ecode,1); while (*ecode == OP_ALT);
- goto NEG_ASSERT_TRUE; /* Break out of alternation loop */
-
- /* Anything else is an error */
-
- default:
- RRETURN(rrc);
- }
-
- /* Continue with next branch */
-
- ecode += GET(ecode,1);
- }
- while (*ecode == OP_ALT);
-
- /* All branches in the assertion failed to match. */
-
- NEG_ASSERT_TRUE:
- if (condassert) RRETURN(MATCH_MATCH); /* Condition assertion */
- ecode += 1 + LINK_SIZE; /* Continue with current branch */
- continue;
-
- /* Move the subject pointer back. This occurs only at the start of
- each branch of a lookbehind assertion. If we are too close to the start to
- move back, this match function fails. When working with UTF-8 we move
- back a number of characters, not bytes. */
-
- case OP_REVERSE:
-#ifdef SUPPORT_UTF
- if (utf)
- {
- i = GET(ecode, 1);
- while (i-- > 0)
- {
- eptr--;
- if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
- BACKCHAR(eptr);
- }
- }
- else
-#endif
-
- /* No UTF-8 support, or not in UTF-8 mode: count is byte count */
-
- {
- eptr -= GET(ecode, 1);
- if (eptr < md->start_subject) RRETURN(MATCH_NOMATCH);
- }
-
- /* Save the earliest consulted character, then skip to next op code */
-
- if (eptr < md->start_used_ptr) md->start_used_ptr = eptr;
- ecode += 1 + LINK_SIZE;
- break;
-
- /* The callout item calls an external function, if one is provided, passing
- details of the match so far. This is mainly for debugging, though the
- function is able to force a failure. */
-
- case OP_CALLOUT:
- if (PUBL(callout) != NULL)
- {
- PUBL(callout_block) cb;
- cb.version = 2; /* Version 1 of the callout block */
- cb.callout_number = ecode[1];
- cb.offset_vector = md->offset_vector;
-#if defined COMPILE_PCRE8
- cb.subject = (PCRE_SPTR)md->start_subject;
-#elif defined COMPILE_PCRE16
- cb.subject = (PCRE_SPTR16)md->start_subject;
-#elif defined COMPILE_PCRE32
- cb.subject = (PCRE_SPTR32)md->start_subject;
-#endif
- cb.subject_length = (int)(md->end_subject - md->start_subject);
- cb.start_match = (int)(mstart - md->start_subject);
- cb.current_position = (int)(eptr - md->start_subject);
- cb.pattern_position = GET(ecode, 2);
- cb.next_item_length = GET(ecode, 2 + LINK_SIZE);
- cb.capture_top = offset_top/2;
- cb.capture_last = md->capture_last & CAPLMASK;
- /* Internal change requires this for API compatibility. */
- if (cb.capture_last == 0) cb.capture_last = -1;
- cb.callout_data = md->callout_data;
- cb.mark = md->nomatch_mark;
- if ((rrc = (*PUBL(callout))(&cb)) > 0) RRETURN(MATCH_NOMATCH);
- if (rrc < 0) RRETURN(rrc);
- }
- ecode += 2 + 2*LINK_SIZE;
- break;
-
- /* Recursion either matches the current regex, or some subexpression. The
- offset data is the offset to the starting bracket from the start of the
- whole pattern. (This is so that it works from duplicated subpatterns.)
-
- The state of the capturing groups is preserved over recursion, and
- re-instated afterwards. We don't know how many are started and not yet
- finished (offset_top records the completed total) so we just have to save
- all the potential data. There may be up to 65535 such values, which is too
- large to put on the stack, but using malloc for small numbers seems
- expensive. As a compromise, the stack is used when there are no more than
- REC_STACK_SAVE_MAX values to store; otherwise malloc is used.
-
- There are also other values that have to be saved. We use a chained
- sequence of blocks that actually live on the stack. Thanks to Robin Houston
- for the original version of this logic. It has, however, been hacked around
- a lot, so he is not to blame for the current way it works. */
-
- case OP_RECURSE:
- {
- recursion_info *ri;
- unsigned int recno;
-
- callpat = md->start_code + GET(ecode, 1);
- recno = (callpat == md->start_code)? 0 :
- GET2(callpat, 1 + LINK_SIZE);
-
- /* Check for repeating a recursion without advancing the subject pointer.
- This should catch convoluted mutual recursions. (Some simple cases are
- caught at compile time.) */
-
- for (ri = md->recursive; ri != NULL; ri = ri->prevrec)
- if (recno == ri->group_num && eptr == ri->subject_position)
- RRETURN(PCRE_ERROR_RECURSELOOP);
-
- /* Add to "recursing stack" */
-
- new_recursive.group_num = recno;
- new_recursive.saved_capture_last = md->capture_last;
- new_recursive.subject_position = eptr;
- new_recursive.prevrec = md->recursive;
- md->recursive = &new_recursive;
-
- /* Where to continue from afterwards */
-
- ecode += 1 + LINK_SIZE;
-
- /* Now save the offset data */
-
- new_recursive.saved_max = md->offset_end;
- if (new_recursive.saved_max <= REC_STACK_SAVE_MAX)
- new_recursive.offset_save = stacksave;
- else
- {
- new_recursive.offset_save =
- (int *)(PUBL(malloc))(new_recursive.saved_max * sizeof(int));
- if (new_recursive.offset_save == NULL) RRETURN(PCRE_ERROR_NOMEMORY);
- }
- memcpy(new_recursive.offset_save, md->offset_vector,
- new_recursive.saved_max * sizeof(int));
-
- /* OK, now we can do the recursion. After processing each alternative,
- restore the offset data and the last captured value. If there were nested
- recursions, md->recursive might be changed, so reset it before looping.
- */
-
- DPRINTF(("Recursing into group %d\n", new_recursive.group_num));
- cbegroup = (*callpat >= OP_SBRA);
- do
- {
- if (cbegroup) md->match_function_type = MATCH_CBEGROUP;
- RMATCH(eptr, callpat + PRIV(OP_lengths)[*callpat], offset_top,
- md, eptrb, RM6);
- memcpy(md->offset_vector, new_recursive.offset_save,
- new_recursive.saved_max * sizeof(int));
- md->capture_last = new_recursive.saved_capture_last;
- md->recursive = new_recursive.prevrec;
- if (rrc == MATCH_MATCH || rrc == MATCH_ACCEPT)
- {
- DPRINTF(("Recursion matched\n"));
- if (new_recursive.offset_save != stacksave)
- (PUBL(free))(new_recursive.offset_save);
-
- /* Set where we got to in the subject, and reset the start in case
- it was changed by \K. This *is* propagated back out of a recursion,
- for Perl compatibility. */
-
- eptr = md->end_match_ptr;
- mstart = md->start_match_ptr;
- goto RECURSION_MATCHED; /* Exit loop; end processing */
- }
-
- /* PCRE does not allow THEN, SKIP, PRUNE or COMMIT to escape beyond a
- recursion; they cause a NOMATCH for the entire recursion. These codes
- are defined in a range that can be tested for. */
-
- if (rrc >= MATCH_BACKTRACK_MIN && rrc <= MATCH_BACKTRACK_MAX)
- {
- if (new_recursive.offset_save != stacksave)
- (PUBL(free))(new_recursive.offset_save);
- RRETURN(MATCH_NOMATCH);
- }
-
- /* Any return code other than NOMATCH is an error. */
-
- if (rrc != MATCH_NOMATCH)
- {
- DPRINTF(("Recursion gave error %d\n", rrc));
- if (new_recursive.offset_save != stacksave)
- (PUBL(free))(new_recursive.offset_save);
- RRETURN(rrc);
- }
-
- md->recursive = &new_recursive;
- callpat += GET(callpat, 1);
- }
- while (*callpat == OP_ALT);
-
- DPRINTF(("Recursion didn't match\n"));
- md->recursive = new_recursive.prevrec;
- if (new_recursive.offset_save != stacksave)
- (PUBL(free))(new_recursive.offset_save);
- RRETURN(MATCH_NOMATCH);
- }
-
- RECURSION_MATCHED:
- break;
-
- /* An alternation is the end of a branch; scan along to find the end of the
- bracketed group and go to there. */
-
- case OP_ALT:
- do ecode += GET(ecode,1); while (*ecode == OP_ALT);
- break;
-
- /* BRAZERO, BRAMINZERO and SKIPZERO occur just before a bracket group,
- indicating that it may occur zero times. It may repeat infinitely, or not
- at all - i.e. it could be ()* or ()? or even (){0} in the pattern. Brackets
- with fixed upper repeat limits are compiled as a number of copies, with the
- optional ones preceded by BRAZERO or BRAMINZERO. */
-
- case OP_BRAZERO:
- next = ecode + 1;
- RMATCH(eptr, next, offset_top, md, eptrb, RM10);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- do next += GET(next, 1); while (*next == OP_ALT);
- ecode = next + 1 + LINK_SIZE;
- break;
-
- case OP_BRAMINZERO:
- next = ecode + 1;
- do next += GET(next, 1); while (*next == OP_ALT);
- RMATCH(eptr, next + 1+LINK_SIZE, offset_top, md, eptrb, RM11);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- ecode++;
- break;
-
- case OP_SKIPZERO:
- next = ecode+1;
- do next += GET(next,1); while (*next == OP_ALT);
- ecode = next + 1 + LINK_SIZE;
- break;
-
- /* BRAPOSZERO occurs before a possessive bracket group. Don't do anything
- here; just jump to the group, with allow_zero set TRUE. */
-
- case OP_BRAPOSZERO:
- op = *(++ecode);
- allow_zero = TRUE;
- if (op == OP_CBRAPOS || op == OP_SCBRAPOS) goto POSSESSIVE_CAPTURE;
- goto POSSESSIVE_NON_CAPTURE;
-
- /* End of a group, repeated or non-repeating. */
-
- case OP_KET:
- case OP_KETRMIN:
- case OP_KETRMAX:
- case OP_KETRPOS:
- prev = ecode - GET(ecode, 1);
-
- /* If this was a group that remembered the subject start, in order to break
- infinite repeats of empty string matches, retrieve the subject start from
- the chain. Otherwise, set it NULL. */
-
- if (*prev >= OP_SBRA || *prev == OP_ONCE)
- {
- saved_eptr = eptrb->epb_saved_eptr; /* Value at start of group */
- eptrb = eptrb->epb_prev; /* Backup to previous group */
- }
- else saved_eptr = NULL;
-
- /* If we are at the end of an assertion group or a non-capturing atomic
- group, stop matching and return MATCH_MATCH, but record the current high
- water mark for use by positive assertions. We also need to record the match
- start in case it was changed by \K. */
-
- if ((*prev >= OP_ASSERT && *prev <= OP_ASSERTBACK_NOT) ||
- *prev == OP_ONCE_NC)
- {
- md->end_match_ptr = eptr; /* For ONCE_NC */
- md->end_offset_top = offset_top;
- md->start_match_ptr = mstart;
- RRETURN(MATCH_MATCH); /* Sets md->mark */
- }
-
- /* For capturing groups we have to check the group number back at the start
- and if necessary complete handling an extraction by setting the offsets and
- bumping the high water mark. Whole-pattern recursion is coded as a recurse
- into group 0, so it won't be picked up here. Instead, we catch it when the
- OP_END is reached. Other recursion is handled here. We just have to record
- the current subject position and start match pointer and give a MATCH
- return. */
-
- if (*prev == OP_CBRA || *prev == OP_SCBRA ||
- *prev == OP_CBRAPOS || *prev == OP_SCBRAPOS)
- {
- number = GET2(prev, 1+LINK_SIZE);
- offset = number << 1;
-
-#ifdef PCRE_DEBUG
- printf("end bracket %d", number);
- printf("\n");
-#endif
-
- /* Handle a recursively called group. */
-
- if (md->recursive != NULL && md->recursive->group_num == number)
- {
- md->end_match_ptr = eptr;
- md->start_match_ptr = mstart;
- RRETURN(MATCH_MATCH);
- }
-
- /* Deal with capturing */
-
- md->capture_last = (md->capture_last & OVFLMASK) | number;
- if (offset >= md->offset_max) md->capture_last |= OVFLBIT; else
- {
- /* If offset is greater than offset_top, it means that we are
- "skipping" a capturing group, and that group's offsets must be marked
- unset. In earlier versions of PCRE, all the offsets were unset at the
- start of matching, but this doesn't work because atomic groups and
- assertions can cause a value to be set that should later be unset.
- Example: matching /(?>(a))b|(a)c/ against "ac". This sets group 1 as
- part of the atomic group, but this is not on the final matching path,
- so must be unset when 2 is set. (If there is no group 2, there is no
- problem, because offset_top will then be 2, indicating no capture.) */
-
- if (offset > offset_top)
- {
- register int *iptr = md->offset_vector + offset_top;
- register int *iend = md->offset_vector + offset;
- while (iptr < iend) *iptr++ = -1;
- }
-
- /* Now make the extraction */
-
- md->offset_vector[offset] =
- md->offset_vector[md->offset_end - number];
- md->offset_vector[offset+1] = (int)(eptr - md->start_subject);
- if (offset_top <= offset) offset_top = offset + 2;
- }
- }
-
- /* OP_KETRPOS is a possessive repeating ket. Remember the current position,
- and return the MATCH_KETRPOS. This makes it possible to do the repeats one
- at a time from the outer level, thus saving stack. This must precede the
- empty string test - in this case that test is done at the outer level. */
-
- if (*ecode == OP_KETRPOS)
- {
- md->start_match_ptr = mstart; /* In case \K reset it */
- md->end_match_ptr = eptr;
- md->end_offset_top = offset_top;
- RRETURN(MATCH_KETRPOS);
- }
-
- /* For an ordinary non-repeating ket, just continue at this level. This
- also happens for a repeating ket if no characters were matched in the
- group. This is the forcible breaking of infinite loops as implemented in
- Perl 5.005. For a non-repeating atomic group that includes captures,
- establish a backup point by processing the rest of the pattern at a lower
- level. If this results in a NOMATCH return, pass MATCH_ONCE back to the
- original OP_ONCE level, thereby bypassing intermediate backup points, but
- resetting any captures that happened along the way. */
-
- if (*ecode == OP_KET || eptr == saved_eptr)
- {
- if (*prev == OP_ONCE)
- {
- RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM12);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- md->once_target = prev; /* Level at which to change to MATCH_NOMATCH */
- RRETURN(MATCH_ONCE);
- }
- ecode += 1 + LINK_SIZE; /* Carry on at this level */
- break;
- }
-
- /* The normal repeating kets try the rest of the pattern or restart from
- the preceding bracket, in the appropriate order. In the second case, we can
- use tail recursion to avoid using another stack frame, unless we have an
- an atomic group or an unlimited repeat of a group that can match an empty
- string. */
-
- if (*ecode == OP_KETRMIN)
- {
- RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM7);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (*prev == OP_ONCE)
- {
- RMATCH(eptr, prev, offset_top, md, eptrb, RM8);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- md->once_target = prev; /* Level at which to change to MATCH_NOMATCH */
- RRETURN(MATCH_ONCE);
- }
- if (*prev >= OP_SBRA) /* Could match an empty string */
- {
- RMATCH(eptr, prev, offset_top, md, eptrb, RM50);
- RRETURN(rrc);
- }
- ecode = prev;
- goto TAIL_RECURSE;
- }
- else /* OP_KETRMAX */
- {
- RMATCH(eptr, prev, offset_top, md, eptrb, RM13);
- if (rrc == MATCH_ONCE && md->once_target == prev) rrc = MATCH_NOMATCH;
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (*prev == OP_ONCE)
- {
- RMATCH(eptr, ecode + 1 + LINK_SIZE, offset_top, md, eptrb, RM9);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- md->once_target = prev;
- RRETURN(MATCH_ONCE);
- }
- ecode += 1 + LINK_SIZE;
- goto TAIL_RECURSE;
- }
- /* Control never gets here */
-
- /* Not multiline mode: start of subject assertion, unless notbol. */
-
- case OP_CIRC:
- if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);
-
- /* Start of subject assertion */
-
- case OP_SOD:
- if (eptr != md->start_subject) RRETURN(MATCH_NOMATCH);
- ecode++;
- break;
-
- /* Multiline mode: start of subject unless notbol, or after any newline. */
-
- case OP_CIRCM:
- if (md->notbol && eptr == md->start_subject) RRETURN(MATCH_NOMATCH);
- if (eptr != md->start_subject &&
- (eptr == md->end_subject || !WAS_NEWLINE(eptr)))
- RRETURN(MATCH_NOMATCH);
- ecode++;
- break;
-
- /* Start of match assertion */
-
- case OP_SOM:
- if (eptr != md->start_subject + md->start_offset) RRETURN(MATCH_NOMATCH);
- ecode++;
- break;
-
- /* Reset the start of match point */
-
- case OP_SET_SOM:
- mstart = eptr;
- ecode++;
- break;
-
- /* Multiline mode: assert before any newline, or before end of subject
- unless noteol is set. */
-
- case OP_DOLLM:
- if (eptr < md->end_subject)
- {
- if (!IS_NEWLINE(eptr))
- {
- if (md->partial != 0 &&
- eptr + 1 >= md->end_subject &&
- NLBLOCK->nltype == NLTYPE_FIXED &&
- NLBLOCK->nllen == 2 &&
- UCHAR21TEST(eptr) == NLBLOCK->nl[0])
- {
- md->hitend = TRUE;
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
- }
- RRETURN(MATCH_NOMATCH);
- }
- }
- else
- {
- if (md->noteol) RRETURN(MATCH_NOMATCH);
- SCHECK_PARTIAL();
- }
- ecode++;
- break;
-
- /* Not multiline mode: assert before a terminating newline or before end of
- subject unless noteol is set. */
-
- case OP_DOLL:
- if (md->noteol) RRETURN(MATCH_NOMATCH);
- if (!md->endonly) goto ASSERT_NL_OR_EOS;
-
- /* ... else fall through for endonly */
-
- /* End of subject assertion (\z) */
-
- case OP_EOD:
- if (eptr < md->end_subject) RRETURN(MATCH_NOMATCH);
- SCHECK_PARTIAL();
- ecode++;
- break;
-
- /* End of subject or ending \n assertion (\Z) */
-
- case OP_EODN:
- ASSERT_NL_OR_EOS:
- if (eptr < md->end_subject &&
- (!IS_NEWLINE(eptr) || eptr != md->end_subject - md->nllen))
- {
- if (md->partial != 0 &&
- eptr + 1 >= md->end_subject &&
- NLBLOCK->nltype == NLTYPE_FIXED &&
- NLBLOCK->nllen == 2 &&
- UCHAR21TEST(eptr) == NLBLOCK->nl[0])
- {
- md->hitend = TRUE;
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
- }
- RRETURN(MATCH_NOMATCH);
- }
-
- /* Either at end of string or \n before end. */
-
- SCHECK_PARTIAL();
- ecode++;
- break;
-
- /* Word boundary assertions */
-
- case OP_NOT_WORD_BOUNDARY:
- case OP_WORD_BOUNDARY:
- {
-
- /* Find out if the previous and current characters are "word" characters.
- It takes a bit more work in UTF-8 mode. Characters > 255 are assumed to
- be "non-word" characters. Remember the earliest consulted character for
- partial matching. */
-
-#ifdef SUPPORT_UTF
- if (utf)
- {
- /* Get status of previous character */
-
- if (eptr == md->start_subject) prev_is_word = FALSE; else
- {
- PCRE_PUCHAR lastptr = eptr - 1;
- BACKCHAR(lastptr);
- if (lastptr < md->start_used_ptr) md->start_used_ptr = lastptr;
- GETCHAR(c, lastptr);
-#ifdef SUPPORT_UCP
- if (md->use_ucp)
- {
- if (c == '_') prev_is_word = TRUE; else
- {
- int cat = UCD_CATEGORY(c);
- prev_is_word = (cat == ucp_L || cat == ucp_N);
- }
- }
- else
-#endif
- prev_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
- }
-
- /* Get status of next character */
-
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- cur_is_word = FALSE;
- }
- else
- {
- GETCHAR(c, eptr);
-#ifdef SUPPORT_UCP
- if (md->use_ucp)
- {
- if (c == '_') cur_is_word = TRUE; else
- {
- int cat = UCD_CATEGORY(c);
- cur_is_word = (cat == ucp_L || cat == ucp_N);
- }
- }
- else
-#endif
- cur_is_word = c < 256 && (md->ctypes[c] & ctype_word) != 0;
- }
- }
- else
-#endif
-
- /* Not in UTF-8 mode, but we may still have PCRE_UCP set, and for
- consistency with the behaviour of \w we do use it in this case. */
-
- {
- /* Get status of previous character */
-
- if (eptr == md->start_subject) prev_is_word = FALSE; else
- {
- if (eptr <= md->start_used_ptr) md->start_used_ptr = eptr - 1;
-#ifdef SUPPORT_UCP
- if (md->use_ucp)
- {
- c = eptr[-1];
- if (c == '_') prev_is_word = TRUE; else
- {
- int cat = UCD_CATEGORY(c);
- prev_is_word = (cat == ucp_L || cat == ucp_N);
- }
- }
- else
-#endif
- prev_is_word = MAX_255(eptr[-1])
- && ((md->ctypes[eptr[-1]] & ctype_word) != 0);
- }
-
- /* Get status of next character */
-
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- cur_is_word = FALSE;
- }
- else
-#ifdef SUPPORT_UCP
- if (md->use_ucp)
- {
- c = *eptr;
- if (c == '_') cur_is_word = TRUE; else
- {
- int cat = UCD_CATEGORY(c);
- cur_is_word = (cat == ucp_L || cat == ucp_N);
- }
- }
- else
-#endif
- cur_is_word = MAX_255(*eptr)
- && ((md->ctypes[*eptr] & ctype_word) != 0);
- }
-
- /* Now see if the situation is what we want */
-
- if ((*ecode++ == OP_WORD_BOUNDARY)?
- cur_is_word == prev_is_word : cur_is_word != prev_is_word)
- RRETURN(MATCH_NOMATCH);
- }
- break;
-
- /* Match any single character type except newline; have to take care with
- CRLF newlines and partial matching. */
-
- case OP_ANY:
- if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
- if (md->partial != 0 &&
- eptr + 1 >= md->end_subject &&
- NLBLOCK->nltype == NLTYPE_FIXED &&
- NLBLOCK->nllen == 2 &&
- UCHAR21TEST(eptr) == NLBLOCK->nl[0])
- {
- md->hitend = TRUE;
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
- }
-
- /* Fall through */
-
- /* Match any single character whatsoever. */
-
- case OP_ALLANY:
- if (eptr >= md->end_subject) /* DO NOT merge the eptr++ here; it must */
- { /* not be updated before SCHECK_PARTIAL. */
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- eptr++;
-#ifdef SUPPORT_UTF
- if (utf) ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
-#endif
- ecode++;
- break;
-
- /* Match a single byte, even in UTF-8 mode. This opcode really does match
- any byte, even newline, independent of the setting of PCRE_DOTALL. */
-
- case OP_ANYBYTE:
- if (eptr >= md->end_subject) /* DO NOT merge the eptr++ here; it must */
- { /* not be updated before SCHECK_PARTIAL. */
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- eptr++;
- ecode++;
- break;
-
- case OP_NOT_DIGIT:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if (
-#if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
- c < 256 &&
-#endif
- (md->ctypes[c] & ctype_digit) != 0
- )
- RRETURN(MATCH_NOMATCH);
- ecode++;
- break;
-
- case OP_DIGIT:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if (
-#if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
- c > 255 ||
-#endif
- (md->ctypes[c] & ctype_digit) == 0
- )
- RRETURN(MATCH_NOMATCH);
- ecode++;
- break;
-
- case OP_NOT_WHITESPACE:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if (
-#if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
- c < 256 &&
-#endif
- (md->ctypes[c] & ctype_space) != 0
- )
- RRETURN(MATCH_NOMATCH);
- ecode++;
- break;
-
- case OP_WHITESPACE:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if (
-#if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
- c > 255 ||
-#endif
- (md->ctypes[c] & ctype_space) == 0
- )
- RRETURN(MATCH_NOMATCH);
- ecode++;
- break;
-
- case OP_NOT_WORDCHAR:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if (
-#if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
- c < 256 &&
-#endif
- (md->ctypes[c] & ctype_word) != 0
- )
- RRETURN(MATCH_NOMATCH);
- ecode++;
- break;
-
- case OP_WORDCHAR:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if (
-#if defined SUPPORT_UTF || !(defined COMPILE_PCRE8)
- c > 255 ||
-#endif
- (md->ctypes[c] & ctype_word) == 0
- )
- RRETURN(MATCH_NOMATCH);
- ecode++;
- break;
-
- case OP_ANYNL:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- switch(c)
- {
- default: RRETURN(MATCH_NOMATCH);
-
- case CHAR_CR:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- }
- else if (UCHAR21TEST(eptr) == CHAR_LF) eptr++;
- break;
-
- case CHAR_LF:
- break;
-
- case CHAR_VT:
- case CHAR_FF:
- case CHAR_NEL:
-#ifndef EBCDIC
- case 0x2028:
- case 0x2029:
-#endif /* Not EBCDIC */
- if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
- break;
- }
- ecode++;
- break;
-
- case OP_NOT_HSPACE:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- switch(c)
- {
- HSPACE_CASES: RRETURN(MATCH_NOMATCH); /* Byte and multibyte cases */
- default: break;
- }
- ecode++;
- break;
-
- case OP_HSPACE:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- switch(c)
- {
- HSPACE_CASES: break; /* Byte and multibyte cases */
- default: RRETURN(MATCH_NOMATCH);
- }
- ecode++;
- break;
-
- case OP_NOT_VSPACE:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- switch(c)
- {
- VSPACE_CASES: RRETURN(MATCH_NOMATCH);
- default: break;
- }
- ecode++;
- break;
-
- case OP_VSPACE:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- switch(c)
- {
- VSPACE_CASES: break;
- default: RRETURN(MATCH_NOMATCH);
- }
- ecode++;
- break;
-
-#ifdef SUPPORT_UCP
- /* Check the next character by Unicode property. We will get here only
- if the support is in the binary; otherwise a compile-time error occurs. */
-
- case OP_PROP:
- case OP_NOTPROP:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- {
- const pcre_uint32 *cp;
- const ucd_record *prop = GET_UCD(c);
-
- switch(ecode[1])
- {
- case PT_ANY:
- if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH);
- break;
-
- case PT_LAMP:
- if ((prop->chartype == ucp_Lu ||
- prop->chartype == ucp_Ll ||
- prop->chartype == ucp_Lt) == (op == OP_NOTPROP))
- RRETURN(MATCH_NOMATCH);
- break;
-
- case PT_GC:
- if ((ecode[2] != PRIV(ucp_gentype)[prop->chartype]) == (op == OP_PROP))
- RRETURN(MATCH_NOMATCH);
- break;
-
- case PT_PC:
- if ((ecode[2] != prop->chartype) == (op == OP_PROP))
- RRETURN(MATCH_NOMATCH);
- break;
-
- case PT_SC:
- if ((ecode[2] != prop->script) == (op == OP_PROP))
- RRETURN(MATCH_NOMATCH);
- break;
-
- /* These are specials */
-
- case PT_ALNUM:
- if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
- PRIV(ucp_gentype)[prop->chartype] == ucp_N) == (op == OP_NOTPROP))
- RRETURN(MATCH_NOMATCH);
- break;
-
- /* Perl space used to exclude VT, but from Perl 5.18 it is included,
- which means that Perl space and POSIX space are now identical. PCRE
- was changed at release 8.34. */
-
- case PT_SPACE: /* Perl space */
- case PT_PXSPACE: /* POSIX space */
- switch(c)
- {
- HSPACE_CASES:
- VSPACE_CASES:
- if (op == OP_NOTPROP) RRETURN(MATCH_NOMATCH);
- break;
-
- default:
- if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z) ==
- (op == OP_NOTPROP)) RRETURN(MATCH_NOMATCH);
- break;
- }
- break;
-
- case PT_WORD:
- if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
- PRIV(ucp_gentype)[prop->chartype] == ucp_N ||
- c == CHAR_UNDERSCORE) == (op == OP_NOTPROP))
- RRETURN(MATCH_NOMATCH);
- break;
-
- case PT_CLIST:
- cp = PRIV(ucd_caseless_sets) + ecode[2];
- for (;;)
- {
- if (c < *cp)
- { if (op == OP_PROP) { RRETURN(MATCH_NOMATCH); } else break; }
- if (c == *cp++)
- { if (op == OP_PROP) break; else { RRETURN(MATCH_NOMATCH); } }
- }
- break;
-
- case PT_UCNC:
- if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
- c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
- c >= 0xe000) == (op == OP_NOTPROP))
- RRETURN(MATCH_NOMATCH);
- break;
-
- /* This should never occur */
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
-
- ecode += 3;
- }
- break;
-
- /* Match an extended Unicode sequence. We will get here only if the support
- is in the binary; otherwise a compile-time error occurs. */
-
- case OP_EXTUNI:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- else
- {
- int lgb, rgb;
- GETCHARINCTEST(c, eptr);
- lgb = UCD_GRAPHBREAK(c);
- while (eptr < md->end_subject)
- {
- int len = 1;
- if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
- rgb = UCD_GRAPHBREAK(c);
- if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
- lgb = rgb;
- eptr += len;
- }
- }
- CHECK_PARTIAL();
- ecode++;
- break;
-#endif /* SUPPORT_UCP */
-
-
- /* Match a back reference, possibly repeatedly. Look past the end of the
- item to see if there is repeat information following. The code is similar
- to that for character classes, but repeated for efficiency. Then obey
- similar code to character type repeats - written out again for speed.
- However, if the referenced string is the empty string, always treat
- it as matched, any number of times (otherwise there could be infinite
- loops). If the reference is unset, there are two possibilities:
-
- (a) In the default, Perl-compatible state, set the length negative;
- this ensures that every attempt at a match fails. We can't just fail
- here, because of the possibility of quantifiers with zero minima.
-
- (b) If the JavaScript compatibility flag is set, set the length to zero
- so that the back reference matches an empty string.
-
- Otherwise, set the length to the length of what was matched by the
- referenced subpattern.
-
- The OP_REF and OP_REFI opcodes are used for a reference to a numbered group
- or to a non-duplicated named group. For a duplicated named group, OP_DNREF
- and OP_DNREFI are used. In this case we must scan the list of groups to
- which the name refers, and use the first one that is set. */
-
- case OP_DNREF:
- case OP_DNREFI:
- caseless = op == OP_DNREFI;
- {
- int count = GET2(ecode, 1+IMM2_SIZE);
- pcre_uchar *slot = md->name_table + GET2(ecode, 1) * md->name_entry_size;
- ecode += 1 + 2*IMM2_SIZE;
-
- /* Setting the default length first and initializing 'offset' avoids
- compiler warnings in the REF_REPEAT code. */
-
- length = (md->jscript_compat)? 0 : -1;
- offset = 0;
-
- while (count-- > 0)
- {
- offset = GET2(slot, 0) << 1;
- if (offset < offset_top && md->offset_vector[offset] >= 0)
- {
- length = md->offset_vector[offset+1] - md->offset_vector[offset];
- break;
- }
- slot += md->name_entry_size;
- }
- }
- goto REF_REPEAT;
-
- case OP_REF:
- case OP_REFI:
- caseless = op == OP_REFI;
- offset = GET2(ecode, 1) << 1; /* Doubled ref number */
- ecode += 1 + IMM2_SIZE;
- if (offset >= offset_top || md->offset_vector[offset] < 0)
- length = (md->jscript_compat)? 0 : -1;
- else
- length = md->offset_vector[offset+1] - md->offset_vector[offset];
-
- /* Set up for repetition, or handle the non-repeated case */
-
- REF_REPEAT:
- switch (*ecode)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- c = *ecode++ - OP_CRSTAR;
- minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0) max = INT_MAX;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- minimize = (*ecode == OP_CRMINRANGE);
- min = GET2(ecode, 1);
- max = GET2(ecode, 1 + IMM2_SIZE);
- if (max == 0) max = INT_MAX;
- ecode += 1 + 2 * IMM2_SIZE;
- break;
-
- default: /* No repeat follows */
- if ((length = match_ref(offset, eptr, length, md, caseless)) < 0)
- {
- if (length == -2) eptr = md->end_subject; /* Partial match */
- CHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- eptr += length;
- continue; /* With the main loop */
- }
-
- /* Handle repeated back references. If the length of the reference is
- zero, just continue with the main loop. If the length is negative, it
- means the reference is unset in non-Java-compatible mode. If the minimum is
- zero, we can continue at the same level without recursion. For any other
- minimum, carrying on will result in NOMATCH. */
-
- if (length == 0) continue;
- if (length < 0 && min == 0) continue;
-
- /* First, ensure the minimum number of matches are present. We get back
- the length of the reference string explicitly rather than passing the
- address of eptr, so that eptr can be a register variable. */
-
- for (i = 1; i <= min; i++)
- {
- int slength;
- if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
- {
- if (slength == -2) eptr = md->end_subject; /* Partial match */
- CHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- eptr += slength;
- }
-
- /* If min = max, continue at the same level without recursion.
- They are not both allowed to be zero. */
-
- if (min == max) continue;
-
- /* If minimizing, keep trying and advancing the pointer */
-
- if (minimize)
- {
- for (fi = min;; fi++)
- {
- int slength;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM14);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
- {
- if (slength == -2) eptr = md->end_subject; /* Partial match */
- CHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- eptr += slength;
- }
- /* Control never gets here */
- }
-
- /* If maximizing, find the longest string and work backwards */
-
- else
- {
- pp = eptr;
- for (i = min; i < max; i++)
- {
- int slength;
- if ((slength = match_ref(offset, eptr, length, md, caseless)) < 0)
- {
- /* Can't use CHECK_PARTIAL because we don't want to update eptr in
- the soft partial matching case. */
-
- if (slength == -2 && md->partial != 0 &&
- md->end_subject > md->start_used_ptr)
- {
- md->hitend = TRUE;
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
- }
- break;
- }
- eptr += slength;
- }
-
- while (eptr >= pp)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM15);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- eptr -= length;
- }
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
-
- /* Match a bit-mapped character class, possibly repeatedly. This op code is
- used when all the characters in the class have values in the range 0-255,
- and either the matching is caseful, or the characters are in the range
- 0-127 when UTF-8 processing is enabled. The only difference between
- OP_CLASS and OP_NCLASS occurs when a data character outside the range is
- encountered.
-
- First, look past the end of the item to see if there is repeat information
- following. Then obey similar code to character type repeats - written out
- again for speed. */
-
- case OP_NCLASS:
- case OP_CLASS:
- {
- /* The data variable is saved across frames, so the byte map needs to
- be stored there. */
-#define BYTE_MAP ((pcre_uint8 *)data)
- data = ecode + 1; /* Save for matching */
- ecode += 1 + (32 / sizeof(pcre_uchar)); /* Advance past the item */
-
- switch (*ecode)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- case OP_CRPOSSTAR:
- case OP_CRPOSPLUS:
- case OP_CRPOSQUERY:
- c = *ecode++ - OP_CRSTAR;
- if (c < OP_CRPOSSTAR - OP_CRSTAR) minimize = (c & 1) != 0;
- else possessive = TRUE;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0) max = INT_MAX;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- case OP_CRPOSRANGE:
- minimize = (*ecode == OP_CRMINRANGE);
- possessive = (*ecode == OP_CRPOSRANGE);
- min = GET2(ecode, 1);
- max = GET2(ecode, 1 + IMM2_SIZE);
- if (max == 0) max = INT_MAX;
- ecode += 1 + 2 * IMM2_SIZE;
- break;
-
- default: /* No repeat follows */
- min = max = 1;
- break;
- }
-
- /* First, ensure the minimum number of matches are present. */
-
-#ifdef SUPPORT_UTF
- if (utf)
- {
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(c, eptr);
- if (c > 255)
- {
- if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
- }
- else
- if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
- }
- }
- else
-#endif
- /* Not UTF mode */
- {
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- c = *eptr++;
-#ifndef COMPILE_PCRE8
- if (c > 255)
- {
- if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
- }
- else
-#endif
- if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
- }
- }
-
- /* If max == min we can continue with the main loop without the
- need to recurse. */
-
- if (min == max) continue;
-
- /* If minimizing, keep testing the rest of the expression and advancing
- the pointer while it matches the class. */
-
- if (minimize)
- {
-#ifdef SUPPORT_UTF
- if (utf)
- {
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM16);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(c, eptr);
- if (c > 255)
- {
- if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
- }
- else
- if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
- }
- }
- else
-#endif
- /* Not UTF mode */
- {
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM17);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- c = *eptr++;
-#ifndef COMPILE_PCRE8
- if (c > 255)
- {
- if (op == OP_CLASS) RRETURN(MATCH_NOMATCH);
- }
- else
-#endif
- if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) RRETURN(MATCH_NOMATCH);
- }
- }
- /* Control never gets here */
- }
-
- /* If maximizing, find the longest possible run, then work backwards. */
-
- else
- {
- pp = eptr;
-
-#ifdef SUPPORT_UTF
- if (utf)
- {
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(c, eptr, len);
- if (c > 255)
- {
- if (op == OP_CLASS) break;
- }
- else
- if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) break;
- eptr += len;
- }
-
- if (possessive) continue; /* No backtracking */
-
- for (;;)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM18);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (eptr-- == pp) break; /* Stop if tried at original pos */
- BACKCHAR(eptr);
- }
- }
- else
-#endif
- /* Not UTF mode */
- {
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- c = *eptr;
-#ifndef COMPILE_PCRE8
- if (c > 255)
- {
- if (op == OP_CLASS) break;
- }
- else
-#endif
- if ((BYTE_MAP[c/8] & (1 << (c&7))) == 0) break;
- eptr++;
- }
-
- if (possessive) continue; /* No backtracking */
-
- while (eptr >= pp)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM19);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- eptr--;
- }
- }
-
- RRETURN(MATCH_NOMATCH);
- }
-#undef BYTE_MAP
- }
- /* Control never gets here */
-
-
- /* Match an extended character class. In the 8-bit library, this opcode is
- encountered only when UTF-8 mode mode is supported. In the 16-bit and
- 32-bit libraries, codepoints greater than 255 may be encountered even when
- UTF is not supported. */
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- {
- data = ecode + 1 + LINK_SIZE; /* Save for matching */
- ecode += GET(ecode, 1); /* Advance past the item */
-
- switch (*ecode)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- case OP_CRPOSSTAR:
- case OP_CRPOSPLUS:
- case OP_CRPOSQUERY:
- c = *ecode++ - OP_CRSTAR;
- if (c < OP_CRPOSSTAR - OP_CRSTAR) minimize = (c & 1) != 0;
- else possessive = TRUE;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0) max = INT_MAX;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- case OP_CRPOSRANGE:
- minimize = (*ecode == OP_CRMINRANGE);
- possessive = (*ecode == OP_CRPOSRANGE);
- min = GET2(ecode, 1);
- max = GET2(ecode, 1 + IMM2_SIZE);
- if (max == 0) max = INT_MAX;
- ecode += 1 + 2 * IMM2_SIZE;
- break;
-
- default: /* No repeat follows */
- min = max = 1;
- break;
- }
-
- /* First, ensure the minimum number of matches are present. */
-
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if (!PRIV(xclass)(c, data, utf)) RRETURN(MATCH_NOMATCH);
- }
-
- /* If max == min we can continue with the main loop without the
- need to recurse. */
-
- if (min == max) continue;
-
- /* If minimizing, keep testing the rest of the expression and advancing
- the pointer while it matches the class. */
-
- if (minimize)
- {
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM20);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if (!PRIV(xclass)(c, data, utf)) RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
- }
-
- /* If maximizing, find the longest possible run, then work backwards. */
-
- else
- {
- pp = eptr;
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
-#ifdef SUPPORT_UTF
- GETCHARLENTEST(c, eptr, len);
-#else
- c = *eptr;
-#endif
- if (!PRIV(xclass)(c, data, utf)) break;
- eptr += len;
- }
-
- if (possessive) continue; /* No backtracking */
-
- for(;;)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM21);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (eptr-- == pp) break; /* Stop if tried at original pos */
-#ifdef SUPPORT_UTF
- if (utf) BACKCHAR(eptr);
-#endif
- }
- RRETURN(MATCH_NOMATCH);
- }
-
- /* Control never gets here */
- }
-#endif /* End of XCLASS */
-
- /* Match a single character, casefully */
-
- case OP_CHAR:
-#ifdef SUPPORT_UTF
- if (utf)
- {
- length = 1;
- ecode++;
- GETCHARLEN(fc, ecode, length);
- if (length > md->end_subject - eptr)
- {
- CHECK_PARTIAL(); /* Not SCHECK_PARTIAL() */
- RRETURN(MATCH_NOMATCH);
- }
- while (length-- > 0) if (*ecode++ != UCHAR21INC(eptr)) RRETURN(MATCH_NOMATCH);
- }
- else
-#endif
- /* Not UTF mode */
- {
- if (md->end_subject - eptr < 1)
- {
- SCHECK_PARTIAL(); /* This one can use SCHECK_PARTIAL() */
- RRETURN(MATCH_NOMATCH);
- }
- if (ecode[1] != *eptr++) RRETURN(MATCH_NOMATCH);
- ecode += 2;
- }
- break;
-
- /* Match a single character, caselessly. If we are at the end of the
- subject, give up immediately. */
-
- case OP_CHARI:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
-
-#ifdef SUPPORT_UTF
- if (utf)
- {
- length = 1;
- ecode++;
- GETCHARLEN(fc, ecode, length);
-
- /* If the pattern character's value is < 128, we have only one byte, and
- we know that its other case must also be one byte long, so we can use the
- fast lookup table. We know that there is at least one byte left in the
- subject. */
-
- if (fc < 128)
- {
- pcre_uint32 cc = UCHAR21(eptr);
- if (md->lcc[fc] != TABLE_GET(cc, md->lcc, cc)) RRETURN(MATCH_NOMATCH);
- ecode++;
- eptr++;
- }
-
- /* Otherwise we must pick up the subject character. Note that we cannot
- use the value of "length" to check for sufficient bytes left, because the
- other case of the character may have more or fewer bytes. */
-
- else
- {
- pcre_uint32 dc;
- GETCHARINC(dc, eptr);
- ecode += length;
-
- /* If we have Unicode property support, we can use it to test the other
- case of the character, if there is one. */
-
- if (fc != dc)
- {
-#ifdef SUPPORT_UCP
- if (dc != UCD_OTHERCASE(fc))
-#endif
- RRETURN(MATCH_NOMATCH);
- }
- }
- }
- else
-#endif /* SUPPORT_UTF */
-
- /* Not UTF mode */
- {
- if (TABLE_GET(ecode[1], md->lcc, ecode[1])
- != TABLE_GET(*eptr, md->lcc, *eptr)) RRETURN(MATCH_NOMATCH);
- eptr++;
- ecode += 2;
- }
- break;
-
- /* Match a single character repeatedly. */
-
- case OP_EXACT:
- case OP_EXACTI:
- min = max = GET2(ecode, 1);
- ecode += 1 + IMM2_SIZE;
- goto REPEATCHAR;
-
- case OP_POSUPTO:
- case OP_POSUPTOI:
- possessive = TRUE;
- /* Fall through */
-
- case OP_UPTO:
- case OP_UPTOI:
- case OP_MINUPTO:
- case OP_MINUPTOI:
- min = 0;
- max = GET2(ecode, 1);
- minimize = *ecode == OP_MINUPTO || *ecode == OP_MINUPTOI;
- ecode += 1 + IMM2_SIZE;
- goto REPEATCHAR;
-
- case OP_POSSTAR:
- case OP_POSSTARI:
- possessive = TRUE;
- min = 0;
- max = INT_MAX;
- ecode++;
- goto REPEATCHAR;
-
- case OP_POSPLUS:
- case OP_POSPLUSI:
- possessive = TRUE;
- min = 1;
- max = INT_MAX;
- ecode++;
- goto REPEATCHAR;
-
- case OP_POSQUERY:
- case OP_POSQUERYI:
- possessive = TRUE;
- min = 0;
- max = 1;
- ecode++;
- goto REPEATCHAR;
-
- case OP_STAR:
- case OP_STARI:
- case OP_MINSTAR:
- case OP_MINSTARI:
- case OP_PLUS:
- case OP_PLUSI:
- case OP_MINPLUS:
- case OP_MINPLUSI:
- case OP_QUERY:
- case OP_QUERYI:
- case OP_MINQUERY:
- case OP_MINQUERYI:
- c = *ecode++ - ((op < OP_STARI)? OP_STAR : OP_STARI);
- minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0) max = INT_MAX;
-
- /* Common code for all repeated single-character matches. We first check
- for the minimum number of characters. If the minimum equals the maximum, we
- are done. Otherwise, if minimizing, check the rest of the pattern for a
- match; if there isn't one, advance up to the maximum, one character at a
- time.
-
- If maximizing, advance up to the maximum number of matching characters,
- until eptr is past the end of the maximum run. If possessive, we are
- then done (no backing up). Otherwise, match at this position; anything
- other than no match is immediately returned. For nomatch, back up one
- character, unless we are matching \R and the last thing matched was
- \r\n, in which case, back up two bytes. When we reach the first optional
- character position, we can save stack by doing a tail recurse.
-
- The various UTF/non-UTF and caseful/caseless cases are handled separately,
- for speed. */
-
- REPEATCHAR:
-#ifdef SUPPORT_UTF
- if (utf)
- {
- length = 1;
- charptr = ecode;
- GETCHARLEN(fc, ecode, length);
- ecode += length;
-
- /* Handle multibyte character matching specially here. There is
- support for caseless matching if UCP support is present. */
-
- if (length > 1)
- {
-#ifdef SUPPORT_UCP
- pcre_uint32 othercase;
- if (op >= OP_STARI && /* Caseless */
- (othercase = UCD_OTHERCASE(fc)) != fc)
- oclength = PRIV(ord2utf)(othercase, occhars);
- else oclength = 0;
-#endif /* SUPPORT_UCP */
-
- for (i = 1; i <= min; i++)
- {
- if (eptr <= md->end_subject - length &&
- memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
-#ifdef SUPPORT_UCP
- else if (oclength > 0 &&
- eptr <= md->end_subject - oclength &&
- memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
-#endif /* SUPPORT_UCP */
- else
- {
- CHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- }
-
- if (min == max) continue;
-
- if (minimize)
- {
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM22);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr <= md->end_subject - length &&
- memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
-#ifdef SUPPORT_UCP
- else if (oclength > 0 &&
- eptr <= md->end_subject - oclength &&
- memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
-#endif /* SUPPORT_UCP */
- else
- {
- CHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- }
- /* Control never gets here */
- }
-
- else /* Maximize */
- {
- pp = eptr;
- for (i = min; i < max; i++)
- {
- if (eptr <= md->end_subject - length &&
- memcmp(eptr, charptr, IN_UCHARS(length)) == 0) eptr += length;
-#ifdef SUPPORT_UCP
- else if (oclength > 0 &&
- eptr <= md->end_subject - oclength &&
- memcmp(eptr, occhars, IN_UCHARS(oclength)) == 0) eptr += oclength;
-#endif /* SUPPORT_UCP */
- else
- {
- CHECK_PARTIAL();
- break;
- }
- }
-
- if (possessive) continue; /* No backtracking */
- for(;;)
- {
- if (eptr <= pp) goto TAIL_RECURSE;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM23);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-#ifdef SUPPORT_UCP
- eptr--;
- BACKCHAR(eptr);
-#else /* without SUPPORT_UCP */
- eptr -= length;
-#endif /* SUPPORT_UCP */
- }
- }
- /* Control never gets here */
- }
-
- /* If the length of a UTF-8 character is 1, we fall through here, and
- obey the code as for non-UTF-8 characters below, though in this case the
- value of fc will always be < 128. */
- }
- else
-#endif /* SUPPORT_UTF */
- /* When not in UTF-8 mode, load a single-byte character. */
- fc = *ecode++;
-
- /* The value of fc at this point is always one character, though we may
- or may not be in UTF mode. The code is duplicated for the caseless and
- caseful cases, for speed, since matching characters is likely to be quite
- common. First, ensure the minimum number of matches are present. If min =
- max, continue at the same level without recursing. Otherwise, if
- minimizing, keep trying the rest of the expression and advancing one
- matching character if failing, up to the maximum. Alternatively, if
- maximizing, find the maximum number of characters and work backwards. */
-
- DPRINTF(("matching %c{%d,%d} against subject %.*s\n", fc, min, max,
- max, (char *)eptr));
-
- if (op >= OP_STARI) /* Caseless */
- {
-#ifdef COMPILE_PCRE8
- /* fc must be < 128 if UTF is enabled. */
- foc = md->fcc[fc];
-#else
-#ifdef SUPPORT_UTF
-#ifdef SUPPORT_UCP
- if (utf && fc > 127)
- foc = UCD_OTHERCASE(fc);
-#else
- if (utf && fc > 127)
- foc = fc;
-#endif /* SUPPORT_UCP */
- else
-#endif /* SUPPORT_UTF */
- foc = TABLE_GET(fc, md->fcc, fc);
-#endif /* COMPILE_PCRE8 */
-
- for (i = 1; i <= min; i++)
- {
- pcre_uint32 cc; /* Faster than pcre_uchar */
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- cc = UCHAR21TEST(eptr);
- if (fc != cc && foc != cc) RRETURN(MATCH_NOMATCH);
- eptr++;
- }
- if (min == max) continue;
- if (minimize)
- {
- for (fi = min;; fi++)
- {
- pcre_uint32 cc; /* Faster than pcre_uchar */
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM24);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- cc = UCHAR21TEST(eptr);
- if (fc != cc && foc != cc) RRETURN(MATCH_NOMATCH);
- eptr++;
- }
- /* Control never gets here */
- }
- else /* Maximize */
- {
- pp = eptr;
- for (i = min; i < max; i++)
- {
- pcre_uint32 cc; /* Faster than pcre_uchar */
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- cc = UCHAR21TEST(eptr);
- if (fc != cc && foc != cc) break;
- eptr++;
- }
- if (possessive) continue; /* No backtracking */
- for (;;)
- {
- if (eptr == pp) goto TAIL_RECURSE;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM25);
- eptr--;
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- }
- /* Control never gets here */
- }
- }
-
- /* Caseful comparisons (includes all multi-byte characters) */
-
- else
- {
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (fc != UCHAR21INCTEST(eptr)) RRETURN(MATCH_NOMATCH);
- }
-
- if (min == max) continue;
-
- if (minimize)
- {
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM26);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (fc != UCHAR21INCTEST(eptr)) RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
- }
- else /* Maximize */
- {
- pp = eptr;
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- if (fc != UCHAR21TEST(eptr)) break;
- eptr++;
- }
- if (possessive) continue; /* No backtracking */
- for (;;)
- {
- if (eptr == pp) goto TAIL_RECURSE;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM27);
- eptr--;
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- }
- /* Control never gets here */
- }
- }
- /* Control never gets here */
-
- /* Match a negated single one-byte character. The character we are
- checking can be multibyte. */
-
- case OP_NOT:
- case OP_NOTI:
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
-#ifdef SUPPORT_UTF
- if (utf)
- {
- register pcre_uint32 ch, och;
-
- ecode++;
- GETCHARINC(ch, ecode);
- GETCHARINC(c, eptr);
-
- if (op == OP_NOT)
- {
- if (ch == c) RRETURN(MATCH_NOMATCH);
- }
- else
- {
-#ifdef SUPPORT_UCP
- if (ch > 127)
- och = UCD_OTHERCASE(ch);
-#else
- if (ch > 127)
- och = ch;
-#endif /* SUPPORT_UCP */
- else
- och = TABLE_GET(ch, md->fcc, ch);
- if (ch == c || och == c) RRETURN(MATCH_NOMATCH);
- }
- }
- else
-#endif
- {
- register pcre_uint32 ch = ecode[1];
- c = *eptr++;
- if (ch == c || (op == OP_NOTI && TABLE_GET(ch, md->fcc, ch) == c))
- RRETURN(MATCH_NOMATCH);
- ecode += 2;
- }
- break;
-
- /* Match a negated single one-byte character repeatedly. This is almost a
- repeat of the code for a repeated single character, but I haven't found a
- nice way of commoning these up that doesn't require a test of the
- positive/negative option for each character match. Maybe that wouldn't add
- very much to the time taken, but character matching *is* what this is all
- about... */
-
- case OP_NOTEXACT:
- case OP_NOTEXACTI:
- min = max = GET2(ecode, 1);
- ecode += 1 + IMM2_SIZE;
- goto REPEATNOTCHAR;
-
- case OP_NOTUPTO:
- case OP_NOTUPTOI:
- case OP_NOTMINUPTO:
- case OP_NOTMINUPTOI:
- min = 0;
- max = GET2(ecode, 1);
- minimize = *ecode == OP_NOTMINUPTO || *ecode == OP_NOTMINUPTOI;
- ecode += 1 + IMM2_SIZE;
- goto REPEATNOTCHAR;
-
- case OP_NOTPOSSTAR:
- case OP_NOTPOSSTARI:
- possessive = TRUE;
- min = 0;
- max = INT_MAX;
- ecode++;
- goto REPEATNOTCHAR;
-
- case OP_NOTPOSPLUS:
- case OP_NOTPOSPLUSI:
- possessive = TRUE;
- min = 1;
- max = INT_MAX;
- ecode++;
- goto REPEATNOTCHAR;
-
- case OP_NOTPOSQUERY:
- case OP_NOTPOSQUERYI:
- possessive = TRUE;
- min = 0;
- max = 1;
- ecode++;
- goto REPEATNOTCHAR;
-
- case OP_NOTPOSUPTO:
- case OP_NOTPOSUPTOI:
- possessive = TRUE;
- min = 0;
- max = GET2(ecode, 1);
- ecode += 1 + IMM2_SIZE;
- goto REPEATNOTCHAR;
-
- case OP_NOTSTAR:
- case OP_NOTSTARI:
- case OP_NOTMINSTAR:
- case OP_NOTMINSTARI:
- case OP_NOTPLUS:
- case OP_NOTPLUSI:
- case OP_NOTMINPLUS:
- case OP_NOTMINPLUSI:
- case OP_NOTQUERY:
- case OP_NOTQUERYI:
- case OP_NOTMINQUERY:
- case OP_NOTMINQUERYI:
- c = *ecode++ - ((op >= OP_NOTSTARI)? OP_NOTSTARI: OP_NOTSTAR);
- minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0) max = INT_MAX;
-
- /* Common code for all repeated single-byte matches. */
-
- REPEATNOTCHAR:
- GETCHARINCTEST(fc, ecode);
-
- /* The code is duplicated for the caseless and caseful cases, for speed,
- since matching characters is likely to be quite common. First, ensure the
- minimum number of matches are present. If min = max, continue at the same
- level without recursing. Otherwise, if minimizing, keep trying the rest of
- the expression and advancing one matching character if failing, up to the
- maximum. Alternatively, if maximizing, find the maximum number of
- characters and work backwards. */
-
- DPRINTF(("negative matching %c{%d,%d} against subject %.*s\n", fc, min, max,
- max, (char *)eptr));
-
- if (op >= OP_NOTSTARI) /* Caseless */
- {
-#ifdef SUPPORT_UTF
-#ifdef SUPPORT_UCP
- if (utf && fc > 127)
- foc = UCD_OTHERCASE(fc);
-#else
- if (utf && fc > 127)
- foc = fc;
-#endif /* SUPPORT_UCP */
- else
-#endif /* SUPPORT_UTF */
- foc = TABLE_GET(fc, md->fcc, fc);
-
-#ifdef SUPPORT_UTF
- if (utf)
- {
- register pcre_uint32 d;
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(d, eptr);
- if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
- }
- }
- else
-#endif /* SUPPORT_UTF */
- /* Not UTF mode */
- {
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (fc == *eptr || foc == *eptr) RRETURN(MATCH_NOMATCH);
- eptr++;
- }
- }
-
- if (min == max) continue;
-
- if (minimize)
- {
-#ifdef SUPPORT_UTF
- if (utf)
- {
- register pcre_uint32 d;
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM28);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(d, eptr);
- if (fc == d || (unsigned int)foc == d) RRETURN(MATCH_NOMATCH);
- }
- }
- else
-#endif /*SUPPORT_UTF */
- /* Not UTF mode */
- {
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM29);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (fc == *eptr || foc == *eptr) RRETURN(MATCH_NOMATCH);
- eptr++;
- }
- }
- /* Control never gets here */
- }
-
- /* Maximize case */
-
- else
- {
- pp = eptr;
-
-#ifdef SUPPORT_UTF
- if (utf)
- {
- register pcre_uint32 d;
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(d, eptr, len);
- if (fc == d || (unsigned int)foc == d) break;
- eptr += len;
- }
- if (possessive) continue; /* No backtracking */
- for(;;)
- {
- if (eptr <= pp) goto TAIL_RECURSE;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM30);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- eptr--;
- BACKCHAR(eptr);
- }
- }
- else
-#endif /* SUPPORT_UTF */
- /* Not UTF mode */
- {
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- if (fc == *eptr || foc == *eptr) break;
- eptr++;
- }
- if (possessive) continue; /* No backtracking */
- for (;;)
- {
- if (eptr == pp) goto TAIL_RECURSE;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM31);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- eptr--;
- }
- }
- /* Control never gets here */
- }
- }
-
- /* Caseful comparisons */
-
- else
- {
-#ifdef SUPPORT_UTF
- if (utf)
- {
- register pcre_uint32 d;
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(d, eptr);
- if (fc == d) RRETURN(MATCH_NOMATCH);
- }
- }
- else
-#endif
- /* Not UTF mode */
- {
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
- }
- }
-
- if (min == max) continue;
-
- if (minimize)
- {
-#ifdef SUPPORT_UTF
- if (utf)
- {
- register pcre_uint32 d;
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM32);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(d, eptr);
- if (fc == d) RRETURN(MATCH_NOMATCH);
- }
- }
- else
-#endif
- /* Not UTF mode */
- {
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM33);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (fc == *eptr++) RRETURN(MATCH_NOMATCH);
- }
- }
- /* Control never gets here */
- }
-
- /* Maximize case */
-
- else
- {
- pp = eptr;
-
-#ifdef SUPPORT_UTF
- if (utf)
- {
- register pcre_uint32 d;
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(d, eptr, len);
- if (fc == d) break;
- eptr += len;
- }
- if (possessive) continue; /* No backtracking */
- for(;;)
- {
- if (eptr <= pp) goto TAIL_RECURSE;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM34);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- eptr--;
- BACKCHAR(eptr);
- }
- }
- else
-#endif
- /* Not UTF mode */
- {
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- if (fc == *eptr) break;
- eptr++;
- }
- if (possessive) continue; /* No backtracking */
- for (;;)
- {
- if (eptr == pp) goto TAIL_RECURSE;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM35);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- eptr--;
- }
- }
- /* Control never gets here */
- }
- }
- /* Control never gets here */
-
- /* Match a single character type repeatedly; several different opcodes
- share code. This is very similar to the code for single characters, but we
- repeat it in the interests of efficiency. */
-
- case OP_TYPEEXACT:
- min = max = GET2(ecode, 1);
- minimize = TRUE;
- ecode += 1 + IMM2_SIZE;
- goto REPEATTYPE;
-
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- min = 0;
- max = GET2(ecode, 1);
- minimize = *ecode == OP_TYPEMINUPTO;
- ecode += 1 + IMM2_SIZE;
- goto REPEATTYPE;
-
- case OP_TYPEPOSSTAR:
- possessive = TRUE;
- min = 0;
- max = INT_MAX;
- ecode++;
- goto REPEATTYPE;
-
- case OP_TYPEPOSPLUS:
- possessive = TRUE;
- min = 1;
- max = INT_MAX;
- ecode++;
- goto REPEATTYPE;
-
- case OP_TYPEPOSQUERY:
- possessive = TRUE;
- min = 0;
- max = 1;
- ecode++;
- goto REPEATTYPE;
-
- case OP_TYPEPOSUPTO:
- possessive = TRUE;
- min = 0;
- max = GET2(ecode, 1);
- ecode += 1 + IMM2_SIZE;
- goto REPEATTYPE;
-
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- c = *ecode++ - OP_TYPESTAR;
- minimize = (c & 1) != 0;
- min = rep_min[c]; /* Pick up values from tables; */
- max = rep_max[c]; /* zero for max => infinity */
- if (max == 0) max = INT_MAX;
-
- /* Common code for all repeated single character type matches. Note that
- in UTF-8 mode, '.' matches a character of any length, but for the other
- character types, the valid characters are all one-byte long. */
-
- REPEATTYPE:
- ctype = *ecode++; /* Code for the character type */
-
-#ifdef SUPPORT_UCP
- if (ctype == OP_PROP || ctype == OP_NOTPROP)
- {
- prop_fail_result = ctype == OP_NOTPROP;
- prop_type = *ecode++;
- prop_value = *ecode++;
- }
- else prop_type = -1;
-#endif
-
- /* First, ensure the minimum number of matches are present. Use inline
- code for maximizing the speed, and do the type test once at the start
- (i.e. keep it out of the loop). Separate the UTF-8 code completely as that
- is tidier. Also separate the UCP code, which can be the same for both UTF-8
- and single-bytes. */
-
- if (min > 0)
- {
-#ifdef SUPPORT_UCP
- if (prop_type >= 0)
- {
- switch(prop_type)
- {
- case PT_ANY:
- if (prop_fail_result) RRETURN(MATCH_NOMATCH);
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- }
- break;
-
- case PT_LAMP:
- for (i = 1; i <= min; i++)
- {
- int chartype;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- chartype = UCD_CHARTYPE(c);
- if ((chartype == ucp_Lu ||
- chartype == ucp_Ll ||
- chartype == ucp_Lt) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- break;
-
- case PT_GC:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- break;
-
- case PT_PC:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- break;
-
- case PT_SC:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if ((UCD_SCRIPT(c) == prop_value) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- break;
-
- case PT_ALNUM:
- for (i = 1; i <= min; i++)
- {
- int category;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- category = UCD_CATEGORY(c);
- if ((category == ucp_L || category == ucp_N) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- break;
-
- /* Perl space used to exclude VT, but from Perl 5.18 it is included,
- which means that Perl space and POSIX space are now identical. PCRE
- was changed at release 8.34. */
-
- case PT_SPACE: /* Perl space */
- case PT_PXSPACE: /* POSIX space */
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- switch(c)
- {
- HSPACE_CASES:
- VSPACE_CASES:
- if (prop_fail_result) RRETURN(MATCH_NOMATCH);
- break;
-
- default:
- if ((UCD_CATEGORY(c) == ucp_Z) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- break;
- }
- }
- break;
-
- case PT_WORD:
- for (i = 1; i <= min; i++)
- {
- int category;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- category = UCD_CATEGORY(c);
- if ((category == ucp_L || category == ucp_N || c == CHAR_UNDERSCORE)
- == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- break;
-
- case PT_CLIST:
- for (i = 1; i <= min; i++)
- {
- const pcre_uint32 *cp;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- cp = PRIV(ucd_caseless_sets) + prop_value;
- for (;;)
- {
- if (c < *cp)
- { if (prop_fail_result) break; else { RRETURN(MATCH_NOMATCH); } }
- if (c == *cp++)
- { if (prop_fail_result) { RRETURN(MATCH_NOMATCH); } else break; }
- }
- }
- break;
-
- case PT_UCNC:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
- c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
- c >= 0xe000) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- break;
-
- /* This should not occur */
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
- }
-
- /* Match extended Unicode sequences. We will get here only if the
- support is in the binary; otherwise a compile-time error occurs. */
-
- else if (ctype == OP_EXTUNI)
- {
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- else
- {
- int lgb, rgb;
- GETCHARINCTEST(c, eptr);
- lgb = UCD_GRAPHBREAK(c);
- while (eptr < md->end_subject)
- {
- int len = 1;
- if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
- rgb = UCD_GRAPHBREAK(c);
- if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
- lgb = rgb;
- eptr += len;
- }
- }
- CHECK_PARTIAL();
- }
- }
-
- else
-#endif /* SUPPORT_UCP */
-
-/* Handle all other cases when the coding is UTF-8 */
-
-#ifdef SUPPORT_UTF
- if (utf) switch(ctype)
- {
- case OP_ANY:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
- if (md->partial != 0 &&
- eptr + 1 >= md->end_subject &&
- NLBLOCK->nltype == NLTYPE_FIXED &&
- NLBLOCK->nllen == 2 &&
- UCHAR21(eptr) == NLBLOCK->nl[0])
- {
- md->hitend = TRUE;
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
- }
- eptr++;
- ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
- }
- break;
-
- case OP_ALLANY:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- eptr++;
- ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
- }
- break;
-
- case OP_ANYBYTE:
- if (eptr > md->end_subject - min) RRETURN(MATCH_NOMATCH);
- eptr += min;
- break;
-
- case OP_ANYNL:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(c, eptr);
- switch(c)
- {
- default: RRETURN(MATCH_NOMATCH);
-
- case CHAR_CR:
- if (eptr < md->end_subject && UCHAR21(eptr) == CHAR_LF) eptr++;
- break;
-
- case CHAR_LF:
- break;
-
- case CHAR_VT:
- case CHAR_FF:
- case CHAR_NEL:
-#ifndef EBCDIC
- case 0x2028:
- case 0x2029:
-#endif /* Not EBCDIC */
- if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
- break;
- }
- }
- break;
-
- case OP_NOT_HSPACE:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(c, eptr);
- switch(c)
- {
- HSPACE_CASES: RRETURN(MATCH_NOMATCH); /* Byte and multibyte cases */
- default: break;
- }
- }
- break;
-
- case OP_HSPACE:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(c, eptr);
- switch(c)
- {
- HSPACE_CASES: break; /* Byte and multibyte cases */
- default: RRETURN(MATCH_NOMATCH);
- }
- }
- break;
-
- case OP_NOT_VSPACE:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(c, eptr);
- switch(c)
- {
- VSPACE_CASES: RRETURN(MATCH_NOMATCH);
- default: break;
- }
- }
- break;
-
- case OP_VSPACE:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(c, eptr);
- switch(c)
- {
- VSPACE_CASES: break;
- default: RRETURN(MATCH_NOMATCH);
- }
- }
- break;
-
- case OP_NOT_DIGIT:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINC(c, eptr);
- if (c < 128 && (md->ctypes[c] & ctype_digit) != 0)
- RRETURN(MATCH_NOMATCH);
- }
- break;
-
- case OP_DIGIT:
- for (i = 1; i <= min; i++)
- {
- pcre_uint32 cc;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- cc = UCHAR21(eptr);
- if (cc >= 128 || (md->ctypes[cc] & ctype_digit) == 0)
- RRETURN(MATCH_NOMATCH);
- eptr++;
- /* No need to skip more bytes - we know it's a 1-byte character */
- }
- break;
-
- case OP_NOT_WHITESPACE:
- for (i = 1; i <= min; i++)
- {
- pcre_uint32 cc;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- cc = UCHAR21(eptr);
- if (cc < 128 && (md->ctypes[cc] & ctype_space) != 0)
- RRETURN(MATCH_NOMATCH);
- eptr++;
- ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
- }
- break;
-
- case OP_WHITESPACE:
- for (i = 1; i <= min; i++)
- {
- pcre_uint32 cc;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- cc = UCHAR21(eptr);
- if (cc >= 128 || (md->ctypes[cc] & ctype_space) == 0)
- RRETURN(MATCH_NOMATCH);
- eptr++;
- /* No need to skip more bytes - we know it's a 1-byte character */
- }
- break;
-
- case OP_NOT_WORDCHAR:
- for (i = 1; i <= min; i++)
- {
- pcre_uint32 cc;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- cc = UCHAR21(eptr);
- if (cc < 128 && (md->ctypes[cc] & ctype_word) != 0)
- RRETURN(MATCH_NOMATCH);
- eptr++;
- ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
- }
- break;
-
- case OP_WORDCHAR:
- for (i = 1; i <= min; i++)
- {
- pcre_uint32 cc;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- cc = UCHAR21(eptr);
- if (cc >= 128 || (md->ctypes[cc] & ctype_word) == 0)
- RRETURN(MATCH_NOMATCH);
- eptr++;
- /* No need to skip more bytes - we know it's a 1-byte character */
- }
- break;
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- } /* End switch(ctype) */
-
- else
-#endif /* SUPPORT_UTF */
-
- /* Code for the non-UTF-8 case for minimum matching of operators other
- than OP_PROP and OP_NOTPROP. */
-
- switch(ctype)
- {
- case OP_ANY:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (IS_NEWLINE(eptr)) RRETURN(MATCH_NOMATCH);
- if (md->partial != 0 &&
- eptr + 1 >= md->end_subject &&
- NLBLOCK->nltype == NLTYPE_FIXED &&
- NLBLOCK->nllen == 2 &&
- *eptr == NLBLOCK->nl[0])
- {
- md->hitend = TRUE;
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
- }
- eptr++;
- }
- break;
-
- case OP_ALLANY:
- if (eptr > md->end_subject - min)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- eptr += min;
- break;
-
- case OP_ANYBYTE:
- if (eptr > md->end_subject - min)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- eptr += min;
- break;
-
- case OP_ANYNL:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- switch(*eptr++)
- {
- default: RRETURN(MATCH_NOMATCH);
-
- case CHAR_CR:
- if (eptr < md->end_subject && *eptr == CHAR_LF) eptr++;
- break;
-
- case CHAR_LF:
- break;
-
- case CHAR_VT:
- case CHAR_FF:
- case CHAR_NEL:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- case 0x2028:
- case 0x2029:
-#endif
- if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
- break;
- }
- }
- break;
-
- case OP_NOT_HSPACE:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- switch(*eptr++)
- {
- default: break;
- HSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- HSPACE_MULTIBYTE_CASES:
-#endif
- RRETURN(MATCH_NOMATCH);
- }
- }
- break;
-
- case OP_HSPACE:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- switch(*eptr++)
- {
- default: RRETURN(MATCH_NOMATCH);
- HSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- HSPACE_MULTIBYTE_CASES:
-#endif
- break;
- }
- }
- break;
-
- case OP_NOT_VSPACE:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- switch(*eptr++)
- {
- VSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- VSPACE_MULTIBYTE_CASES:
-#endif
- RRETURN(MATCH_NOMATCH);
- default: break;
- }
- }
- break;
-
- case OP_VSPACE:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- switch(*eptr++)
- {
- default: RRETURN(MATCH_NOMATCH);
- VSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- VSPACE_MULTIBYTE_CASES:
-#endif
- break;
- }
- }
- break;
-
- case OP_NOT_DIGIT:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_digit) != 0)
- RRETURN(MATCH_NOMATCH);
- eptr++;
- }
- break;
-
- case OP_DIGIT:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_digit) == 0)
- RRETURN(MATCH_NOMATCH);
- eptr++;
- }
- break;
-
- case OP_NOT_WHITESPACE:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_space) != 0)
- RRETURN(MATCH_NOMATCH);
- eptr++;
- }
- break;
-
- case OP_WHITESPACE:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_space) == 0)
- RRETURN(MATCH_NOMATCH);
- eptr++;
- }
- break;
-
- case OP_NOT_WORDCHAR:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_word) != 0)
- RRETURN(MATCH_NOMATCH);
- eptr++;
- }
- break;
-
- case OP_WORDCHAR:
- for (i = 1; i <= min; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_word) == 0)
- RRETURN(MATCH_NOMATCH);
- eptr++;
- }
- break;
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
- }
-
- /* If min = max, continue at the same level without recursing */
-
- if (min == max) continue;
-
- /* If minimizing, we have to test the rest of the pattern before each
- subsequent match. Again, separate the UTF-8 case for speed, and also
- separate the UCP cases. */
-
- if (minimize)
- {
-#ifdef SUPPORT_UCP
- if (prop_type >= 0)
- {
- switch(prop_type)
- {
- case PT_ANY:
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM36);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if (prop_fail_result) RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
-
- case PT_LAMP:
- for (fi = min;; fi++)
- {
- int chartype;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM37);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- chartype = UCD_CHARTYPE(c);
- if ((chartype == ucp_Lu ||
- chartype == ucp_Ll ||
- chartype == ucp_Lt) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
-
- case PT_GC:
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM38);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
-
- case PT_PC:
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM39);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
-
- case PT_SC:
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM40);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if ((UCD_SCRIPT(c) == prop_value) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
-
- case PT_ALNUM:
- for (fi = min;; fi++)
- {
- int category;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM59);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- category = UCD_CATEGORY(c);
- if ((category == ucp_L || category == ucp_N) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
-
- /* Perl space used to exclude VT, but from Perl 5.18 it is included,
- which means that Perl space and POSIX space are now identical. PCRE
- was changed at release 8.34. */
-
- case PT_SPACE: /* Perl space */
- case PT_PXSPACE: /* POSIX space */
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM61);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- switch(c)
- {
- HSPACE_CASES:
- VSPACE_CASES:
- if (prop_fail_result) RRETURN(MATCH_NOMATCH);
- break;
-
- default:
- if ((UCD_CATEGORY(c) == ucp_Z) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- break;
- }
- }
- /* Control never gets here */
-
- case PT_WORD:
- for (fi = min;; fi++)
- {
- int category;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM62);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- category = UCD_CATEGORY(c);
- if ((category == ucp_L ||
- category == ucp_N ||
- c == CHAR_UNDERSCORE)
- == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
-
- case PT_CLIST:
- for (fi = min;; fi++)
- {
- const pcre_uint32 *cp;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM67);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- cp = PRIV(ucd_caseless_sets) + prop_value;
- for (;;)
- {
- if (c < *cp)
- { if (prop_fail_result) break; else { RRETURN(MATCH_NOMATCH); } }
- if (c == *cp++)
- { if (prop_fail_result) { RRETURN(MATCH_NOMATCH); } else break; }
- }
- }
- /* Control never gets here */
-
- case PT_UCNC:
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM60);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- GETCHARINCTEST(c, eptr);
- if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
- c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
- c >= 0xe000) == prop_fail_result)
- RRETURN(MATCH_NOMATCH);
- }
- /* Control never gets here */
-
- /* This should never occur */
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
- }
-
- /* Match extended Unicode sequences. We will get here only if the
- support is in the binary; otherwise a compile-time error occurs. */
-
- else if (ctype == OP_EXTUNI)
- {
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM41);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- else
- {
- int lgb, rgb;
- GETCHARINCTEST(c, eptr);
- lgb = UCD_GRAPHBREAK(c);
- while (eptr < md->end_subject)
- {
- int len = 1;
- if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
- rgb = UCD_GRAPHBREAK(c);
- if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
- lgb = rgb;
- eptr += len;
- }
- }
- CHECK_PARTIAL();
- }
- }
- else
-#endif /* SUPPORT_UCP */
-
-#ifdef SUPPORT_UTF
- if (utf)
- {
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM42);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (ctype == OP_ANY && IS_NEWLINE(eptr))
- RRETURN(MATCH_NOMATCH);
- GETCHARINC(c, eptr);
- switch(ctype)
- {
- case OP_ANY: /* This is the non-NL case */
- if (md->partial != 0 && /* Take care with CRLF partial */
- eptr >= md->end_subject &&
- NLBLOCK->nltype == NLTYPE_FIXED &&
- NLBLOCK->nllen == 2 &&
- c == NLBLOCK->nl[0])
- {
- md->hitend = TRUE;
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
- }
- break;
-
- case OP_ALLANY:
- case OP_ANYBYTE:
- break;
-
- case OP_ANYNL:
- switch(c)
- {
- default: RRETURN(MATCH_NOMATCH);
- case CHAR_CR:
- if (eptr < md->end_subject && UCHAR21(eptr) == CHAR_LF) eptr++;
- break;
-
- case CHAR_LF:
- break;
-
- case CHAR_VT:
- case CHAR_FF:
- case CHAR_NEL:
-#ifndef EBCDIC
- case 0x2028:
- case 0x2029:
-#endif /* Not EBCDIC */
- if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
- break;
- }
- break;
-
- case OP_NOT_HSPACE:
- switch(c)
- {
- HSPACE_CASES: RRETURN(MATCH_NOMATCH);
- default: break;
- }
- break;
-
- case OP_HSPACE:
- switch(c)
- {
- HSPACE_CASES: break;
- default: RRETURN(MATCH_NOMATCH);
- }
- break;
-
- case OP_NOT_VSPACE:
- switch(c)
- {
- VSPACE_CASES: RRETURN(MATCH_NOMATCH);
- default: break;
- }
- break;
-
- case OP_VSPACE:
- switch(c)
- {
- VSPACE_CASES: break;
- default: RRETURN(MATCH_NOMATCH);
- }
- break;
-
- case OP_NOT_DIGIT:
- if (c < 256 && (md->ctypes[c] & ctype_digit) != 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_DIGIT:
- if (c >= 256 || (md->ctypes[c] & ctype_digit) == 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_NOT_WHITESPACE:
- if (c < 256 && (md->ctypes[c] & ctype_space) != 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_WHITESPACE:
- if (c >= 256 || (md->ctypes[c] & ctype_space) == 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_NOT_WORDCHAR:
- if (c < 256 && (md->ctypes[c] & ctype_word) != 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_WORDCHAR:
- if (c >= 256 || (md->ctypes[c] & ctype_word) == 0)
- RRETURN(MATCH_NOMATCH);
- break;
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
- }
- }
- else
-#endif
- /* Not UTF mode */
- {
- for (fi = min;; fi++)
- {
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM43);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- if (fi >= max) RRETURN(MATCH_NOMATCH);
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- RRETURN(MATCH_NOMATCH);
- }
- if (ctype == OP_ANY && IS_NEWLINE(eptr))
- RRETURN(MATCH_NOMATCH);
- c = *eptr++;
- switch(ctype)
- {
- case OP_ANY: /* This is the non-NL case */
- if (md->partial != 0 && /* Take care with CRLF partial */
- eptr >= md->end_subject &&
- NLBLOCK->nltype == NLTYPE_FIXED &&
- NLBLOCK->nllen == 2 &&
- c == NLBLOCK->nl[0])
- {
- md->hitend = TRUE;
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
- }
- break;
-
- case OP_ALLANY:
- case OP_ANYBYTE:
- break;
-
- case OP_ANYNL:
- switch(c)
- {
- default: RRETURN(MATCH_NOMATCH);
- case CHAR_CR:
- if (eptr < md->end_subject && *eptr == CHAR_LF) eptr++;
- break;
-
- case CHAR_LF:
- break;
-
- case CHAR_VT:
- case CHAR_FF:
- case CHAR_NEL:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- case 0x2028:
- case 0x2029:
-#endif
- if (md->bsr_anycrlf) RRETURN(MATCH_NOMATCH);
- break;
- }
- break;
-
- case OP_NOT_HSPACE:
- switch(c)
- {
- default: break;
- HSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- HSPACE_MULTIBYTE_CASES:
-#endif
- RRETURN(MATCH_NOMATCH);
- }
- break;
-
- case OP_HSPACE:
- switch(c)
- {
- default: RRETURN(MATCH_NOMATCH);
- HSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- HSPACE_MULTIBYTE_CASES:
-#endif
- break;
- }
- break;
-
- case OP_NOT_VSPACE:
- switch(c)
- {
- default: break;
- VSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- VSPACE_MULTIBYTE_CASES:
-#endif
- RRETURN(MATCH_NOMATCH);
- }
- break;
-
- case OP_VSPACE:
- switch(c)
- {
- default: RRETURN(MATCH_NOMATCH);
- VSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- VSPACE_MULTIBYTE_CASES:
-#endif
- break;
- }
- break;
-
- case OP_NOT_DIGIT:
- if (MAX_255(c) && (md->ctypes[c] & ctype_digit) != 0) RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_DIGIT:
- if (!MAX_255(c) || (md->ctypes[c] & ctype_digit) == 0) RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_NOT_WHITESPACE:
- if (MAX_255(c) && (md->ctypes[c] & ctype_space) != 0) RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_WHITESPACE:
- if (!MAX_255(c) || (md->ctypes[c] & ctype_space) == 0) RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_NOT_WORDCHAR:
- if (MAX_255(c) && (md->ctypes[c] & ctype_word) != 0) RRETURN(MATCH_NOMATCH);
- break;
-
- case OP_WORDCHAR:
- if (!MAX_255(c) || (md->ctypes[c] & ctype_word) == 0) RRETURN(MATCH_NOMATCH);
- break;
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
- }
- }
- /* Control never gets here */
- }
-
- /* If maximizing, it is worth using inline code for speed, doing the type
- test once at the start (i.e. keep it out of the loop). Again, keep the
- UTF-8 and UCP stuff separate. */
-
- else
- {
- pp = eptr; /* Remember where we started */
-
-#ifdef SUPPORT_UCP
- if (prop_type >= 0)
- {
- switch(prop_type)
- {
- case PT_ANY:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLENTEST(c, eptr, len);
- if (prop_fail_result) break;
- eptr+= len;
- }
- break;
-
- case PT_LAMP:
- for (i = min; i < max; i++)
- {
- int chartype;
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLENTEST(c, eptr, len);
- chartype = UCD_CHARTYPE(c);
- if ((chartype == ucp_Lu ||
- chartype == ucp_Ll ||
- chartype == ucp_Lt) == prop_fail_result)
- break;
- eptr+= len;
- }
- break;
-
- case PT_GC:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLENTEST(c, eptr, len);
- if ((UCD_CATEGORY(c) == prop_value) == prop_fail_result) break;
- eptr+= len;
- }
- break;
-
- case PT_PC:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLENTEST(c, eptr, len);
- if ((UCD_CHARTYPE(c) == prop_value) == prop_fail_result) break;
- eptr+= len;
- }
- break;
-
- case PT_SC:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLENTEST(c, eptr, len);
- if ((UCD_SCRIPT(c) == prop_value) == prop_fail_result) break;
- eptr+= len;
- }
- break;
-
- case PT_ALNUM:
- for (i = min; i < max; i++)
- {
- int category;
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLENTEST(c, eptr, len);
- category = UCD_CATEGORY(c);
- if ((category == ucp_L || category == ucp_N) == prop_fail_result)
- break;
- eptr+= len;
- }
- break;
-
- /* Perl space used to exclude VT, but from Perl 5.18 it is included,
- which means that Perl space and POSIX space are now identical. PCRE
- was changed at release 8.34. */
-
- case PT_SPACE: /* Perl space */
- case PT_PXSPACE: /* POSIX space */
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLENTEST(c, eptr, len);
- switch(c)
- {
- HSPACE_CASES:
- VSPACE_CASES:
- if (prop_fail_result) goto ENDLOOP99; /* Break the loop */
- break;
-
- default:
- if ((UCD_CATEGORY(c) == ucp_Z) == prop_fail_result)
- goto ENDLOOP99; /* Break the loop */
- break;
- }
- eptr+= len;
- }
- ENDLOOP99:
- break;
-
- case PT_WORD:
- for (i = min; i < max; i++)
- {
- int category;
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLENTEST(c, eptr, len);
- category = UCD_CATEGORY(c);
- if ((category == ucp_L || category == ucp_N ||
- c == CHAR_UNDERSCORE) == prop_fail_result)
- break;
- eptr+= len;
- }
- break;
-
- case PT_CLIST:
- for (i = min; i < max; i++)
- {
- const pcre_uint32 *cp;
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLENTEST(c, eptr, len);
- cp = PRIV(ucd_caseless_sets) + prop_value;
- for (;;)
- {
- if (c < *cp)
- { if (prop_fail_result) break; else goto GOT_MAX; }
- if (c == *cp++)
- { if (prop_fail_result) goto GOT_MAX; else break; }
- }
- eptr += len;
- }
- GOT_MAX:
- break;
-
- case PT_UCNC:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLENTEST(c, eptr, len);
- if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
- c == CHAR_GRAVE_ACCENT || (c >= 0xa0 && c <= 0xd7ff) ||
- c >= 0xe000) == prop_fail_result)
- break;
- eptr += len;
- }
- break;
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
-
- /* eptr is now past the end of the maximum run */
-
- if (possessive) continue; /* No backtracking */
- for(;;)
- {
- if (eptr <= pp) goto TAIL_RECURSE;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM44);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- eptr--;
- if (utf) BACKCHAR(eptr);
- }
- }
-
- /* Match extended Unicode grapheme clusters. We will get here only if the
- support is in the binary; otherwise a compile-time error occurs. */
-
- else if (ctype == OP_EXTUNI)
- {
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- else
- {
- int lgb, rgb;
- GETCHARINCTEST(c, eptr);
- lgb = UCD_GRAPHBREAK(c);
- while (eptr < md->end_subject)
- {
- int len = 1;
- if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); }
- rgb = UCD_GRAPHBREAK(c);
- if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
- lgb = rgb;
- eptr += len;
- }
- }
- CHECK_PARTIAL();
- }
-
- /* eptr is now past the end of the maximum run */
-
- if (possessive) continue; /* No backtracking */
-
- /* We use <= pp rather than == pp to detect the start of the run while
- backtracking because the use of \C in UTF mode can cause BACKCHAR to
- move back past pp. This is just palliative; the use of \C in UTF mode
- is fraught with danger. */
-
- for(;;)
- {
- int lgb, rgb;
- PCRE_PUCHAR fptr;
-
- if (eptr <= pp) goto TAIL_RECURSE; /* At start of char run */
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM45);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
-
- /* Backtracking over an extended grapheme cluster involves inspecting
- the previous two characters (if present) to see if a break is
- permitted between them. */
-
- eptr--;
- if (!utf) c = *eptr; else
- {
- BACKCHAR(eptr);
- GETCHAR(c, eptr);
- }
- rgb = UCD_GRAPHBREAK(c);
-
- for (;;)
- {
- if (eptr <= pp) goto TAIL_RECURSE; /* At start of char run */
- fptr = eptr - 1;
- if (!utf) c = *fptr; else
- {
- BACKCHAR(fptr);
- GETCHAR(c, fptr);
- }
- lgb = UCD_GRAPHBREAK(c);
- if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break;
- eptr = fptr;
- rgb = lgb;
- }
- }
- }
-
- else
-#endif /* SUPPORT_UCP */
-
-#ifdef SUPPORT_UTF
- if (utf)
- {
- switch(ctype)
- {
- case OP_ANY:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- if (IS_NEWLINE(eptr)) break;
- if (md->partial != 0 && /* Take care with CRLF partial */
- eptr + 1 >= md->end_subject &&
- NLBLOCK->nltype == NLTYPE_FIXED &&
- NLBLOCK->nllen == 2 &&
- UCHAR21(eptr) == NLBLOCK->nl[0])
- {
- md->hitend = TRUE;
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
- }
- eptr++;
- ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
- }
- break;
-
- case OP_ALLANY:
- if (max < INT_MAX)
- {
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- eptr++;
- ACROSSCHAR(eptr < md->end_subject, *eptr, eptr++);
- }
- }
- else
- {
- eptr = md->end_subject; /* Unlimited UTF-8 repeat */
- SCHECK_PARTIAL();
- }
- break;
-
- /* The byte case is the same as non-UTF8 */
-
- case OP_ANYBYTE:
- c = max - min;
- if (c > (unsigned int)(md->end_subject - eptr))
- {
- eptr = md->end_subject;
- SCHECK_PARTIAL();
- }
- else eptr += c;
- break;
-
- case OP_ANYNL:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(c, eptr, len);
- if (c == CHAR_CR)
- {
- if (++eptr >= md->end_subject) break;
- if (UCHAR21(eptr) == CHAR_LF) eptr++;
- }
- else
- {
- if (c != CHAR_LF &&
- (md->bsr_anycrlf ||
- (c != CHAR_VT && c != CHAR_FF && c != CHAR_NEL
-#ifndef EBCDIC
- && c != 0x2028 && c != 0x2029
-#endif /* Not EBCDIC */
- )))
- break;
- eptr += len;
- }
- }
- break;
-
- case OP_NOT_HSPACE:
- case OP_HSPACE:
- for (i = min; i < max; i++)
- {
- BOOL gotspace;
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(c, eptr, len);
- switch(c)
- {
- HSPACE_CASES: gotspace = TRUE; break;
- default: gotspace = FALSE; break;
- }
- if (gotspace == (ctype == OP_NOT_HSPACE)) break;
- eptr += len;
- }
- break;
-
- case OP_NOT_VSPACE:
- case OP_VSPACE:
- for (i = min; i < max; i++)
- {
- BOOL gotspace;
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(c, eptr, len);
- switch(c)
- {
- VSPACE_CASES: gotspace = TRUE; break;
- default: gotspace = FALSE; break;
- }
- if (gotspace == (ctype == OP_NOT_VSPACE)) break;
- eptr += len;
- }
- break;
-
- case OP_NOT_DIGIT:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(c, eptr, len);
- if (c < 256 && (md->ctypes[c] & ctype_digit) != 0) break;
- eptr+= len;
- }
- break;
-
- case OP_DIGIT:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(c, eptr, len);
- if (c >= 256 ||(md->ctypes[c] & ctype_digit) == 0) break;
- eptr+= len;
- }
- break;
-
- case OP_NOT_WHITESPACE:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(c, eptr, len);
- if (c < 256 && (md->ctypes[c] & ctype_space) != 0) break;
- eptr+= len;
- }
- break;
-
- case OP_WHITESPACE:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(c, eptr, len);
- if (c >= 256 ||(md->ctypes[c] & ctype_space) == 0) break;
- eptr+= len;
- }
- break;
-
- case OP_NOT_WORDCHAR:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(c, eptr, len);
- if (c < 256 && (md->ctypes[c] & ctype_word) != 0) break;
- eptr+= len;
- }
- break;
-
- case OP_WORDCHAR:
- for (i = min; i < max; i++)
- {
- int len = 1;
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- GETCHARLEN(c, eptr, len);
- if (c >= 256 || (md->ctypes[c] & ctype_word) == 0) break;
- eptr+= len;
- }
- break;
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
-
- if (possessive) continue; /* No backtracking */
- for(;;)
- {
- if (eptr <= pp) goto TAIL_RECURSE;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM46);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- eptr--;
- BACKCHAR(eptr);
- if (ctype == OP_ANYNL && eptr > pp && UCHAR21(eptr) == CHAR_NL &&
- UCHAR21(eptr - 1) == CHAR_CR) eptr--;
- }
- }
- else
-#endif /* SUPPORT_UTF */
- /* Not UTF mode */
- {
- switch(ctype)
- {
- case OP_ANY:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- if (IS_NEWLINE(eptr)) break;
- if (md->partial != 0 && /* Take care with CRLF partial */
- eptr + 1 >= md->end_subject &&
- NLBLOCK->nltype == NLTYPE_FIXED &&
- NLBLOCK->nllen == 2 &&
- *eptr == NLBLOCK->nl[0])
- {
- md->hitend = TRUE;
- if (md->partial > 1) RRETURN(PCRE_ERROR_PARTIAL);
- }
- eptr++;
- }
- break;
-
- case OP_ALLANY:
- case OP_ANYBYTE:
- c = max - min;
- if (c > (unsigned int)(md->end_subject - eptr))
- {
- eptr = md->end_subject;
- SCHECK_PARTIAL();
- }
- else eptr += c;
- break;
-
- case OP_ANYNL:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- c = *eptr;
- if (c == CHAR_CR)
- {
- if (++eptr >= md->end_subject) break;
- if (*eptr == CHAR_LF) eptr++;
- }
- else
- {
- if (c != CHAR_LF && (md->bsr_anycrlf ||
- (c != CHAR_VT && c != CHAR_FF && c != CHAR_NEL
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- && c != 0x2028 && c != 0x2029
-#endif
- ))) break;
- eptr++;
- }
- }
- break;
-
- case OP_NOT_HSPACE:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- switch(*eptr)
- {
- default: eptr++; break;
- HSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- HSPACE_MULTIBYTE_CASES:
-#endif
- goto ENDLOOP00;
- }
- }
- ENDLOOP00:
- break;
-
- case OP_HSPACE:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- switch(*eptr)
- {
- default: goto ENDLOOP01;
- HSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- HSPACE_MULTIBYTE_CASES:
-#endif
- eptr++; break;
- }
- }
- ENDLOOP01:
- break;
-
- case OP_NOT_VSPACE:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- switch(*eptr)
- {
- default: eptr++; break;
- VSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- VSPACE_MULTIBYTE_CASES:
-#endif
- goto ENDLOOP02;
- }
- }
- ENDLOOP02:
- break;
-
- case OP_VSPACE:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- switch(*eptr)
- {
- default: goto ENDLOOP03;
- VSPACE_BYTE_CASES:
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- VSPACE_MULTIBYTE_CASES:
-#endif
- eptr++; break;
- }
- }
- ENDLOOP03:
- break;
-
- case OP_NOT_DIGIT:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_digit) != 0) break;
- eptr++;
- }
- break;
-
- case OP_DIGIT:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_digit) == 0) break;
- eptr++;
- }
- break;
-
- case OP_NOT_WHITESPACE:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_space) != 0) break;
- eptr++;
- }
- break;
-
- case OP_WHITESPACE:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_space) == 0) break;
- eptr++;
- }
- break;
-
- case OP_NOT_WORDCHAR:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- if (MAX_255(*eptr) && (md->ctypes[*eptr] & ctype_word) != 0) break;
- eptr++;
- }
- break;
-
- case OP_WORDCHAR:
- for (i = min; i < max; i++)
- {
- if (eptr >= md->end_subject)
- {
- SCHECK_PARTIAL();
- break;
- }
- if (!MAX_255(*eptr) || (md->ctypes[*eptr] & ctype_word) == 0) break;
- eptr++;
- }
- break;
-
- default:
- RRETURN(PCRE_ERROR_INTERNAL);
- }
-
- if (possessive) continue; /* No backtracking */
- for (;;)
- {
- if (eptr == pp) goto TAIL_RECURSE;
- RMATCH(eptr, ecode, offset_top, md, eptrb, RM47);
- if (rrc != MATCH_NOMATCH) RRETURN(rrc);
- eptr--;
- if (ctype == OP_ANYNL && eptr > pp && *eptr == CHAR_LF &&
- eptr[-1] == CHAR_CR) eptr--;
- }
- }
-
- /* Control never gets here */
- }
-
- /* There's been some horrible disaster. Arrival here can only mean there is
- something seriously wrong in the code above or the OP_xxx definitions. */
-
- default:
- DPRINTF(("Unknown opcode %d\n", *ecode));
- RRETURN(PCRE_ERROR_UNKNOWN_OPCODE);
- }
-
- /* Do not stick any code in here without much thought; it is assumed
- that "continue" in the code above comes out to here to repeat the main
- loop. */
-
- } /* End of main loop */
-/* Control never reaches here */
-
-
-/* When compiling to use the heap rather than the stack for recursive calls to
-match(), the RRETURN() macro jumps here. The number that is saved in
-frame->Xwhere indicates which label we actually want to return to. */
-
-#ifdef NO_RECURSE
-#define LBL(val) case val: goto L_RM##val;
-HEAP_RETURN:
-switch (frame->Xwhere)
- {
- LBL( 1) LBL( 2) LBL( 3) LBL( 4) LBL( 5) LBL( 6) LBL( 7) LBL( 8)
- LBL( 9) LBL(10) LBL(11) LBL(12) LBL(13) LBL(14) LBL(15) LBL(17)
- LBL(19) LBL(24) LBL(25) LBL(26) LBL(27) LBL(29) LBL(31) LBL(33)
- LBL(35) LBL(43) LBL(47) LBL(48) LBL(49) LBL(50) LBL(51) LBL(52)
- LBL(53) LBL(54) LBL(55) LBL(56) LBL(57) LBL(58) LBL(63) LBL(64)
- LBL(65) LBL(66)
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- LBL(20) LBL(21)
-#endif
-#ifdef SUPPORT_UTF
- LBL(16) LBL(18)
- LBL(22) LBL(23) LBL(28) LBL(30)
- LBL(32) LBL(34) LBL(42) LBL(46)
-#ifdef SUPPORT_UCP
- LBL(36) LBL(37) LBL(38) LBL(39) LBL(40) LBL(41) LBL(44) LBL(45)
- LBL(59) LBL(60) LBL(61) LBL(62) LBL(67)
-#endif /* SUPPORT_UCP */
-#endif /* SUPPORT_UTF */
- default:
- DPRINTF(("jump error in pcre match: label %d non-existent\n", frame->Xwhere));
- return PCRE_ERROR_INTERNAL;
- }
-#undef LBL
-#endif /* NO_RECURSE */
-}
-
-
-/***************************************************************************
-****************************************************************************
- RECURSION IN THE match() FUNCTION
-
-Undefine all the macros that were defined above to handle this. */
-
-#ifdef NO_RECURSE
-#undef eptr
-#undef ecode
-#undef mstart
-#undef offset_top
-#undef eptrb
-#undef flags
-
-#undef callpat
-#undef charptr
-#undef data
-#undef next
-#undef pp
-#undef prev
-#undef saved_eptr
-
-#undef new_recursive
-
-#undef cur_is_word
-#undef condition
-#undef prev_is_word
-
-#undef ctype
-#undef length
-#undef max
-#undef min
-#undef number
-#undef offset
-#undef op
-#undef save_capture_last
-#undef save_offset1
-#undef save_offset2
-#undef save_offset3
-#undef stacksave
-
-#undef newptrb
-
-#endif
-
-/* These two are defined as macros in both cases */
-
-#undef fc
-#undef fi
-
-/***************************************************************************
-***************************************************************************/
-
-
-#ifdef NO_RECURSE
-/*************************************************
-* Release allocated heap frames *
-*************************************************/
-
-/* This function releases all the allocated frames. The base frame is on the
-machine stack, and so must not be freed.
-
-Argument: the address of the base frame
-Returns: nothing
-*/
-
-static void
-release_match_heapframes (heapframe *frame_base)
-{
-heapframe *nextframe = frame_base->Xnextframe;
-while (nextframe != NULL)
- {
- heapframe *oldframe = nextframe;
- nextframe = nextframe->Xnextframe;
- (PUBL(stack_free))(oldframe);
- }
-}
-#endif
-
-
-/*************************************************
-* Execute a Regular Expression *
-*************************************************/
-
-/* This function applies a compiled re to a subject string and picks out
-portions of the string if it matches. Two elements in the vector are set for
-each substring: the offsets to the start and end of the substring.
-
-Arguments:
- argument_re points to the compiled expression
- extra_data points to extra data or is NULL
- subject points to the subject string
- length length of subject string (may contain binary zeros)
- start_offset where to start in the subject string
- options option bits
- offsets points to a vector of ints to be filled in with offsets
- offsetcount the number of elements in the vector
-
-Returns: > 0 => success; value is the number of elements filled in
- = 0 => success, but offsets is not big enough
- -1 => failed to match
- < -1 => some kind of unexpected problem
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
- PCRE_SPTR subject, int length, int start_offset, int options, int *offsets,
- int offsetcount)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,
- PCRE_SPTR16 subject, int length, int start_offset, int options, int *offsets,
- int offsetcount)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_exec(const pcre32 *argument_re, const pcre32_extra *extra_data,
- PCRE_SPTR32 subject, int length, int start_offset, int options, int *offsets,
- int offsetcount)
-#endif
-{
-int rc, ocount, arg_offset_max;
-int newline;
-BOOL using_temporary_offsets = FALSE;
-BOOL anchored;
-BOOL startline;
-BOOL firstline;
-BOOL utf;
-BOOL has_first_char = FALSE;
-BOOL has_req_char = FALSE;
-pcre_uchar first_char = 0;
-pcre_uchar first_char2 = 0;
-pcre_uchar req_char = 0;
-pcre_uchar req_char2 = 0;
-match_data match_block;
-match_data *md = &match_block;
-const pcre_uint8 *tables;
-const pcre_uint8 *start_bits = NULL;
-PCRE_PUCHAR start_match = (PCRE_PUCHAR)subject + start_offset;
-PCRE_PUCHAR end_subject;
-PCRE_PUCHAR start_partial = NULL;
-PCRE_PUCHAR match_partial = NULL;
-PCRE_PUCHAR req_char_ptr = start_match - 1;
-
-const pcre_study_data *study;
-const REAL_PCRE *re = (const REAL_PCRE *)argument_re;
-
-#ifdef NO_RECURSE
-heapframe frame_zero;
-frame_zero.Xprevframe = NULL; /* Marks the top level */
-frame_zero.Xnextframe = NULL; /* None are allocated yet */
-md->match_frames_base = &frame_zero;
-#endif
-
-/* Check for the special magic call that measures the size of the stack used
-per recursive call of match(). Without the funny casting for sizeof, a Windows
-compiler gave this error: "unary minus operator applied to unsigned type,
-result still unsigned". Hopefully the cast fixes that. */
-
-if (re == NULL && extra_data == NULL && subject == NULL && length == -999 &&
- start_offset == -999)
-#ifdef NO_RECURSE
- return -((int)sizeof(heapframe));
-#else
- return match(NULL, NULL, NULL, 0, NULL, NULL, 0);
-#endif
-
-/* Plausibility checks */
-
-if ((options & ~PUBLIC_EXEC_OPTIONS) != 0) return PCRE_ERROR_BADOPTION;
-if (re == NULL || subject == NULL || (offsets == NULL && offsetcount > 0))
- return PCRE_ERROR_NULL;
-if (offsetcount < 0) return PCRE_ERROR_BADCOUNT;
-if (length < 0) return PCRE_ERROR_BADLENGTH;
-if (start_offset < 0 || start_offset > length) return PCRE_ERROR_BADOFFSET;
-
-/* Check that the first field in the block is the magic number. If it is not,
-return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to
-REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which
-means that the pattern is likely compiled with different endianness. */
-
-if (re->magic_number != MAGIC_NUMBER)
- return re->magic_number == REVERSED_MAGIC_NUMBER?
- PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;
-if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
-
-/* These two settings are used in the code for checking a UTF-8 string that
-follows immediately afterwards. Other values in the md block are used only
-during "normal" pcre_exec() processing, not when the JIT support is in use,
-so they are set up later. */
-
-/* PCRE_UTF16 has the same value as PCRE_UTF8. */
-utf = md->utf = (re->options & PCRE_UTF8) != 0;
-md->partial = ((options & PCRE_PARTIAL_HARD) != 0)? 2 :
- ((options & PCRE_PARTIAL_SOFT) != 0)? 1 : 0;
-
-/* Check a UTF-8 string if required. Pass back the character offset and error
-code for an invalid string if a results vector is available. */
-
-#ifdef SUPPORT_UTF
-if (utf && (options & PCRE_NO_UTF8_CHECK) == 0)
- {
- int erroroffset;
- int errorcode = PRIV(valid_utf)((PCRE_PUCHAR)subject, length, &erroroffset);
- if (errorcode != 0)
- {
- if (offsetcount >= 2)
- {
- offsets[0] = erroroffset;
- offsets[1] = errorcode;
- }
-#if defined COMPILE_PCRE8
- return (errorcode <= PCRE_UTF8_ERR5 && md->partial > 1)?
- PCRE_ERROR_SHORTUTF8 : PCRE_ERROR_BADUTF8;
-#elif defined COMPILE_PCRE16
- return (errorcode <= PCRE_UTF16_ERR1 && md->partial > 1)?
- PCRE_ERROR_SHORTUTF16 : PCRE_ERROR_BADUTF16;
-#elif defined COMPILE_PCRE32
- return PCRE_ERROR_BADUTF32;
-#endif
- }
-#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
- /* Check that a start_offset points to the start of a UTF character. */
- if (start_offset > 0 && start_offset < length &&
- NOT_FIRSTCHAR(((PCRE_PUCHAR)subject)[start_offset]))
- return PCRE_ERROR_BADUTF8_OFFSET;
-#endif
- }
-#endif
-
-/* If the pattern was successfully studied with JIT support, run the JIT
-executable instead of the rest of this function. Most options must be set at
-compile time for the JIT code to be usable. Fallback to the normal code path if
-an unsupported flag is set. */
-
-#ifdef SUPPORT_JIT
-if (extra_data != NULL
- && (extra_data->flags & (PCRE_EXTRA_EXECUTABLE_JIT |
- PCRE_EXTRA_TABLES)) == PCRE_EXTRA_EXECUTABLE_JIT
- && extra_data->executable_jit != NULL
- && (options & ~PUBLIC_JIT_EXEC_OPTIONS) == 0)
- {
- rc = PRIV(jit_exec)(extra_data, (const pcre_uchar *)subject, length,
- start_offset, options, offsets, offsetcount);
-
- /* PCRE_ERROR_NULL means that the selected normal or partial matching
- mode is not compiled. In this case we simply fallback to interpreter. */
-
- if (rc != PCRE_ERROR_JIT_BADOPTION) return rc;
- }
-#endif
-
-/* Carry on with non-JIT matching. This information is for finding all the
-numbers associated with a given name, for condition testing. */
-
-md->name_table = (pcre_uchar *)re + re->name_table_offset;
-md->name_count = re->name_count;
-md->name_entry_size = re->name_entry_size;
-
-/* Fish out the optional data from the extra_data structure, first setting
-the default values. */
-
-study = NULL;
-md->match_limit = MATCH_LIMIT;
-md->match_limit_recursion = MATCH_LIMIT_RECURSION;
-md->callout_data = NULL;
-
-/* The table pointer is always in native byte order. */
-
-tables = re->tables;
-
-/* The two limit values override the defaults, whatever their value. */
-
-if (extra_data != NULL)
- {
- unsigned long int flags = extra_data->flags;
- if ((flags & PCRE_EXTRA_STUDY_DATA) != 0)
- study = (const pcre_study_data *)extra_data->study_data;
- if ((flags & PCRE_EXTRA_MATCH_LIMIT) != 0)
- md->match_limit = extra_data->match_limit;
- if ((flags & PCRE_EXTRA_MATCH_LIMIT_RECURSION) != 0)
- md->match_limit_recursion = extra_data->match_limit_recursion;
- if ((flags & PCRE_EXTRA_CALLOUT_DATA) != 0)
- md->callout_data = extra_data->callout_data;
- if ((flags & PCRE_EXTRA_TABLES) != 0) tables = extra_data->tables;
- }
-
-/* Limits in the regex override only if they are smaller. */
-
-if ((re->flags & PCRE_MLSET) != 0 && re->limit_match < md->match_limit)
- md->match_limit = re->limit_match;
-
-if ((re->flags & PCRE_RLSET) != 0 &&
- re->limit_recursion < md->match_limit_recursion)
- md->match_limit_recursion = re->limit_recursion;
-
-/* If the exec call supplied NULL for tables, use the inbuilt ones. This
-is a feature that makes it possible to save compiled regex and re-use them
-in other programs later. */
-
-if (tables == NULL) tables = PRIV(default_tables);
-
-/* Set up other data */
-
-anchored = ((re->options | options) & PCRE_ANCHORED) != 0;
-startline = (re->flags & PCRE_STARTLINE) != 0;
-firstline = (re->options & PCRE_FIRSTLINE) != 0;
-
-/* The code starts after the real_pcre block and the capture name table. */
-
-md->start_code = (const pcre_uchar *)re + re->name_table_offset +
- re->name_count * re->name_entry_size;
-
-md->start_subject = (PCRE_PUCHAR)subject;
-md->start_offset = start_offset;
-md->end_subject = md->start_subject + length;
-end_subject = md->end_subject;
-
-md->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
-md->use_ucp = (re->options & PCRE_UCP) != 0;
-md->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
-md->ignore_skip_arg = 0;
-
-/* Some options are unpacked into BOOL variables in the hope that testing
-them will be faster than individual option bits. */
-
-md->notbol = (options & PCRE_NOTBOL) != 0;
-md->noteol = (options & PCRE_NOTEOL) != 0;
-md->notempty = (options & PCRE_NOTEMPTY) != 0;
-md->notempty_atstart = (options & PCRE_NOTEMPTY_ATSTART) != 0;
-
-md->hitend = FALSE;
-md->mark = md->nomatch_mark = NULL; /* In case never set */
-
-md->recursive = NULL; /* No recursion at top level */
-md->hasthen = (re->flags & PCRE_HASTHEN) != 0;
-
-md->lcc = tables + lcc_offset;
-md->fcc = tables + fcc_offset;
-md->ctypes = tables + ctypes_offset;
-
-/* Handle different \R options. */
-
-switch (options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE))
- {
- case 0:
- if ((re->options & (PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE)) != 0)
- md->bsr_anycrlf = (re->options & PCRE_BSR_ANYCRLF) != 0;
- else
-#ifdef BSR_ANYCRLF
- md->bsr_anycrlf = TRUE;
-#else
- md->bsr_anycrlf = FALSE;
-#endif
- break;
-
- case PCRE_BSR_ANYCRLF:
- md->bsr_anycrlf = TRUE;
- break;
-
- case PCRE_BSR_UNICODE:
- md->bsr_anycrlf = FALSE;
- break;
-
- default: return PCRE_ERROR_BADNEWLINE;
- }
-
-/* Handle different types of newline. The three bits give eight cases. If
-nothing is set at run time, whatever was used at compile time applies. */
-
-switch ((((options & PCRE_NEWLINE_BITS) == 0)? re->options :
- (pcre_uint32)options) & PCRE_NEWLINE_BITS)
- {
- case 0: newline = NEWLINE; break; /* Compile-time default */
- case PCRE_NEWLINE_CR: newline = CHAR_CR; break;
- case PCRE_NEWLINE_LF: newline = CHAR_NL; break;
- case PCRE_NEWLINE_CR+
- PCRE_NEWLINE_LF: newline = (CHAR_CR << 8) | CHAR_NL; break;
- case PCRE_NEWLINE_ANY: newline = -1; break;
- case PCRE_NEWLINE_ANYCRLF: newline = -2; break;
- default: return PCRE_ERROR_BADNEWLINE;
- }
-
-if (newline == -2)
- {
- md->nltype = NLTYPE_ANYCRLF;
- }
-else if (newline < 0)
- {
- md->nltype = NLTYPE_ANY;
- }
-else
- {
- md->nltype = NLTYPE_FIXED;
- if (newline > 255)
- {
- md->nllen = 2;
- md->nl[0] = (newline >> 8) & 255;
- md->nl[1] = newline & 255;
- }
- else
- {
- md->nllen = 1;
- md->nl[0] = newline;
- }
- }
-
-/* Partial matching was originally supported only for a restricted set of
-regexes; from release 8.00 there are no restrictions, but the bits are still
-defined (though never set). So there's no harm in leaving this code. */
-
-if (md->partial && (re->flags & PCRE_NOPARTIAL) != 0)
- return PCRE_ERROR_BADPARTIAL;
-
-/* If the expression has got more back references than the offsets supplied can
-hold, we get a temporary chunk of working store to use during the matching.
-Otherwise, we can use the vector supplied, rounding down its size to a multiple
-of 3. */
-
-ocount = offsetcount - (offsetcount % 3);
-arg_offset_max = (2*ocount)/3;
-
-if (re->top_backref > 0 && re->top_backref >= ocount/3)
- {
- ocount = re->top_backref * 3 + 3;
- md->offset_vector = (int *)(PUBL(malloc))(ocount * sizeof(int));
- if (md->offset_vector == NULL) return PCRE_ERROR_NOMEMORY;
- using_temporary_offsets = TRUE;
- DPRINTF(("Got memory to hold back references\n"));
- }
-else md->offset_vector = offsets;
-md->offset_end = ocount;
-md->offset_max = (2*ocount)/3;
-md->capture_last = 0;
-
-/* Reset the working variable associated with each extraction. These should
-never be used unless previously set, but they get saved and restored, and so we
-initialize them to avoid reading uninitialized locations. Also, unset the
-offsets for the matched string. This is really just for tidiness with callouts,
-in case they inspect these fields. */
-
-if (md->offset_vector != NULL)
- {
- register int *iptr = md->offset_vector + ocount;
- register int *iend = iptr - re->top_bracket;
- if (iend < md->offset_vector + 2) iend = md->offset_vector + 2;
- while (--iptr >= iend) *iptr = -1;
- if (offsetcount > 0) md->offset_vector[0] = -1;
- if (offsetcount > 1) md->offset_vector[1] = -1;
- }
-
-/* Set up the first character to match, if available. The first_char value is
-never set for an anchored regular expression, but the anchoring may be forced
-at run time, so we have to test for anchoring. The first char may be unset for
-an unanchored pattern, of course. If there's no first char and the pattern was
-studied, there may be a bitmap of possible first characters. */
-
-if (!anchored)
- {
- if ((re->flags & PCRE_FIRSTSET) != 0)
- {
- has_first_char = TRUE;
- first_char = first_char2 = (pcre_uchar)(re->first_char);
- if ((re->flags & PCRE_FCH_CASELESS) != 0)
- {
- first_char2 = TABLE_GET(first_char, md->fcc, first_char);
-#if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)
- if (utf && first_char > 127)
- first_char2 = UCD_OTHERCASE(first_char);
-#endif
- }
- }
- else
- if (!startline && study != NULL &&
- (study->flags & PCRE_STUDY_MAPPED) != 0)
- start_bits = study->start_bits;
- }
-
-/* For anchored or unanchored matches, there may be a "last known required
-character" set. */
-
-if ((re->flags & PCRE_REQCHSET) != 0)
- {
- has_req_char = TRUE;
- req_char = req_char2 = (pcre_uchar)(re->req_char);
- if ((re->flags & PCRE_RCH_CASELESS) != 0)
- {
- req_char2 = TABLE_GET(req_char, md->fcc, req_char);
-#if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)
- if (utf && req_char > 127)
- req_char2 = UCD_OTHERCASE(req_char);
-#endif
- }
- }
-
-
-/* ==========================================================================*/
-
-/* Loop for handling unanchored repeated matching attempts; for anchored regexs
-the loop runs just once. */
-
-for(;;)
- {
- PCRE_PUCHAR save_end_subject = end_subject;
- PCRE_PUCHAR new_start_match;
-
- /* If firstline is TRUE, the start of the match is constrained to the first
- line of a multiline string. That is, the match must be before or at the first
- newline. Implement this by temporarily adjusting end_subject so that we stop
- scanning at a newline. If the match fails at the newline, later code breaks
- this loop. */
-
- if (firstline)
- {
- PCRE_PUCHAR t = start_match;
-#ifdef SUPPORT_UTF
- if (utf)
- {
- while (t < md->end_subject && !IS_NEWLINE(t))
- {
- t++;
- ACROSSCHAR(t < end_subject, *t, t++);
- }
- }
- else
-#endif
- while (t < md->end_subject && !IS_NEWLINE(t)) t++;
- end_subject = t;
- }
-
- /* There are some optimizations that avoid running the match if a known
- starting point is not found, or if a known later character is not present.
- However, there is an option that disables these, for testing and for ensuring
- that all callouts do actually occur. The option can be set in the regex by
- (*NO_START_OPT) or passed in match-time options. */
-
- if (((options | re->options) & PCRE_NO_START_OPTIMIZE) == 0)
- {
- /* Advance to a unique first char if there is one. */
-
- if (has_first_char)
- {
- pcre_uchar smc;
-
- if (first_char != first_char2)
- while (start_match < end_subject &&
- (smc = UCHAR21TEST(start_match)) != first_char && smc != first_char2)
- start_match++;
- else
- while (start_match < end_subject && UCHAR21TEST(start_match) != first_char)
- start_match++;
- }
-
- /* Or to just after a linebreak for a multiline match */
-
- else if (startline)
- {
- if (start_match > md->start_subject + start_offset)
- {
-#ifdef SUPPORT_UTF
- if (utf)
- {
- while (start_match < end_subject && !WAS_NEWLINE(start_match))
- {
- start_match++;
- ACROSSCHAR(start_match < end_subject, *start_match,
- start_match++);
- }
- }
- else
-#endif
- while (start_match < end_subject && !WAS_NEWLINE(start_match))
- start_match++;
-
- /* If we have just passed a CR and the newline option is ANY or ANYCRLF,
- and we are now at a LF, advance the match position by one more character.
- */
-
- if (start_match[-1] == CHAR_CR &&
- (md->nltype == NLTYPE_ANY || md->nltype == NLTYPE_ANYCRLF) &&
- start_match < end_subject &&
- UCHAR21TEST(start_match) == CHAR_NL)
- start_match++;
- }
- }
-
- /* Or to a non-unique first byte after study */
-
- else if (start_bits != NULL)
- {
- while (start_match < end_subject)
- {
- register pcre_uint32 c = UCHAR21TEST(start_match);
-#ifndef COMPILE_PCRE8
- if (c > 255) c = 255;
-#endif
- if ((start_bits[c/8] & (1 << (c&7))) != 0) break;
- start_match++;
- }
- }
- } /* Starting optimizations */
-
- /* Restore fudged end_subject */
-
- end_subject = save_end_subject;
-
- /* The following two optimizations are disabled for partial matching or if
- disabling is explicitly requested. */
-
- if (((options | re->options) & PCRE_NO_START_OPTIMIZE) == 0 && !md->partial)
- {
- /* If the pattern was studied, a minimum subject length may be set. This is
- a lower bound; no actual string of that length may actually match the
- pattern. Although the value is, strictly, in characters, we treat it as
- bytes to avoid spending too much time in this optimization. */
-
- if (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0 &&
- (pcre_uint32)(end_subject - start_match) < study->minlength)
- {
- rc = MATCH_NOMATCH;
- break;
- }
-
- /* If req_char is set, we know that that character must appear in the
- subject for the match to succeed. If the first character is set, req_char
- must be later in the subject; otherwise the test starts at the match point.
- This optimization can save a huge amount of backtracking in patterns with
- nested unlimited repeats that aren't going to match. Writing separate code
- for cased/caseless versions makes it go faster, as does using an
- autoincrement and backing off on a match.
-
- HOWEVER: when the subject string is very, very long, searching to its end
- can take a long time, and give bad performance on quite ordinary patterns.
- This showed up when somebody was matching something like /^\d+C/ on a
- 32-megabyte string... so we don't do this when the string is sufficiently
- long. */
-
- if (has_req_char && end_subject - start_match < REQ_BYTE_MAX)
- {
- register PCRE_PUCHAR p = start_match + (has_first_char? 1:0);
-
- /* We don't need to repeat the search if we haven't yet reached the
- place we found it at last time. */
-
- if (p > req_char_ptr)
- {
- if (req_char != req_char2)
- {
- while (p < end_subject)
- {
- register pcre_uint32 pp = UCHAR21INCTEST(p);
- if (pp == req_char || pp == req_char2) { p--; break; }
- }
- }
- else
- {
- while (p < end_subject)
- {
- if (UCHAR21INCTEST(p) == req_char) { p--; break; }
- }
- }
-
- /* If we can't find the required character, break the matching loop,
- forcing a match failure. */
-
- if (p >= end_subject)
- {
- rc = MATCH_NOMATCH;
- break;
- }
-
- /* If we have found the required character, save the point where we
- found it, so that we don't search again next time round the loop if
- the start hasn't passed this character yet. */
-
- req_char_ptr = p;
- }
- }
- }
-
-#ifdef PCRE_DEBUG /* Sigh. Some compilers never learn. */
- printf(">>>> Match against: ");
- pchars(start_match, end_subject - start_match, TRUE, md);
- printf("\n");
-#endif
-
- /* OK, we can now run the match. If "hitend" is set afterwards, remember the
- first starting point for which a partial match was found. */
-
- md->start_match_ptr = start_match;
- md->start_used_ptr = start_match;
- md->match_call_count = 0;
- md->match_function_type = 0;
- md->end_offset_top = 0;
- md->skip_arg_count = 0;
- rc = match(start_match, md->start_code, start_match, 2, md, NULL, 0);
- if (md->hitend && start_partial == NULL)
- {
- start_partial = md->start_used_ptr;
- match_partial = start_match;
- }
-
- switch(rc)
- {
- /* If MATCH_SKIP_ARG reaches this level it means that a MARK that matched
- the SKIP's arg was not found. In this circumstance, Perl ignores the SKIP
- entirely. The only way we can do that is to re-do the match at the same
- point, with a flag to force SKIP with an argument to be ignored. Just
- treating this case as NOMATCH does not work because it does not check other
- alternatives in patterns such as A(*SKIP:A)B|AC when the subject is AC. */
-
- case MATCH_SKIP_ARG:
- new_start_match = start_match;
- md->ignore_skip_arg = md->skip_arg_count;
- break;
-
- /* SKIP passes back the next starting point explicitly, but if it is no
- greater than the match we have just done, treat it as NOMATCH. */
-
- case MATCH_SKIP:
- if (md->start_match_ptr > start_match)
- {
- new_start_match = md->start_match_ptr;
- break;
- }
- /* Fall through */
-
- /* NOMATCH and PRUNE advance by one character. THEN at this level acts
- exactly like PRUNE. Unset ignore SKIP-with-argument. */
-
- case MATCH_NOMATCH:
- case MATCH_PRUNE:
- case MATCH_THEN:
- md->ignore_skip_arg = 0;
- new_start_match = start_match + 1;
-#ifdef SUPPORT_UTF
- if (utf)
- ACROSSCHAR(new_start_match < end_subject, *new_start_match,
- new_start_match++);
-#endif
- break;
-
- /* COMMIT disables the bumpalong, but otherwise behaves as NOMATCH. */
-
- case MATCH_COMMIT:
- rc = MATCH_NOMATCH;
- goto ENDLOOP;
-
- /* Any other return is either a match, or some kind of error. */
-
- default:
- goto ENDLOOP;
- }
-
- /* Control reaches here for the various types of "no match at this point"
- result. Reset the code to MATCH_NOMATCH for subsequent checking. */
-
- rc = MATCH_NOMATCH;
-
- /* If PCRE_FIRSTLINE is set, the match must happen before or at the first
- newline in the subject (though it may continue over the newline). Therefore,
- if we have just failed to match, starting at a newline, do not continue. */
-
- if (firstline && IS_NEWLINE(start_match)) break;
-
- /* Advance to new matching position */
-
- start_match = new_start_match;
-
- /* Break the loop if the pattern is anchored or if we have passed the end of
- the subject. */
-
- if (anchored || start_match > end_subject) break;
-
- /* If we have just passed a CR and we are now at a LF, and the pattern does
- not contain any explicit matches for \r or \n, and the newline option is CRLF
- or ANY or ANYCRLF, advance the match position by one more character. In
- normal matching start_match will aways be greater than the first position at
- this stage, but a failed *SKIP can cause a return at the same point, which is
- why the first test exists. */
-
- if (start_match > (PCRE_PUCHAR)subject + start_offset &&
- start_match[-1] == CHAR_CR &&
- start_match < end_subject &&
- *start_match == CHAR_NL &&
- (re->flags & PCRE_HASCRORLF) == 0 &&
- (md->nltype == NLTYPE_ANY ||
- md->nltype == NLTYPE_ANYCRLF ||
- md->nllen == 2))
- start_match++;
-
- md->mark = NULL; /* Reset for start of next match attempt */
- } /* End of for(;;) "bumpalong" loop */
-
-/* ==========================================================================*/
-
-/* We reach here when rc is not MATCH_NOMATCH, or if one of the stopping
-conditions is true:
-
-(1) The pattern is anchored or the match was failed by (*COMMIT);
-
-(2) We are past the end of the subject;
-
-(3) PCRE_FIRSTLINE is set and we have failed to match at a newline, because
- this option requests that a match occur at or before the first newline in
- the subject.
-
-When we have a match and the offset vector is big enough to deal with any
-backreferences, captured substring offsets will already be set up. In the case
-where we had to get some local store to hold offsets for backreference
-processing, copy those that we can. In this case there need not be overflow if
-certain parts of the pattern were not used, even though there are more
-capturing parentheses than vector slots. */
-
-ENDLOOP:
-
-if (rc == MATCH_MATCH || rc == MATCH_ACCEPT)
- {
- if (using_temporary_offsets)
- {
- if (arg_offset_max >= 4)
- {
- memcpy(offsets + 2, md->offset_vector + 2,
- (arg_offset_max - 2) * sizeof(int));
- DPRINTF(("Copied offsets from temporary memory\n"));
- }
- if (md->end_offset_top > arg_offset_max) md->capture_last |= OVFLBIT;
- DPRINTF(("Freeing temporary memory\n"));
- (PUBL(free))(md->offset_vector);
- }
-
- /* Set the return code to the number of captured strings, or 0 if there were
- too many to fit into the vector. */
-
- rc = ((md->capture_last & OVFLBIT) != 0 &&
- md->end_offset_top >= arg_offset_max)?
- 0 : md->end_offset_top/2;
-
- /* If there is space in the offset vector, set any unused pairs at the end of
- the pattern to -1 for backwards compatibility. It is documented that this
- happens. In earlier versions, the whole set of potential capturing offsets
- was set to -1 each time round the loop, but this is handled differently now.
- "Gaps" are set to -1 dynamically instead (this fixes a bug). Thus, it is only
- those at the end that need unsetting here. We can't just unset them all at
- the start of the whole thing because they may get set in one branch that is
- not the final matching branch. */
-
- if (md->end_offset_top/2 <= re->top_bracket && offsets != NULL)
- {
- register int *iptr, *iend;
- int resetcount = 2 + re->top_bracket * 2;
- if (resetcount > offsetcount) resetcount = offsetcount;
- iptr = offsets + md->end_offset_top;
- iend = offsets + resetcount;
- while (iptr < iend) *iptr++ = -1;
- }
-
- /* If there is space, set up the whole thing as substring 0. The value of
- md->start_match_ptr might be modified if \K was encountered on the success
- matching path. */
-
- if (offsetcount < 2) rc = 0; else
- {
- offsets[0] = (int)(md->start_match_ptr - md->start_subject);
- offsets[1] = (int)(md->end_match_ptr - md->start_subject);
- }
-
- /* Return MARK data if requested */
-
- if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
- *(extra_data->mark) = (pcre_uchar *)md->mark;
- DPRINTF((">>>> returning %d\n", rc));
-#ifdef NO_RECURSE
- release_match_heapframes(&frame_zero);
-#endif
- return rc;
- }
-
-/* Control gets here if there has been an error, or if the overall match
-attempt has failed at all permitted starting positions. */
-
-if (using_temporary_offsets)
- {
- DPRINTF(("Freeing temporary memory\n"));
- (PUBL(free))(md->offset_vector);
- }
-
-/* For anything other than nomatch or partial match, just return the code. */
-
-if (rc != MATCH_NOMATCH && rc != PCRE_ERROR_PARTIAL)
- {
- DPRINTF((">>>> error: returning %d\n", rc));
-#ifdef NO_RECURSE
- release_match_heapframes(&frame_zero);
-#endif
- return rc;
- }
-
-/* Handle partial matches - disable any mark data */
-
-if (match_partial != NULL)
- {
- DPRINTF((">>>> returning PCRE_ERROR_PARTIAL\n"));
- md->mark = NULL;
- if (offsetcount > 1)
- {
- offsets[0] = (int)(start_partial - (PCRE_PUCHAR)subject);
- offsets[1] = (int)(end_subject - (PCRE_PUCHAR)subject);
- if (offsetcount > 2)
- offsets[2] = (int)(match_partial - (PCRE_PUCHAR)subject);
- }
- rc = PCRE_ERROR_PARTIAL;
- }
-
-/* This is the classic nomatch case */
-
-else
- {
- DPRINTF((">>>> returning PCRE_ERROR_NOMATCH\n"));
- rc = PCRE_ERROR_NOMATCH;
- }
-
-/* Return the MARK data if it has been requested. */
-
-if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_MARK) != 0)
- *(extra_data->mark) = (pcre_uchar *)md->nomatch_mark;
-#ifdef NO_RECURSE
- release_match_heapframes(&frame_zero);
-#endif
-return rc;
-}
-
-/* End of pcre_exec.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_fullinfo.c r-base-3.3.1/src/extra/pcre/pcre_fullinfo.c
--- r-base-3.2.3/src/extra/pcre/pcre_fullinfo.c 2013-12-30 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_fullinfo.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,245 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2013 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains the external function pcre_fullinfo(), which returns
-information about a compiled pattern. */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pcre_internal.h"
-
-
-/*************************************************
-* Return info about compiled pattern *
-*************************************************/
-
-/* This is a newer "info" function which has an extensible interface so
-that additional items can be added compatibly.
-
-Arguments:
- argument_re points to compiled code
- extra_data points extra data, or NULL
- what what information is required
- where where to put the information
-
-Returns: 0 if data returned, negative on error
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data,
- int what, void *where)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_fullinfo(const pcre16 *argument_re, const pcre16_extra *extra_data,
- int what, void *where)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_fullinfo(const pcre32 *argument_re, const pcre32_extra *extra_data,
- int what, void *where)
-#endif
-{
-const REAL_PCRE *re = (const REAL_PCRE *)argument_re;
-const pcre_study_data *study = NULL;
-
-if (re == NULL || where == NULL) return PCRE_ERROR_NULL;
-
-if (extra_data != NULL && (extra_data->flags & PCRE_EXTRA_STUDY_DATA) != 0)
- study = (const pcre_study_data *)extra_data->study_data;
-
-/* Check that the first field in the block is the magic number. If it is not,
-return with PCRE_ERROR_BADMAGIC. However, if the magic number is equal to
-REVERSED_MAGIC_NUMBER we return with PCRE_ERROR_BADENDIANNESS, which
-means that the pattern is likely compiled with different endianness. */
-
-if (re->magic_number != MAGIC_NUMBER)
- return re->magic_number == REVERSED_MAGIC_NUMBER?
- PCRE_ERROR_BADENDIANNESS:PCRE_ERROR_BADMAGIC;
-
-/* Check that this pattern was compiled in the correct bit mode */
-
-if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
-
-switch (what)
- {
- case PCRE_INFO_OPTIONS:
- *((unsigned long int *)where) = re->options & PUBLIC_COMPILE_OPTIONS;
- break;
-
- case PCRE_INFO_SIZE:
- *((size_t *)where) = re->size;
- break;
-
- case PCRE_INFO_STUDYSIZE:
- *((size_t *)where) = (study == NULL)? 0 : study->size;
- break;
-
- case PCRE_INFO_JITSIZE:
-#ifdef SUPPORT_JIT
- *((size_t *)where) =
- (extra_data != NULL &&
- (extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&
- extra_data->executable_jit != NULL)?
- PRIV(jit_get_size)(extra_data->executable_jit) : 0;
-#else
- *((size_t *)where) = 0;
-#endif
- break;
-
- case PCRE_INFO_CAPTURECOUNT:
- *((int *)where) = re->top_bracket;
- break;
-
- case PCRE_INFO_BACKREFMAX:
- *((int *)where) = re->top_backref;
- break;
-
- case PCRE_INFO_FIRSTBYTE:
- *((int *)where) =
- ((re->flags & PCRE_FIRSTSET) != 0)? (int)re->first_char :
- ((re->flags & PCRE_STARTLINE) != 0)? -1 : -2;
- break;
-
- case PCRE_INFO_FIRSTCHARACTER:
- *((pcre_uint32 *)where) =
- (re->flags & PCRE_FIRSTSET) != 0 ? re->first_char : 0;
- break;
-
- case PCRE_INFO_FIRSTCHARACTERFLAGS:
- *((int *)where) =
- ((re->flags & PCRE_FIRSTSET) != 0) ? 1 :
- ((re->flags & PCRE_STARTLINE) != 0) ? 2 : 0;
- break;
-
- /* Make sure we pass back the pointer to the bit vector in the external
- block, not the internal copy (with flipped integer fields). */
-
- case PCRE_INFO_FIRSTTABLE:
- *((const pcre_uint8 **)where) =
- (study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)?
- ((const pcre_study_data *)extra_data->study_data)->start_bits : NULL;
- break;
-
- case PCRE_INFO_MINLENGTH:
- *((int *)where) =
- (study != NULL && (study->flags & PCRE_STUDY_MINLEN) != 0)?
- (int)(study->minlength) : -1;
- break;
-
- case PCRE_INFO_JIT:
- *((int *)where) = extra_data != NULL &&
- (extra_data->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&
- extra_data->executable_jit != NULL;
- break;
-
- case PCRE_INFO_LASTLITERAL:
- *((int *)where) =
- ((re->flags & PCRE_REQCHSET) != 0)? (int)re->req_char : -1;
- break;
-
- case PCRE_INFO_REQUIREDCHAR:
- *((pcre_uint32 *)where) =
- ((re->flags & PCRE_REQCHSET) != 0) ? re->req_char : 0;
- break;
-
- case PCRE_INFO_REQUIREDCHARFLAGS:
- *((int *)where) =
- ((re->flags & PCRE_REQCHSET) != 0);
- break;
-
- case PCRE_INFO_NAMEENTRYSIZE:
- *((int *)where) = re->name_entry_size;
- break;
-
- case PCRE_INFO_NAMECOUNT:
- *((int *)where) = re->name_count;
- break;
-
- case PCRE_INFO_NAMETABLE:
- *((const pcre_uchar **)where) = (const pcre_uchar *)re + re->name_table_offset;
- break;
-
- case PCRE_INFO_DEFAULT_TABLES:
- *((const pcre_uint8 **)where) = (const pcre_uint8 *)(PRIV(default_tables));
- break;
-
- /* From release 8.00 this will always return TRUE because NOPARTIAL is
- no longer ever set (the restrictions have been removed). */
-
- case PCRE_INFO_OKPARTIAL:
- *((int *)where) = (re->flags & PCRE_NOPARTIAL) == 0;
- break;
-
- case PCRE_INFO_JCHANGED:
- *((int *)where) = (re->flags & PCRE_JCHANGED) != 0;
- break;
-
- case PCRE_INFO_HASCRORLF:
- *((int *)where) = (re->flags & PCRE_HASCRORLF) != 0;
- break;
-
- case PCRE_INFO_MAXLOOKBEHIND:
- *((int *)where) = re->max_lookbehind;
- break;
-
- case PCRE_INFO_MATCHLIMIT:
- if ((re->flags & PCRE_MLSET) == 0) return PCRE_ERROR_UNSET;
- *((pcre_uint32 *)where) = re->limit_match;
- break;
-
- case PCRE_INFO_RECURSIONLIMIT:
- if ((re->flags & PCRE_RLSET) == 0) return PCRE_ERROR_UNSET;
- *((pcre_uint32 *)where) = re->limit_recursion;
- break;
-
- case PCRE_INFO_MATCH_EMPTY:
- *((int *)where) = (re->flags & PCRE_MATCH_EMPTY) != 0;
- break;
-
- default: return PCRE_ERROR_BADOPTION;
- }
-
-return 0;
-}
-
-/* End of pcre_fullinfo.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_get.c r-base-3.3.1/src/extra/pcre/pcre_get.c
--- r-base-3.2.3/src/extra/pcre/pcre_get.c 2013-02-04 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_get.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,662 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2012 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains some convenience functions for extracting substrings
-from the subject string after a regex match has succeeded. The original idea
-for these functions came from Scott Wimer. */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pcre_internal.h"
-
-
-/*************************************************
-* Find number for named string *
-*************************************************/
-
-/* This function is used by the get_first_set() function below, as well
-as being generally available. It assumes that names are unique.
-
-Arguments:
- code the compiled regex
- stringname the name whose number is required
-
-Returns: the number of the named parentheses, or a negative number
- (PCRE_ERROR_NOSUBSTRING) if not found
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_get_stringnumber(const pcre *code, const char *stringname)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_get_stringnumber(const pcre16 *code, PCRE_SPTR16 stringname)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_get_stringnumber(const pcre32 *code, PCRE_SPTR32 stringname)
-#endif
-{
-int rc;
-int entrysize;
-int top, bot;
-pcre_uchar *nametable;
-
-#ifdef COMPILE_PCRE8
-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
- return rc;
-if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
-
-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
- return rc;
-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
- return rc;
-#endif
-#ifdef COMPILE_PCRE16
-if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
- return rc;
-if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
-
-if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
- return rc;
-if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
- return rc;
-#endif
-#ifdef COMPILE_PCRE32
-if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
- return rc;
-if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
-
-if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
- return rc;
-if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
- return rc;
-#endif
-
-bot = 0;
-while (top > bot)
- {
- int mid = (top + bot) / 2;
- pcre_uchar *entry = nametable + entrysize*mid;
- int c = STRCMP_UC_UC((pcre_uchar *)stringname,
- (pcre_uchar *)(entry + IMM2_SIZE));
- if (c == 0) return GET2(entry, 0);
- if (c > 0) bot = mid + 1; else top = mid;
- }
-
-return PCRE_ERROR_NOSUBSTRING;
-}
-
-
-
-/*************************************************
-* Find (multiple) entries for named string *
-*************************************************/
-
-/* This is used by the get_first_set() function below, as well as being
-generally available. It is used when duplicated names are permitted.
-
-Arguments:
- code the compiled regex
- stringname the name whose entries required
- firstptr where to put the pointer to the first entry
- lastptr where to put the pointer to the last entry
-
-Returns: the length of each entry, or a negative number
- (PCRE_ERROR_NOSUBSTRING) if not found
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_get_stringtable_entries(const pcre *code, const char *stringname,
- char **firstptr, char **lastptr)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_get_stringtable_entries(const pcre16 *code, PCRE_SPTR16 stringname,
- PCRE_UCHAR16 **firstptr, PCRE_UCHAR16 **lastptr)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_get_stringtable_entries(const pcre32 *code, PCRE_SPTR32 stringname,
- PCRE_UCHAR32 **firstptr, PCRE_UCHAR32 **lastptr)
-#endif
-{
-int rc;
-int entrysize;
-int top, bot;
-pcre_uchar *nametable, *lastentry;
-
-#ifdef COMPILE_PCRE8
-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
- return rc;
-if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
-
-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
- return rc;
-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
- return rc;
-#endif
-#ifdef COMPILE_PCRE16
-if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
- return rc;
-if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
-
-if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
- return rc;
-if ((rc = pcre16_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
- return rc;
-#endif
-#ifdef COMPILE_PCRE32
-if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
- return rc;
-if (top <= 0) return PCRE_ERROR_NOSUBSTRING;
-
-if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)
- return rc;
-if ((rc = pcre32_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
- return rc;
-#endif
-
-lastentry = nametable + entrysize * (top - 1);
-bot = 0;
-while (top > bot)
- {
- int mid = (top + bot) / 2;
- pcre_uchar *entry = nametable + entrysize*mid;
- int c = STRCMP_UC_UC((pcre_uchar *)stringname,
- (pcre_uchar *)(entry + IMM2_SIZE));
- if (c == 0)
- {
- pcre_uchar *first = entry;
- pcre_uchar *last = entry;
- while (first > nametable)
- {
- if (STRCMP_UC_UC((pcre_uchar *)stringname,
- (pcre_uchar *)(first - entrysize + IMM2_SIZE)) != 0) break;
- first -= entrysize;
- }
- while (last < lastentry)
- {
- if (STRCMP_UC_UC((pcre_uchar *)stringname,
- (pcre_uchar *)(last + entrysize + IMM2_SIZE)) != 0) break;
- last += entrysize;
- }
-#if defined COMPILE_PCRE8
- *firstptr = (char *)first;
- *lastptr = (char *)last;
-#elif defined COMPILE_PCRE16
- *firstptr = (PCRE_UCHAR16 *)first;
- *lastptr = (PCRE_UCHAR16 *)last;
-#elif defined COMPILE_PCRE32
- *firstptr = (PCRE_UCHAR32 *)first;
- *lastptr = (PCRE_UCHAR32 *)last;
-#endif
- return entrysize;
- }
- if (c > 0) bot = mid + 1; else top = mid;
- }
-
-return PCRE_ERROR_NOSUBSTRING;
-}
-
-
-
-/*************************************************
-* Find first set of multiple named strings *
-*************************************************/
-
-/* This function allows for duplicate names in the table of named substrings.
-It returns the number of the first one that was set in a pattern match.
-
-Arguments:
- code the compiled regex
- stringname the name of the capturing substring
- ovector the vector of matched substrings
-
-Returns: the number of the first that is set,
- or the number of the last one if none are set,
- or a negative number on error
-*/
-
-#if defined COMPILE_PCRE8
-static int
-get_first_set(const pcre *code, const char *stringname, int *ovector)
-#elif defined COMPILE_PCRE16
-static int
-get_first_set(const pcre16 *code, PCRE_SPTR16 stringname, int *ovector)
-#elif defined COMPILE_PCRE32
-static int
-get_first_set(const pcre32 *code, PCRE_SPTR32 stringname, int *ovector)
-#endif
-{
-const REAL_PCRE *re = (const REAL_PCRE *)code;
-int entrysize;
-pcre_uchar *entry;
-#if defined COMPILE_PCRE8
-char *first, *last;
-#elif defined COMPILE_PCRE16
-PCRE_UCHAR16 *first, *last;
-#elif defined COMPILE_PCRE32
-PCRE_UCHAR32 *first, *last;
-#endif
-
-#if defined COMPILE_PCRE8
-if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)
- return pcre_get_stringnumber(code, stringname);
-entrysize = pcre_get_stringtable_entries(code, stringname, &first, &last);
-#elif defined COMPILE_PCRE16
-if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)
- return pcre16_get_stringnumber(code, stringname);
-entrysize = pcre16_get_stringtable_entries(code, stringname, &first, &last);
-#elif defined COMPILE_PCRE32
-if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) == 0)
- return pcre32_get_stringnumber(code, stringname);
-entrysize = pcre32_get_stringtable_entries(code, stringname, &first, &last);
-#endif
-if (entrysize <= 0) return entrysize;
-for (entry = (pcre_uchar *)first; entry <= (pcre_uchar *)last; entry += entrysize)
- {
- int n = GET2(entry, 0);
- if (ovector[n*2] >= 0) return n;
- }
-return GET2(entry, 0);
-}
-
-
-
-
-/*************************************************
-* Copy captured string to given buffer *
-*************************************************/
-
-/* This function copies a single captured substring into a given buffer.
-Note that we use memcpy() rather than strncpy() in case there are binary zeros
-in the string.
-
-Arguments:
- subject the subject string that was matched
- ovector pointer to the offsets table
- stringcount the number of substrings that were captured
- (i.e. the yield of the pcre_exec call, unless
- that was zero, in which case it should be 1/3
- of the offset table size)
- stringnumber the number of the required substring
- buffer where to put the substring
- size the size of the buffer
-
-Returns: if successful:
- the length of the copied string, not including the zero
- that is put on the end; can be zero
- if not successful:
- PCRE_ERROR_NOMEMORY (-6) buffer too small
- PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_copy_substring(const char *subject, int *ovector, int stringcount,
- int stringnumber, char *buffer, int size)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_copy_substring(PCRE_SPTR16 subject, int *ovector, int stringcount,
- int stringnumber, PCRE_UCHAR16 *buffer, int size)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_copy_substring(PCRE_SPTR32 subject, int *ovector, int stringcount,
- int stringnumber, PCRE_UCHAR32 *buffer, int size)
-#endif
-{
-int yield;
-if (stringnumber < 0 || stringnumber >= stringcount)
- return PCRE_ERROR_NOSUBSTRING;
-stringnumber *= 2;
-yield = ovector[stringnumber+1] - ovector[stringnumber];
-if (size < yield + 1) return PCRE_ERROR_NOMEMORY;
-memcpy(buffer, subject + ovector[stringnumber], IN_UCHARS(yield));
-buffer[yield] = 0;
-return yield;
-}
-
-
-
-/*************************************************
-* Copy named captured string to given buffer *
-*************************************************/
-
-/* This function copies a single captured substring into a given buffer,
-identifying it by name. If the regex permits duplicate names, the first
-substring that is set is chosen.
-
-Arguments:
- code the compiled regex
- subject the subject string that was matched
- ovector pointer to the offsets table
- stringcount the number of substrings that were captured
- (i.e. the yield of the pcre_exec call, unless
- that was zero, in which case it should be 1/3
- of the offset table size)
- stringname the name of the required substring
- buffer where to put the substring
- size the size of the buffer
-
-Returns: if successful:
- the length of the copied string, not including the zero
- that is put on the end; can be zero
- if not successful:
- PCRE_ERROR_NOMEMORY (-6) buffer too small
- PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_copy_named_substring(const pcre *code, const char *subject,
- int *ovector, int stringcount, const char *stringname,
- char *buffer, int size)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_copy_named_substring(const pcre16 *code, PCRE_SPTR16 subject,
- int *ovector, int stringcount, PCRE_SPTR16 stringname,
- PCRE_UCHAR16 *buffer, int size)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_copy_named_substring(const pcre32 *code, PCRE_SPTR32 subject,
- int *ovector, int stringcount, PCRE_SPTR32 stringname,
- PCRE_UCHAR32 *buffer, int size)
-#endif
-{
-int n = get_first_set(code, stringname, ovector);
-if (n <= 0) return n;
-#if defined COMPILE_PCRE8
-return pcre_copy_substring(subject, ovector, stringcount, n, buffer, size);
-#elif defined COMPILE_PCRE16
-return pcre16_copy_substring(subject, ovector, stringcount, n, buffer, size);
-#elif defined COMPILE_PCRE32
-return pcre32_copy_substring(subject, ovector, stringcount, n, buffer, size);
-#endif
-}
-
-
-
-/*************************************************
-* Copy all captured strings to new store *
-*************************************************/
-
-/* This function gets one chunk of store and builds a list of pointers and all
-of the captured substrings in it. A NULL pointer is put on the end of the list.
-
-Arguments:
- subject the subject string that was matched
- ovector pointer to the offsets table
- stringcount the number of substrings that were captured
- (i.e. the yield of the pcre_exec call, unless
- that was zero, in which case it should be 1/3
- of the offset table size)
- listptr set to point to the list of pointers
-
-Returns: if successful: 0
- if not successful:
- PCRE_ERROR_NOMEMORY (-6) failed to get store
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_get_substring_list(const char *subject, int *ovector, int stringcount,
- const char ***listptr)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_get_substring_list(PCRE_SPTR16 subject, int *ovector, int stringcount,
- PCRE_SPTR16 **listptr)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_get_substring_list(PCRE_SPTR32 subject, int *ovector, int stringcount,
- PCRE_SPTR32 **listptr)
-#endif
-{
-int i;
-int size = sizeof(pcre_uchar *);
-int double_count = stringcount * 2;
-pcre_uchar **stringlist;
-pcre_uchar *p;
-
-for (i = 0; i < double_count; i += 2)
- size += sizeof(pcre_uchar *) + IN_UCHARS(ovector[i+1] - ovector[i] + 1);
-
-stringlist = (pcre_uchar **)(PUBL(malloc))(size);
-if (stringlist == NULL) return PCRE_ERROR_NOMEMORY;
-
-#if defined COMPILE_PCRE8
-*listptr = (const char **)stringlist;
-#elif defined COMPILE_PCRE16
-*listptr = (PCRE_SPTR16 *)stringlist;
-#elif defined COMPILE_PCRE32
-*listptr = (PCRE_SPTR32 *)stringlist;
-#endif
-p = (pcre_uchar *)(stringlist + stringcount + 1);
-
-for (i = 0; i < double_count; i += 2)
- {
- int len = ovector[i+1] - ovector[i];
- memcpy(p, subject + ovector[i], IN_UCHARS(len));
- *stringlist++ = p;
- p += len;
- *p++ = 0;
- }
-
-*stringlist = NULL;
-return 0;
-}
-
-
-
-/*************************************************
-* Free store obtained by get_substring_list *
-*************************************************/
-
-/* This function exists for the benefit of people calling PCRE from non-C
-programs that can call its functions, but not free() or (PUBL(free))()
-directly.
-
-Argument: the result of a previous pcre_get_substring_list()
-Returns: nothing
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
-pcre_free_substring_list(const char **pointer)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
-pcre16_free_substring_list(PCRE_SPTR16 *pointer)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
-pcre32_free_substring_list(PCRE_SPTR32 *pointer)
-#endif
-{
-(PUBL(free))((void *)pointer);
-}
-
-
-
-/*************************************************
-* Copy captured string to new store *
-*************************************************/
-
-/* This function copies a single captured substring into a piece of new
-store
-
-Arguments:
- subject the subject string that was matched
- ovector pointer to the offsets table
- stringcount the number of substrings that were captured
- (i.e. the yield of the pcre_exec call, unless
- that was zero, in which case it should be 1/3
- of the offset table size)
- stringnumber the number of the required substring
- stringptr where to put a pointer to the substring
-
-Returns: if successful:
- the length of the string, not including the zero that
- is put on the end; can be zero
- if not successful:
- PCRE_ERROR_NOMEMORY (-6) failed to get store
- PCRE_ERROR_NOSUBSTRING (-7) substring not present
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_get_substring(const char *subject, int *ovector, int stringcount,
- int stringnumber, const char **stringptr)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_get_substring(PCRE_SPTR16 subject, int *ovector, int stringcount,
- int stringnumber, PCRE_SPTR16 *stringptr)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_get_substring(PCRE_SPTR32 subject, int *ovector, int stringcount,
- int stringnumber, PCRE_SPTR32 *stringptr)
-#endif
-{
-int yield;
-pcre_uchar *substring;
-if (stringnumber < 0 || stringnumber >= stringcount)
- return PCRE_ERROR_NOSUBSTRING;
-stringnumber *= 2;
-yield = ovector[stringnumber+1] - ovector[stringnumber];
-substring = (pcre_uchar *)(PUBL(malloc))(IN_UCHARS(yield + 1));
-if (substring == NULL) return PCRE_ERROR_NOMEMORY;
-memcpy(substring, subject + ovector[stringnumber], IN_UCHARS(yield));
-substring[yield] = 0;
-#if defined COMPILE_PCRE8
-*stringptr = (const char *)substring;
-#elif defined COMPILE_PCRE16
-*stringptr = (PCRE_SPTR16)substring;
-#elif defined COMPILE_PCRE32
-*stringptr = (PCRE_SPTR32)substring;
-#endif
-return yield;
-}
-
-
-
-/*************************************************
-* Copy named captured string to new store *
-*************************************************/
-
-/* This function copies a single captured substring, identified by name, into
-new store. If the regex permits duplicate names, the first substring that is
-set is chosen.
-
-Arguments:
- code the compiled regex
- subject the subject string that was matched
- ovector pointer to the offsets table
- stringcount the number of substrings that were captured
- (i.e. the yield of the pcre_exec call, unless
- that was zero, in which case it should be 1/3
- of the offset table size)
- stringname the name of the required substring
- stringptr where to put the pointer
-
-Returns: if successful:
- the length of the copied string, not including the zero
- that is put on the end; can be zero
- if not successful:
- PCRE_ERROR_NOMEMORY (-6) couldn't get memory
- PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_get_named_substring(const pcre *code, const char *subject,
- int *ovector, int stringcount, const char *stringname,
- const char **stringptr)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_get_named_substring(const pcre16 *code, PCRE_SPTR16 subject,
- int *ovector, int stringcount, PCRE_SPTR16 stringname,
- PCRE_SPTR16 *stringptr)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_get_named_substring(const pcre32 *code, PCRE_SPTR32 subject,
- int *ovector, int stringcount, PCRE_SPTR32 stringname,
- PCRE_SPTR32 *stringptr)
-#endif
-{
-int n = get_first_set(code, stringname, ovector);
-if (n <= 0) return n;
-#if defined COMPILE_PCRE8
-return pcre_get_substring(subject, ovector, stringcount, n, stringptr);
-#elif defined COMPILE_PCRE16
-return pcre16_get_substring(subject, ovector, stringcount, n, stringptr);
-#elif defined COMPILE_PCRE32
-return pcre32_get_substring(subject, ovector, stringcount, n, stringptr);
-#endif
-}
-
-
-
-
-/*************************************************
-* Free store obtained by get_substring *
-*************************************************/
-
-/* This function exists for the benefit of people calling PCRE from non-C
-programs that can call its functions, but not free() or (PUBL(free))()
-directly.
-
-Argument: the result of a previous pcre_get_substring()
-Returns: nothing
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
-pcre_free_substring(const char *pointer)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
-pcre16_free_substring(PCRE_SPTR16 pointer)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN void PCRE_CALL_CONVENTION
-pcre32_free_substring(PCRE_SPTR32 pointer)
-#endif
-{
-(PUBL(free))((void *)pointer);
-}
-
-/* End of pcre_get.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_globals.c r-base-3.3.1/src/extra/pcre/pcre_globals.c
--- r-base-3.2.3/src/extra/pcre/pcre_globals.c 2014-04-20 22:15:04.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_globals.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,86 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2014 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains global variables that are exported by the PCRE library.
-PCRE is thread-clean and doesn't use any global variables in the normal sense.
-However, it calls memory allocation and freeing functions via the four
-indirections below, and it can optionally do callouts, using the fifth
-indirection. These values can be changed by the caller, but are shared between
-all threads.
-
-For MS Visual Studio and Symbian OS, there are problems in initializing these
-variables to non-local functions. In these cases, therefore, an indirection via
-a local function is used.
-
-Also, when compiling for Virtual Pascal, things are done differently, and
-global variables are not used. */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pcre_internal.h"
-
-#if defined _MSC_VER || defined __SYMBIAN32__
-static void* LocalPcreMalloc(size_t aSize)
- {
- return malloc(aSize);
- }
-static void LocalPcreFree(void* aPtr)
- {
- free(aPtr);
- }
-PCRE_EXP_DATA_DEFN void *(*PUBL(malloc))(size_t) = LocalPcreMalloc;
-PCRE_EXP_DATA_DEFN void (*PUBL(free))(void *) = LocalPcreFree;
-PCRE_EXP_DATA_DEFN void *(*PUBL(stack_malloc))(size_t) = LocalPcreMalloc;
-PCRE_EXP_DATA_DEFN void (*PUBL(stack_free))(void *) = LocalPcreFree;
-PCRE_EXP_DATA_DEFN int (*PUBL(callout))(PUBL(callout_block) *) = NULL;
-PCRE_EXP_DATA_DEFN int (*PUBL(stack_guard))(void) = NULL;
-
-#elif !defined VPCOMPAT
-PCRE_EXP_DATA_DEFN void *(*PUBL(malloc))(size_t) = malloc;
-PCRE_EXP_DATA_DEFN void (*PUBL(free))(void *) = free;
-PCRE_EXP_DATA_DEFN void *(*PUBL(stack_malloc))(size_t) = malloc;
-PCRE_EXP_DATA_DEFN void (*PUBL(stack_free))(void *) = free;
-PCRE_EXP_DATA_DEFN int (*PUBL(callout))(PUBL(callout_block) *) = NULL;
-PCRE_EXP_DATA_DEFN int (*PUBL(stack_guard))(void) = NULL;
-#endif
-
-/* End of pcre_globals.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre.h r-base-3.3.1/src/extra/pcre/pcre.h
--- r-base-3.2.3/src/extra/pcre/pcre.h 2015-11-26 23:15:10.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,677 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* This is the public header file for the PCRE library, to be #included by
-applications that call the PCRE functions.
-
- Copyright (c) 1997-2014 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-#ifndef _PCRE_H
-#define _PCRE_H
-
-/* The current PCRE version information. */
-
-#define PCRE_MAJOR 8
-#define PCRE_MINOR 38
-#define PCRE_PRERELEASE
-#define PCRE_DATE 2015-11-23
-
-/* When an application links to a PCRE DLL in Windows, the symbols that are
-imported have to be identified as such. When building PCRE, the appropriate
-export setting is defined in pcre_internal.h, which includes this file. So we
-don't change existing definitions of PCRE_EXP_DECL and PCRECPP_EXP_DECL. */
-
-#if defined(_WIN32) && !defined(PCRE_STATIC)
-# ifndef PCRE_EXP_DECL
-# define PCRE_EXP_DECL extern __declspec(dllimport)
-# endif
-# ifdef __cplusplus
-# ifndef PCRECPP_EXP_DECL
-# define PCRECPP_EXP_DECL extern __declspec(dllimport)
-# endif
-# ifndef PCRECPP_EXP_DEFN
-# define PCRECPP_EXP_DEFN __declspec(dllimport)
-# endif
-# endif
-#endif
-
-/* By default, we use the standard "extern" declarations. */
-
-#ifndef PCRE_EXP_DECL
-# ifdef __cplusplus
-# define PCRE_EXP_DECL extern "C"
-# else
-# define PCRE_EXP_DECL extern
-# endif
-#endif
-
-#ifdef __cplusplus
-# ifndef PCRECPP_EXP_DECL
-# define PCRECPP_EXP_DECL extern
-# endif
-# ifndef PCRECPP_EXP_DEFN
-# define PCRECPP_EXP_DEFN
-# endif
-#endif
-
-/* Have to include stdlib.h in order to ensure that size_t is defined;
-it is needed here for malloc. */
-
-#include
-
-/* Allow for C++ users */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Public options. Some are compile-time only, some are run-time only, and some
-are both. Most of the compile-time options are saved with the compiled regex so
-that they can be inspected during studying (and therefore JIT compiling). Note
-that pcre_study() has its own set of options. Originally, all the options
-defined here used distinct bits. However, almost all the bits in a 32-bit word
-are now used, so in order to conserve them, option bits that were previously
-only recognized at matching time (i.e. by pcre_exec() or pcre_dfa_exec()) may
-also be used for compile-time options that affect only compiling and are not
-relevant for studying or JIT compiling.
-
-Some options for pcre_compile() change its behaviour but do not affect the
-behaviour of the execution functions. Other options are passed through to the
-execution functions and affect their behaviour, with or without affecting the
-behaviour of pcre_compile().
-
-Options that can be passed to pcre_compile() are tagged Cx below, with these
-variants:
-
-C1 Affects compile only
-C2 Does not affect compile; affects exec, dfa_exec
-C3 Affects compile, exec, dfa_exec
-C4 Affects compile, exec, dfa_exec, study
-C5 Affects compile, exec, study
-
-Options that can be set for pcre_exec() and/or pcre_dfa_exec() are flagged with
-E and D, respectively. They take precedence over C3, C4, and C5 settings passed
-from pcre_compile(). Those that are compatible with JIT execution are flagged
-with J. */
-
-#define PCRE_CASELESS 0x00000001 /* C1 */
-#define PCRE_MULTILINE 0x00000002 /* C1 */
-#define PCRE_DOTALL 0x00000004 /* C1 */
-#define PCRE_EXTENDED 0x00000008 /* C1 */
-#define PCRE_ANCHORED 0x00000010 /* C4 E D */
-#define PCRE_DOLLAR_ENDONLY 0x00000020 /* C2 */
-#define PCRE_EXTRA 0x00000040 /* C1 */
-#define PCRE_NOTBOL 0x00000080 /* E D J */
-#define PCRE_NOTEOL 0x00000100 /* E D J */
-#define PCRE_UNGREEDY 0x00000200 /* C1 */
-#define PCRE_NOTEMPTY 0x00000400 /* E D J */
-#define PCRE_UTF8 0x00000800 /* C4 ) */
-#define PCRE_UTF16 0x00000800 /* C4 ) Synonyms */
-#define PCRE_UTF32 0x00000800 /* C4 ) */
-#define PCRE_NO_AUTO_CAPTURE 0x00001000 /* C1 */
-#define PCRE_NO_UTF8_CHECK 0x00002000 /* C1 E D J ) */
-#define PCRE_NO_UTF16_CHECK 0x00002000 /* C1 E D J ) Synonyms */
-#define PCRE_NO_UTF32_CHECK 0x00002000 /* C1 E D J ) */
-#define PCRE_AUTO_CALLOUT 0x00004000 /* C1 */
-#define PCRE_PARTIAL_SOFT 0x00008000 /* E D J ) Synonyms */
-#define PCRE_PARTIAL 0x00008000 /* E D J ) */
-
-/* This pair use the same bit. */
-#define PCRE_NEVER_UTF 0x00010000 /* C1 ) Overlaid */
-#define PCRE_DFA_SHORTEST 0x00010000 /* D ) Overlaid */
-
-/* This pair use the same bit. */
-#define PCRE_NO_AUTO_POSSESS 0x00020000 /* C1 ) Overlaid */
-#define PCRE_DFA_RESTART 0x00020000 /* D ) Overlaid */
-
-#define PCRE_FIRSTLINE 0x00040000 /* C3 */
-#define PCRE_DUPNAMES 0x00080000 /* C1 */
-#define PCRE_NEWLINE_CR 0x00100000 /* C3 E D */
-#define PCRE_NEWLINE_LF 0x00200000 /* C3 E D */
-#define PCRE_NEWLINE_CRLF 0x00300000 /* C3 E D */
-#define PCRE_NEWLINE_ANY 0x00400000 /* C3 E D */
-#define PCRE_NEWLINE_ANYCRLF 0x00500000 /* C3 E D */
-#define PCRE_BSR_ANYCRLF 0x00800000 /* C3 E D */
-#define PCRE_BSR_UNICODE 0x01000000 /* C3 E D */
-#define PCRE_JAVASCRIPT_COMPAT 0x02000000 /* C5 */
-#define PCRE_NO_START_OPTIMIZE 0x04000000 /* C2 E D ) Synonyms */
-#define PCRE_NO_START_OPTIMISE 0x04000000 /* C2 E D ) */
-#define PCRE_PARTIAL_HARD 0x08000000 /* E D J */
-#define PCRE_NOTEMPTY_ATSTART 0x10000000 /* E D J */
-#define PCRE_UCP 0x20000000 /* C3 */
-
-/* Exec-time and get/set-time error codes */
-
-#define PCRE_ERROR_NOMATCH (-1)
-#define PCRE_ERROR_NULL (-2)
-#define PCRE_ERROR_BADOPTION (-3)
-#define PCRE_ERROR_BADMAGIC (-4)
-#define PCRE_ERROR_UNKNOWN_OPCODE (-5)
-#define PCRE_ERROR_UNKNOWN_NODE (-5) /* For backward compatibility */
-#define PCRE_ERROR_NOMEMORY (-6)
-#define PCRE_ERROR_NOSUBSTRING (-7)
-#define PCRE_ERROR_MATCHLIMIT (-8)
-#define PCRE_ERROR_CALLOUT (-9) /* Never used by PCRE itself */
-#define PCRE_ERROR_BADUTF8 (-10) /* Same for 8/16/32 */
-#define PCRE_ERROR_BADUTF16 (-10) /* Same for 8/16/32 */
-#define PCRE_ERROR_BADUTF32 (-10) /* Same for 8/16/32 */
-#define PCRE_ERROR_BADUTF8_OFFSET (-11) /* Same for 8/16 */
-#define PCRE_ERROR_BADUTF16_OFFSET (-11) /* Same for 8/16 */
-#define PCRE_ERROR_PARTIAL (-12)
-#define PCRE_ERROR_BADPARTIAL (-13)
-#define PCRE_ERROR_INTERNAL (-14)
-#define PCRE_ERROR_BADCOUNT (-15)
-#define PCRE_ERROR_DFA_UITEM (-16)
-#define PCRE_ERROR_DFA_UCOND (-17)
-#define PCRE_ERROR_DFA_UMLIMIT (-18)
-#define PCRE_ERROR_DFA_WSSIZE (-19)
-#define PCRE_ERROR_DFA_RECURSE (-20)
-#define PCRE_ERROR_RECURSIONLIMIT (-21)
-#define PCRE_ERROR_NULLWSLIMIT (-22) /* No longer actually used */
-#define PCRE_ERROR_BADNEWLINE (-23)
-#define PCRE_ERROR_BADOFFSET (-24)
-#define PCRE_ERROR_SHORTUTF8 (-25)
-#define PCRE_ERROR_SHORTUTF16 (-25) /* Same for 8/16 */
-#define PCRE_ERROR_RECURSELOOP (-26)
-#define PCRE_ERROR_JIT_STACKLIMIT (-27)
-#define PCRE_ERROR_BADMODE (-28)
-#define PCRE_ERROR_BADENDIANNESS (-29)
-#define PCRE_ERROR_DFA_BADRESTART (-30)
-#define PCRE_ERROR_JIT_BADOPTION (-31)
-#define PCRE_ERROR_BADLENGTH (-32)
-#define PCRE_ERROR_UNSET (-33)
-
-/* Specific error codes for UTF-8 validity checks */
-
-#define PCRE_UTF8_ERR0 0
-#define PCRE_UTF8_ERR1 1
-#define PCRE_UTF8_ERR2 2
-#define PCRE_UTF8_ERR3 3
-#define PCRE_UTF8_ERR4 4
-#define PCRE_UTF8_ERR5 5
-#define PCRE_UTF8_ERR6 6
-#define PCRE_UTF8_ERR7 7
-#define PCRE_UTF8_ERR8 8
-#define PCRE_UTF8_ERR9 9
-#define PCRE_UTF8_ERR10 10
-#define PCRE_UTF8_ERR11 11
-#define PCRE_UTF8_ERR12 12
-#define PCRE_UTF8_ERR13 13
-#define PCRE_UTF8_ERR14 14
-#define PCRE_UTF8_ERR15 15
-#define PCRE_UTF8_ERR16 16
-#define PCRE_UTF8_ERR17 17
-#define PCRE_UTF8_ERR18 18
-#define PCRE_UTF8_ERR19 19
-#define PCRE_UTF8_ERR20 20
-#define PCRE_UTF8_ERR21 21
-#define PCRE_UTF8_ERR22 22 /* Unused (was non-character) */
-
-/* Specific error codes for UTF-16 validity checks */
-
-#define PCRE_UTF16_ERR0 0
-#define PCRE_UTF16_ERR1 1
-#define PCRE_UTF16_ERR2 2
-#define PCRE_UTF16_ERR3 3
-#define PCRE_UTF16_ERR4 4 /* Unused (was non-character) */
-
-/* Specific error codes for UTF-32 validity checks */
-
-#define PCRE_UTF32_ERR0 0
-#define PCRE_UTF32_ERR1 1
-#define PCRE_UTF32_ERR2 2 /* Unused (was non-character) */
-#define PCRE_UTF32_ERR3 3
-
-/* Request types for pcre_fullinfo() */
-
-#define PCRE_INFO_OPTIONS 0
-#define PCRE_INFO_SIZE 1
-#define PCRE_INFO_CAPTURECOUNT 2
-#define PCRE_INFO_BACKREFMAX 3
-#define PCRE_INFO_FIRSTBYTE 4
-#define PCRE_INFO_FIRSTCHAR 4 /* For backwards compatibility */
-#define PCRE_INFO_FIRSTTABLE 5
-#define PCRE_INFO_LASTLITERAL 6
-#define PCRE_INFO_NAMEENTRYSIZE 7
-#define PCRE_INFO_NAMECOUNT 8
-#define PCRE_INFO_NAMETABLE 9
-#define PCRE_INFO_STUDYSIZE 10
-#define PCRE_INFO_DEFAULT_TABLES 11
-#define PCRE_INFO_OKPARTIAL 12
-#define PCRE_INFO_JCHANGED 13
-#define PCRE_INFO_HASCRORLF 14
-#define PCRE_INFO_MINLENGTH 15
-#define PCRE_INFO_JIT 16
-#define PCRE_INFO_JITSIZE 17
-#define PCRE_INFO_MAXLOOKBEHIND 18
-#define PCRE_INFO_FIRSTCHARACTER 19
-#define PCRE_INFO_FIRSTCHARACTERFLAGS 20
-#define PCRE_INFO_REQUIREDCHAR 21
-#define PCRE_INFO_REQUIREDCHARFLAGS 22
-#define PCRE_INFO_MATCHLIMIT 23
-#define PCRE_INFO_RECURSIONLIMIT 24
-#define PCRE_INFO_MATCH_EMPTY 25
-
-/* Request types for pcre_config(). Do not re-arrange, in order to remain
-compatible. */
-
-#define PCRE_CONFIG_UTF8 0
-#define PCRE_CONFIG_NEWLINE 1
-#define PCRE_CONFIG_LINK_SIZE 2
-#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD 3
-#define PCRE_CONFIG_MATCH_LIMIT 4
-#define PCRE_CONFIG_STACKRECURSE 5
-#define PCRE_CONFIG_UNICODE_PROPERTIES 6
-#define PCRE_CONFIG_MATCH_LIMIT_RECURSION 7
-#define PCRE_CONFIG_BSR 8
-#define PCRE_CONFIG_JIT 9
-#define PCRE_CONFIG_UTF16 10
-#define PCRE_CONFIG_JITTARGET 11
-#define PCRE_CONFIG_UTF32 12
-#define PCRE_CONFIG_PARENS_LIMIT 13
-
-/* Request types for pcre_study(). Do not re-arrange, in order to remain
-compatible. */
-
-#define PCRE_STUDY_JIT_COMPILE 0x0001
-#define PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE 0x0002
-#define PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE 0x0004
-#define PCRE_STUDY_EXTRA_NEEDED 0x0008
-
-/* Bit flags for the pcre[16|32]_extra structure. Do not re-arrange or redefine
-these bits, just add new ones on the end, in order to remain compatible. */
-
-#define PCRE_EXTRA_STUDY_DATA 0x0001
-#define PCRE_EXTRA_MATCH_LIMIT 0x0002
-#define PCRE_EXTRA_CALLOUT_DATA 0x0004
-#define PCRE_EXTRA_TABLES 0x0008
-#define PCRE_EXTRA_MATCH_LIMIT_RECURSION 0x0010
-#define PCRE_EXTRA_MARK 0x0020
-#define PCRE_EXTRA_EXECUTABLE_JIT 0x0040
-
-/* Types */
-
-struct real_pcre; /* declaration; the definition is private */
-typedef struct real_pcre pcre;
-
-struct real_pcre16; /* declaration; the definition is private */
-typedef struct real_pcre16 pcre16;
-
-struct real_pcre32; /* declaration; the definition is private */
-typedef struct real_pcre32 pcre32;
-
-struct real_pcre_jit_stack; /* declaration; the definition is private */
-typedef struct real_pcre_jit_stack pcre_jit_stack;
-
-struct real_pcre16_jit_stack; /* declaration; the definition is private */
-typedef struct real_pcre16_jit_stack pcre16_jit_stack;
-
-struct real_pcre32_jit_stack; /* declaration; the definition is private */
-typedef struct real_pcre32_jit_stack pcre32_jit_stack;
-
-/* If PCRE is compiled with 16 bit character support, PCRE_UCHAR16 must contain
-a 16 bit wide signed data type. Otherwise it can be a dummy data type since
-pcre16 functions are not implemented. There is a check for this in pcre_internal.h. */
-#ifndef PCRE_UCHAR16
-#define PCRE_UCHAR16 unsigned short
-#endif
-
-#ifndef PCRE_SPTR16
-#define PCRE_SPTR16 const PCRE_UCHAR16 *
-#endif
-
-/* If PCRE is compiled with 32 bit character support, PCRE_UCHAR32 must contain
-a 32 bit wide signed data type. Otherwise it can be a dummy data type since
-pcre32 functions are not implemented. There is a check for this in pcre_internal.h. */
-#ifndef PCRE_UCHAR32
-#define PCRE_UCHAR32 unsigned int
-#endif
-
-#ifndef PCRE_SPTR32
-#define PCRE_SPTR32 const PCRE_UCHAR32 *
-#endif
-
-/* When PCRE is compiled as a C++ library, the subject pointer type can be
-replaced with a custom type. For conventional use, the public interface is a
-const char *. */
-
-#ifndef PCRE_SPTR
-#define PCRE_SPTR const char *
-#endif
-
-/* The structure for passing additional data to pcre_exec(). This is defined in
-such as way as to be extensible. Always add new fields at the end, in order to
-remain compatible. */
-
-typedef struct pcre_extra {
- unsigned long int flags; /* Bits for which fields are set */
- void *study_data; /* Opaque data from pcre_study() */
- unsigned long int match_limit; /* Maximum number of calls to match() */
- void *callout_data; /* Data passed back in callouts */
- const unsigned char *tables; /* Pointer to character tables */
- unsigned long int match_limit_recursion; /* Max recursive calls to match() */
- unsigned char **mark; /* For passing back a mark pointer */
- void *executable_jit; /* Contains a pointer to a compiled jit code */
-} pcre_extra;
-
-/* Same structure as above, but with 16 bit char pointers. */
-
-typedef struct pcre16_extra {
- unsigned long int flags; /* Bits for which fields are set */
- void *study_data; /* Opaque data from pcre_study() */
- unsigned long int match_limit; /* Maximum number of calls to match() */
- void *callout_data; /* Data passed back in callouts */
- const unsigned char *tables; /* Pointer to character tables */
- unsigned long int match_limit_recursion; /* Max recursive calls to match() */
- PCRE_UCHAR16 **mark; /* For passing back a mark pointer */
- void *executable_jit; /* Contains a pointer to a compiled jit code */
-} pcre16_extra;
-
-/* Same structure as above, but with 32 bit char pointers. */
-
-typedef struct pcre32_extra {
- unsigned long int flags; /* Bits for which fields are set */
- void *study_data; /* Opaque data from pcre_study() */
- unsigned long int match_limit; /* Maximum number of calls to match() */
- void *callout_data; /* Data passed back in callouts */
- const unsigned char *tables; /* Pointer to character tables */
- unsigned long int match_limit_recursion; /* Max recursive calls to match() */
- PCRE_UCHAR32 **mark; /* For passing back a mark pointer */
- void *executable_jit; /* Contains a pointer to a compiled jit code */
-} pcre32_extra;
-
-/* The structure for passing out data via the pcre_callout_function. We use a
-structure so that new fields can be added on the end in future versions,
-without changing the API of the function, thereby allowing old clients to work
-without modification. */
-
-typedef struct pcre_callout_block {
- int version; /* Identifies version of block */
- /* ------------------------ Version 0 ------------------------------- */
- int callout_number; /* Number compiled into pattern */
- int *offset_vector; /* The offset vector */
- PCRE_SPTR subject; /* The subject being matched */
- int subject_length; /* The length of the subject */
- int start_match; /* Offset to start of this match attempt */
- int current_position; /* Where we currently are in the subject */
- int capture_top; /* Max current capture */
- int capture_last; /* Most recently closed capture */
- void *callout_data; /* Data passed in with the call */
- /* ------------------- Added for Version 1 -------------------------- */
- int pattern_position; /* Offset to next item in the pattern */
- int next_item_length; /* Length of next item in the pattern */
- /* ------------------- Added for Version 2 -------------------------- */
- const unsigned char *mark; /* Pointer to current mark or NULL */
- /* ------------------------------------------------------------------ */
-} pcre_callout_block;
-
-/* Same structure as above, but with 16 bit char pointers. */
-
-typedef struct pcre16_callout_block {
- int version; /* Identifies version of block */
- /* ------------------------ Version 0 ------------------------------- */
- int callout_number; /* Number compiled into pattern */
- int *offset_vector; /* The offset vector */
- PCRE_SPTR16 subject; /* The subject being matched */
- int subject_length; /* The length of the subject */
- int start_match; /* Offset to start of this match attempt */
- int current_position; /* Where we currently are in the subject */
- int capture_top; /* Max current capture */
- int capture_last; /* Most recently closed capture */
- void *callout_data; /* Data passed in with the call */
- /* ------------------- Added for Version 1 -------------------------- */
- int pattern_position; /* Offset to next item in the pattern */
- int next_item_length; /* Length of next item in the pattern */
- /* ------------------- Added for Version 2 -------------------------- */
- const PCRE_UCHAR16 *mark; /* Pointer to current mark or NULL */
- /* ------------------------------------------------------------------ */
-} pcre16_callout_block;
-
-/* Same structure as above, but with 32 bit char pointers. */
-
-typedef struct pcre32_callout_block {
- int version; /* Identifies version of block */
- /* ------------------------ Version 0 ------------------------------- */
- int callout_number; /* Number compiled into pattern */
- int *offset_vector; /* The offset vector */
- PCRE_SPTR32 subject; /* The subject being matched */
- int subject_length; /* The length of the subject */
- int start_match; /* Offset to start of this match attempt */
- int current_position; /* Where we currently are in the subject */
- int capture_top; /* Max current capture */
- int capture_last; /* Most recently closed capture */
- void *callout_data; /* Data passed in with the call */
- /* ------------------- Added for Version 1 -------------------------- */
- int pattern_position; /* Offset to next item in the pattern */
- int next_item_length; /* Length of next item in the pattern */
- /* ------------------- Added for Version 2 -------------------------- */
- const PCRE_UCHAR32 *mark; /* Pointer to current mark or NULL */
- /* ------------------------------------------------------------------ */
-} pcre32_callout_block;
-
-/* Indirection for store get and free functions. These can be set to
-alternative malloc/free functions if required. Special ones are used in the
-non-recursive case for "frames". There is also an optional callout function
-that is triggered by the (?) regex item. For Virtual Pascal, these definitions
-have to take another form. */
-
-#ifndef VPCOMPAT
-PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
-PCRE_EXP_DECL void (*pcre_free)(void *);
-PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
-PCRE_EXP_DECL void (*pcre_stack_free)(void *);
-PCRE_EXP_DECL int (*pcre_callout)(pcre_callout_block *);
-PCRE_EXP_DECL int (*pcre_stack_guard)(void);
-
-PCRE_EXP_DECL void *(*pcre16_malloc)(size_t);
-PCRE_EXP_DECL void (*pcre16_free)(void *);
-PCRE_EXP_DECL void *(*pcre16_stack_malloc)(size_t);
-PCRE_EXP_DECL void (*pcre16_stack_free)(void *);
-PCRE_EXP_DECL int (*pcre16_callout)(pcre16_callout_block *);
-PCRE_EXP_DECL int (*pcre16_stack_guard)(void);
-
-PCRE_EXP_DECL void *(*pcre32_malloc)(size_t);
-PCRE_EXP_DECL void (*pcre32_free)(void *);
-PCRE_EXP_DECL void *(*pcre32_stack_malloc)(size_t);
-PCRE_EXP_DECL void (*pcre32_stack_free)(void *);
-PCRE_EXP_DECL int (*pcre32_callout)(pcre32_callout_block *);
-PCRE_EXP_DECL int (*pcre32_stack_guard)(void);
-#else /* VPCOMPAT */
-PCRE_EXP_DECL void *pcre_malloc(size_t);
-PCRE_EXP_DECL void pcre_free(void *);
-PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
-PCRE_EXP_DECL void pcre_stack_free(void *);
-PCRE_EXP_DECL int pcre_callout(pcre_callout_block *);
-PCRE_EXP_DECL int pcre_stack_guard(void);
-
-PCRE_EXP_DECL void *pcre16_malloc(size_t);
-PCRE_EXP_DECL void pcre16_free(void *);
-PCRE_EXP_DECL void *pcre16_stack_malloc(size_t);
-PCRE_EXP_DECL void pcre16_stack_free(void *);
-PCRE_EXP_DECL int pcre16_callout(pcre16_callout_block *);
-PCRE_EXP_DECL int pcre16_stack_guard(void);
-
-PCRE_EXP_DECL void *pcre32_malloc(size_t);
-PCRE_EXP_DECL void pcre32_free(void *);
-PCRE_EXP_DECL void *pcre32_stack_malloc(size_t);
-PCRE_EXP_DECL void pcre32_stack_free(void *);
-PCRE_EXP_DECL int pcre32_callout(pcre32_callout_block *);
-PCRE_EXP_DECL int pcre32_stack_guard(void);
-#endif /* VPCOMPAT */
-
-/* User defined callback which provides a stack just before the match starts. */
-
-typedef pcre_jit_stack *(*pcre_jit_callback)(void *);
-typedef pcre16_jit_stack *(*pcre16_jit_callback)(void *);
-typedef pcre32_jit_stack *(*pcre32_jit_callback)(void *);
-
-/* Exported PCRE functions */
-
-PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
- const unsigned char *);
-PCRE_EXP_DECL pcre16 *pcre16_compile(PCRE_SPTR16, int, const char **, int *,
- const unsigned char *);
-PCRE_EXP_DECL pcre32 *pcre32_compile(PCRE_SPTR32, int, const char **, int *,
- const unsigned char *);
-PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
- int *, const unsigned char *);
-PCRE_EXP_DECL pcre16 *pcre16_compile2(PCRE_SPTR16, int, int *, const char **,
- int *, const unsigned char *);
-PCRE_EXP_DECL pcre32 *pcre32_compile2(PCRE_SPTR32, int, int *, const char **,
- int *, const unsigned char *);
-PCRE_EXP_DECL int pcre_config(int, void *);
-PCRE_EXP_DECL int pcre16_config(int, void *);
-PCRE_EXP_DECL int pcre32_config(int, void *);
-PCRE_EXP_DECL int pcre_copy_named_substring(const pcre *, const char *,
- int *, int, const char *, char *, int);
-PCRE_EXP_DECL int pcre16_copy_named_substring(const pcre16 *, PCRE_SPTR16,
- int *, int, PCRE_SPTR16, PCRE_UCHAR16 *, int);
-PCRE_EXP_DECL int pcre32_copy_named_substring(const pcre32 *, PCRE_SPTR32,
- int *, int, PCRE_SPTR32, PCRE_UCHAR32 *, int);
-PCRE_EXP_DECL int pcre_copy_substring(const char *, int *, int, int,
- char *, int);
-PCRE_EXP_DECL int pcre16_copy_substring(PCRE_SPTR16, int *, int, int,
- PCRE_UCHAR16 *, int);
-PCRE_EXP_DECL int pcre32_copy_substring(PCRE_SPTR32, int *, int, int,
- PCRE_UCHAR32 *, int);
-PCRE_EXP_DECL int pcre_dfa_exec(const pcre *, const pcre_extra *,
- const char *, int, int, int, int *, int , int *, int);
-PCRE_EXP_DECL int pcre16_dfa_exec(const pcre16 *, const pcre16_extra *,
- PCRE_SPTR16, int, int, int, int *, int , int *, int);
-PCRE_EXP_DECL int pcre32_dfa_exec(const pcre32 *, const pcre32_extra *,
- PCRE_SPTR32, int, int, int, int *, int , int *, int);
-PCRE_EXP_DECL int pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
- int, int, int, int *, int);
-PCRE_EXP_DECL int pcre16_exec(const pcre16 *, const pcre16_extra *,
- PCRE_SPTR16, int, int, int, int *, int);
-PCRE_EXP_DECL int pcre32_exec(const pcre32 *, const pcre32_extra *,
- PCRE_SPTR32, int, int, int, int *, int);
-PCRE_EXP_DECL int pcre_jit_exec(const pcre *, const pcre_extra *,
- PCRE_SPTR, int, int, int, int *, int,
- pcre_jit_stack *);
-PCRE_EXP_DECL int pcre16_jit_exec(const pcre16 *, const pcre16_extra *,
- PCRE_SPTR16, int, int, int, int *, int,
- pcre16_jit_stack *);
-PCRE_EXP_DECL int pcre32_jit_exec(const pcre32 *, const pcre32_extra *,
- PCRE_SPTR32, int, int, int, int *, int,
- pcre32_jit_stack *);
-PCRE_EXP_DECL void pcre_free_substring(const char *);
-PCRE_EXP_DECL void pcre16_free_substring(PCRE_SPTR16);
-PCRE_EXP_DECL void pcre32_free_substring(PCRE_SPTR32);
-PCRE_EXP_DECL void pcre_free_substring_list(const char **);
-PCRE_EXP_DECL void pcre16_free_substring_list(PCRE_SPTR16 *);
-PCRE_EXP_DECL void pcre32_free_substring_list(PCRE_SPTR32 *);
-PCRE_EXP_DECL int pcre_fullinfo(const pcre *, const pcre_extra *, int,
- void *);
-PCRE_EXP_DECL int pcre16_fullinfo(const pcre16 *, const pcre16_extra *, int,
- void *);
-PCRE_EXP_DECL int pcre32_fullinfo(const pcre32 *, const pcre32_extra *, int,
- void *);
-PCRE_EXP_DECL int pcre_get_named_substring(const pcre *, const char *,
- int *, int, const char *, const char **);
-PCRE_EXP_DECL int pcre16_get_named_substring(const pcre16 *, PCRE_SPTR16,
- int *, int, PCRE_SPTR16, PCRE_SPTR16 *);
-PCRE_EXP_DECL int pcre32_get_named_substring(const pcre32 *, PCRE_SPTR32,
- int *, int, PCRE_SPTR32, PCRE_SPTR32 *);
-PCRE_EXP_DECL int pcre_get_stringnumber(const pcre *, const char *);
-PCRE_EXP_DECL int pcre16_get_stringnumber(const pcre16 *, PCRE_SPTR16);
-PCRE_EXP_DECL int pcre32_get_stringnumber(const pcre32 *, PCRE_SPTR32);
-PCRE_EXP_DECL int pcre_get_stringtable_entries(const pcre *, const char *,
- char **, char **);
-PCRE_EXP_DECL int pcre16_get_stringtable_entries(const pcre16 *, PCRE_SPTR16,
- PCRE_UCHAR16 **, PCRE_UCHAR16 **);
-PCRE_EXP_DECL int pcre32_get_stringtable_entries(const pcre32 *, PCRE_SPTR32,
- PCRE_UCHAR32 **, PCRE_UCHAR32 **);
-PCRE_EXP_DECL int pcre_get_substring(const char *, int *, int, int,
- const char **);
-PCRE_EXP_DECL int pcre16_get_substring(PCRE_SPTR16, int *, int, int,
- PCRE_SPTR16 *);
-PCRE_EXP_DECL int pcre32_get_substring(PCRE_SPTR32, int *, int, int,
- PCRE_SPTR32 *);
-PCRE_EXP_DECL int pcre_get_substring_list(const char *, int *, int,
- const char ***);
-PCRE_EXP_DECL int pcre16_get_substring_list(PCRE_SPTR16, int *, int,
- PCRE_SPTR16 **);
-PCRE_EXP_DECL int pcre32_get_substring_list(PCRE_SPTR32, int *, int,
- PCRE_SPTR32 **);
-PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
-PCRE_EXP_DECL const unsigned char *pcre16_maketables(void);
-PCRE_EXP_DECL const unsigned char *pcre32_maketables(void);
-PCRE_EXP_DECL int pcre_refcount(pcre *, int);
-PCRE_EXP_DECL int pcre16_refcount(pcre16 *, int);
-PCRE_EXP_DECL int pcre32_refcount(pcre32 *, int);
-PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
-PCRE_EXP_DECL pcre16_extra *pcre16_study(const pcre16 *, int, const char **);
-PCRE_EXP_DECL pcre32_extra *pcre32_study(const pcre32 *, int, const char **);
-PCRE_EXP_DECL void pcre_free_study(pcre_extra *);
-PCRE_EXP_DECL void pcre16_free_study(pcre16_extra *);
-PCRE_EXP_DECL void pcre32_free_study(pcre32_extra *);
-PCRE_EXP_DECL const char *pcre_version(void);
-PCRE_EXP_DECL const char *pcre16_version(void);
-PCRE_EXP_DECL const char *pcre32_version(void);
-
-/* Utility functions for byte order swaps. */
-PCRE_EXP_DECL int pcre_pattern_to_host_byte_order(pcre *, pcre_extra *,
- const unsigned char *);
-PCRE_EXP_DECL int pcre16_pattern_to_host_byte_order(pcre16 *, pcre16_extra *,
- const unsigned char *);
-PCRE_EXP_DECL int pcre32_pattern_to_host_byte_order(pcre32 *, pcre32_extra *,
- const unsigned char *);
-PCRE_EXP_DECL int pcre16_utf16_to_host_byte_order(PCRE_UCHAR16 *,
- PCRE_SPTR16, int, int *, int);
-PCRE_EXP_DECL int pcre32_utf32_to_host_byte_order(PCRE_UCHAR32 *,
- PCRE_SPTR32, int, int *, int);
-
-/* JIT compiler related functions. */
-
-PCRE_EXP_DECL pcre_jit_stack *pcre_jit_stack_alloc(int, int);
-PCRE_EXP_DECL pcre16_jit_stack *pcre16_jit_stack_alloc(int, int);
-PCRE_EXP_DECL pcre32_jit_stack *pcre32_jit_stack_alloc(int, int);
-PCRE_EXP_DECL void pcre_jit_stack_free(pcre_jit_stack *);
-PCRE_EXP_DECL void pcre16_jit_stack_free(pcre16_jit_stack *);
-PCRE_EXP_DECL void pcre32_jit_stack_free(pcre32_jit_stack *);
-PCRE_EXP_DECL void pcre_assign_jit_stack(pcre_extra *,
- pcre_jit_callback, void *);
-PCRE_EXP_DECL void pcre16_assign_jit_stack(pcre16_extra *,
- pcre16_jit_callback, void *);
-PCRE_EXP_DECL void pcre32_assign_jit_stack(pcre32_extra *,
- pcre32_jit_callback, void *);
-PCRE_EXP_DECL void pcre_jit_free_unused_memory(void);
-PCRE_EXP_DECL void pcre16_jit_free_unused_memory(void);
-PCRE_EXP_DECL void pcre32_jit_free_unused_memory(void);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* End of pcre.h */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_internal.h r-base-3.3.1/src/extra/pcre/pcre_internal.h
--- r-base-3.2.3/src/extra/pcre/pcre_internal.h 2015-11-26 23:15:13.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_internal.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,2825 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2014 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-/* This header contains definitions that are shared between the different
-modules, but which are not relevant to the exported API. This includes some
-functions whose names all begin with "_pcre_", "_pcre16_" or "_pcre32_"
-depending on the PRIV macro. */
-
-#ifndef PCRE_INTERNAL_H
-#define PCRE_INTERNAL_H
-
-#include
-
-/* and those that are not in R's configure:
- LINK_SIZE is set on the command line */
-#define HAVE_MEMMOVE 1
-#define MATCH_LIMIT 10000000
-#define MATCH_LIMIT_RECURSION MATCH_LIMIT
-#define MAX_NAME_COUNT 10000
-#define MAX_NAME_SIZE 32
-#define NEWLINE 10
-#define PARENS_NEST_LIMIT 250
-#define POSIX_MALLOC_THRESHOLD 10
-#define SUPPORT_UCP
-#define SUPPORT_UTF
-
-/* See http://sourceforge.net/p/predef/wiki/Architectures/
- SPARC_32 support added in 8.32, 'experimental'.
-
- At least i386 support did not compile on Solaris Studio.
- */
-#ifndef __SUNPRO_C
-#if defined(WIN32) || defined(__i386__) || defined(__i386) || defined(__x86_64__) || defined(__ppc64__) || defined(__powerpc64__) || defined(__ppc__) || defined(__powerpc__) || defined(__sparc__)
-# define SUPPORT_JIT
-#endif
-#endif
-
-
-/* Define PCRE_DEBUG to get debugging output on stdout. */
-
-#if 0
-#define PCRE_DEBUG
-#endif
-
-/* PCRE is compiled as an 8 bit library if it is not requested otherwise. */
-
-#if !defined COMPILE_PCRE16 && !defined COMPILE_PCRE32
-#define COMPILE_PCRE8
-#endif
-
-/* If SUPPORT_UCP is defined, SUPPORT_UTF must also be defined. The
-"configure" script ensures this, but not everybody uses "configure". */
-
-#if defined SUPPORT_UCP && !(defined SUPPORT_UTF)
-#define SUPPORT_UTF 1
-#endif
-
-/* We define SUPPORT_UTF if SUPPORT_UTF8 is enabled for compatibility
-reasons with existing code. */
-
-#if defined SUPPORT_UTF8 && !(defined SUPPORT_UTF)
-#define SUPPORT_UTF 1
-#endif
-
-/* Fixme: SUPPORT_UTF8 should be eventually disappear from the code.
-Until then we define it if SUPPORT_UTF is defined. */
-
-#if defined SUPPORT_UTF && !(defined SUPPORT_UTF8)
-#define SUPPORT_UTF8 1
-#endif
-
-/* We do not support both EBCDIC and UTF-8/16/32 at the same time. The "configure"
-script prevents both being selected, but not everybody uses "configure". */
-
-#if defined EBCDIC && defined SUPPORT_UTF
-#error The use of both EBCDIC and SUPPORT_UTF is not supported.
-#endif
-
-/* Use a macro for debugging printing, 'cause that eliminates the use of #ifdef
-inline, and there are *still* stupid compilers about that don't like indented
-pre-processor statements, or at least there were when I first wrote this. After
-all, it had only been about 10 years then...
-
-It turns out that the Mac Debugging.h header also defines the macro DPRINTF, so
-be absolutely sure we get our version. */
-
-#undef DPRINTF
-#ifdef PCRE_DEBUG
-#define DPRINTF(p) printf p
-#else
-#define DPRINTF(p) /* Nothing */
-#endif
-
-
-/* Standard C headers plus the external interface definition. The only time
-setjmp and stdarg are used is when NO_RECURSE is set. */
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-/* Valgrind (memcheck) support */
-
-#ifdef SUPPORT_VALGRIND
-#include
-#endif
-
-/* When compiling a DLL for Windows, the exported symbols have to be declared
-using some MS magic. I found some useful information on this web page:
-http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the
-information there, using __declspec(dllexport) without "extern" we have a
-definition; with "extern" we have a declaration. The settings here override the
-setting in pcre.h (which is included below); it defines only PCRE_EXP_DECL,
-which is all that is needed for applications (they just import the symbols). We
-use:
-
- PCRE_EXP_DECL for declarations
- PCRE_EXP_DEFN for definitions of exported functions
- PCRE_EXP_DATA_DEFN for definitions of exported variables
-
-The reason for the two DEFN macros is that in non-Windows environments, one
-does not want to have "extern" before variable definitions because it leads to
-compiler warnings. So we distinguish between functions and variables. In
-Windows, the two should always be the same.
-
-The reason for wrapping this in #ifndef PCRE_EXP_DECL is so that pcretest,
-which is an application, but needs to import this file in order to "peek" at
-internals, can #include pcre.h first to get an application's-eye view.
-
-In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon,
-special-purpose environments) might want to stick other stuff in front of
-exported symbols. That's why, in the non-Windows case, we set PCRE_EXP_DEFN and
-PCRE_EXP_DATA_DEFN only if they are not already set. */
-
-#ifndef PCRE_EXP_DECL
-# ifdef _WIN32
-# ifndef PCRE_STATIC
-# define PCRE_EXP_DECL extern __declspec(dllexport)
-# define PCRE_EXP_DEFN __declspec(dllexport)
-# define PCRE_EXP_DATA_DEFN __declspec(dllexport)
-# else
-# define PCRE_EXP_DECL extern
-# define PCRE_EXP_DEFN
-# define PCRE_EXP_DATA_DEFN
-# endif
-# else
-# ifdef __cplusplus
-# define PCRE_EXP_DECL extern "C"
-# else
-# define PCRE_EXP_DECL extern
-# endif
-# ifndef PCRE_EXP_DEFN
-# define PCRE_EXP_DEFN PCRE_EXP_DECL
-# endif
-# ifndef PCRE_EXP_DATA_DEFN
-# define PCRE_EXP_DATA_DEFN
-# endif
-# endif
-#endif
-
-/* When compiling with the MSVC compiler, it is sometimes necessary to include
-a "calling convention" before exported function names. (This is secondhand
-information; I know nothing about MSVC myself). For example, something like
-
- void __cdecl function(....)
-
-might be needed. In order so make this easy, all the exported functions have
-PCRE_CALL_CONVENTION just before their names. It is rarely needed; if not
-set, we ensure here that it has no effect. */
-
-#ifndef PCRE_CALL_CONVENTION
-#define PCRE_CALL_CONVENTION
-#endif
-
-/* We need to have types that specify unsigned 8, 16 and 32-bit integers. We
-cannot determine these outside the compilation (e.g. by running a program as
-part of "configure") because PCRE is often cross-compiled for use on other
-systems. Instead we make use of the maximum sizes that are available at
-preprocessor time in standard C environments. */
-
-typedef unsigned char pcre_uint8;
-
-#if USHRT_MAX == 65535
-typedef unsigned short pcre_uint16;
-typedef short pcre_int16;
-#define PCRE_UINT16_MAX USHRT_MAX
-#define PCRE_INT16_MAX SHRT_MAX
-#elif UINT_MAX == 65535
-typedef unsigned int pcre_uint16;
-typedef int pcre_int16;
-#define PCRE_UINT16_MAX UINT_MAX
-#define PCRE_INT16_MAX INT_MAX
-#else
-#error Cannot determine a type for 16-bit integers
-#endif
-
-#if UINT_MAX == 4294967295U
-typedef unsigned int pcre_uint32;
-typedef int pcre_int32;
-#define PCRE_UINT32_MAX UINT_MAX
-#define PCRE_INT32_MAX INT_MAX
-#elif ULONG_MAX == 4294967295UL
-typedef unsigned long int pcre_uint32;
-typedef long int pcre_int32;
-#define PCRE_UINT32_MAX ULONG_MAX
-#define PCRE_INT32_MAX LONG_MAX
-#else
-#error Cannot determine a type for 32-bit integers
-#endif
-
-/* When checking for integer overflow in pcre_compile(), we need to handle
-large integers. If a 64-bit integer type is available, we can use that.
-Otherwise we have to cast to double, which of course requires floating point
-arithmetic. Handle this by defining a macro for the appropriate type. If
-stdint.h is available, include it; it may define INT64_MAX. Systems that do not
-have stdint.h (e.g. Solaris) may have inttypes.h. The macro int64_t may be set
-by "configure". */
-
-#if defined HAVE_STDINT_H
-#include
-#elif defined HAVE_INTTYPES_H
-#include
-#endif
-
-#if defined INT64_MAX || defined int64_t
-#define INT64_OR_DOUBLE int64_t
-#else
-#define INT64_OR_DOUBLE double
-#endif
-
-/* All character handling must be done as unsigned characters. Otherwise there
-are problems with top-bit-set characters and functions such as isspace().
-However, we leave the interface to the outside world as char * or short *,
-because that should make things easier for callers. This character type is
-called pcre_uchar.
-
-The IN_UCHARS macro multiply its argument with the byte size of the current
-pcre_uchar type. Useful for memcpy and such operations, whose require the
-byte size of their input/output buffers.
-
-The MAX_255 macro checks whether its pcre_uchar input is less than 256.
-
-The TABLE_GET macro is designed for accessing elements of tables whose contain
-exactly 256 items. When the character is able to contain more than 256
-items, some check is needed before accessing these tables.
-*/
-
-#if defined COMPILE_PCRE8
-
-typedef unsigned char pcre_uchar;
-#define IN_UCHARS(x) (x)
-#define MAX_255(c) 1
-#define TABLE_GET(c, table, default) ((table)[c])
-
-#elif defined COMPILE_PCRE16
-
-#if USHRT_MAX != 65535
-/* This is a warning message. Change PCRE_UCHAR16 to a 16 bit data type in
-pcre.h(.in) and disable (comment out) this message. */
-#error Warning: PCRE_UCHAR16 is not a 16 bit data type.
-#endif
-
-typedef pcre_uint16 pcre_uchar;
-#define UCHAR_SHIFT (1)
-#define IN_UCHARS(x) ((x) << UCHAR_SHIFT)
-#define MAX_255(c) ((c) <= 255u)
-#define TABLE_GET(c, table, default) (MAX_255(c)? ((table)[c]):(default))
-
-#elif defined COMPILE_PCRE32
-
-typedef pcre_uint32 pcre_uchar;
-#define UCHAR_SHIFT (2)
-#define IN_UCHARS(x) ((x) << UCHAR_SHIFT)
-#define MAX_255(c) ((c) <= 255u)
-#define TABLE_GET(c, table, default) (MAX_255(c)? ((table)[c]):(default))
-
-#else
-#error Unsupported compiling mode
-#endif /* COMPILE_PCRE[8|16|32] */
-
-/* This is an unsigned int value that no character can ever have. UTF-8
-characters only go up to 0x7fffffff (though Unicode doesn't go beyond
-0x0010ffff). */
-
-#define NOTACHAR 0xffffffff
-
-/* PCRE is able to support several different kinds of newline (CR, LF, CRLF,
-"any" and "anycrlf" at present). The following macros are used to package up
-testing for newlines. NLBLOCK, PSSTART, and PSEND are defined in the various
-modules to indicate in which datablock the parameters exist, and what the
-start/end of string field names are. */
-
-#define NLTYPE_FIXED 0 /* Newline is a fixed length string */
-#define NLTYPE_ANY 1 /* Newline is any Unicode line ending */
-#define NLTYPE_ANYCRLF 2 /* Newline is CR, LF, or CRLF */
-
-/* This macro checks for a newline at the given position */
-
-#define IS_NEWLINE(p) \
- ((NLBLOCK->nltype != NLTYPE_FIXED)? \
- ((p) < NLBLOCK->PSEND && \
- PRIV(is_newline)((p), NLBLOCK->nltype, NLBLOCK->PSEND, \
- &(NLBLOCK->nllen), utf)) \
- : \
- ((p) <= NLBLOCK->PSEND - NLBLOCK->nllen && \
- UCHAR21TEST(p) == NLBLOCK->nl[0] && \
- (NLBLOCK->nllen == 1 || UCHAR21TEST(p+1) == NLBLOCK->nl[1]) \
- ) \
- )
-
-/* This macro checks for a newline immediately preceding the given position */
-
-#define WAS_NEWLINE(p) \
- ((NLBLOCK->nltype != NLTYPE_FIXED)? \
- ((p) > NLBLOCK->PSSTART && \
- PRIV(was_newline)((p), NLBLOCK->nltype, NLBLOCK->PSSTART, \
- &(NLBLOCK->nllen), utf)) \
- : \
- ((p) >= NLBLOCK->PSSTART + NLBLOCK->nllen && \
- UCHAR21TEST(p - NLBLOCK->nllen) == NLBLOCK->nl[0] && \
- (NLBLOCK->nllen == 1 || UCHAR21TEST(p - NLBLOCK->nllen + 1) == NLBLOCK->nl[1]) \
- ) \
- )
-
-/* When PCRE is compiled as a C++ library, the subject pointer can be replaced
-with a custom type. This makes it possible, for example, to allow pcre_exec()
-to process subject strings that are discontinuous by using a smart pointer
-class. It must always be possible to inspect all of the subject string in
-pcre_exec() because of the way it backtracks. Two macros are required in the
-normal case, for sign-unspecified and unsigned char pointers. The former is
-used for the external interface and appears in pcre.h, which is why its name
-must begin with PCRE_. */
-
-#ifdef CUSTOM_SUBJECT_PTR
-#define PCRE_PUCHAR CUSTOM_SUBJECT_PTR
-#else
-#define PCRE_PUCHAR const pcre_uchar *
-#endif
-
-/* Include the public PCRE header and the definitions of UCP character property
-values. */
-
-#include "pcre.h"
-#include "ucp.h"
-
-#ifdef COMPILE_PCRE32
-/* Assert that the public PCRE_UCHAR32 is a 32-bit type */
-typedef int __assert_pcre_uchar32_size[sizeof(PCRE_UCHAR32) == 4 ? 1 : -1];
-#endif
-
-/* When compiling for use with the Virtual Pascal compiler, these functions
-need to have their names changed. PCRE must be compiled with the -DVPCOMPAT
-option on the command line. */
-
-#ifdef VPCOMPAT
-#define strlen(s) _strlen(s)
-#define strncmp(s1,s2,m) _strncmp(s1,s2,m)
-#define memcmp(s,c,n) _memcmp(s,c,n)
-#define memcpy(d,s,n) _memcpy(d,s,n)
-#define memmove(d,s,n) _memmove(d,s,n)
-#define memset(s,c,n) _memset(s,c,n)
-#else /* VPCOMPAT */
-
-/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(),
-define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY
-is set. Otherwise, include an emulating function for those systems that have
-neither (there some non-Unix environments where this is the case). */
-
-#ifndef HAVE_MEMMOVE
-#undef memmove /* some systems may have a macro */
-#ifdef HAVE_BCOPY
-#define memmove(a, b, c) bcopy(b, a, c)
-#else /* HAVE_BCOPY */
-static void *
-pcre_memmove(void *d, const void *s, size_t n)
-{
-size_t i;
-unsigned char *dest = (unsigned char *)d;
-const unsigned char *src = (const unsigned char *)s;
-if (dest > src)
- {
- dest += n;
- src += n;
- for (i = 0; i < n; ++i) *(--dest) = *(--src);
- return (void *)dest;
- }
-else
- {
- for (i = 0; i < n; ++i) *dest++ = *src++;
- return (void *)(dest - n);
- }
-}
-#define memmove(a, b, c) pcre_memmove(a, b, c)
-#endif /* not HAVE_BCOPY */
-#endif /* not HAVE_MEMMOVE */
-#endif /* not VPCOMPAT */
-
-
-/* PCRE keeps offsets in its compiled code as 2-byte quantities (always stored
-in big-endian order) by default. These are used, for example, to link from the
-start of a subpattern to its alternatives and its end. The use of 2 bytes per
-offset limits the size of the compiled regex to around 64K, which is big enough
-for almost everybody. However, I received a request for an even bigger limit.
-For this reason, and also to make the code easier to maintain, the storing and
-loading of offsets from the byte string is now handled by the macros that are
-defined here.
-
-The macros are controlled by the value of LINK_SIZE. This defaults to 2 in
-the config.h file, but can be overridden by using -D on the command line. This
-is automated on Unix systems via the "configure" command. */
-
-#if defined COMPILE_PCRE8
-
-#if LINK_SIZE == 2
-
-#define PUT(a,n,d) \
- (a[n] = (d) >> 8), \
- (a[(n)+1] = (d) & 255)
-
-#define GET(a,n) \
- (((a)[n] << 8) | (a)[(n)+1])
-
-#define MAX_PATTERN_SIZE (1 << 16)
-
-
-#elif LINK_SIZE == 3
-
-#define PUT(a,n,d) \
- (a[n] = (d) >> 16), \
- (a[(n)+1] = (d) >> 8), \
- (a[(n)+2] = (d) & 255)
-
-#define GET(a,n) \
- (((a)[n] << 16) | ((a)[(n)+1] << 8) | (a)[(n)+2])
-
-#define MAX_PATTERN_SIZE (1 << 24)
-
-
-#elif LINK_SIZE == 4
-
-#define PUT(a,n,d) \
- (a[n] = (d) >> 24), \
- (a[(n)+1] = (d) >> 16), \
- (a[(n)+2] = (d) >> 8), \
- (a[(n)+3] = (d) & 255)
-
-#define GET(a,n) \
- (((a)[n] << 24) | ((a)[(n)+1] << 16) | ((a)[(n)+2] << 8) | (a)[(n)+3])
-
-/* Keep it positive */
-#define MAX_PATTERN_SIZE (1 << 30)
-
-#else
-#error LINK_SIZE must be either 2, 3, or 4
-#endif
-
-#elif defined COMPILE_PCRE16
-
-#if LINK_SIZE == 2
-
-/* Redefine LINK_SIZE as a multiple of sizeof(pcre_uchar) */
-#undef LINK_SIZE
-#define LINK_SIZE 1
-
-#define PUT(a,n,d) \
- (a[n] = (d))
-
-#define GET(a,n) \
- (a[n])
-
-#define MAX_PATTERN_SIZE (1 << 16)
-
-#elif LINK_SIZE == 3 || LINK_SIZE == 4
-
-/* Redefine LINK_SIZE as a multiple of sizeof(pcre_uchar) */
-#undef LINK_SIZE
-#define LINK_SIZE 2
-
-#define PUT(a,n,d) \
- (a[n] = (d) >> 16), \
- (a[(n)+1] = (d) & 65535)
-
-#define GET(a,n) \
- (((a)[n] << 16) | (a)[(n)+1])
-
-/* Keep it positive */
-#define MAX_PATTERN_SIZE (1 << 30)
-
-#else
-#error LINK_SIZE must be either 2, 3, or 4
-#endif
-
-#elif defined COMPILE_PCRE32
-
-/* Only supported LINK_SIZE is 4 */
-/* Redefine LINK_SIZE as a multiple of sizeof(pcre_uchar) */
-#undef LINK_SIZE
-#define LINK_SIZE 1
-
-#define PUT(a,n,d) \
- (a[n] = (d))
-
-#define GET(a,n) \
- (a[n])
-
-/* Keep it positive */
-#define MAX_PATTERN_SIZE (1 << 30)
-
-#else
-#error Unsupported compiling mode
-#endif /* COMPILE_PCRE[8|16|32] */
-
-/* Convenience macro defined in terms of the others */
-
-#define PUTINC(a,n,d) PUT(a,n,d), a += LINK_SIZE
-
-
-/* PCRE uses some other 2-byte quantities that do not change when the size of
-offsets changes. There are used for repeat counts and for other things such as
-capturing parenthesis numbers in back references. */
-
-#if defined COMPILE_PCRE8
-
-#define IMM2_SIZE 2
-
-#define PUT2(a,n,d) \
- a[n] = (d) >> 8; \
- a[(n)+1] = (d) & 255
-
-/* For reasons that I do not understand, the expression in this GET2 macro is
-treated by gcc as a signed expression, even when a is declared as unsigned. It
-seems that any kind of arithmetic results in a signed value. */
-
-#define GET2(a,n) \
- (unsigned int)(((a)[n] << 8) | (a)[(n)+1])
-
-#elif defined COMPILE_PCRE16
-
-#define IMM2_SIZE 1
-
-#define PUT2(a,n,d) \
- a[n] = d
-
-#define GET2(a,n) \
- a[n]
-
-#elif defined COMPILE_PCRE32
-
-#define IMM2_SIZE 1
-
-#define PUT2(a,n,d) \
- a[n] = d
-
-#define GET2(a,n) \
- a[n]
-
-#else
-#error Unsupported compiling mode
-#endif /* COMPILE_PCRE[8|16|32] */
-
-#define PUT2INC(a,n,d) PUT2(a,n,d), a += IMM2_SIZE
-
-/* The maximum length of a MARK name is currently one data unit; it may be
-changed in future to be a fixed number of bytes or to depend on LINK_SIZE. */
-
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-#define MAX_MARK ((1u << 16) - 1)
-#else
-#define MAX_MARK ((1u << 8) - 1)
-#endif
-
-/* There is a proposed future special "UTF-21" mode, in which only the lowest
-21 bits of a 32-bit character are interpreted as UTF, with the remaining 11
-high-order bits available to the application for other uses. In preparation for
-the future implementation of this mode, there are macros that load a data item
-and, if in this special mode, mask it to 21 bits. These macros all have names
-starting with UCHAR21. In all other modes, including the normal 32-bit
-library, the macros all have the same simple definitions. When the new mode is
-implemented, it is expected that these definitions will be varied appropriately
-using #ifdef when compiling the library that supports the special mode. */
-
-#define UCHAR21(eptr) (*(eptr))
-#define UCHAR21TEST(eptr) (*(eptr))
-#define UCHAR21INC(eptr) (*(eptr)++)
-#define UCHAR21INCTEST(eptr) (*(eptr)++)
-
-/* When UTF encoding is being used, a character is no longer just a single
-byte in 8-bit mode or a single short in 16-bit mode. The macros for character
-handling generate simple sequences when used in the basic mode, and more
-complicated ones for UTF characters. GETCHARLENTEST and other macros are not
-used when UTF is not supported. To make sure they can never even appear when
-UTF support is omitted, we don't even define them. */
-
-#ifndef SUPPORT_UTF
-
-/* #define MAX_VALUE_FOR_SINGLE_CHAR */
-/* #define HAS_EXTRALEN(c) */
-/* #define GET_EXTRALEN(c) */
-/* #define NOT_FIRSTCHAR(c) */
-#define GETCHAR(c, eptr) c = *eptr;
-#define GETCHARTEST(c, eptr) c = *eptr;
-#define GETCHARINC(c, eptr) c = *eptr++;
-#define GETCHARINCTEST(c, eptr) c = *eptr++;
-#define GETCHARLEN(c, eptr, len) c = *eptr;
-/* #define GETCHARLENTEST(c, eptr, len) */
-/* #define BACKCHAR(eptr) */
-/* #define FORWARDCHAR(eptr) */
-/* #define ACROSSCHAR(condition, eptr, action) */
-
-#else /* SUPPORT_UTF */
-
-/* Tests whether the code point needs extra characters to decode. */
-
-#define HASUTF8EXTRALEN(c) ((c) >= 0xc0)
-
-/* Base macro to pick up the remaining bytes of a UTF-8 character, not
-advancing the pointer. */
-
-#define GETUTF8(c, eptr) \
- { \
- if ((c & 0x20) == 0) \
- c = ((c & 0x1f) << 6) | (eptr[1] & 0x3f); \
- else if ((c & 0x10) == 0) \
- c = ((c & 0x0f) << 12) | ((eptr[1] & 0x3f) << 6) | (eptr[2] & 0x3f); \
- else if ((c & 0x08) == 0) \
- c = ((c & 0x07) << 18) | ((eptr[1] & 0x3f) << 12) | \
- ((eptr[2] & 0x3f) << 6) | (eptr[3] & 0x3f); \
- else if ((c & 0x04) == 0) \
- c = ((c & 0x03) << 24) | ((eptr[1] & 0x3f) << 18) | \
- ((eptr[2] & 0x3f) << 12) | ((eptr[3] & 0x3f) << 6) | \
- (eptr[4] & 0x3f); \
- else \
- c = ((c & 0x01) << 30) | ((eptr[1] & 0x3f) << 24) | \
- ((eptr[2] & 0x3f) << 18) | ((eptr[3] & 0x3f) << 12) | \
- ((eptr[4] & 0x3f) << 6) | (eptr[5] & 0x3f); \
- }
-
-/* Base macro to pick up the remaining bytes of a UTF-8 character, advancing
-the pointer. */
-
-#define GETUTF8INC(c, eptr) \
- { \
- if ((c & 0x20) == 0) \
- c = ((c & 0x1f) << 6) | (*eptr++ & 0x3f); \
- else if ((c & 0x10) == 0) \
- { \
- c = ((c & 0x0f) << 12) | ((*eptr & 0x3f) << 6) | (eptr[1] & 0x3f); \
- eptr += 2; \
- } \
- else if ((c & 0x08) == 0) \
- { \
- c = ((c & 0x07) << 18) | ((*eptr & 0x3f) << 12) | \
- ((eptr[1] & 0x3f) << 6) | (eptr[2] & 0x3f); \
- eptr += 3; \
- } \
- else if ((c & 0x04) == 0) \
- { \
- c = ((c & 0x03) << 24) | ((*eptr & 0x3f) << 18) | \
- ((eptr[1] & 0x3f) << 12) | ((eptr[2] & 0x3f) << 6) | \
- (eptr[3] & 0x3f); \
- eptr += 4; \
- } \
- else \
- { \
- c = ((c & 0x01) << 30) | ((*eptr & 0x3f) << 24) | \
- ((eptr[1] & 0x3f) << 18) | ((eptr[2] & 0x3f) << 12) | \
- ((eptr[3] & 0x3f) << 6) | (eptr[4] & 0x3f); \
- eptr += 5; \
- } \
- }
-
-#if defined COMPILE_PCRE8
-
-/* These macros were originally written in the form of loops that used data
-from the tables whose names start with PRIV(utf8_table). They were rewritten by
-a user so as not to use loops, because in some environments this gives a
-significant performance advantage, and it seems never to do any harm. */
-
-/* Tells the biggest code point which can be encoded as a single character. */
-
-#define MAX_VALUE_FOR_SINGLE_CHAR 127
-
-/* Tests whether the code point needs extra characters to decode. */
-
-#define HAS_EXTRALEN(c) ((c) >= 0xc0)
-
-/* Returns with the additional number of characters if IS_MULTICHAR(c) is TRUE.
-Otherwise it has an undefined behaviour. */
-
-#define GET_EXTRALEN(c) (PRIV(utf8_table4)[(c) & 0x3f])
-
-/* Returns TRUE, if the given character is not the first character
-of a UTF sequence. */
-
-#define NOT_FIRSTCHAR(c) (((c) & 0xc0) == 0x80)
-
-/* Get the next UTF-8 character, not advancing the pointer. This is called when
-we know we are in UTF-8 mode. */
-
-#define GETCHAR(c, eptr) \
- c = *eptr; \
- if (c >= 0xc0) GETUTF8(c, eptr);
-
-/* Get the next UTF-8 character, testing for UTF-8 mode, and not advancing the
-pointer. */
-
-#define GETCHARTEST(c, eptr) \
- c = *eptr; \
- if (utf && c >= 0xc0) GETUTF8(c, eptr);
-
-/* Get the next UTF-8 character, advancing the pointer. This is called when we
-know we are in UTF-8 mode. */
-
-#define GETCHARINC(c, eptr) \
- c = *eptr++; \
- if (c >= 0xc0) GETUTF8INC(c, eptr);
-
-/* Get the next character, testing for UTF-8 mode, and advancing the pointer.
-This is called when we don't know if we are in UTF-8 mode. */
-
-#define GETCHARINCTEST(c, eptr) \
- c = *eptr++; \
- if (utf && c >= 0xc0) GETUTF8INC(c, eptr);
-
-/* Base macro to pick up the remaining bytes of a UTF-8 character, not
-advancing the pointer, incrementing the length. */
-
-#define GETUTF8LEN(c, eptr, len) \
- { \
- if ((c & 0x20) == 0) \
- { \
- c = ((c & 0x1f) << 6) | (eptr[1] & 0x3f); \
- len++; \
- } \
- else if ((c & 0x10) == 0) \
- { \
- c = ((c & 0x0f) << 12) | ((eptr[1] & 0x3f) << 6) | (eptr[2] & 0x3f); \
- len += 2; \
- } \
- else if ((c & 0x08) == 0) \
- {\
- c = ((c & 0x07) << 18) | ((eptr[1] & 0x3f) << 12) | \
- ((eptr[2] & 0x3f) << 6) | (eptr[3] & 0x3f); \
- len += 3; \
- } \
- else if ((c & 0x04) == 0) \
- { \
- c = ((c & 0x03) << 24) | ((eptr[1] & 0x3f) << 18) | \
- ((eptr[2] & 0x3f) << 12) | ((eptr[3] & 0x3f) << 6) | \
- (eptr[4] & 0x3f); \
- len += 4; \
- } \
- else \
- {\
- c = ((c & 0x01) << 30) | ((eptr[1] & 0x3f) << 24) | \
- ((eptr[2] & 0x3f) << 18) | ((eptr[3] & 0x3f) << 12) | \
- ((eptr[4] & 0x3f) << 6) | (eptr[5] & 0x3f); \
- len += 5; \
- } \
- }
-
-/* Get the next UTF-8 character, not advancing the pointer, incrementing length
-if there are extra bytes. This is called when we know we are in UTF-8 mode. */
-
-#define GETCHARLEN(c, eptr, len) \
- c = *eptr; \
- if (c >= 0xc0) GETUTF8LEN(c, eptr, len);
-
-/* Get the next UTF-8 character, testing for UTF-8 mode, not advancing the
-pointer, incrementing length if there are extra bytes. This is called when we
-do not know if we are in UTF-8 mode. */
-
-#define GETCHARLENTEST(c, eptr, len) \
- c = *eptr; \
- if (utf && c >= 0xc0) GETUTF8LEN(c, eptr, len);
-
-/* If the pointer is not at the start of a character, move it back until
-it is. This is called only in UTF-8 mode - we don't put a test within the macro
-because almost all calls are already within a block of UTF-8 only code. */
-
-#define BACKCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr--
-
-/* Same as above, just in the other direction. */
-#define FORWARDCHAR(eptr) while((*eptr & 0xc0) == 0x80) eptr++
-
-/* Same as above, but it allows a fully customizable form. */
-#define ACROSSCHAR(condition, eptr, action) \
- while((condition) && ((eptr) & 0xc0) == 0x80) action
-
-#elif defined COMPILE_PCRE16
-
-/* Tells the biggest code point which can be encoded as a single character. */
-
-#define MAX_VALUE_FOR_SINGLE_CHAR 65535
-
-/* Tests whether the code point needs extra characters to decode. */
-
-#define HAS_EXTRALEN(c) (((c) & 0xfc00) == 0xd800)
-
-/* Returns with the additional number of characters if IS_MULTICHAR(c) is TRUE.
-Otherwise it has an undefined behaviour. */
-
-#define GET_EXTRALEN(c) 1
-
-/* Returns TRUE, if the given character is not the first character
-of a UTF sequence. */
-
-#define NOT_FIRSTCHAR(c) (((c) & 0xfc00) == 0xdc00)
-
-/* Base macro to pick up the low surrogate of a UTF-16 character, not
-advancing the pointer. */
-
-#define GETUTF16(c, eptr) \
- { c = (((c & 0x3ff) << 10) | (eptr[1] & 0x3ff)) + 0x10000; }
-
-/* Get the next UTF-16 character, not advancing the pointer. This is called when
-we know we are in UTF-16 mode. */
-
-#define GETCHAR(c, eptr) \
- c = *eptr; \
- if ((c & 0xfc00) == 0xd800) GETUTF16(c, eptr);
-
-/* Get the next UTF-16 character, testing for UTF-16 mode, and not advancing the
-pointer. */
-
-#define GETCHARTEST(c, eptr) \
- c = *eptr; \
- if (utf && (c & 0xfc00) == 0xd800) GETUTF16(c, eptr);
-
-/* Base macro to pick up the low surrogate of a UTF-16 character, advancing
-the pointer. */
-
-#define GETUTF16INC(c, eptr) \
- { c = (((c & 0x3ff) << 10) | (*eptr++ & 0x3ff)) + 0x10000; }
-
-/* Get the next UTF-16 character, advancing the pointer. This is called when we
-know we are in UTF-16 mode. */
-
-#define GETCHARINC(c, eptr) \
- c = *eptr++; \
- if ((c & 0xfc00) == 0xd800) GETUTF16INC(c, eptr);
-
-/* Get the next character, testing for UTF-16 mode, and advancing the pointer.
-This is called when we don't know if we are in UTF-16 mode. */
-
-#define GETCHARINCTEST(c, eptr) \
- c = *eptr++; \
- if (utf && (c & 0xfc00) == 0xd800) GETUTF16INC(c, eptr);
-
-/* Base macro to pick up the low surrogate of a UTF-16 character, not
-advancing the pointer, incrementing the length. */
-
-#define GETUTF16LEN(c, eptr, len) \
- { c = (((c & 0x3ff) << 10) | (eptr[1] & 0x3ff)) + 0x10000; len++; }
-
-/* Get the next UTF-16 character, not advancing the pointer, incrementing
-length if there is a low surrogate. This is called when we know we are in
-UTF-16 mode. */
-
-#define GETCHARLEN(c, eptr, len) \
- c = *eptr; \
- if ((c & 0xfc00) == 0xd800) GETUTF16LEN(c, eptr, len);
-
-/* Get the next UTF-816character, testing for UTF-16 mode, not advancing the
-pointer, incrementing length if there is a low surrogate. This is called when
-we do not know if we are in UTF-16 mode. */
-
-#define GETCHARLENTEST(c, eptr, len) \
- c = *eptr; \
- if (utf && (c & 0xfc00) == 0xd800) GETUTF16LEN(c, eptr, len);
-
-/* If the pointer is not at the start of a character, move it back until
-it is. This is called only in UTF-16 mode - we don't put a test within the
-macro because almost all calls are already within a block of UTF-16 only
-code. */
-
-#define BACKCHAR(eptr) if ((*eptr & 0xfc00) == 0xdc00) eptr--
-
-/* Same as above, just in the other direction. */
-#define FORWARDCHAR(eptr) if ((*eptr & 0xfc00) == 0xdc00) eptr++
-
-/* Same as above, but it allows a fully customizable form. */
-#define ACROSSCHAR(condition, eptr, action) \
- if ((condition) && ((eptr) & 0xfc00) == 0xdc00) action
-
-#elif defined COMPILE_PCRE32
-
-/* These are trivial for the 32-bit library, since all UTF-32 characters fit
-into one pcre_uchar unit. */
-#define MAX_VALUE_FOR_SINGLE_CHAR (0x10ffffu)
-#define HAS_EXTRALEN(c) (0)
-#define GET_EXTRALEN(c) (0)
-#define NOT_FIRSTCHAR(c) (0)
-
-/* Get the next UTF-32 character, not advancing the pointer. This is called when
-we know we are in UTF-32 mode. */
-
-#define GETCHAR(c, eptr) \
- c = *(eptr);
-
-/* Get the next UTF-32 character, testing for UTF-32 mode, and not advancing the
-pointer. */
-
-#define GETCHARTEST(c, eptr) \
- c = *(eptr);
-
-/* Get the next UTF-32 character, advancing the pointer. This is called when we
-know we are in UTF-32 mode. */
-
-#define GETCHARINC(c, eptr) \
- c = *((eptr)++);
-
-/* Get the next character, testing for UTF-32 mode, and advancing the pointer.
-This is called when we don't know if we are in UTF-32 mode. */
-
-#define GETCHARINCTEST(c, eptr) \
- c = *((eptr)++);
-
-/* Get the next UTF-32 character, not advancing the pointer, not incrementing
-length (since all UTF-32 is of length 1). This is called when we know we are in
-UTF-32 mode. */
-
-#define GETCHARLEN(c, eptr, len) \
- GETCHAR(c, eptr)
-
-/* Get the next UTF-32character, testing for UTF-32 mode, not advancing the
-pointer, not incrementing the length (since all UTF-32 is of length 1).
-This is called when we do not know if we are in UTF-32 mode. */
-
-#define GETCHARLENTEST(c, eptr, len) \
- GETCHARTEST(c, eptr)
-
-/* If the pointer is not at the start of a character, move it back until
-it is. This is called only in UTF-32 mode - we don't put a test within the
-macro because almost all calls are already within a block of UTF-32 only
-code.
-These are all no-ops since all UTF-32 characters fit into one pcre_uchar. */
-
-#define BACKCHAR(eptr) do { } while (0)
-
-/* Same as above, just in the other direction. */
-#define FORWARDCHAR(eptr) do { } while (0)
-
-/* Same as above, but it allows a fully customizable form. */
-#define ACROSSCHAR(condition, eptr, action) do { } while (0)
-
-#else
-#error Unsupported compiling mode
-#endif /* COMPILE_PCRE[8|16|32] */
-
-#endif /* SUPPORT_UTF */
-
-/* Tests for Unicode horizontal and vertical whitespace characters must check a
-number of different values. Using a switch statement for this generates the
-fastest code (no loop, no memory access), and there are several places in the
-interpreter code where this happens. In order to ensure that all the case lists
-remain in step, we use macros so that there is only one place where the lists
-are defined.
-
-These values are also required as lists in pcre_compile.c when processing \h,
-\H, \v and \V in a character class. The lists are defined in pcre_tables.c, but
-macros that define the values are here so that all the definitions are
-together. The lists must be in ascending character order, terminated by
-NOTACHAR (which is 0xffffffff).
-
-Any changes should ensure that the various macros are kept in step with each
-other. NOTE: The values also appear in pcre_jit_compile.c. */
-
-/* ------ ASCII/Unicode environments ------ */
-
-#ifndef EBCDIC
-
-#define HSPACE_LIST \
- CHAR_HT, CHAR_SPACE, CHAR_NBSP, \
- 0x1680, 0x180e, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, \
- 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202f, 0x205f, 0x3000, \
- NOTACHAR
-
-#define HSPACE_MULTIBYTE_CASES \
- case 0x1680: /* OGHAM SPACE MARK */ \
- case 0x180e: /* MONGOLIAN VOWEL SEPARATOR */ \
- case 0x2000: /* EN QUAD */ \
- case 0x2001: /* EM QUAD */ \
- case 0x2002: /* EN SPACE */ \
- case 0x2003: /* EM SPACE */ \
- case 0x2004: /* THREE-PER-EM SPACE */ \
- case 0x2005: /* FOUR-PER-EM SPACE */ \
- case 0x2006: /* SIX-PER-EM SPACE */ \
- case 0x2007: /* FIGURE SPACE */ \
- case 0x2008: /* PUNCTUATION SPACE */ \
- case 0x2009: /* THIN SPACE */ \
- case 0x200A: /* HAIR SPACE */ \
- case 0x202f: /* NARROW NO-BREAK SPACE */ \
- case 0x205f: /* MEDIUM MATHEMATICAL SPACE */ \
- case 0x3000 /* IDEOGRAPHIC SPACE */
-
-#define HSPACE_BYTE_CASES \
- case CHAR_HT: \
- case CHAR_SPACE: \
- case CHAR_NBSP
-
-#define HSPACE_CASES \
- HSPACE_BYTE_CASES: \
- HSPACE_MULTIBYTE_CASES
-
-#define VSPACE_LIST \
- CHAR_LF, CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, 0x2028, 0x2029, NOTACHAR
-
-#define VSPACE_MULTIBYTE_CASES \
- case 0x2028: /* LINE SEPARATOR */ \
- case 0x2029 /* PARAGRAPH SEPARATOR */
-
-#define VSPACE_BYTE_CASES \
- case CHAR_LF: \
- case CHAR_VT: \
- case CHAR_FF: \
- case CHAR_CR: \
- case CHAR_NEL
-
-#define VSPACE_CASES \
- VSPACE_BYTE_CASES: \
- VSPACE_MULTIBYTE_CASES
-
-/* ------ EBCDIC environments ------ */
-
-#else
-#define HSPACE_LIST CHAR_HT, CHAR_SPACE, CHAR_NBSP, NOTACHAR
-
-#define HSPACE_BYTE_CASES \
- case CHAR_HT: \
- case CHAR_SPACE: \
- case CHAR_NBSP
-
-#define HSPACE_CASES HSPACE_BYTE_CASES
-
-#ifdef EBCDIC_NL25
-#define VSPACE_LIST \
- CHAR_VT, CHAR_FF, CHAR_CR, CHAR_NEL, CHAR_LF, NOTACHAR
-#else
-#define VSPACE_LIST \
- CHAR_VT, CHAR_FF, CHAR_CR, CHAR_LF, CHAR_NEL, NOTACHAR
-#endif
-
-#define VSPACE_BYTE_CASES \
- case CHAR_LF: \
- case CHAR_VT: \
- case CHAR_FF: \
- case CHAR_CR: \
- case CHAR_NEL
-
-#define VSPACE_CASES VSPACE_BYTE_CASES
-#endif /* EBCDIC */
-
-/* ------ End of whitespace macros ------ */
-
-
-
-/* Private flags containing information about the compiled regex. They used to
-live at the top end of the options word, but that got almost full, so they were
-moved to a 16-bit flags word - which got almost full, so now they are in a
-32-bit flags word. From release 8.00, PCRE_NOPARTIAL is unused, as the
-restrictions on partial matching have been lifted. It remains for backwards
-compatibility. */
-
-#define PCRE_MODE8 0x00000001 /* compiled in 8 bit mode */
-#define PCRE_MODE16 0x00000002 /* compiled in 16 bit mode */
-#define PCRE_MODE32 0x00000004 /* compiled in 32 bit mode */
-#define PCRE_FIRSTSET 0x00000010 /* first_char is set */
-#define PCRE_FCH_CASELESS 0x00000020 /* caseless first char */
-#define PCRE_REQCHSET 0x00000040 /* req_byte is set */
-#define PCRE_RCH_CASELESS 0x00000080 /* caseless requested char */
-#define PCRE_STARTLINE 0x00000100 /* start after \n for multiline */
-#define PCRE_NOPARTIAL 0x00000200 /* can't use partial with this regex */
-#define PCRE_JCHANGED 0x00000400 /* j option used in regex */
-#define PCRE_HASCRORLF 0x00000800 /* explicit \r or \n in pattern */
-#define PCRE_HASTHEN 0x00001000 /* pattern contains (*THEN) */
-#define PCRE_MLSET 0x00002000 /* match limit set by regex */
-#define PCRE_RLSET 0x00004000 /* recursion limit set by regex */
-#define PCRE_MATCH_EMPTY 0x00008000 /* pattern can match empty string */
-
-#if defined COMPILE_PCRE8
-#define PCRE_MODE PCRE_MODE8
-#elif defined COMPILE_PCRE16
-#define PCRE_MODE PCRE_MODE16
-#elif defined COMPILE_PCRE32
-#define PCRE_MODE PCRE_MODE32
-#endif
-#define PCRE_MODE_MASK (PCRE_MODE8 | PCRE_MODE16 | PCRE_MODE32)
-
-/* Flags for the "extra" block produced by pcre_study(). */
-
-#define PCRE_STUDY_MAPPED 0x0001 /* a map of starting chars exists */
-#define PCRE_STUDY_MINLEN 0x0002 /* a minimum length field exists */
-
-/* Masks for identifying the public options that are permitted at compile
-time, run time, or study time, respectively. */
-
-#define PCRE_NEWLINE_BITS (PCRE_NEWLINE_CR|PCRE_NEWLINE_LF|PCRE_NEWLINE_ANY| \
- PCRE_NEWLINE_ANYCRLF)
-
-#define PUBLIC_COMPILE_OPTIONS \
- (PCRE_CASELESS|PCRE_EXTENDED|PCRE_ANCHORED|PCRE_MULTILINE| \
- PCRE_DOTALL|PCRE_DOLLAR_ENDONLY|PCRE_EXTRA|PCRE_UNGREEDY|PCRE_UTF8| \
- PCRE_NO_AUTO_CAPTURE|PCRE_NO_AUTO_POSSESS| \
- PCRE_NO_UTF8_CHECK|PCRE_AUTO_CALLOUT|PCRE_FIRSTLINE| \
- PCRE_DUPNAMES|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
- PCRE_JAVASCRIPT_COMPAT|PCRE_UCP|PCRE_NO_START_OPTIMIZE|PCRE_NEVER_UTF)
-
-#define PUBLIC_EXEC_OPTIONS \
- (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NOTEMPTY_ATSTART| \
- PCRE_NO_UTF8_CHECK|PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT|PCRE_NEWLINE_BITS| \
- PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE|PCRE_NO_START_OPTIMIZE)
-
-#define PUBLIC_DFA_EXEC_OPTIONS \
- (PCRE_ANCHORED|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|PCRE_NOTEMPTY_ATSTART| \
- PCRE_NO_UTF8_CHECK|PCRE_PARTIAL_HARD|PCRE_PARTIAL_SOFT|PCRE_DFA_SHORTEST| \
- PCRE_DFA_RESTART|PCRE_NEWLINE_BITS|PCRE_BSR_ANYCRLF|PCRE_BSR_UNICODE| \
- PCRE_NO_START_OPTIMIZE)
-
-#define PUBLIC_STUDY_OPTIONS \
- (PCRE_STUDY_JIT_COMPILE|PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE| \
- PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE|PCRE_STUDY_EXTRA_NEEDED)
-
-#define PUBLIC_JIT_EXEC_OPTIONS \
- (PCRE_NO_UTF8_CHECK|PCRE_NOTBOL|PCRE_NOTEOL|PCRE_NOTEMPTY|\
- PCRE_NOTEMPTY_ATSTART|PCRE_PARTIAL_SOFT|PCRE_PARTIAL_HARD)
-
-/* Magic number to provide a small check against being handed junk. */
-
-#define MAGIC_NUMBER 0x50435245UL /* 'PCRE' */
-
-/* This variable is used to detect a loaded regular expression
-in different endianness. */
-
-#define REVERSED_MAGIC_NUMBER 0x45524350UL /* 'ERCP' */
-
-/* The maximum remaining length of subject we are prepared to search for a
-req_byte match. */
-
-#define REQ_BYTE_MAX 1000
-
-/* Miscellaneous definitions. The #ifndef is to pacify compiler warnings in
-environments where these macros are defined elsewhere. Unfortunately, there
-is no way to do the same for the typedef. */
-
-typedef int BOOL;
-
-#ifndef FALSE
-#define FALSE 0
-#define TRUE 1
-#endif
-
-/* If PCRE is to support UTF-8 on EBCDIC platforms, we cannot use normal
-character constants like '*' because the compiler would emit their EBCDIC code,
-which is different from their ASCII/UTF-8 code. Instead we define macros for
-the characters so that they always use the ASCII/UTF-8 code when UTF-8 support
-is enabled. When UTF-8 support is not enabled, the definitions use character
-literals. Both character and string versions of each character are needed, and
-there are some longer strings as well.
-
-This means that, on EBCDIC platforms, the PCRE library can handle either
-EBCDIC, or UTF-8, but not both. To support both in the same compiled library
-would need different lookups depending on whether PCRE_UTF8 was set or not.
-This would make it impossible to use characters in switch/case statements,
-which would reduce performance. For a theoretical use (which nobody has asked
-for) in a minority area (EBCDIC platforms), this is not sensible. Any
-application that did need both could compile two versions of the library, using
-macros to give the functions distinct names. */
-
-#ifndef SUPPORT_UTF
-
-/* UTF-8 support is not enabled; use the platform-dependent character literals
-so that PCRE works in both ASCII and EBCDIC environments, but only in non-UTF
-mode. Newline characters are problematic in EBCDIC. Though it has CR and LF
-characters, a common practice has been to use its NL (0x15) character as the
-line terminator in C-like processing environments. However, sometimes the LF
-(0x25) character is used instead, according to this Unicode document:
-
-http://unicode.org/standard/reports/tr13/tr13-5.html
-
-PCRE defaults EBCDIC NL to 0x15, but has a build-time option to select 0x25
-instead. Whichever is *not* chosen is defined as NEL.
-
-In both ASCII and EBCDIC environments, CHAR_NL and CHAR_LF are synonyms for the
-same code point. */
-
-#ifdef EBCDIC
-
-#ifndef EBCDIC_NL25
-#define CHAR_NL '\x15'
-#define CHAR_NEL '\x25'
-#define STR_NL "\x15"
-#define STR_NEL "\x25"
-#else
-#define CHAR_NL '\x25'
-#define CHAR_NEL '\x15'
-#define STR_NL "\x25"
-#define STR_NEL "\x15"
-#endif
-
-#define CHAR_LF CHAR_NL
-#define STR_LF STR_NL
-
-#define CHAR_ESC '\047'
-#define CHAR_DEL '\007'
-#define CHAR_NBSP '\x41'
-#define STR_ESC "\047"
-#define STR_DEL "\007"
-
-#else /* Not EBCDIC */
-
-/* In ASCII/Unicode, linefeed is '\n' and we equate this to NL for
-compatibility. NEL is the Unicode newline character; make sure it is
-a positive value. */
-
-#define CHAR_LF '\n'
-#define CHAR_NL CHAR_LF
-#define CHAR_NEL ((unsigned char)'\x85')
-#define CHAR_ESC '\033'
-#define CHAR_DEL '\177'
-#define CHAR_NBSP ((unsigned char)'\xa0')
-
-#define STR_LF "\n"
-#define STR_NL STR_LF
-#define STR_NEL "\x85"
-#define STR_ESC "\033"
-#define STR_DEL "\177"
-
-#endif /* EBCDIC */
-
-/* The remaining definitions work in both environments. */
-
-#define CHAR_NULL '\0'
-#define CHAR_HT '\t'
-#define CHAR_VT '\v'
-#define CHAR_FF '\f'
-#define CHAR_CR '\r'
-#define CHAR_BS '\b'
-#define CHAR_BEL '\a'
-
-#define CHAR_SPACE ' '
-#define CHAR_EXCLAMATION_MARK '!'
-#define CHAR_QUOTATION_MARK '"'
-#define CHAR_NUMBER_SIGN '#'
-#define CHAR_DOLLAR_SIGN '$'
-#define CHAR_PERCENT_SIGN '%'
-#define CHAR_AMPERSAND '&'
-#define CHAR_APOSTROPHE '\''
-#define CHAR_LEFT_PARENTHESIS '('
-#define CHAR_RIGHT_PARENTHESIS ')'
-#define CHAR_ASTERISK '*'
-#define CHAR_PLUS '+'
-#define CHAR_COMMA ','
-#define CHAR_MINUS '-'
-#define CHAR_DOT '.'
-#define CHAR_SLASH '/'
-#define CHAR_0 '0'
-#define CHAR_1 '1'
-#define CHAR_2 '2'
-#define CHAR_3 '3'
-#define CHAR_4 '4'
-#define CHAR_5 '5'
-#define CHAR_6 '6'
-#define CHAR_7 '7'
-#define CHAR_8 '8'
-#define CHAR_9 '9'
-#define CHAR_COLON ':'
-#define CHAR_SEMICOLON ';'
-#define CHAR_LESS_THAN_SIGN '<'
-#define CHAR_EQUALS_SIGN '='
-#define CHAR_GREATER_THAN_SIGN '>'
-#define CHAR_QUESTION_MARK '?'
-#define CHAR_COMMERCIAL_AT '@'
-#define CHAR_A 'A'
-#define CHAR_B 'B'
-#define CHAR_C 'C'
-#define CHAR_D 'D'
-#define CHAR_E 'E'
-#define CHAR_F 'F'
-#define CHAR_G 'G'
-#define CHAR_H 'H'
-#define CHAR_I 'I'
-#define CHAR_J 'J'
-#define CHAR_K 'K'
-#define CHAR_L 'L'
-#define CHAR_M 'M'
-#define CHAR_N 'N'
-#define CHAR_O 'O'
-#define CHAR_P 'P'
-#define CHAR_Q 'Q'
-#define CHAR_R 'R'
-#define CHAR_S 'S'
-#define CHAR_T 'T'
-#define CHAR_U 'U'
-#define CHAR_V 'V'
-#define CHAR_W 'W'
-#define CHAR_X 'X'
-#define CHAR_Y 'Y'
-#define CHAR_Z 'Z'
-#define CHAR_LEFT_SQUARE_BRACKET '['
-#define CHAR_BACKSLASH '\\'
-#define CHAR_RIGHT_SQUARE_BRACKET ']'
-#define CHAR_CIRCUMFLEX_ACCENT '^'
-#define CHAR_UNDERSCORE '_'
-#define CHAR_GRAVE_ACCENT '`'
-#define CHAR_a 'a'
-#define CHAR_b 'b'
-#define CHAR_c 'c'
-#define CHAR_d 'd'
-#define CHAR_e 'e'
-#define CHAR_f 'f'
-#define CHAR_g 'g'
-#define CHAR_h 'h'
-#define CHAR_i 'i'
-#define CHAR_j 'j'
-#define CHAR_k 'k'
-#define CHAR_l 'l'
-#define CHAR_m 'm'
-#define CHAR_n 'n'
-#define CHAR_o 'o'
-#define CHAR_p 'p'
-#define CHAR_q 'q'
-#define CHAR_r 'r'
-#define CHAR_s 's'
-#define CHAR_t 't'
-#define CHAR_u 'u'
-#define CHAR_v 'v'
-#define CHAR_w 'w'
-#define CHAR_x 'x'
-#define CHAR_y 'y'
-#define CHAR_z 'z'
-#define CHAR_LEFT_CURLY_BRACKET '{'
-#define CHAR_VERTICAL_LINE '|'
-#define CHAR_RIGHT_CURLY_BRACKET '}'
-#define CHAR_TILDE '~'
-
-#define STR_HT "\t"
-#define STR_VT "\v"
-#define STR_FF "\f"
-#define STR_CR "\r"
-#define STR_BS "\b"
-#define STR_BEL "\a"
-
-#define STR_SPACE " "
-#define STR_EXCLAMATION_MARK "!"
-#define STR_QUOTATION_MARK "\""
-#define STR_NUMBER_SIGN "#"
-#define STR_DOLLAR_SIGN "$"
-#define STR_PERCENT_SIGN "%"
-#define STR_AMPERSAND "&"
-#define STR_APOSTROPHE "'"
-#define STR_LEFT_PARENTHESIS "("
-#define STR_RIGHT_PARENTHESIS ")"
-#define STR_ASTERISK "*"
-#define STR_PLUS "+"
-#define STR_COMMA ","
-#define STR_MINUS "-"
-#define STR_DOT "."
-#define STR_SLASH "/"
-#define STR_0 "0"
-#define STR_1 "1"
-#define STR_2 "2"
-#define STR_3 "3"
-#define STR_4 "4"
-#define STR_5 "5"
-#define STR_6 "6"
-#define STR_7 "7"
-#define STR_8 "8"
-#define STR_9 "9"
-#define STR_COLON ":"
-#define STR_SEMICOLON ";"
-#define STR_LESS_THAN_SIGN "<"
-#define STR_EQUALS_SIGN "="
-#define STR_GREATER_THAN_SIGN ">"
-#define STR_QUESTION_MARK "?"
-#define STR_COMMERCIAL_AT "@"
-#define STR_A "A"
-#define STR_B "B"
-#define STR_C "C"
-#define STR_D "D"
-#define STR_E "E"
-#define STR_F "F"
-#define STR_G "G"
-#define STR_H "H"
-#define STR_I "I"
-#define STR_J "J"
-#define STR_K "K"
-#define STR_L "L"
-#define STR_M "M"
-#define STR_N "N"
-#define STR_O "O"
-#define STR_P "P"
-#define STR_Q "Q"
-#define STR_R "R"
-#define STR_S "S"
-#define STR_T "T"
-#define STR_U "U"
-#define STR_V "V"
-#define STR_W "W"
-#define STR_X "X"
-#define STR_Y "Y"
-#define STR_Z "Z"
-#define STR_LEFT_SQUARE_BRACKET "["
-#define STR_BACKSLASH "\\"
-#define STR_RIGHT_SQUARE_BRACKET "]"
-#define STR_CIRCUMFLEX_ACCENT "^"
-#define STR_UNDERSCORE "_"
-#define STR_GRAVE_ACCENT "`"
-#define STR_a "a"
-#define STR_b "b"
-#define STR_c "c"
-#define STR_d "d"
-#define STR_e "e"
-#define STR_f "f"
-#define STR_g "g"
-#define STR_h "h"
-#define STR_i "i"
-#define STR_j "j"
-#define STR_k "k"
-#define STR_l "l"
-#define STR_m "m"
-#define STR_n "n"
-#define STR_o "o"
-#define STR_p "p"
-#define STR_q "q"
-#define STR_r "r"
-#define STR_s "s"
-#define STR_t "t"
-#define STR_u "u"
-#define STR_v "v"
-#define STR_w "w"
-#define STR_x "x"
-#define STR_y "y"
-#define STR_z "z"
-#define STR_LEFT_CURLY_BRACKET "{"
-#define STR_VERTICAL_LINE "|"
-#define STR_RIGHT_CURLY_BRACKET "}"
-#define STR_TILDE "~"
-
-#define STRING_ACCEPT0 "ACCEPT\0"
-#define STRING_COMMIT0 "COMMIT\0"
-#define STRING_F0 "F\0"
-#define STRING_FAIL0 "FAIL\0"
-#define STRING_MARK0 "MARK\0"
-#define STRING_PRUNE0 "PRUNE\0"
-#define STRING_SKIP0 "SKIP\0"
-#define STRING_THEN "THEN"
-
-#define STRING_alpha0 "alpha\0"
-#define STRING_lower0 "lower\0"
-#define STRING_upper0 "upper\0"
-#define STRING_alnum0 "alnum\0"
-#define STRING_ascii0 "ascii\0"
-#define STRING_blank0 "blank\0"
-#define STRING_cntrl0 "cntrl\0"
-#define STRING_digit0 "digit\0"
-#define STRING_graph0 "graph\0"
-#define STRING_print0 "print\0"
-#define STRING_punct0 "punct\0"
-#define STRING_space0 "space\0"
-#define STRING_word0 "word\0"
-#define STRING_xdigit "xdigit"
-
-#define STRING_DEFINE "DEFINE"
-#define STRING_WEIRD_STARTWORD "[:<:]]"
-#define STRING_WEIRD_ENDWORD "[:>:]]"
-
-#define STRING_CR_RIGHTPAR "CR)"
-#define STRING_LF_RIGHTPAR "LF)"
-#define STRING_CRLF_RIGHTPAR "CRLF)"
-#define STRING_ANY_RIGHTPAR "ANY)"
-#define STRING_ANYCRLF_RIGHTPAR "ANYCRLF)"
-#define STRING_BSR_ANYCRLF_RIGHTPAR "BSR_ANYCRLF)"
-#define STRING_BSR_UNICODE_RIGHTPAR "BSR_UNICODE)"
-#define STRING_UTF8_RIGHTPAR "UTF8)"
-#define STRING_UTF16_RIGHTPAR "UTF16)"
-#define STRING_UTF32_RIGHTPAR "UTF32)"
-#define STRING_UTF_RIGHTPAR "UTF)"
-#define STRING_UCP_RIGHTPAR "UCP)"
-#define STRING_NO_AUTO_POSSESS_RIGHTPAR "NO_AUTO_POSSESS)"
-#define STRING_NO_START_OPT_RIGHTPAR "NO_START_OPT)"
-#define STRING_LIMIT_MATCH_EQ "LIMIT_MATCH="
-#define STRING_LIMIT_RECURSION_EQ "LIMIT_RECURSION="
-
-#else /* SUPPORT_UTF */
-
-/* UTF-8 support is enabled; always use UTF-8 (=ASCII) character codes. This
-works in both modes non-EBCDIC platforms, and on EBCDIC platforms in UTF-8 mode
-only. */
-
-#define CHAR_HT '\011'
-#define CHAR_VT '\013'
-#define CHAR_FF '\014'
-#define CHAR_CR '\015'
-#define CHAR_LF '\012'
-#define CHAR_NL CHAR_LF
-#define CHAR_NEL ((unsigned char)'\x85')
-#define CHAR_BS '\010'
-#define CHAR_BEL '\007'
-#define CHAR_ESC '\033'
-#define CHAR_DEL '\177'
-
-#define CHAR_NULL '\0'
-#define CHAR_SPACE '\040'
-#define CHAR_EXCLAMATION_MARK '\041'
-#define CHAR_QUOTATION_MARK '\042'
-#define CHAR_NUMBER_SIGN '\043'
-#define CHAR_DOLLAR_SIGN '\044'
-#define CHAR_PERCENT_SIGN '\045'
-#define CHAR_AMPERSAND '\046'
-#define CHAR_APOSTROPHE '\047'
-#define CHAR_LEFT_PARENTHESIS '\050'
-#define CHAR_RIGHT_PARENTHESIS '\051'
-#define CHAR_ASTERISK '\052'
-#define CHAR_PLUS '\053'
-#define CHAR_COMMA '\054'
-#define CHAR_MINUS '\055'
-#define CHAR_DOT '\056'
-#define CHAR_SLASH '\057'
-#define CHAR_0 '\060'
-#define CHAR_1 '\061'
-#define CHAR_2 '\062'
-#define CHAR_3 '\063'
-#define CHAR_4 '\064'
-#define CHAR_5 '\065'
-#define CHAR_6 '\066'
-#define CHAR_7 '\067'
-#define CHAR_8 '\070'
-#define CHAR_9 '\071'
-#define CHAR_COLON '\072'
-#define CHAR_SEMICOLON '\073'
-#define CHAR_LESS_THAN_SIGN '\074'
-#define CHAR_EQUALS_SIGN '\075'
-#define CHAR_GREATER_THAN_SIGN '\076'
-#define CHAR_QUESTION_MARK '\077'
-#define CHAR_COMMERCIAL_AT '\100'
-#define CHAR_A '\101'
-#define CHAR_B '\102'
-#define CHAR_C '\103'
-#define CHAR_D '\104'
-#define CHAR_E '\105'
-#define CHAR_F '\106'
-#define CHAR_G '\107'
-#define CHAR_H '\110'
-#define CHAR_I '\111'
-#define CHAR_J '\112'
-#define CHAR_K '\113'
-#define CHAR_L '\114'
-#define CHAR_M '\115'
-#define CHAR_N '\116'
-#define CHAR_O '\117'
-#define CHAR_P '\120'
-#define CHAR_Q '\121'
-#define CHAR_R '\122'
-#define CHAR_S '\123'
-#define CHAR_T '\124'
-#define CHAR_U '\125'
-#define CHAR_V '\126'
-#define CHAR_W '\127'
-#define CHAR_X '\130'
-#define CHAR_Y '\131'
-#define CHAR_Z '\132'
-#define CHAR_LEFT_SQUARE_BRACKET '\133'
-#define CHAR_BACKSLASH '\134'
-#define CHAR_RIGHT_SQUARE_BRACKET '\135'
-#define CHAR_CIRCUMFLEX_ACCENT '\136'
-#define CHAR_UNDERSCORE '\137'
-#define CHAR_GRAVE_ACCENT '\140'
-#define CHAR_a '\141'
-#define CHAR_b '\142'
-#define CHAR_c '\143'
-#define CHAR_d '\144'
-#define CHAR_e '\145'
-#define CHAR_f '\146'
-#define CHAR_g '\147'
-#define CHAR_h '\150'
-#define CHAR_i '\151'
-#define CHAR_j '\152'
-#define CHAR_k '\153'
-#define CHAR_l '\154'
-#define CHAR_m '\155'
-#define CHAR_n '\156'
-#define CHAR_o '\157'
-#define CHAR_p '\160'
-#define CHAR_q '\161'
-#define CHAR_r '\162'
-#define CHAR_s '\163'
-#define CHAR_t '\164'
-#define CHAR_u '\165'
-#define CHAR_v '\166'
-#define CHAR_w '\167'
-#define CHAR_x '\170'
-#define CHAR_y '\171'
-#define CHAR_z '\172'
-#define CHAR_LEFT_CURLY_BRACKET '\173'
-#define CHAR_VERTICAL_LINE '\174'
-#define CHAR_RIGHT_CURLY_BRACKET '\175'
-#define CHAR_TILDE '\176'
-#define CHAR_NBSP ((unsigned char)'\xa0')
-
-#define STR_HT "\011"
-#define STR_VT "\013"
-#define STR_FF "\014"
-#define STR_CR "\015"
-#define STR_NL "\012"
-#define STR_BS "\010"
-#define STR_BEL "\007"
-#define STR_ESC "\033"
-#define STR_DEL "\177"
-
-#define STR_SPACE "\040"
-#define STR_EXCLAMATION_MARK "\041"
-#define STR_QUOTATION_MARK "\042"
-#define STR_NUMBER_SIGN "\043"
-#define STR_DOLLAR_SIGN "\044"
-#define STR_PERCENT_SIGN "\045"
-#define STR_AMPERSAND "\046"
-#define STR_APOSTROPHE "\047"
-#define STR_LEFT_PARENTHESIS "\050"
-#define STR_RIGHT_PARENTHESIS "\051"
-#define STR_ASTERISK "\052"
-#define STR_PLUS "\053"
-#define STR_COMMA "\054"
-#define STR_MINUS "\055"
-#define STR_DOT "\056"
-#define STR_SLASH "\057"
-#define STR_0 "\060"
-#define STR_1 "\061"
-#define STR_2 "\062"
-#define STR_3 "\063"
-#define STR_4 "\064"
-#define STR_5 "\065"
-#define STR_6 "\066"
-#define STR_7 "\067"
-#define STR_8 "\070"
-#define STR_9 "\071"
-#define STR_COLON "\072"
-#define STR_SEMICOLON "\073"
-#define STR_LESS_THAN_SIGN "\074"
-#define STR_EQUALS_SIGN "\075"
-#define STR_GREATER_THAN_SIGN "\076"
-#define STR_QUESTION_MARK "\077"
-#define STR_COMMERCIAL_AT "\100"
-#define STR_A "\101"
-#define STR_B "\102"
-#define STR_C "\103"
-#define STR_D "\104"
-#define STR_E "\105"
-#define STR_F "\106"
-#define STR_G "\107"
-#define STR_H "\110"
-#define STR_I "\111"
-#define STR_J "\112"
-#define STR_K "\113"
-#define STR_L "\114"
-#define STR_M "\115"
-#define STR_N "\116"
-#define STR_O "\117"
-#define STR_P "\120"
-#define STR_Q "\121"
-#define STR_R "\122"
-#define STR_S "\123"
-#define STR_T "\124"
-#define STR_U "\125"
-#define STR_V "\126"
-#define STR_W "\127"
-#define STR_X "\130"
-#define STR_Y "\131"
-#define STR_Z "\132"
-#define STR_LEFT_SQUARE_BRACKET "\133"
-#define STR_BACKSLASH "\134"
-#define STR_RIGHT_SQUARE_BRACKET "\135"
-#define STR_CIRCUMFLEX_ACCENT "\136"
-#define STR_UNDERSCORE "\137"
-#define STR_GRAVE_ACCENT "\140"
-#define STR_a "\141"
-#define STR_b "\142"
-#define STR_c "\143"
-#define STR_d "\144"
-#define STR_e "\145"
-#define STR_f "\146"
-#define STR_g "\147"
-#define STR_h "\150"
-#define STR_i "\151"
-#define STR_j "\152"
-#define STR_k "\153"
-#define STR_l "\154"
-#define STR_m "\155"
-#define STR_n "\156"
-#define STR_o "\157"
-#define STR_p "\160"
-#define STR_q "\161"
-#define STR_r "\162"
-#define STR_s "\163"
-#define STR_t "\164"
-#define STR_u "\165"
-#define STR_v "\166"
-#define STR_w "\167"
-#define STR_x "\170"
-#define STR_y "\171"
-#define STR_z "\172"
-#define STR_LEFT_CURLY_BRACKET "\173"
-#define STR_VERTICAL_LINE "\174"
-#define STR_RIGHT_CURLY_BRACKET "\175"
-#define STR_TILDE "\176"
-
-#define STRING_ACCEPT0 STR_A STR_C STR_C STR_E STR_P STR_T "\0"
-#define STRING_COMMIT0 STR_C STR_O STR_M STR_M STR_I STR_T "\0"
-#define STRING_F0 STR_F "\0"
-#define STRING_FAIL0 STR_F STR_A STR_I STR_L "\0"
-#define STRING_MARK0 STR_M STR_A STR_R STR_K "\0"
-#define STRING_PRUNE0 STR_P STR_R STR_U STR_N STR_E "\0"
-#define STRING_SKIP0 STR_S STR_K STR_I STR_P "\0"
-#define STRING_THEN STR_T STR_H STR_E STR_N
-
-#define STRING_alpha0 STR_a STR_l STR_p STR_h STR_a "\0"
-#define STRING_lower0 STR_l STR_o STR_w STR_e STR_r "\0"
-#define STRING_upper0 STR_u STR_p STR_p STR_e STR_r "\0"
-#define STRING_alnum0 STR_a STR_l STR_n STR_u STR_m "\0"
-#define STRING_ascii0 STR_a STR_s STR_c STR_i STR_i "\0"
-#define STRING_blank0 STR_b STR_l STR_a STR_n STR_k "\0"
-#define STRING_cntrl0 STR_c STR_n STR_t STR_r STR_l "\0"
-#define STRING_digit0 STR_d STR_i STR_g STR_i STR_t "\0"
-#define STRING_graph0 STR_g STR_r STR_a STR_p STR_h "\0"
-#define STRING_print0 STR_p STR_r STR_i STR_n STR_t "\0"
-#define STRING_punct0 STR_p STR_u STR_n STR_c STR_t "\0"
-#define STRING_space0 STR_s STR_p STR_a STR_c STR_e "\0"
-#define STRING_word0 STR_w STR_o STR_r STR_d "\0"
-#define STRING_xdigit STR_x STR_d STR_i STR_g STR_i STR_t
-
-#define STRING_DEFINE STR_D STR_E STR_F STR_I STR_N STR_E
-#define STRING_WEIRD_STARTWORD STR_LEFT_SQUARE_BRACKET STR_COLON STR_LESS_THAN_SIGN STR_COLON STR_RIGHT_SQUARE_BRACKET STR_RIGHT_SQUARE_BRACKET
-#define STRING_WEIRD_ENDWORD STR_LEFT_SQUARE_BRACKET STR_COLON STR_GREATER_THAN_SIGN STR_COLON STR_RIGHT_SQUARE_BRACKET STR_RIGHT_SQUARE_BRACKET
-
-#define STRING_CR_RIGHTPAR STR_C STR_R STR_RIGHT_PARENTHESIS
-#define STRING_LF_RIGHTPAR STR_L STR_F STR_RIGHT_PARENTHESIS
-#define STRING_CRLF_RIGHTPAR STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
-#define STRING_ANY_RIGHTPAR STR_A STR_N STR_Y STR_RIGHT_PARENTHESIS
-#define STRING_ANYCRLF_RIGHTPAR STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
-#define STRING_BSR_ANYCRLF_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_A STR_N STR_Y STR_C STR_R STR_L STR_F STR_RIGHT_PARENTHESIS
-#define STRING_BSR_UNICODE_RIGHTPAR STR_B STR_S STR_R STR_UNDERSCORE STR_U STR_N STR_I STR_C STR_O STR_D STR_E STR_RIGHT_PARENTHESIS
-#define STRING_UTF8_RIGHTPAR STR_U STR_T STR_F STR_8 STR_RIGHT_PARENTHESIS
-#define STRING_UTF16_RIGHTPAR STR_U STR_T STR_F STR_1 STR_6 STR_RIGHT_PARENTHESIS
-#define STRING_UTF32_RIGHTPAR STR_U STR_T STR_F STR_3 STR_2 STR_RIGHT_PARENTHESIS
-#define STRING_UTF_RIGHTPAR STR_U STR_T STR_F STR_RIGHT_PARENTHESIS
-#define STRING_UCP_RIGHTPAR STR_U STR_C STR_P STR_RIGHT_PARENTHESIS
-#define STRING_NO_AUTO_POSSESS_RIGHTPAR STR_N STR_O STR_UNDERSCORE STR_A STR_U STR_T STR_O STR_UNDERSCORE STR_P STR_O STR_S STR_S STR_E STR_S STR_S STR_RIGHT_PARENTHESIS
-#define STRING_NO_START_OPT_RIGHTPAR STR_N STR_O STR_UNDERSCORE STR_S STR_T STR_A STR_R STR_T STR_UNDERSCORE STR_O STR_P STR_T STR_RIGHT_PARENTHESIS
-#define STRING_LIMIT_MATCH_EQ STR_L STR_I STR_M STR_I STR_T STR_UNDERSCORE STR_M STR_A STR_T STR_C STR_H STR_EQUALS_SIGN
-#define STRING_LIMIT_RECURSION_EQ STR_L STR_I STR_M STR_I STR_T STR_UNDERSCORE STR_R STR_E STR_C STR_U STR_R STR_S STR_I STR_O STR_N STR_EQUALS_SIGN
-
-#endif /* SUPPORT_UTF */
-
-/* Escape items that are just an encoding of a particular data value. */
-
-#ifndef ESC_a
-#define ESC_a CHAR_BEL
-#endif
-
-#ifndef ESC_e
-#define ESC_e CHAR_ESC
-#endif
-
-#ifndef ESC_f
-#define ESC_f CHAR_FF
-#endif
-
-#ifndef ESC_n
-#define ESC_n CHAR_LF
-#endif
-
-#ifndef ESC_r
-#define ESC_r CHAR_CR
-#endif
-
-/* We can't officially use ESC_t because it is a POSIX reserved identifier
-(presumably because of all the others like size_t). */
-
-#ifndef ESC_tee
-#define ESC_tee CHAR_HT
-#endif
-
-/* Codes for different types of Unicode property */
-
-#define PT_ANY 0 /* Any property - matches all chars */
-#define PT_LAMP 1 /* L& - the union of Lu, Ll, Lt */
-#define PT_GC 2 /* Specified general characteristic (e.g. L) */
-#define PT_PC 3 /* Specified particular characteristic (e.g. Lu) */
-#define PT_SC 4 /* Script (e.g. Han) */
-#define PT_ALNUM 5 /* Alphanumeric - the union of L and N */
-#define PT_SPACE 6 /* Perl space - Z plus 9,10,12,13 */
-#define PT_PXSPACE 7 /* POSIX space - Z plus 9,10,11,12,13 */
-#define PT_WORD 8 /* Word - L plus N plus underscore */
-#define PT_CLIST 9 /* Pseudo-property: match character list */
-#define PT_UCNC 10 /* Universal Character nameable character */
-#define PT_TABSIZE 11 /* Size of square table for autopossessify tests */
-
-/* The following special properties are used only in XCLASS items, when POSIX
-classes are specified and PCRE_UCP is set - in other words, for Unicode
-handling of these classes. They are not available via the \p or \P escapes like
-those in the above list, and so they do not take part in the autopossessifying
-table. */
-
-#define PT_PXGRAPH 11 /* [:graph:] - characters that mark the paper */
-#define PT_PXPRINT 12 /* [:print:] - [:graph:] plus non-control spaces */
-#define PT_PXPUNCT 13 /* [:punct:] - punctuation characters */
-
-/* Flag bits and data types for the extended class (OP_XCLASS) for classes that
-contain characters with values greater than 255. */
-
-#define XCL_NOT 0x01 /* Flag: this is a negative class */
-#define XCL_MAP 0x02 /* Flag: a 32-byte map is present */
-#define XCL_HASPROP 0x04 /* Flag: property checks are present. */
-
-#define XCL_END 0 /* Marks end of individual items */
-#define XCL_SINGLE 1 /* Single item (one multibyte char) follows */
-#define XCL_RANGE 2 /* A range (two multibyte chars) follows */
-#define XCL_PROP 3 /* Unicode property (2-byte property code follows) */
-#define XCL_NOTPROP 4 /* Unicode inverted property (ditto) */
-
-/* These are escaped items that aren't just an encoding of a particular data
-value such as \n. They must have non-zero values, as check_escape() returns 0
-for a data character. Also, they must appear in the same order as in the
-opcode definitions below, up to ESC_z. There's a dummy for OP_ALLANY because it
-corresponds to "." in DOTALL mode rather than an escape sequence. It is also
-used for [^] in JavaScript compatibility mode, and for \C in non-utf mode. In
-non-DOTALL mode, "." behaves like \N.
-
-The special values ESC_DU, ESC_du, etc. are used instead of ESC_D, ESC_d, etc.
-when PCRE_UCP is set and replacement of \d etc by \p sequences is required.
-They must be contiguous, and remain in order so that the replacements can be
-looked up from a table.
-
-Negative numbers are used to encode a backreference (\1, \2, \3, etc.) in
-check_escape(). There are two tests in the code for an escape
-greater than ESC_b and less than ESC_Z to detect the types that may be
-repeated. These are the types that consume characters. If any new escapes are
-put in between that don't consume a character, that code will have to change.
-*/
-
-enum { ESC_A = 1, ESC_G, ESC_K, ESC_B, ESC_b, ESC_D, ESC_d, ESC_S, ESC_s,
- ESC_W, ESC_w, ESC_N, ESC_dum, ESC_C, ESC_P, ESC_p, ESC_R, ESC_H,
- ESC_h, ESC_V, ESC_v, ESC_X, ESC_Z, ESC_z,
- ESC_E, ESC_Q, ESC_g, ESC_k,
- ESC_DU, ESC_du, ESC_SU, ESC_su, ESC_WU, ESC_wu };
-
-
-/********************** Opcode definitions ******************/
-
-/****** NOTE NOTE NOTE ******
-
-Starting from 1 (i.e. after OP_END), the values up to OP_EOD must correspond in
-order to the list of escapes immediately above. Furthermore, values up to
-OP_DOLLM must not be changed without adjusting the table called autoposstab in
-pcre_compile.c
-
-Whenever this list is updated, the two macro definitions that follow must be
-updated to match. The possessification table called "opcode_possessify" in
-pcre_compile.c must also be updated, and also the tables called "coptable"
-and "poptable" in pcre_dfa_exec.c.
-
-****** NOTE NOTE NOTE ******/
-
-
-/* The values between FIRST_AUTOTAB_OP and LAST_AUTOTAB_RIGHT_OP, inclusive,
-are used in a table for deciding whether a repeated character type can be
-auto-possessified. */
-
-#define FIRST_AUTOTAB_OP OP_NOT_DIGIT
-#define LAST_AUTOTAB_LEFT_OP OP_EXTUNI
-#define LAST_AUTOTAB_RIGHT_OP OP_DOLLM
-
-enum {
- OP_END, /* 0 End of pattern */
-
- /* Values corresponding to backslashed metacharacters */
-
- OP_SOD, /* 1 Start of data: \A */
- OP_SOM, /* 2 Start of match (subject + offset): \G */
- OP_SET_SOM, /* 3 Set start of match (\K) */
- OP_NOT_WORD_BOUNDARY, /* 4 \B */
- OP_WORD_BOUNDARY, /* 5 \b */
- OP_NOT_DIGIT, /* 6 \D */
- OP_DIGIT, /* 7 \d */
- OP_NOT_WHITESPACE, /* 8 \S */
- OP_WHITESPACE, /* 9 \s */
- OP_NOT_WORDCHAR, /* 10 \W */
- OP_WORDCHAR, /* 11 \w */
-
- OP_ANY, /* 12 Match any character except newline (\N) */
- OP_ALLANY, /* 13 Match any character */
- OP_ANYBYTE, /* 14 Match any byte (\C); different to OP_ANY for UTF-8 */
- OP_NOTPROP, /* 15 \P (not Unicode property) */
- OP_PROP, /* 16 \p (Unicode property) */
- OP_ANYNL, /* 17 \R (any newline sequence) */
- OP_NOT_HSPACE, /* 18 \H (not horizontal whitespace) */
- OP_HSPACE, /* 19 \h (horizontal whitespace) */
- OP_NOT_VSPACE, /* 20 \V (not vertical whitespace) */
- OP_VSPACE, /* 21 \v (vertical whitespace) */
- OP_EXTUNI, /* 22 \X (extended Unicode sequence */
- OP_EODN, /* 23 End of data or \n at end of data (\Z) */
- OP_EOD, /* 24 End of data (\z) */
-
- /* Line end assertions */
-
- OP_DOLL, /* 25 End of line - not multiline */
- OP_DOLLM, /* 26 End of line - multiline */
- OP_CIRC, /* 27 Start of line - not multiline */
- OP_CIRCM, /* 28 Start of line - multiline */
-
- /* Single characters; caseful must precede the caseless ones */
-
- OP_CHAR, /* 29 Match one character, casefully */
- OP_CHARI, /* 30 Match one character, caselessly */
- OP_NOT, /* 31 Match one character, not the given one, casefully */
- OP_NOTI, /* 32 Match one character, not the given one, caselessly */
-
- /* The following sets of 13 opcodes must always be kept in step because
- the offset from the first one is used to generate the others. */
-
- /* Repeated characters; caseful must precede the caseless ones */
-
- OP_STAR, /* 33 The maximizing and minimizing versions of */
- OP_MINSTAR, /* 34 these six opcodes must come in pairs, with */
- OP_PLUS, /* 35 the minimizing one second. */
- OP_MINPLUS, /* 36 */
- OP_QUERY, /* 37 */
- OP_MINQUERY, /* 38 */
-
- OP_UPTO, /* 39 From 0 to n matches of one character, caseful*/
- OP_MINUPTO, /* 40 */
- OP_EXACT, /* 41 Exactly n matches */
-
- OP_POSSTAR, /* 42 Possessified star, caseful */
- OP_POSPLUS, /* 43 Possessified plus, caseful */
- OP_POSQUERY, /* 44 Posesssified query, caseful */
- OP_POSUPTO, /* 45 Possessified upto, caseful */
-
- /* Repeated characters; caseless must follow the caseful ones */
-
- OP_STARI, /* 46 */
- OP_MINSTARI, /* 47 */
- OP_PLUSI, /* 48 */
- OP_MINPLUSI, /* 49 */
- OP_QUERYI, /* 50 */
- OP_MINQUERYI, /* 51 */
-
- OP_UPTOI, /* 52 From 0 to n matches of one character, caseless */
- OP_MINUPTOI, /* 53 */
- OP_EXACTI, /* 54 */
-
- OP_POSSTARI, /* 55 Possessified star, caseless */
- OP_POSPLUSI, /* 56 Possessified plus, caseless */
- OP_POSQUERYI, /* 57 Posesssified query, caseless */
- OP_POSUPTOI, /* 58 Possessified upto, caseless */
-
- /* The negated ones must follow the non-negated ones, and match them */
- /* Negated repeated character, caseful; must precede the caseless ones */
-
- OP_NOTSTAR, /* 59 The maximizing and minimizing versions of */
- OP_NOTMINSTAR, /* 60 these six opcodes must come in pairs, with */
- OP_NOTPLUS, /* 61 the minimizing one second. They must be in */
- OP_NOTMINPLUS, /* 62 exactly the same order as those above. */
- OP_NOTQUERY, /* 63 */
- OP_NOTMINQUERY, /* 64 */
-
- OP_NOTUPTO, /* 65 From 0 to n matches, caseful */
- OP_NOTMINUPTO, /* 66 */
- OP_NOTEXACT, /* 67 Exactly n matches */
-
- OP_NOTPOSSTAR, /* 68 Possessified versions, caseful */
- OP_NOTPOSPLUS, /* 69 */
- OP_NOTPOSQUERY, /* 70 */
- OP_NOTPOSUPTO, /* 71 */
-
- /* Negated repeated character, caseless; must follow the caseful ones */
-
- OP_NOTSTARI, /* 72 */
- OP_NOTMINSTARI, /* 73 */
- OP_NOTPLUSI, /* 74 */
- OP_NOTMINPLUSI, /* 75 */
- OP_NOTQUERYI, /* 76 */
- OP_NOTMINQUERYI, /* 77 */
-
- OP_NOTUPTOI, /* 78 From 0 to n matches, caseless */
- OP_NOTMINUPTOI, /* 79 */
- OP_NOTEXACTI, /* 80 Exactly n matches */
-
- OP_NOTPOSSTARI, /* 81 Possessified versions, caseless */
- OP_NOTPOSPLUSI, /* 82 */
- OP_NOTPOSQUERYI, /* 83 */
- OP_NOTPOSUPTOI, /* 84 */
-
- /* Character types */
-
- OP_TYPESTAR, /* 85 The maximizing and minimizing versions of */
- OP_TYPEMINSTAR, /* 86 these six opcodes must come in pairs, with */
- OP_TYPEPLUS, /* 87 the minimizing one second. These codes must */
- OP_TYPEMINPLUS, /* 88 be in exactly the same order as those above. */
- OP_TYPEQUERY, /* 89 */
- OP_TYPEMINQUERY, /* 90 */
-
- OP_TYPEUPTO, /* 91 From 0 to n matches */
- OP_TYPEMINUPTO, /* 92 */
- OP_TYPEEXACT, /* 93 Exactly n matches */
-
- OP_TYPEPOSSTAR, /* 94 Possessified versions */
- OP_TYPEPOSPLUS, /* 95 */
- OP_TYPEPOSQUERY, /* 96 */
- OP_TYPEPOSUPTO, /* 97 */
-
- /* These are used for character classes and back references; only the
- first six are the same as the sets above. */
-
- OP_CRSTAR, /* 98 The maximizing and minimizing versions of */
- OP_CRMINSTAR, /* 99 all these opcodes must come in pairs, with */
- OP_CRPLUS, /* 100 the minimizing one second. These codes must */
- OP_CRMINPLUS, /* 101 be in exactly the same order as those above. */
- OP_CRQUERY, /* 102 */
- OP_CRMINQUERY, /* 103 */
-
- OP_CRRANGE, /* 104 These are different to the three sets above. */
- OP_CRMINRANGE, /* 105 */
-
- OP_CRPOSSTAR, /* 106 Possessified versions */
- OP_CRPOSPLUS, /* 107 */
- OP_CRPOSQUERY, /* 108 */
- OP_CRPOSRANGE, /* 109 */
-
- /* End of quantifier opcodes */
-
- OP_CLASS, /* 110 Match a character class, chars < 256 only */
- OP_NCLASS, /* 111 Same, but the bitmap was created from a negative
- class - the difference is relevant only when a
- character > 255 is encountered. */
- OP_XCLASS, /* 112 Extended class for handling > 255 chars within the
- class. This does both positive and negative. */
- OP_REF, /* 113 Match a back reference, casefully */
- OP_REFI, /* 114 Match a back reference, caselessly */
- OP_DNREF, /* 115 Match a duplicate name backref, casefully */
- OP_DNREFI, /* 116 Match a duplicate name backref, caselessly */
- OP_RECURSE, /* 117 Match a numbered subpattern (possibly recursive) */
- OP_CALLOUT, /* 118 Call out to external function if provided */
-
- OP_ALT, /* 119 Start of alternation */
- OP_KET, /* 120 End of group that doesn't have an unbounded repeat */
- OP_KETRMAX, /* 121 These two must remain together and in this */
- OP_KETRMIN, /* 122 order. They are for groups the repeat for ever. */
- OP_KETRPOS, /* 123 Possessive unlimited repeat. */
-
- /* The assertions must come before BRA, CBRA, ONCE, and COND, and the four
- asserts must remain in order. */
-
- OP_REVERSE, /* 124 Move pointer back - used in lookbehind assertions */
- OP_ASSERT, /* 125 Positive lookahead */
- OP_ASSERT_NOT, /* 126 Negative lookahead */
- OP_ASSERTBACK, /* 127 Positive lookbehind */
- OP_ASSERTBACK_NOT, /* 128 Negative lookbehind */
-
- /* ONCE, ONCE_NC, BRA, BRAPOS, CBRA, CBRAPOS, and COND must come immediately
- after the assertions, with ONCE first, as there's a test for >= ONCE for a
- subpattern that isn't an assertion. The POS versions must immediately follow
- the non-POS versions in each case. */
-
- OP_ONCE, /* 129 Atomic group, contains captures */
- OP_ONCE_NC, /* 130 Atomic group containing no captures */
- OP_BRA, /* 131 Start of non-capturing bracket */
- OP_BRAPOS, /* 132 Ditto, with unlimited, possessive repeat */
- OP_CBRA, /* 133 Start of capturing bracket */
- OP_CBRAPOS, /* 134 Ditto, with unlimited, possessive repeat */
- OP_COND, /* 135 Conditional group */
-
- /* These five must follow the previous five, in the same order. There's a
- check for >= SBRA to distinguish the two sets. */
-
- OP_SBRA, /* 136 Start of non-capturing bracket, check empty */
- OP_SBRAPOS, /* 137 Ditto, with unlimited, possessive repeat */
- OP_SCBRA, /* 138 Start of capturing bracket, check empty */
- OP_SCBRAPOS, /* 139 Ditto, with unlimited, possessive repeat */
- OP_SCOND, /* 140 Conditional group, check empty */
-
- /* The next two pairs must (respectively) be kept together. */
-
- OP_CREF, /* 141 Used to hold a capture number as condition */
- OP_DNCREF, /* 142 Used to point to duplicate names as a condition */
- OP_RREF, /* 143 Used to hold a recursion number as condition */
- OP_DNRREF, /* 144 Used to point to duplicate names as a condition */
- OP_DEF, /* 145 The DEFINE condition */
-
- OP_BRAZERO, /* 146 These two must remain together and in this */
- OP_BRAMINZERO, /* 147 order. */
- OP_BRAPOSZERO, /* 148 */
-
- /* These are backtracking control verbs */
-
- OP_MARK, /* 149 always has an argument */
- OP_PRUNE, /* 150 */
- OP_PRUNE_ARG, /* 151 same, but with argument */
- OP_SKIP, /* 152 */
- OP_SKIP_ARG, /* 153 same, but with argument */
- OP_THEN, /* 154 */
- OP_THEN_ARG, /* 155 same, but with argument */
- OP_COMMIT, /* 156 */
-
- /* These are forced failure and success verbs */
-
- OP_FAIL, /* 157 */
- OP_ACCEPT, /* 158 */
- OP_ASSERT_ACCEPT, /* 159 Used inside assertions */
- OP_CLOSE, /* 160 Used before OP_ACCEPT to close open captures */
-
- /* This is used to skip a subpattern with a {0} quantifier */
-
- OP_SKIPZERO, /* 161 */
-
- /* This is not an opcode, but is used to check that tables indexed by opcode
- are the correct length, in order to catch updating errors - there have been
- some in the past. */
-
- OP_TABLE_LENGTH
-};
-
-/* *** NOTE NOTE NOTE *** Whenever the list above is updated, the two macro
-definitions that follow must also be updated to match. There are also tables
-called "opcode_possessify" in pcre_compile.c and "coptable" and "poptable" in
-pcre_dfa_exec.c that must be updated. */
-
-
-/* This macro defines textual names for all the opcodes. These are used only
-for debugging, and some of them are only partial names. The macro is referenced
-only in pcre_printint.c, which fills out the full names in many cases (and in
-some cases doesn't actually use these names at all). */
-
-#define OP_NAME_LIST \
- "End", "\\A", "\\G", "\\K", "\\B", "\\b", "\\D", "\\d", \
- "\\S", "\\s", "\\W", "\\w", "Any", "AllAny", "Anybyte", \
- "notprop", "prop", "\\R", "\\H", "\\h", "\\V", "\\v", \
- "extuni", "\\Z", "\\z", \
- "$", "$", "^", "^", "char", "chari", "not", "noti", \
- "*", "*?", "+", "+?", "?", "??", \
- "{", "{", "{", \
- "*+","++", "?+", "{", \
- "*", "*?", "+", "+?", "?", "??", \
- "{", "{", "{", \
- "*+","++", "?+", "{", \
- "*", "*?", "+", "+?", "?", "??", \
- "{", "{", "{", \
- "*+","++", "?+", "{", \
- "*", "*?", "+", "+?", "?", "??", \
- "{", "{", "{", \
- "*+","++", "?+", "{", \
- "*", "*?", "+", "+?", "?", "??", "{", "{", "{", \
- "*+","++", "?+", "{", \
- "*", "*?", "+", "+?", "?", "??", "{", "{", \
- "*+","++", "?+", "{", \
- "class", "nclass", "xclass", "Ref", "Refi", "DnRef", "DnRefi", \
- "Recurse", "Callout", \
- "Alt", "Ket", "KetRmax", "KetRmin", "KetRpos", \
- "Reverse", "Assert", "Assert not", "AssertB", "AssertB not", \
- "Once", "Once_NC", \
- "Bra", "BraPos", "CBra", "CBraPos", \
- "Cond", \
- "SBra", "SBraPos", "SCBra", "SCBraPos", \
- "SCond", \
- "Cond ref", "Cond dnref", "Cond rec", "Cond dnrec", "Cond def", \
- "Brazero", "Braminzero", "Braposzero", \
- "*MARK", "*PRUNE", "*PRUNE", "*SKIP", "*SKIP", \
- "*THEN", "*THEN", "*COMMIT", "*FAIL", \
- "*ACCEPT", "*ASSERT_ACCEPT", \
- "Close", "Skip zero"
-
-
-/* This macro defines the length of fixed length operations in the compiled
-regex. The lengths are used when searching for specific things, and also in the
-debugging printing of a compiled regex. We use a macro so that it can be
-defined close to the definitions of the opcodes themselves.
-
-As things have been extended, some of these are no longer fixed lenths, but are
-minima instead. For example, the length of a single-character repeat may vary
-in UTF-8 mode. The code that uses this table must know about such things. */
-
-#define OP_LENGTHS \
- 1, /* End */ \
- 1, 1, 1, 1, 1, /* \A, \G, \K, \B, \b */ \
- 1, 1, 1, 1, 1, 1, /* \D, \d, \S, \s, \W, \w */ \
- 1, 1, 1, /* Any, AllAny, Anybyte */ \
- 3, 3, /* \P, \p */ \
- 1, 1, 1, 1, 1, /* \R, \H, \h, \V, \v */ \
- 1, /* \X */ \
- 1, 1, 1, 1, 1, 1, /* \Z, \z, $, $M ^, ^M */ \
- 2, /* Char - the minimum length */ \
- 2, /* Chari - the minimum length */ \
- 2, /* not */ \
- 2, /* noti */ \
- /* Positive single-char repeats ** These are */ \
- 2, 2, 2, 2, 2, 2, /* *, *?, +, +?, ?, ?? ** minima in */ \
- 2+IMM2_SIZE, 2+IMM2_SIZE, /* upto, minupto ** mode */ \
- 2+IMM2_SIZE, /* exact */ \
- 2, 2, 2, 2+IMM2_SIZE, /* *+, ++, ?+, upto+ */ \
- 2, 2, 2, 2, 2, 2, /* *I, *?I, +I, +?I, ?I, ??I ** UTF-8 */ \
- 2+IMM2_SIZE, 2+IMM2_SIZE, /* upto I, minupto I */ \
- 2+IMM2_SIZE, /* exact I */ \
- 2, 2, 2, 2+IMM2_SIZE, /* *+I, ++I, ?+I, upto+I */ \
- /* Negative single-char repeats - only for chars < 256 */ \
- 2, 2, 2, 2, 2, 2, /* NOT *, *?, +, +?, ?, ?? */ \
- 2+IMM2_SIZE, 2+IMM2_SIZE, /* NOT upto, minupto */ \
- 2+IMM2_SIZE, /* NOT exact */ \
- 2, 2, 2, 2+IMM2_SIZE, /* Possessive NOT *, +, ?, upto */ \
- 2, 2, 2, 2, 2, 2, /* NOT *I, *?I, +I, +?I, ?I, ??I */ \
- 2+IMM2_SIZE, 2+IMM2_SIZE, /* NOT upto I, minupto I */ \
- 2+IMM2_SIZE, /* NOT exact I */ \
- 2, 2, 2, 2+IMM2_SIZE, /* Possessive NOT *I, +I, ?I, upto I */ \
- /* Positive type repeats */ \
- 2, 2, 2, 2, 2, 2, /* Type *, *?, +, +?, ?, ?? */ \
- 2+IMM2_SIZE, 2+IMM2_SIZE, /* Type upto, minupto */ \
- 2+IMM2_SIZE, /* Type exact */ \
- 2, 2, 2, 2+IMM2_SIZE, /* Possessive *+, ++, ?+, upto+ */ \
- /* Character class & ref repeats */ \
- 1, 1, 1, 1, 1, 1, /* *, *?, +, +?, ?, ?? */ \
- 1+2*IMM2_SIZE, 1+2*IMM2_SIZE, /* CRRANGE, CRMINRANGE */ \
- 1, 1, 1, 1+2*IMM2_SIZE, /* Possessive *+, ++, ?+, CRPOSRANGE */ \
- 1+(32/sizeof(pcre_uchar)), /* CLASS */ \
- 1+(32/sizeof(pcre_uchar)), /* NCLASS */ \
- 0, /* XCLASS - variable length */ \
- 1+IMM2_SIZE, /* REF */ \
- 1+IMM2_SIZE, /* REFI */ \
- 1+2*IMM2_SIZE, /* DNREF */ \
- 1+2*IMM2_SIZE, /* DNREFI */ \
- 1+LINK_SIZE, /* RECURSE */ \
- 2+2*LINK_SIZE, /* CALLOUT */ \
- 1+LINK_SIZE, /* Alt */ \
- 1+LINK_SIZE, /* Ket */ \
- 1+LINK_SIZE, /* KetRmax */ \
- 1+LINK_SIZE, /* KetRmin */ \
- 1+LINK_SIZE, /* KetRpos */ \
- 1+LINK_SIZE, /* Reverse */ \
- 1+LINK_SIZE, /* Assert */ \
- 1+LINK_SIZE, /* Assert not */ \
- 1+LINK_SIZE, /* Assert behind */ \
- 1+LINK_SIZE, /* Assert behind not */ \
- 1+LINK_SIZE, /* ONCE */ \
- 1+LINK_SIZE, /* ONCE_NC */ \
- 1+LINK_SIZE, /* BRA */ \
- 1+LINK_SIZE, /* BRAPOS */ \
- 1+LINK_SIZE+IMM2_SIZE, /* CBRA */ \
- 1+LINK_SIZE+IMM2_SIZE, /* CBRAPOS */ \
- 1+LINK_SIZE, /* COND */ \
- 1+LINK_SIZE, /* SBRA */ \
- 1+LINK_SIZE, /* SBRAPOS */ \
- 1+LINK_SIZE+IMM2_SIZE, /* SCBRA */ \
- 1+LINK_SIZE+IMM2_SIZE, /* SCBRAPOS */ \
- 1+LINK_SIZE, /* SCOND */ \
- 1+IMM2_SIZE, 1+2*IMM2_SIZE, /* CREF, DNCREF */ \
- 1+IMM2_SIZE, 1+2*IMM2_SIZE, /* RREF, DNRREF */ \
- 1, /* DEF */ \
- 1, 1, 1, /* BRAZERO, BRAMINZERO, BRAPOSZERO */ \
- 3, 1, 3, /* MARK, PRUNE, PRUNE_ARG */ \
- 1, 3, /* SKIP, SKIP_ARG */ \
- 1, 3, /* THEN, THEN_ARG */ \
- 1, 1, 1, 1, /* COMMIT, FAIL, ACCEPT, ASSERT_ACCEPT */ \
- 1+IMM2_SIZE, 1 /* CLOSE, SKIPZERO */
-
-/* A magic value for OP_RREF to indicate the "any recursion" condition. */
-
-#define RREF_ANY 0xffff
-
-/* Compile time error code numbers. They are given names so that they can more
-easily be tracked. When a new number is added, the table called eint in
-pcreposix.c must be updated. */
-
-enum { ERR0, ERR1, ERR2, ERR3, ERR4, ERR5, ERR6, ERR7, ERR8, ERR9,
- ERR10, ERR11, ERR12, ERR13, ERR14, ERR15, ERR16, ERR17, ERR18, ERR19,
- ERR20, ERR21, ERR22, ERR23, ERR24, ERR25, ERR26, ERR27, ERR28, ERR29,
- ERR30, ERR31, ERR32, ERR33, ERR34, ERR35, ERR36, ERR37, ERR38, ERR39,
- ERR40, ERR41, ERR42, ERR43, ERR44, ERR45, ERR46, ERR47, ERR48, ERR49,
- ERR50, ERR51, ERR52, ERR53, ERR54, ERR55, ERR56, ERR57, ERR58, ERR59,
- ERR60, ERR61, ERR62, ERR63, ERR64, ERR65, ERR66, ERR67, ERR68, ERR69,
- ERR70, ERR71, ERR72, ERR73, ERR74, ERR75, ERR76, ERR77, ERR78, ERR79,
- ERR80, ERR81, ERR82, ERR83, ERR84, ERR85, ERR86, ERRCOUNT };
-
-/* JIT compiling modes. The function list is indexed by them. */
-
-enum { JIT_COMPILE, JIT_PARTIAL_SOFT_COMPILE, JIT_PARTIAL_HARD_COMPILE,
- JIT_NUMBER_OF_COMPILE_MODES };
-
-/* The real format of the start of the pcre block; the index of names and the
-code vector run on as long as necessary after the end. We store an explicit
-offset to the name table so that if a regex is compiled on one host, saved, and
-then run on another where the size of pointers is different, all might still
-be well.
-
-The size of the structure must be a multiple of 8 bytes. For the case of
-compiled-on-4 and run-on-8, we include an extra pointer that is always NULL so
-that there are an even number of pointers which therefore are a multiple of 8
-bytes.
-
-It is necessary to fork the struct for the 32 bit library, since it needs to
-use pcre_uint32 for first_char and req_char. We can't put an ifdef inside the
-typedef because pcretest needs access to the struct of the 8-, 16- and 32-bit
-variants.
-
-*** WARNING ***
-When new fields are added to these structures, remember to adjust the code in
-pcre_byte_order.c that is concerned with swapping the byte order of the fields
-when a compiled regex is reloaded on a host with different endianness.
-*** WARNING ***
-There is also similar byte-flipping code in pcretest.c, which is used for
-testing the byte-flipping features. It must also be kept in step.
-*** WARNING ***
-*/
-
-typedef struct real_pcre8_or_16 {
- pcre_uint32 magic_number;
- pcre_uint32 size; /* Total that was malloced */
- pcre_uint32 options; /* Public options */
- pcre_uint32 flags; /* Private flags */
- pcre_uint32 limit_match; /* Limit set from regex */
- pcre_uint32 limit_recursion; /* Limit set from regex */
- pcre_uint16 first_char; /* Starting character */
- pcre_uint16 req_char; /* This character must be seen */
- pcre_uint16 max_lookbehind; /* Longest lookbehind (characters) */
- pcre_uint16 top_bracket; /* Highest numbered group */
- pcre_uint16 top_backref; /* Highest numbered back reference */
- pcre_uint16 name_table_offset; /* Offset to name table that follows */
- pcre_uint16 name_entry_size; /* Size of any name items */
- pcre_uint16 name_count; /* Number of name items */
- pcre_uint16 ref_count; /* Reference count */
- pcre_uint16 dummy1; /* To ensure size is a multiple of 8 */
- pcre_uint16 dummy2; /* To ensure size is a multiple of 8 */
- pcre_uint16 dummy3; /* To ensure size is a multiple of 8 */
- const pcre_uint8 *tables; /* Pointer to tables or NULL for std */
- void *nullpad; /* NULL padding */
-} real_pcre8_or_16;
-
-typedef struct real_pcre8_or_16 real_pcre;
-typedef struct real_pcre8_or_16 real_pcre16;
-
-typedef struct real_pcre32 {
- pcre_uint32 magic_number;
- pcre_uint32 size; /* Total that was malloced */
- pcre_uint32 options; /* Public options */
- pcre_uint32 flags; /* Private flags */
- pcre_uint32 limit_match; /* Limit set from regex */
- pcre_uint32 limit_recursion; /* Limit set from regex */
- pcre_uint32 first_char; /* Starting character */
- pcre_uint32 req_char; /* This character must be seen */
- pcre_uint16 max_lookbehind; /* Longest lookbehind (characters) */
- pcre_uint16 top_bracket; /* Highest numbered group */
- pcre_uint16 top_backref; /* Highest numbered back reference */
- pcre_uint16 name_table_offset; /* Offset to name table that follows */
- pcre_uint16 name_entry_size; /* Size of any name items */
- pcre_uint16 name_count; /* Number of name items */
- pcre_uint16 ref_count; /* Reference count */
- pcre_uint16 dummy; /* To ensure size is a multiple of 8 */
- const pcre_uint8 *tables; /* Pointer to tables or NULL for std */
- void *nullpad; /* NULL padding */
-} real_pcre32;
-
-#if defined COMPILE_PCRE8
-#define REAL_PCRE real_pcre
-#elif defined COMPILE_PCRE16
-#define REAL_PCRE real_pcre16
-#elif defined COMPILE_PCRE32
-#define REAL_PCRE real_pcre32
-#endif
-
-/* Assert that the size of REAL_PCRE is divisible by 8 */
-typedef int __assert_real_pcre_size_divisible_8[(sizeof(REAL_PCRE) % 8) == 0 ? 1 : -1];
-
-/* Needed in pcretest to access some fields in the real_pcre* structures
- * directly. They're unified for 8/16/32 bits since the structs only differ
- * after these fields; if that ever changes, need to fork those defines into
- * 8/16 and 32 bit versions. */
-#define REAL_PCRE_MAGIC(re) (((REAL_PCRE*)re)->magic_number)
-#define REAL_PCRE_SIZE(re) (((REAL_PCRE*)re)->size)
-#define REAL_PCRE_OPTIONS(re) (((REAL_PCRE*)re)->options)
-#define REAL_PCRE_FLAGS(re) (((REAL_PCRE*)re)->flags)
-
-/* The format of the block used to store data from pcre_study(). The same
-remark (see NOTE above) about extending this structure applies. */
-
-typedef struct pcre_study_data {
- pcre_uint32 size; /* Total that was malloced */
- pcre_uint32 flags; /* Private flags */
- pcre_uint8 start_bits[32]; /* Starting char bits */
- pcre_uint32 minlength; /* Minimum subject length */
-} pcre_study_data;
-
-/* Structure for building a chain of open capturing subpatterns during
-compiling, so that instructions to close them can be compiled when (*ACCEPT) is
-encountered. This is also used to identify subpatterns that contain recursive
-back references to themselves, so that they can be made atomic. */
-
-typedef struct open_capitem {
- struct open_capitem *next; /* Chain link */
- pcre_uint16 number; /* Capture number */
- pcre_uint16 flag; /* Set TRUE if recursive back ref */
-} open_capitem;
-
-/* Structure for building a list of named groups during the first pass of
-compiling. */
-
-typedef struct named_group {
- const pcre_uchar *name; /* Points to the name in the pattern */
- int length; /* Length of the name */
- pcre_uint32 number; /* Group number */
-} named_group;
-
-/* Structure for passing "static" information around between the functions
-doing the compiling, so that they are thread-safe. */
-
-typedef struct compile_data {
- const pcre_uint8 *lcc; /* Points to lower casing table */
- const pcre_uint8 *fcc; /* Points to case-flipping table */
- const pcre_uint8 *cbits; /* Points to character type table */
- const pcre_uint8 *ctypes; /* Points to table of type maps */
- const pcre_uchar *start_workspace;/* The start of working space */
- const pcre_uchar *start_code; /* The start of the compiled code */
- const pcre_uchar *start_pattern; /* The start of the pattern */
- const pcre_uchar *end_pattern; /* The end of the pattern */
- pcre_uchar *hwm; /* High watermark of workspace */
- open_capitem *open_caps; /* Chain of open capture items */
- named_group *named_groups; /* Points to vector in pre-compile */
- pcre_uchar *name_table; /* The name/number table */
- int names_found; /* Number of entries so far */
- int name_entry_size; /* Size of each entry */
- int named_group_list_size; /* Number of entries in the list */
- int workspace_size; /* Size of workspace */
- unsigned int bracount; /* Count of capturing parens as we compile */
- int final_bracount; /* Saved value after first pass */
- int max_lookbehind; /* Maximum lookbehind (characters) */
- int top_backref; /* Maximum back reference */
- unsigned int backref_map; /* Bitmap of low back refs */
- unsigned int namedrefcount; /* Number of backreferences by name */
- int parens_depth; /* Depth of nested parentheses */
- int assert_depth; /* Depth of nested assertions */
- pcre_uint32 external_options; /* External (initial) options */
- pcre_uint32 external_flags; /* External flag bits to be set */
- int req_varyopt; /* "After variable item" flag for reqbyte */
- BOOL had_accept; /* (*ACCEPT) encountered */
- BOOL had_pruneorskip; /* (*PRUNE) or (*SKIP) encountered */
- BOOL check_lookbehind; /* Lookbehinds need later checking */
- BOOL dupnames; /* Duplicate names exist */
- BOOL dupgroups; /* Duplicate groups exist: (?| found */
- BOOL iscondassert; /* Next assert is a condition */
- int nltype; /* Newline type */
- int nllen; /* Newline string length */
- pcre_uchar nl[4]; /* Newline string when fixed length */
-} compile_data;
-
-/* Structure for maintaining a chain of pointers to the currently incomplete
-branches, for testing for left recursion while compiling. */
-
-typedef struct branch_chain {
- struct branch_chain *outer;
- pcre_uchar *current_branch;
-} branch_chain;
-
-/* Structure for mutual recursion detection. */
-
-typedef struct recurse_check {
- struct recurse_check *prev;
- const pcre_uchar *group;
-} recurse_check;
-
-/* Structure for items in a linked list that represents an explicit recursive
-call within the pattern; used by pcre_exec(). */
-
-typedef struct recursion_info {
- struct recursion_info *prevrec; /* Previous recursion record (or NULL) */
- unsigned int group_num; /* Number of group that was called */
- int *offset_save; /* Pointer to start of saved offsets */
- int saved_max; /* Number of saved offsets */
- int saved_capture_last; /* Last capture number */
- PCRE_PUCHAR subject_position; /* Position at start of recursion */
-} recursion_info;
-
-/* A similar structure for pcre_dfa_exec(). */
-
-typedef struct dfa_recursion_info {
- struct dfa_recursion_info *prevrec;
- int group_num;
- PCRE_PUCHAR subject_position;
-} dfa_recursion_info;
-
-/* Structure for building a chain of data for holding the values of the subject
-pointer at the start of each subpattern, so as to detect when an empty string
-has been matched by a subpattern - to break infinite loops; used by
-pcre_exec(). */
-
-typedef struct eptrblock {
- struct eptrblock *epb_prev;
- PCRE_PUCHAR epb_saved_eptr;
-} eptrblock;
-
-
-/* Structure for passing "static" information around between the functions
-doing traditional NFA matching, so that they are thread-safe. */
-
-typedef struct match_data {
- unsigned long int match_call_count; /* As it says */
- unsigned long int match_limit; /* As it says */
- unsigned long int match_limit_recursion; /* As it says */
- int *offset_vector; /* Offset vector */
- int offset_end; /* One past the end */
- int offset_max; /* The maximum usable for return data */
- int nltype; /* Newline type */
- int nllen; /* Newline string length */
- int name_count; /* Number of names in name table */
- int name_entry_size; /* Size of entry in names table */
- unsigned int skip_arg_count; /* For counting SKIP_ARGs */
- unsigned int ignore_skip_arg; /* For re-run when SKIP arg name not found */
- pcre_uchar *name_table; /* Table of names */
- pcre_uchar nl[4]; /* Newline string when fixed */
- const pcre_uint8 *lcc; /* Points to lower casing table */
- const pcre_uint8 *fcc; /* Points to case-flipping table */
- const pcre_uint8 *ctypes; /* Points to table of type maps */
- BOOL notbol; /* NOTBOL flag */
- BOOL noteol; /* NOTEOL flag */
- BOOL utf; /* UTF-8 / UTF-16 flag */
- BOOL jscript_compat; /* JAVASCRIPT_COMPAT flag */
- BOOL use_ucp; /* PCRE_UCP flag */
- BOOL endonly; /* Dollar not before final \n */
- BOOL notempty; /* Empty string match not wanted */
- BOOL notempty_atstart; /* Empty string match at start not wanted */
- BOOL hitend; /* Hit the end of the subject at some point */
- BOOL bsr_anycrlf; /* \R is just any CRLF, not full Unicode */
- BOOL hasthen; /* Pattern contains (*THEN) */
- const pcre_uchar *start_code; /* For use when recursing */
- PCRE_PUCHAR start_subject; /* Start of the subject string */
- PCRE_PUCHAR end_subject; /* End of the subject string */
- PCRE_PUCHAR start_match_ptr; /* Start of matched string */
- PCRE_PUCHAR end_match_ptr; /* Subject position at end match */
- PCRE_PUCHAR start_used_ptr; /* Earliest consulted character */
- int partial; /* PARTIAL options */
- int end_offset_top; /* Highwater mark at end of match */
- pcre_int32 capture_last; /* Most recent capture number + overflow flag */
- int start_offset; /* The start offset value */
- int match_function_type; /* Set for certain special calls of MATCH() */
- eptrblock *eptrchain; /* Chain of eptrblocks for tail recursions */
- int eptrn; /* Next free eptrblock */
- recursion_info *recursive; /* Linked list of recursion data */
- void *callout_data; /* To pass back to callouts */
- const pcre_uchar *mark; /* Mark pointer to pass back on success */
- const pcre_uchar *nomatch_mark;/* Mark pointer to pass back on failure */
- const pcre_uchar *once_target; /* Where to back up to for atomic groups */
-#ifdef NO_RECURSE
- void *match_frames_base; /* For remembering malloc'd frames */
-#endif
-} match_data;
-
-/* A similar structure is used for the same purpose by the DFA matching
-functions. */
-
-typedef struct dfa_match_data {
- const pcre_uchar *start_code; /* Start of the compiled pattern */
- const pcre_uchar *start_subject ; /* Start of the subject string */
- const pcre_uchar *end_subject; /* End of subject string */
- const pcre_uchar *start_used_ptr; /* Earliest consulted character */
- const pcre_uint8 *tables; /* Character tables */
- int start_offset; /* The start offset value */
- int moptions; /* Match options */
- int poptions; /* Pattern options */
- int nltype; /* Newline type */
- int nllen; /* Newline string length */
- pcre_uchar nl[4]; /* Newline string when fixed */
- void *callout_data; /* To pass back to callouts */
- dfa_recursion_info *recursive; /* Linked list of recursion data */
-} dfa_match_data;
-
-/* Bit definitions for entries in the pcre_ctypes table. */
-
-#define ctype_space 0x01
-#define ctype_letter 0x02
-#define ctype_digit 0x04
-#define ctype_xdigit 0x08
-#define ctype_word 0x10 /* alphanumeric or '_' */
-#define ctype_meta 0x80 /* regexp meta char or zero (end pattern) */
-
-/* Offsets for the bitmap tables in pcre_cbits. Each table contains a set
-of bits for a class map. Some classes are built by combining these tables. */
-
-#define cbit_space 0 /* [:space:] or \s */
-#define cbit_xdigit 32 /* [:xdigit:] */
-#define cbit_digit 64 /* [:digit:] or \d */
-#define cbit_upper 96 /* [:upper:] */
-#define cbit_lower 128 /* [:lower:] */
-#define cbit_word 160 /* [:word:] or \w */
-#define cbit_graph 192 /* [:graph:] */
-#define cbit_print 224 /* [:print:] */
-#define cbit_punct 256 /* [:punct:] */
-#define cbit_cntrl 288 /* [:cntrl:] */
-#define cbit_length 320 /* Length of the cbits table */
-
-/* Offsets of the various tables from the base tables pointer, and
-total length. */
-
-#define lcc_offset 0
-#define fcc_offset 256
-#define cbits_offset 512
-#define ctypes_offset (cbits_offset + cbit_length)
-#define tables_length (ctypes_offset + 256)
-
-/* Internal function and data prefixes. */
-
-#if defined COMPILE_PCRE8
-#ifndef PUBL
-#define PUBL(name) pcre_##name
-#endif
-#ifndef PRIV
-#define PRIV(name) _pcre_##name
-#endif
-#elif defined COMPILE_PCRE16
-#ifndef PUBL
-#define PUBL(name) pcre16_##name
-#endif
-#ifndef PRIV
-#define PRIV(name) _pcre16_##name
-#endif
-#elif defined COMPILE_PCRE32
-#ifndef PUBL
-#define PUBL(name) pcre32_##name
-#endif
-#ifndef PRIV
-#define PRIV(name) _pcre32_##name
-#endif
-#else
-#error Unsupported compiling mode
-#endif /* COMPILE_PCRE[8|16|32] */
-
-/* Layout of the UCP type table that translates property names into types and
-codes. Each entry used to point directly to a name, but to reduce the number of
-relocations in shared libraries, it now has an offset into a single string
-instead. */
-
-typedef struct {
- pcre_uint16 name_offset;
- pcre_uint16 type;
- pcre_uint16 value;
-} ucp_type_table;
-
-
-/* Internal shared data tables. These are tables that are used by more than one
-of the exported public functions. They have to be "external" in the C sense,
-but are not part of the PCRE public API. The data for these tables is in the
-pcre_tables.c module. */
-
-#ifdef COMPILE_PCRE8
-extern const int PRIV(utf8_table1)[];
-extern const int PRIV(utf8_table1_size);
-extern const int PRIV(utf8_table2)[];
-extern const int PRIV(utf8_table3)[];
-extern const pcre_uint8 PRIV(utf8_table4)[];
-#endif /* COMPILE_PCRE8 */
-
-extern const char PRIV(utt_names)[];
-extern const ucp_type_table PRIV(utt)[];
-extern const int PRIV(utt_size);
-
-extern const pcre_uint8 PRIV(OP_lengths)[];
-extern const pcre_uint8 PRIV(default_tables)[];
-
-extern const pcre_uint32 PRIV(hspace_list)[];
-extern const pcre_uint32 PRIV(vspace_list)[];
-
-
-/* Internal shared functions. These are functions that are used by more than
-one of the exported public functions. They have to be "external" in the C
-sense, but are not part of the PCRE public API. */
-
-/* String comparison functions. */
-#if defined COMPILE_PCRE8
-
-#define STRCMP_UC_UC(str1, str2) \
- strcmp((char *)(str1), (char *)(str2))
-#define STRCMP_UC_C8(str1, str2) \
- strcmp((char *)(str1), (str2))
-#define STRNCMP_UC_UC(str1, str2, num) \
- strncmp((char *)(str1), (char *)(str2), (num))
-#define STRNCMP_UC_C8(str1, str2, num) \
- strncmp((char *)(str1), (str2), (num))
-#define STRLEN_UC(str) strlen((const char *)str)
-
-#elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-
-extern int PRIV(strcmp_uc_uc)(const pcre_uchar *,
- const pcre_uchar *);
-extern int PRIV(strcmp_uc_c8)(const pcre_uchar *,
- const char *);
-extern int PRIV(strncmp_uc_uc)(const pcre_uchar *,
- const pcre_uchar *, unsigned int num);
-extern int PRIV(strncmp_uc_c8)(const pcre_uchar *,
- const char *, unsigned int num);
-extern unsigned int PRIV(strlen_uc)(const pcre_uchar *str);
-
-#define STRCMP_UC_UC(str1, str2) \
- PRIV(strcmp_uc_uc)((str1), (str2))
-#define STRCMP_UC_C8(str1, str2) \
- PRIV(strcmp_uc_c8)((str1), (str2))
-#define STRNCMP_UC_UC(str1, str2, num) \
- PRIV(strncmp_uc_uc)((str1), (str2), (num))
-#define STRNCMP_UC_C8(str1, str2, num) \
- PRIV(strncmp_uc_c8)((str1), (str2), (num))
-#define STRLEN_UC(str) PRIV(strlen_uc)(str)
-
-#endif /* COMPILE_PCRE[8|16|32] */
-
-#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
-
-#define STRCMP_UC_UC_TEST(str1, str2) STRCMP_UC_UC(str1, str2)
-#define STRCMP_UC_C8_TEST(str1, str2) STRCMP_UC_C8(str1, str2)
-
-#elif defined COMPILE_PCRE32
-
-extern int PRIV(strcmp_uc_uc_utf)(const pcre_uchar *,
- const pcre_uchar *);
-extern int PRIV(strcmp_uc_c8_utf)(const pcre_uchar *,
- const char *);
-
-#define STRCMP_UC_UC_TEST(str1, str2) \
- (utf ? PRIV(strcmp_uc_uc_utf)((str1), (str2)) : PRIV(strcmp_uc_uc)((str1), (str2)))
-#define STRCMP_UC_C8_TEST(str1, str2) \
- (utf ? PRIV(strcmp_uc_c8_utf)((str1), (str2)) : PRIV(strcmp_uc_c8)((str1), (str2)))
-
-#endif /* COMPILE_PCRE[8|16|32] */
-
-extern const pcre_uchar *PRIV(find_bracket)(const pcre_uchar *, BOOL, int);
-extern BOOL PRIV(is_newline)(PCRE_PUCHAR, int, PCRE_PUCHAR,
- int *, BOOL);
-extern unsigned int PRIV(ord2utf)(pcre_uint32, pcre_uchar *);
-extern int PRIV(valid_utf)(PCRE_PUCHAR, int, int *);
-extern BOOL PRIV(was_newline)(PCRE_PUCHAR, int, PCRE_PUCHAR,
- int *, BOOL);
-extern BOOL PRIV(xclass)(pcre_uint32, const pcre_uchar *, BOOL);
-
-#ifdef SUPPORT_JIT
-extern void PRIV(jit_compile)(const REAL_PCRE *,
- PUBL(extra) *, int);
-extern int PRIV(jit_exec)(const PUBL(extra) *,
- const pcre_uchar *, int, int, int, int *, int);
-extern void PRIV(jit_free)(void *);
-extern int PRIV(jit_get_size)(void *);
-extern const char* PRIV(jit_get_target)(void);
-#endif
-
-/* Unicode character database (UCD) */
-
-typedef struct {
- pcre_uint8 script; /* ucp_Arabic, etc. */
- pcre_uint8 chartype; /* ucp_Cc, etc. (general categories) */
- pcre_uint8 gbprop; /* ucp_gbControl, etc. (grapheme break property) */
- pcre_uint8 caseset; /* offset to multichar other cases or zero */
- pcre_int32 other_case; /* offset to other case, or zero if none */
-} ucd_record;
-
-extern const pcre_uint32 PRIV(ucd_caseless_sets)[];
-extern const ucd_record PRIV(ucd_records)[];
-extern const pcre_uint8 PRIV(ucd_stage1)[];
-extern const pcre_uint16 PRIV(ucd_stage2)[];
-extern const pcre_uint32 PRIV(ucp_gentype)[];
-extern const pcre_uint32 PRIV(ucp_gbtable)[];
-#ifdef SUPPORT_JIT
-extern const int PRIV(ucp_typerange)[];
-#endif
-
-#ifdef SUPPORT_UCP
-/* UCD access macros */
-
-#define UCD_BLOCK_SIZE 128
-#define GET_UCD(ch) (PRIV(ucd_records) + \
- PRIV(ucd_stage2)[PRIV(ucd_stage1)[(int)(ch) / UCD_BLOCK_SIZE] * \
- UCD_BLOCK_SIZE + (int)(ch) % UCD_BLOCK_SIZE])
-
-#define UCD_CHARTYPE(ch) GET_UCD(ch)->chartype
-#define UCD_SCRIPT(ch) GET_UCD(ch)->script
-#define UCD_CATEGORY(ch) PRIV(ucp_gentype)[UCD_CHARTYPE(ch)]
-#define UCD_GRAPHBREAK(ch) GET_UCD(ch)->gbprop
-#define UCD_CASESET(ch) GET_UCD(ch)->caseset
-#define UCD_OTHERCASE(ch) ((pcre_uint32)((int)ch + (int)(GET_UCD(ch)->other_case)))
-
-#endif /* SUPPORT_UCP */
-
-#endif
-
-/* End of pcre_internal.h */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_jit_compile.c r-base-3.3.1/src/extra/pcre/pcre_jit_compile.c
--- r-base-3.2.3/src/extra/pcre/pcre_jit_compile.c 2015-11-26 23:15:13.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_jit_compile.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,10733 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2013 University of Cambridge
-
- The machine code generator part (this module) was written by Zoltan Herczeg
- Copyright (c) 2010-2013
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pcre_internal.h"
-
-#if defined SUPPORT_JIT
-
-/* All-in-one: Since we use the JIT compiler only from here,
-we just include it. This way we don't need to touch the build
-system files. */
-
-#define SLJIT_MALLOC(size, allocator_data) (PUBL(malloc))(size)
-#define SLJIT_FREE(ptr, allocator_data) (PUBL(free))(ptr)
-#define SLJIT_CONFIG_AUTO 1
-#define SLJIT_CONFIG_STATIC 1
-#define SLJIT_VERBOSE 0
-#define SLJIT_DEBUG 0
-
-#include "sljit/sljitLir.c"
-
-#if defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED
-#error Unsupported architecture
-#endif
-
-/* Defines for debugging purposes. */
-
-/* 1 - Use unoptimized capturing brackets.
- 2 - Enable capture_last_ptr (includes option 1). */
-/* #define DEBUG_FORCE_UNOPTIMIZED_CBRAS 2 */
-
-/* 1 - Always have a control head. */
-/* #define DEBUG_FORCE_CONTROL_HEAD 1 */
-
-/* Allocate memory for the regex stack on the real machine stack.
-Fast, but limited size. */
-#define MACHINE_STACK_SIZE 32768
-
-/* Growth rate for stack allocated by the OS. Should be the multiply
-of page size. */
-#define STACK_GROWTH_RATE 8192
-
-/* Enable to check that the allocation could destroy temporaries. */
-#if defined SLJIT_DEBUG && SLJIT_DEBUG
-#define DESTROY_REGISTERS 1
-#endif
-
-/*
-Short summary about the backtracking mechanism empolyed by the jit code generator:
-
-The code generator follows the recursive nature of the PERL compatible regular
-expressions. The basic blocks of regular expressions are condition checkers
-whose execute different commands depending on the result of the condition check.
-The relationship between the operators can be horizontal (concatenation) and
-vertical (sub-expression) (See struct backtrack_common for more details).
-
- 'ab' - 'a' and 'b' regexps are concatenated
- 'a+' - 'a' is the sub-expression of the '+' operator
-
-The condition checkers are boolean (true/false) checkers. Machine code is generated
-for the checker itself and for the actions depending on the result of the checker.
-The 'true' case is called as the matching path (expected path), and the other is called as
-the 'backtrack' path. Branch instructions are expesive for all CPUs, so we avoid taken
-branches on the matching path.
-
- Greedy star operator (*) :
- Matching path: match happens.
- Backtrack path: match failed.
- Non-greedy star operator (*?) :
- Matching path: no need to perform a match.
- Backtrack path: match is required.
-
-The following example shows how the code generated for a capturing bracket
-with two alternatives. Let A, B, C, D are arbirary regular expressions, and
-we have the following regular expression:
-
- A(B|C)D
-
-The generated code will be the following:
-
- A matching path
- '(' matching path (pushing arguments to the stack)
- B matching path
- ')' matching path (pushing arguments to the stack)
- D matching path
- return with successful match
-
- D backtrack path
- ')' backtrack path (If we arrived from "C" jump to the backtrack of "C")
- B backtrack path
- C expected path
- jump to D matching path
- C backtrack path
- A backtrack path
-
- Notice, that the order of backtrack code paths are the opposite of the fast
- code paths. In this way the topmost value on the stack is always belong
- to the current backtrack code path. The backtrack path must check
- whether there is a next alternative. If so, it needs to jump back to
- the matching path eventually. Otherwise it needs to clear out its own stack
- frame and continue the execution on the backtrack code paths.
-*/
-
-/*
-Saved stack frames:
-
-Atomic blocks and asserts require reloading the values of private data
-when the backtrack mechanism performed. Because of OP_RECURSE, the data
-are not necessarly known in compile time, thus we need a dynamic restore
-mechanism.
-
-The stack frames are stored in a chain list, and have the following format:
-([ capturing bracket offset ][ start value ][ end value ])+ ... [ 0 ] [ previous head ]
-
-Thus we can restore the private data to a particular point in the stack.
-*/
-
-typedef struct jit_arguments {
- /* Pointers first. */
- struct sljit_stack *stack;
- const pcre_uchar *str;
- const pcre_uchar *begin;
- const pcre_uchar *end;
- int *offsets;
- pcre_uchar *uchar_ptr;
- pcre_uchar *mark_ptr;
- void *callout_data;
- /* Everything else after. */
- pcre_uint32 limit_match;
- int real_offset_count;
- int offset_count;
- pcre_uint8 notbol;
- pcre_uint8 noteol;
- pcre_uint8 notempty;
- pcre_uint8 notempty_atstart;
-} jit_arguments;
-
-typedef struct executable_functions {
- void *executable_funcs[JIT_NUMBER_OF_COMPILE_MODES];
- void *read_only_data_heads[JIT_NUMBER_OF_COMPILE_MODES];
- sljit_uw executable_sizes[JIT_NUMBER_OF_COMPILE_MODES];
- PUBL(jit_callback) callback;
- void *userdata;
- pcre_uint32 top_bracket;
- pcre_uint32 limit_match;
-} executable_functions;
-
-typedef struct jump_list {
- struct sljit_jump *jump;
- struct jump_list *next;
-} jump_list;
-
-typedef struct stub_list {
- struct sljit_jump *start;
- struct sljit_label *quit;
- struct stub_list *next;
-} stub_list;
-
-typedef struct label_addr_list {
- struct sljit_label *label;
- sljit_uw *update_addr;
- struct label_addr_list *next;
-} label_addr_list;
-
-enum frame_types {
- no_frame = -1,
- no_stack = -2
-};
-
-enum control_types {
- type_mark = 0,
- type_then_trap = 1
-};
-
-typedef int (SLJIT_CALL *jit_function)(jit_arguments *args);
-
-/* The following structure is the key data type for the recursive
-code generator. It is allocated by compile_matchingpath, and contains
-the arguments for compile_backtrackingpath. Must be the first member
-of its descendants. */
-typedef struct backtrack_common {
- /* Concatenation stack. */
- struct backtrack_common *prev;
- jump_list *nextbacktracks;
- /* Internal stack (for component operators). */
- struct backtrack_common *top;
- jump_list *topbacktracks;
- /* Opcode pointer. */
- pcre_uchar *cc;
-} backtrack_common;
-
-typedef struct assert_backtrack {
- backtrack_common common;
- jump_list *condfailed;
- /* Less than 0 if a frame is not needed. */
- int framesize;
- /* Points to our private memory word on the stack. */
- int private_data_ptr;
- /* For iterators. */
- struct sljit_label *matchingpath;
-} assert_backtrack;
-
-typedef struct bracket_backtrack {
- backtrack_common common;
- /* Where to coninue if an alternative is successfully matched. */
- struct sljit_label *alternative_matchingpath;
- /* For rmin and rmax iterators. */
- struct sljit_label *recursive_matchingpath;
- /* For greedy ? operator. */
- struct sljit_label *zero_matchingpath;
- /* Contains the branches of a failed condition. */
- union {
- /* Both for OP_COND, OP_SCOND. */
- jump_list *condfailed;
- assert_backtrack *assert;
- /* For OP_ONCE. Less than 0 if not needed. */
- int framesize;
- } u;
- /* Points to our private memory word on the stack. */
- int private_data_ptr;
-} bracket_backtrack;
-
-typedef struct bracketpos_backtrack {
- backtrack_common common;
- /* Points to our private memory word on the stack. */
- int private_data_ptr;
- /* Reverting stack is needed. */
- int framesize;
- /* Allocated stack size. */
- int stacksize;
-} bracketpos_backtrack;
-
-typedef struct braminzero_backtrack {
- backtrack_common common;
- struct sljit_label *matchingpath;
-} braminzero_backtrack;
-
-typedef struct iterator_backtrack {
- backtrack_common common;
- /* Next iteration. */
- struct sljit_label *matchingpath;
-} iterator_backtrack;
-
-typedef struct recurse_entry {
- struct recurse_entry *next;
- /* Contains the function entry. */
- struct sljit_label *entry;
- /* Collects the calls until the function is not created. */
- jump_list *calls;
- /* Points to the starting opcode. */
- sljit_sw start;
-} recurse_entry;
-
-typedef struct recurse_backtrack {
- backtrack_common common;
- BOOL inlined_pattern;
-} recurse_backtrack;
-
-#define OP_THEN_TRAP OP_TABLE_LENGTH
-
-typedef struct then_trap_backtrack {
- backtrack_common common;
- /* If then_trap is not NULL, this structure contains the real
- then_trap for the backtracking path. */
- struct then_trap_backtrack *then_trap;
- /* Points to the starting opcode. */
- sljit_sw start;
- /* Exit point for the then opcodes of this alternative. */
- jump_list *quit;
- /* Frame size of the current alternative. */
- int framesize;
-} then_trap_backtrack;
-
-#define MAX_RANGE_SIZE 4
-
-typedef struct compiler_common {
- /* The sljit ceneric compiler. */
- struct sljit_compiler *compiler;
- /* First byte code. */
- pcre_uchar *start;
- /* Maps private data offset to each opcode. */
- sljit_si *private_data_ptrs;
- /* Chain list of read-only data ptrs. */
- void *read_only_data_head;
- /* Tells whether the capturing bracket is optimized. */
- pcre_uint8 *optimized_cbracket;
- /* Tells whether the starting offset is a target of then. */
- pcre_uint8 *then_offsets;
- /* Current position where a THEN must jump. */
- then_trap_backtrack *then_trap;
- /* Starting offset of private data for capturing brackets. */
- int cbra_ptr;
- /* Output vector starting point. Must be divisible by 2. */
- int ovector_start;
- /* Last known position of the requested byte. */
- int req_char_ptr;
- /* Head of the last recursion. */
- int recursive_head_ptr;
- /* First inspected character for partial matching. */
- int start_used_ptr;
- /* Starting pointer for partial soft matches. */
- int hit_start;
- /* End pointer of the first line. */
- int first_line_end;
- /* Points to the marked string. */
- int mark_ptr;
- /* Recursive control verb management chain. */
- int control_head_ptr;
- /* Points to the last matched capture block index. */
- int capture_last_ptr;
- /* Points to the starting position of the current match. */
- int start_ptr;
-
- /* Flipped and lower case tables. */
- const pcre_uint8 *fcc;
- sljit_sw lcc;
- /* Mode can be PCRE_STUDY_JIT_COMPILE and others. */
- int mode;
- /* TRUE, when minlength is greater than 0. */
- BOOL might_be_empty;
- /* \K is found in the pattern. */
- BOOL has_set_som;
- /* (*SKIP:arg) is found in the pattern. */
- BOOL has_skip_arg;
- /* (*THEN) is found in the pattern. */
- BOOL has_then;
- /* Needs to know the start position anytime. */
- BOOL needs_start_ptr;
- /* Currently in recurse or negative assert. */
- BOOL local_exit;
- /* Currently in a positive assert. */
- BOOL positive_assert;
- /* Newline control. */
- int nltype;
- pcre_uint32 nlmax;
- pcre_uint32 nlmin;
- int newline;
- int bsr_nltype;
- pcre_uint32 bsr_nlmax;
- pcre_uint32 bsr_nlmin;
- /* Dollar endonly. */
- int endonly;
- /* Tables. */
- sljit_sw ctypes;
- /* Named capturing brackets. */
- pcre_uchar *name_table;
- sljit_sw name_count;
- sljit_sw name_entry_size;
-
- /* Labels and jump lists. */
- struct sljit_label *partialmatchlabel;
- struct sljit_label *quit_label;
- struct sljit_label *forced_quit_label;
- struct sljit_label *accept_label;
- struct sljit_label *ff_newline_shortcut;
- stub_list *stubs;
- label_addr_list *label_addrs;
- recurse_entry *entries;
- recurse_entry *currententry;
- jump_list *partialmatch;
- jump_list *quit;
- jump_list *positive_assert_quit;
- jump_list *forced_quit;
- jump_list *accept;
- jump_list *calllimit;
- jump_list *stackalloc;
- jump_list *revertframes;
- jump_list *wordboundary;
- jump_list *anynewline;
- jump_list *hspace;
- jump_list *vspace;
- jump_list *casefulcmp;
- jump_list *caselesscmp;
- jump_list *reset_match;
- BOOL jscript_compat;
-#ifdef SUPPORT_UTF
- BOOL utf;
-#ifdef SUPPORT_UCP
- BOOL use_ucp;
-#endif
-#ifdef COMPILE_PCRE8
- jump_list *utfreadchar;
- jump_list *utfreadchar16;
- jump_list *utfreadtype8;
-#endif
-#endif /* SUPPORT_UTF */
-#ifdef SUPPORT_UCP
- jump_list *getucd;
-#endif
-} compiler_common;
-
-/* For byte_sequence_compare. */
-
-typedef struct compare_context {
- int length;
- int sourcereg;
-#if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
- int ucharptr;
- union {
- sljit_si asint;
- sljit_uh asushort;
-#if defined COMPILE_PCRE8
- sljit_ub asbyte;
- sljit_ub asuchars[4];
-#elif defined COMPILE_PCRE16
- sljit_uh asuchars[2];
-#elif defined COMPILE_PCRE32
- sljit_ui asuchars[1];
-#endif
- } c;
- union {
- sljit_si asint;
- sljit_uh asushort;
-#if defined COMPILE_PCRE8
- sljit_ub asbyte;
- sljit_ub asuchars[4];
-#elif defined COMPILE_PCRE16
- sljit_uh asuchars[2];
-#elif defined COMPILE_PCRE32
- sljit_ui asuchars[1];
-#endif
- } oc;
-#endif
-} compare_context;
-
-/* Undefine sljit macros. */
-#undef CMP
-
-/* Used for accessing the elements of the stack. */
-#define STACK(i) ((-(i) - 1) * (int)sizeof(sljit_sw))
-
-#define TMP1 SLJIT_R0
-#define TMP2 SLJIT_R2
-#define TMP3 SLJIT_R3
-#define STR_PTR SLJIT_S0
-#define STR_END SLJIT_S1
-#define STACK_TOP SLJIT_R1
-#define STACK_LIMIT SLJIT_S2
-#define COUNT_MATCH SLJIT_S3
-#define ARGUMENTS SLJIT_S4
-#define RETURN_ADDR SLJIT_R4
-
-/* Local space layout. */
-/* These two locals can be used by the current opcode. */
-#define LOCALS0 (0 * sizeof(sljit_sw))
-#define LOCALS1 (1 * sizeof(sljit_sw))
-/* Two local variables for possessive quantifiers (char1 cannot use them). */
-#define POSSESSIVE0 (2 * sizeof(sljit_sw))
-#define POSSESSIVE1 (3 * sizeof(sljit_sw))
-/* Max limit of recursions. */
-#define LIMIT_MATCH (4 * sizeof(sljit_sw))
-/* The output vector is stored on the stack, and contains pointers
-to characters. The vector data is divided into two groups: the first
-group contains the start / end character pointers, and the second is
-the start pointers when the end of the capturing group has not yet reached. */
-#define OVECTOR_START (common->ovector_start)
-#define OVECTOR(i) (OVECTOR_START + (i) * (sljit_sw)sizeof(sljit_sw))
-#define OVECTOR_PRIV(i) (common->cbra_ptr + (i) * (sljit_sw)sizeof(sljit_sw))
-#define PRIVATE_DATA(cc) (common->private_data_ptrs[(cc) - common->start])
-
-#if defined COMPILE_PCRE8
-#define MOV_UCHAR SLJIT_MOV_UB
-#define MOVU_UCHAR SLJIT_MOVU_UB
-#elif defined COMPILE_PCRE16
-#define MOV_UCHAR SLJIT_MOV_UH
-#define MOVU_UCHAR SLJIT_MOVU_UH
-#elif defined COMPILE_PCRE32
-#define MOV_UCHAR SLJIT_MOV_UI
-#define MOVU_UCHAR SLJIT_MOVU_UI
-#else
-#error Unsupported compiling mode
-#endif
-
-/* Shortcuts. */
-#define DEFINE_COMPILER \
- struct sljit_compiler *compiler = common->compiler
-#define OP1(op, dst, dstw, src, srcw) \
- sljit_emit_op1(compiler, (op), (dst), (dstw), (src), (srcw))
-#define OP2(op, dst, dstw, src1, src1w, src2, src2w) \
- sljit_emit_op2(compiler, (op), (dst), (dstw), (src1), (src1w), (src2), (src2w))
-#define LABEL() \
- sljit_emit_label(compiler)
-#define JUMP(type) \
- sljit_emit_jump(compiler, (type))
-#define JUMPTO(type, label) \
- sljit_set_label(sljit_emit_jump(compiler, (type)), (label))
-#define JUMPHERE(jump) \
- sljit_set_label((jump), sljit_emit_label(compiler))
-#define SET_LABEL(jump, label) \
- sljit_set_label((jump), (label))
-#define CMP(type, src1, src1w, src2, src2w) \
- sljit_emit_cmp(compiler, (type), (src1), (src1w), (src2), (src2w))
-#define CMPTO(type, src1, src1w, src2, src2w, label) \
- sljit_set_label(sljit_emit_cmp(compiler, (type), (src1), (src1w), (src2), (src2w)), (label))
-#define OP_FLAGS(op, dst, dstw, src, srcw, type) \
- sljit_emit_op_flags(compiler, (op), (dst), (dstw), (src), (srcw), (type))
-#define GET_LOCAL_BASE(dst, dstw, offset) \
- sljit_get_local_base(compiler, (dst), (dstw), (offset))
-
-#define READ_CHAR_MAX 0x7fffffff
-
-static pcre_uchar *bracketend(pcre_uchar *cc)
-{
-SLJIT_ASSERT((*cc >= OP_ASSERT && *cc <= OP_ASSERTBACK_NOT) || (*cc >= OP_ONCE && *cc <= OP_SCOND));
-do cc += GET(cc, 1); while (*cc == OP_ALT);
-SLJIT_ASSERT(*cc >= OP_KET && *cc <= OP_KETRPOS);
-cc += 1 + LINK_SIZE;
-return cc;
-}
-
-static int no_alternatives(pcre_uchar *cc)
-{
-int count = 0;
-SLJIT_ASSERT((*cc >= OP_ASSERT && *cc <= OP_ASSERTBACK_NOT) || (*cc >= OP_ONCE && *cc <= OP_SCOND));
-do
- {
- cc += GET(cc, 1);
- count++;
- }
-while (*cc == OP_ALT);
-SLJIT_ASSERT(*cc >= OP_KET && *cc <= OP_KETRPOS);
-return count;
-}
-
-static int ones_in_half_byte[16] = {
- /* 0 */ 0, 1, 1, 2, /* 4 */ 1, 2, 2, 3,
- /* 8 */ 1, 2, 2, 3, /* 12 */ 2, 3, 3, 4
-};
-
-/* Functions whose might need modification for all new supported opcodes:
- next_opcode
- check_opcode_types
- set_private_data_ptrs
- get_framesize
- init_frame
- get_private_data_copy_length
- copy_private_data
- compile_matchingpath
- compile_backtrackingpath
-*/
-
-static pcre_uchar *next_opcode(compiler_common *common, pcre_uchar *cc)
-{
-SLJIT_UNUSED_ARG(common);
-switch(*cc)
- {
- case OP_SOD:
- case OP_SOM:
- case OP_SET_SOM:
- case OP_NOT_WORD_BOUNDARY:
- case OP_WORD_BOUNDARY:
- case OP_NOT_DIGIT:
- case OP_DIGIT:
- case OP_NOT_WHITESPACE:
- case OP_WHITESPACE:
- case OP_NOT_WORDCHAR:
- case OP_WORDCHAR:
- case OP_ANY:
- case OP_ALLANY:
- case OP_NOTPROP:
- case OP_PROP:
- case OP_ANYNL:
- case OP_NOT_HSPACE:
- case OP_HSPACE:
- case OP_NOT_VSPACE:
- case OP_VSPACE:
- case OP_EXTUNI:
- case OP_EODN:
- case OP_EOD:
- case OP_CIRC:
- case OP_CIRCM:
- case OP_DOLL:
- case OP_DOLLM:
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- case OP_CRPOSSTAR:
- case OP_CRPOSPLUS:
- case OP_CRPOSQUERY:
- case OP_CRPOSRANGE:
- case OP_CLASS:
- case OP_NCLASS:
- case OP_REF:
- case OP_REFI:
- case OP_DNREF:
- case OP_DNREFI:
- case OP_RECURSE:
- case OP_CALLOUT:
- case OP_ALT:
- case OP_KET:
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_KETRPOS:
- case OP_REVERSE:
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- case OP_ONCE:
- case OP_ONCE_NC:
- case OP_BRA:
- case OP_BRAPOS:
- case OP_CBRA:
- case OP_CBRAPOS:
- case OP_COND:
- case OP_SBRA:
- case OP_SBRAPOS:
- case OP_SCBRA:
- case OP_SCBRAPOS:
- case OP_SCOND:
- case OP_CREF:
- case OP_DNCREF:
- case OP_RREF:
- case OP_DNRREF:
- case OP_DEF:
- case OP_BRAZERO:
- case OP_BRAMINZERO:
- case OP_BRAPOSZERO:
- case OP_PRUNE:
- case OP_SKIP:
- case OP_THEN:
- case OP_COMMIT:
- case OP_FAIL:
- case OP_ACCEPT:
- case OP_ASSERT_ACCEPT:
- case OP_CLOSE:
- case OP_SKIPZERO:
- return cc + PRIV(OP_lengths)[*cc];
-
- case OP_CHAR:
- case OP_CHARI:
- case OP_NOT:
- case OP_NOTI:
- case OP_STAR:
- case OP_MINSTAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_UPTO:
- case OP_MINUPTO:
- case OP_EXACT:
- case OP_POSSTAR:
- case OP_POSPLUS:
- case OP_POSQUERY:
- case OP_POSUPTO:
- case OP_STARI:
- case OP_MINSTARI:
- case OP_PLUSI:
- case OP_MINPLUSI:
- case OP_QUERYI:
- case OP_MINQUERYI:
- case OP_UPTOI:
- case OP_MINUPTOI:
- case OP_EXACTI:
- case OP_POSSTARI:
- case OP_POSPLUSI:
- case OP_POSQUERYI:
- case OP_POSUPTOI:
- case OP_NOTSTAR:
- case OP_NOTMINSTAR:
- case OP_NOTPLUS:
- case OP_NOTMINPLUS:
- case OP_NOTQUERY:
- case OP_NOTMINQUERY:
- case OP_NOTUPTO:
- case OP_NOTMINUPTO:
- case OP_NOTEXACT:
- case OP_NOTPOSSTAR:
- case OP_NOTPOSPLUS:
- case OP_NOTPOSQUERY:
- case OP_NOTPOSUPTO:
- case OP_NOTSTARI:
- case OP_NOTMINSTARI:
- case OP_NOTPLUSI:
- case OP_NOTMINPLUSI:
- case OP_NOTQUERYI:
- case OP_NOTMINQUERYI:
- case OP_NOTUPTOI:
- case OP_NOTMINUPTOI:
- case OP_NOTEXACTI:
- case OP_NOTPOSSTARI:
- case OP_NOTPOSPLUSI:
- case OP_NOTPOSQUERYI:
- case OP_NOTPOSUPTOI:
- cc += PRIV(OP_lengths)[*cc];
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- return cc;
-
- /* Special cases. */
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- case OP_TYPEEXACT:
- case OP_TYPEPOSSTAR:
- case OP_TYPEPOSPLUS:
- case OP_TYPEPOSQUERY:
- case OP_TYPEPOSUPTO:
- return cc + PRIV(OP_lengths)[*cc] - 1;
-
- case OP_ANYBYTE:
-#ifdef SUPPORT_UTF
- if (common->utf) return NULL;
-#endif
- return cc + 1;
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- return cc + GET(cc, 1);
-#endif
-
- case OP_MARK:
- case OP_PRUNE_ARG:
- case OP_SKIP_ARG:
- case OP_THEN_ARG:
- return cc + 1 + 2 + cc[1];
-
- default:
- /* All opcodes are supported now! */
- SLJIT_ASSERT_STOP();
- return NULL;
- }
-}
-
-static BOOL check_opcode_types(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend)
-{
-int count;
-pcre_uchar *slot;
-
-/* Calculate important variables (like stack size) and checks whether all opcodes are supported. */
-while (cc < ccend)
- {
- switch(*cc)
- {
- case OP_SET_SOM:
- common->has_set_som = TRUE;
- common->might_be_empty = TRUE;
- cc += 1;
- break;
-
- case OP_REF:
- case OP_REFI:
- common->optimized_cbracket[GET2(cc, 1)] = 0;
- cc += 1 + IMM2_SIZE;
- break;
-
- case OP_CBRAPOS:
- case OP_SCBRAPOS:
- common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] = 0;
- cc += 1 + LINK_SIZE + IMM2_SIZE;
- break;
-
- case OP_COND:
- case OP_SCOND:
- /* Only AUTO_CALLOUT can insert this opcode. We do
- not intend to support this case. */
- if (cc[1 + LINK_SIZE] == OP_CALLOUT)
- return FALSE;
- cc += 1 + LINK_SIZE;
- break;
-
- case OP_CREF:
- common->optimized_cbracket[GET2(cc, 1)] = 0;
- cc += 1 + IMM2_SIZE;
- break;
-
- case OP_DNREF:
- case OP_DNREFI:
- case OP_DNCREF:
- count = GET2(cc, 1 + IMM2_SIZE);
- slot = common->name_table + GET2(cc, 1) * common->name_entry_size;
- while (count-- > 0)
- {
- common->optimized_cbracket[GET2(slot, 0)] = 0;
- slot += common->name_entry_size;
- }
- cc += 1 + 2 * IMM2_SIZE;
- break;
-
- case OP_RECURSE:
- /* Set its value only once. */
- if (common->recursive_head_ptr == 0)
- {
- common->recursive_head_ptr = common->ovector_start;
- common->ovector_start += sizeof(sljit_sw);
- }
- cc += 1 + LINK_SIZE;
- break;
-
- case OP_CALLOUT:
- if (common->capture_last_ptr == 0)
- {
- common->capture_last_ptr = common->ovector_start;
- common->ovector_start += sizeof(sljit_sw);
- }
- cc += 2 + 2 * LINK_SIZE;
- break;
-
- case OP_THEN_ARG:
- common->has_then = TRUE;
- common->control_head_ptr = 1;
- /* Fall through. */
-
- case OP_PRUNE_ARG:
- common->needs_start_ptr = TRUE;
- /* Fall through. */
-
- case OP_MARK:
- if (common->mark_ptr == 0)
- {
- common->mark_ptr = common->ovector_start;
- common->ovector_start += sizeof(sljit_sw);
- }
- cc += 1 + 2 + cc[1];
- break;
-
- case OP_THEN:
- common->has_then = TRUE;
- common->control_head_ptr = 1;
- /* Fall through. */
-
- case OP_PRUNE:
- case OP_SKIP:
- common->needs_start_ptr = TRUE;
- cc += 1;
- break;
-
- case OP_SKIP_ARG:
- common->control_head_ptr = 1;
- common->has_skip_arg = TRUE;
- cc += 1 + 2 + cc[1];
- break;
-
- default:
- cc = next_opcode(common, cc);
- if (cc == NULL)
- return FALSE;
- break;
- }
- }
-return TRUE;
-}
-
-static int get_class_iterator_size(pcre_uchar *cc)
-{
-switch(*cc)
- {
- case OP_CRSTAR:
- case OP_CRPLUS:
- return 2;
-
- case OP_CRMINSTAR:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- return 1;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- if (GET2(cc, 1) == GET2(cc, 1 + IMM2_SIZE))
- return 0;
- return 2;
-
- default:
- return 0;
- }
-}
-
-static BOOL detect_repeat(compiler_common *common, pcre_uchar *begin)
-{
-pcre_uchar *end = bracketend(begin);
-pcre_uchar *next;
-pcre_uchar *next_end;
-pcre_uchar *max_end;
-pcre_uchar type;
-sljit_sw length = end - begin;
-int min, max, i;
-
-/* Detect fixed iterations first. */
-if (end[-(1 + LINK_SIZE)] != OP_KET)
- return FALSE;
-
-/* Already detected repeat. */
-if (common->private_data_ptrs[end - common->start - LINK_SIZE] != 0)
- return TRUE;
-
-next = end;
-min = 1;
-while (1)
- {
- if (*next != *begin)
- break;
- next_end = bracketend(next);
- if (next_end - next != length || memcmp(begin, next, IN_UCHARS(length)) != 0)
- break;
- next = next_end;
- min++;
- }
-
-if (min == 2)
- return FALSE;
-
-max = 0;
-max_end = next;
-if (*next == OP_BRAZERO || *next == OP_BRAMINZERO)
- {
- type = *next;
- while (1)
- {
- if (next[0] != type || next[1] != OP_BRA || next[2 + LINK_SIZE] != *begin)
- break;
- next_end = bracketend(next + 2 + LINK_SIZE);
- if (next_end - next != (length + 2 + LINK_SIZE) || memcmp(begin, next + 2 + LINK_SIZE, IN_UCHARS(length)) != 0)
- break;
- next = next_end;
- max++;
- }
-
- if (next[0] == type && next[1] == *begin && max >= 1)
- {
- next_end = bracketend(next + 1);
- if (next_end - next == (length + 1) && memcmp(begin, next + 1, IN_UCHARS(length)) == 0)
- {
- for (i = 0; i < max; i++, next_end += 1 + LINK_SIZE)
- if (*next_end != OP_KET)
- break;
-
- if (i == max)
- {
- common->private_data_ptrs[max_end - common->start - LINK_SIZE] = next_end - max_end;
- common->private_data_ptrs[max_end - common->start - LINK_SIZE + 1] = (type == OP_BRAZERO) ? OP_UPTO : OP_MINUPTO;
- /* +2 the original and the last. */
- common->private_data_ptrs[max_end - common->start - LINK_SIZE + 2] = max + 2;
- if (min == 1)
- return TRUE;
- min--;
- max_end -= (1 + LINK_SIZE) + GET(max_end, -LINK_SIZE);
- }
- }
- }
- }
-
-if (min >= 3)
- {
- common->private_data_ptrs[end - common->start - LINK_SIZE] = max_end - end;
- common->private_data_ptrs[end - common->start - LINK_SIZE + 1] = OP_EXACT;
- common->private_data_ptrs[end - common->start - LINK_SIZE + 2] = min;
- return TRUE;
- }
-
-return FALSE;
-}
-
-#define CASE_ITERATOR_PRIVATE_DATA_1 \
- case OP_MINSTAR: \
- case OP_MINPLUS: \
- case OP_QUERY: \
- case OP_MINQUERY: \
- case OP_MINSTARI: \
- case OP_MINPLUSI: \
- case OP_QUERYI: \
- case OP_MINQUERYI: \
- case OP_NOTMINSTAR: \
- case OP_NOTMINPLUS: \
- case OP_NOTQUERY: \
- case OP_NOTMINQUERY: \
- case OP_NOTMINSTARI: \
- case OP_NOTMINPLUSI: \
- case OP_NOTQUERYI: \
- case OP_NOTMINQUERYI:
-
-#define CASE_ITERATOR_PRIVATE_DATA_2A \
- case OP_STAR: \
- case OP_PLUS: \
- case OP_STARI: \
- case OP_PLUSI: \
- case OP_NOTSTAR: \
- case OP_NOTPLUS: \
- case OP_NOTSTARI: \
- case OP_NOTPLUSI:
-
-#define CASE_ITERATOR_PRIVATE_DATA_2B \
- case OP_UPTO: \
- case OP_MINUPTO: \
- case OP_UPTOI: \
- case OP_MINUPTOI: \
- case OP_NOTUPTO: \
- case OP_NOTMINUPTO: \
- case OP_NOTUPTOI: \
- case OP_NOTMINUPTOI:
-
-#define CASE_ITERATOR_TYPE_PRIVATE_DATA_1 \
- case OP_TYPEMINSTAR: \
- case OP_TYPEMINPLUS: \
- case OP_TYPEQUERY: \
- case OP_TYPEMINQUERY:
-
-#define CASE_ITERATOR_TYPE_PRIVATE_DATA_2A \
- case OP_TYPESTAR: \
- case OP_TYPEPLUS:
-
-#define CASE_ITERATOR_TYPE_PRIVATE_DATA_2B \
- case OP_TYPEUPTO: \
- case OP_TYPEMINUPTO:
-
-static void set_private_data_ptrs(compiler_common *common, int *private_data_start, pcre_uchar *ccend)
-{
-pcre_uchar *cc = common->start;
-pcre_uchar *alternative;
-pcre_uchar *end = NULL;
-int private_data_ptr = *private_data_start;
-int space, size, bracketlen;
-BOOL repeat_check = TRUE;
-
-while (cc < ccend)
- {
- space = 0;
- size = 0;
- bracketlen = 0;
- if (private_data_ptr > SLJIT_MAX_LOCAL_SIZE)
- break;
-
- if (repeat_check && (*cc == OP_ONCE || *cc == OP_ONCE_NC || *cc == OP_BRA || *cc == OP_CBRA || *cc == OP_COND))
- {
- if (detect_repeat(common, cc))
- {
- /* These brackets are converted to repeats, so no global
- based single character repeat is allowed. */
- if (cc >= end)
- end = bracketend(cc);
- }
- }
- repeat_check = TRUE;
-
- switch(*cc)
- {
- case OP_KET:
- if (common->private_data_ptrs[cc + 1 - common->start] != 0)
- {
- common->private_data_ptrs[cc - common->start] = private_data_ptr;
- private_data_ptr += sizeof(sljit_sw);
- cc += common->private_data_ptrs[cc + 1 - common->start];
- }
- cc += 1 + LINK_SIZE;
- break;
-
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- case OP_ONCE:
- case OP_ONCE_NC:
- case OP_BRAPOS:
- case OP_SBRA:
- case OP_SBRAPOS:
- case OP_SCOND:
- common->private_data_ptrs[cc - common->start] = private_data_ptr;
- private_data_ptr += sizeof(sljit_sw);
- bracketlen = 1 + LINK_SIZE;
- break;
-
- case OP_CBRAPOS:
- case OP_SCBRAPOS:
- common->private_data_ptrs[cc - common->start] = private_data_ptr;
- private_data_ptr += sizeof(sljit_sw);
- bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
- break;
-
- case OP_COND:
- /* Might be a hidden SCOND. */
- alternative = cc + GET(cc, 1);
- if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
- {
- common->private_data_ptrs[cc - common->start] = private_data_ptr;
- private_data_ptr += sizeof(sljit_sw);
- }
- bracketlen = 1 + LINK_SIZE;
- break;
-
- case OP_BRA:
- bracketlen = 1 + LINK_SIZE;
- break;
-
- case OP_CBRA:
- case OP_SCBRA:
- bracketlen = 1 + LINK_SIZE + IMM2_SIZE;
- break;
-
- case OP_BRAZERO:
- case OP_BRAMINZERO:
- case OP_BRAPOSZERO:
- repeat_check = FALSE;
- size = 1;
- break;
-
- CASE_ITERATOR_PRIVATE_DATA_1
- space = 1;
- size = -2;
- break;
-
- CASE_ITERATOR_PRIVATE_DATA_2A
- space = 2;
- size = -2;
- break;
-
- CASE_ITERATOR_PRIVATE_DATA_2B
- space = 2;
- size = -(2 + IMM2_SIZE);
- break;
-
- CASE_ITERATOR_TYPE_PRIVATE_DATA_1
- space = 1;
- size = 1;
- break;
-
- CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
- if (cc[1] != OP_ANYNL && cc[1] != OP_EXTUNI)
- space = 2;
- size = 1;
- break;
-
- case OP_TYPEUPTO:
- if (cc[1 + IMM2_SIZE] != OP_ANYNL && cc[1 + IMM2_SIZE] != OP_EXTUNI)
- space = 2;
- size = 1 + IMM2_SIZE;
- break;
-
- case OP_TYPEMINUPTO:
- space = 2;
- size = 1 + IMM2_SIZE;
- break;
-
- case OP_CLASS:
- case OP_NCLASS:
- size += 1 + 32 / sizeof(pcre_uchar);
- space = get_class_iterator_size(cc + size);
- break;
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- size = GET(cc, 1);
- space = get_class_iterator_size(cc + size);
- break;
-#endif
-
- default:
- cc = next_opcode(common, cc);
- SLJIT_ASSERT(cc != NULL);
- break;
- }
-
- /* Character iterators, which are not inside a repeated bracket,
- gets a private slot instead of allocating it on the stack. */
- if (space > 0 && cc >= end)
- {
- common->private_data_ptrs[cc - common->start] = private_data_ptr;
- private_data_ptr += sizeof(sljit_sw) * space;
- }
-
- if (size != 0)
- {
- if (size < 0)
- {
- cc += -size;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- }
- else
- cc += size;
- }
-
- if (bracketlen > 0)
- {
- if (cc >= end)
- {
- end = bracketend(cc);
- if (end[-1 - LINK_SIZE] == OP_KET)
- end = NULL;
- }
- cc += bracketlen;
- }
- }
-*private_data_start = private_data_ptr;
-}
-
-/* Returns with a frame_types (always < 0) if no need for frame. */
-static int get_framesize(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, BOOL recursive, BOOL *needs_control_head)
-{
-int length = 0;
-int possessive = 0;
-BOOL stack_restore = FALSE;
-BOOL setsom_found = recursive;
-BOOL setmark_found = recursive;
-/* The last capture is a local variable even for recursions. */
-BOOL capture_last_found = FALSE;
-
-#if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD
-SLJIT_ASSERT(common->control_head_ptr != 0);
-*needs_control_head = TRUE;
-#else
-*needs_control_head = FALSE;
-#endif
-
-if (ccend == NULL)
- {
- ccend = bracketend(cc) - (1 + LINK_SIZE);
- if (!recursive && (*cc == OP_CBRAPOS || *cc == OP_SCBRAPOS))
- {
- possessive = length = (common->capture_last_ptr != 0) ? 5 : 3;
- /* This is correct regardless of common->capture_last_ptr. */
- capture_last_found = TRUE;
- }
- cc = next_opcode(common, cc);
- }
-
-SLJIT_ASSERT(cc != NULL);
-while (cc < ccend)
- switch(*cc)
- {
- case OP_SET_SOM:
- SLJIT_ASSERT(common->has_set_som);
- stack_restore = TRUE;
- if (!setsom_found)
- {
- length += 2;
- setsom_found = TRUE;
- }
- cc += 1;
- break;
-
- case OP_MARK:
- case OP_PRUNE_ARG:
- case OP_THEN_ARG:
- SLJIT_ASSERT(common->mark_ptr != 0);
- stack_restore = TRUE;
- if (!setmark_found)
- {
- length += 2;
- setmark_found = TRUE;
- }
- if (common->control_head_ptr != 0)
- *needs_control_head = TRUE;
- cc += 1 + 2 + cc[1];
- break;
-
- case OP_RECURSE:
- stack_restore = TRUE;
- if (common->has_set_som && !setsom_found)
- {
- length += 2;
- setsom_found = TRUE;
- }
- if (common->mark_ptr != 0 && !setmark_found)
- {
- length += 2;
- setmark_found = TRUE;
- }
- if (common->capture_last_ptr != 0 && !capture_last_found)
- {
- length += 2;
- capture_last_found = TRUE;
- }
- cc += 1 + LINK_SIZE;
- break;
-
- case OP_CBRA:
- case OP_CBRAPOS:
- case OP_SCBRA:
- case OP_SCBRAPOS:
- stack_restore = TRUE;
- if (common->capture_last_ptr != 0 && !capture_last_found)
- {
- length += 2;
- capture_last_found = TRUE;
- }
- length += 3;
- cc += 1 + LINK_SIZE + IMM2_SIZE;
- break;
-
- case OP_THEN:
- stack_restore = TRUE;
- if (common->control_head_ptr != 0)
- *needs_control_head = TRUE;
- cc ++;
- break;
-
- default:
- stack_restore = TRUE;
- /* Fall through. */
-
- case OP_NOT_WORD_BOUNDARY:
- case OP_WORD_BOUNDARY:
- case OP_NOT_DIGIT:
- case OP_DIGIT:
- case OP_NOT_WHITESPACE:
- case OP_WHITESPACE:
- case OP_NOT_WORDCHAR:
- case OP_WORDCHAR:
- case OP_ANY:
- case OP_ALLANY:
- case OP_ANYBYTE:
- case OP_NOTPROP:
- case OP_PROP:
- case OP_ANYNL:
- case OP_NOT_HSPACE:
- case OP_HSPACE:
- case OP_NOT_VSPACE:
- case OP_VSPACE:
- case OP_EXTUNI:
- case OP_EODN:
- case OP_EOD:
- case OP_CIRC:
- case OP_CIRCM:
- case OP_DOLL:
- case OP_DOLLM:
- case OP_CHAR:
- case OP_CHARI:
- case OP_NOT:
- case OP_NOTI:
-
- case OP_EXACT:
- case OP_POSSTAR:
- case OP_POSPLUS:
- case OP_POSQUERY:
- case OP_POSUPTO:
-
- case OP_EXACTI:
- case OP_POSSTARI:
- case OP_POSPLUSI:
- case OP_POSQUERYI:
- case OP_POSUPTOI:
-
- case OP_NOTEXACT:
- case OP_NOTPOSSTAR:
- case OP_NOTPOSPLUS:
- case OP_NOTPOSQUERY:
- case OP_NOTPOSUPTO:
-
- case OP_NOTEXACTI:
- case OP_NOTPOSSTARI:
- case OP_NOTPOSPLUSI:
- case OP_NOTPOSQUERYI:
- case OP_NOTPOSUPTOI:
-
- case OP_TYPEEXACT:
- case OP_TYPEPOSSTAR:
- case OP_TYPEPOSPLUS:
- case OP_TYPEPOSQUERY:
- case OP_TYPEPOSUPTO:
-
- case OP_CLASS:
- case OP_NCLASS:
- case OP_XCLASS:
-
- cc = next_opcode(common, cc);
- SLJIT_ASSERT(cc != NULL);
- break;
- }
-
-/* Possessive quantifiers can use a special case. */
-if (SLJIT_UNLIKELY(possessive == length))
- return stack_restore ? no_frame : no_stack;
-
-if (length > 0)
- return length + 1;
-return stack_restore ? no_frame : no_stack;
-}
-
-static void init_frame(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, int stackpos, int stacktop, BOOL recursive)
-{
-DEFINE_COMPILER;
-BOOL setsom_found = recursive;
-BOOL setmark_found = recursive;
-/* The last capture is a local variable even for recursions. */
-BOOL capture_last_found = FALSE;
-int offset;
-
-/* >= 1 + shortest item size (2) */
-SLJIT_UNUSED_ARG(stacktop);
-SLJIT_ASSERT(stackpos >= stacktop + 2);
-
-stackpos = STACK(stackpos);
-if (ccend == NULL)
- {
- ccend = bracketend(cc) - (1 + LINK_SIZE);
- if (recursive || (*cc != OP_CBRAPOS && *cc != OP_SCBRAPOS))
- cc = next_opcode(common, cc);
- }
-
-SLJIT_ASSERT(cc != NULL);
-while (cc < ccend)
- switch(*cc)
- {
- case OP_SET_SOM:
- SLJIT_ASSERT(common->has_set_som);
- if (!setsom_found)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -OVECTOR(0));
- stackpos += (int)sizeof(sljit_sw);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
- stackpos += (int)sizeof(sljit_sw);
- setsom_found = TRUE;
- }
- cc += 1;
- break;
-
- case OP_MARK:
- case OP_PRUNE_ARG:
- case OP_THEN_ARG:
- SLJIT_ASSERT(common->mark_ptr != 0);
- if (!setmark_found)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->mark_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -common->mark_ptr);
- stackpos += (int)sizeof(sljit_sw);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
- stackpos += (int)sizeof(sljit_sw);
- setmark_found = TRUE;
- }
- cc += 1 + 2 + cc[1];
- break;
-
- case OP_RECURSE:
- if (common->has_set_som && !setsom_found)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -OVECTOR(0));
- stackpos += (int)sizeof(sljit_sw);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
- stackpos += (int)sizeof(sljit_sw);
- setsom_found = TRUE;
- }
- if (common->mark_ptr != 0 && !setmark_found)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->mark_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -common->mark_ptr);
- stackpos += (int)sizeof(sljit_sw);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
- stackpos += (int)sizeof(sljit_sw);
- setmark_found = TRUE;
- }
- if (common->capture_last_ptr != 0 && !capture_last_found)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -common->capture_last_ptr);
- stackpos += (int)sizeof(sljit_sw);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
- stackpos += (int)sizeof(sljit_sw);
- capture_last_found = TRUE;
- }
- cc += 1 + LINK_SIZE;
- break;
-
- case OP_CBRA:
- case OP_CBRAPOS:
- case OP_SCBRA:
- case OP_SCBRAPOS:
- if (common->capture_last_ptr != 0 && !capture_last_found)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, -common->capture_last_ptr);
- stackpos += (int)sizeof(sljit_sw);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
- stackpos += (int)sizeof(sljit_sw);
- capture_last_found = TRUE;
- }
- offset = (GET2(cc, 1 + LINK_SIZE)) << 1;
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, OVECTOR(offset));
- stackpos += (int)sizeof(sljit_sw);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset));
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP1, 0);
- stackpos += (int)sizeof(sljit_sw);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, TMP2, 0);
- stackpos += (int)sizeof(sljit_sw);
-
- cc += 1 + LINK_SIZE + IMM2_SIZE;
- break;
-
- default:
- cc = next_opcode(common, cc);
- SLJIT_ASSERT(cc != NULL);
- break;
- }
-
-OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackpos, SLJIT_IMM, 0);
-SLJIT_ASSERT(stackpos == STACK(stacktop));
-}
-
-static SLJIT_INLINE int get_private_data_copy_length(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, BOOL needs_control_head)
-{
-int private_data_length = needs_control_head ? 3 : 2;
-int size;
-pcre_uchar *alternative;
-/* Calculate the sum of the private machine words. */
-while (cc < ccend)
- {
- size = 0;
- switch(*cc)
- {
- case OP_KET:
- if (PRIVATE_DATA(cc) != 0)
- {
- private_data_length++;
- SLJIT_ASSERT(PRIVATE_DATA(cc + 1) != 0);
- cc += PRIVATE_DATA(cc + 1);
- }
- cc += 1 + LINK_SIZE;
- break;
-
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- case OP_ONCE:
- case OP_ONCE_NC:
- case OP_BRAPOS:
- case OP_SBRA:
- case OP_SBRAPOS:
- case OP_SCOND:
- private_data_length++;
- SLJIT_ASSERT(PRIVATE_DATA(cc) != 0);
- cc += 1 + LINK_SIZE;
- break;
-
- case OP_CBRA:
- case OP_SCBRA:
- if (common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] == 0)
- private_data_length++;
- cc += 1 + LINK_SIZE + IMM2_SIZE;
- break;
-
- case OP_CBRAPOS:
- case OP_SCBRAPOS:
- private_data_length += 2;
- cc += 1 + LINK_SIZE + IMM2_SIZE;
- break;
-
- case OP_COND:
- /* Might be a hidden SCOND. */
- alternative = cc + GET(cc, 1);
- if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
- private_data_length++;
- cc += 1 + LINK_SIZE;
- break;
-
- CASE_ITERATOR_PRIVATE_DATA_1
- if (PRIVATE_DATA(cc))
- private_data_length++;
- cc += 2;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- break;
-
- CASE_ITERATOR_PRIVATE_DATA_2A
- if (PRIVATE_DATA(cc))
- private_data_length += 2;
- cc += 2;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- break;
-
- CASE_ITERATOR_PRIVATE_DATA_2B
- if (PRIVATE_DATA(cc))
- private_data_length += 2;
- cc += 2 + IMM2_SIZE;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- break;
-
- CASE_ITERATOR_TYPE_PRIVATE_DATA_1
- if (PRIVATE_DATA(cc))
- private_data_length++;
- cc += 1;
- break;
-
- CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
- if (PRIVATE_DATA(cc))
- private_data_length += 2;
- cc += 1;
- break;
-
- CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
- if (PRIVATE_DATA(cc))
- private_data_length += 2;
- cc += 1 + IMM2_SIZE;
- break;
-
- case OP_CLASS:
- case OP_NCLASS:
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- size = (*cc == OP_XCLASS) ? GET(cc, 1) : 1 + 32 / (int)sizeof(pcre_uchar);
-#else
- size = 1 + 32 / (int)sizeof(pcre_uchar);
-#endif
- if (PRIVATE_DATA(cc))
- private_data_length += get_class_iterator_size(cc + size);
- cc += size;
- break;
-
- default:
- cc = next_opcode(common, cc);
- SLJIT_ASSERT(cc != NULL);
- break;
- }
- }
-SLJIT_ASSERT(cc == ccend);
-return private_data_length;
-}
-
-static void copy_private_data(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend,
- BOOL save, int stackptr, int stacktop, BOOL needs_control_head)
-{
-DEFINE_COMPILER;
-int srcw[2];
-int count, size;
-BOOL tmp1next = TRUE;
-BOOL tmp1empty = TRUE;
-BOOL tmp2empty = TRUE;
-pcre_uchar *alternative;
-enum {
- start,
- loop,
- end
-} status;
-
-status = save ? start : loop;
-stackptr = STACK(stackptr - 2);
-stacktop = STACK(stacktop - 1);
-
-if (!save)
- {
- stackptr += (needs_control_head ? 2 : 1) * sizeof(sljit_sw);
- if (stackptr < stacktop)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);
- stackptr += sizeof(sljit_sw);
- tmp1empty = FALSE;
- }
- if (stackptr < stacktop)
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), stackptr);
- stackptr += sizeof(sljit_sw);
- tmp2empty = FALSE;
- }
- /* The tmp1next must be TRUE in either way. */
- }
-
-do
- {
- count = 0;
- switch(status)
- {
- case start:
- SLJIT_ASSERT(save && common->recursive_head_ptr != 0);
- count = 1;
- srcw[0] = common->recursive_head_ptr;
- if (needs_control_head)
- {
- SLJIT_ASSERT(common->control_head_ptr != 0);
- count = 2;
- srcw[1] = common->control_head_ptr;
- }
- status = loop;
- break;
-
- case loop:
- if (cc >= ccend)
- {
- status = end;
- break;
- }
-
- switch(*cc)
- {
- case OP_KET:
- if (PRIVATE_DATA(cc) != 0)
- {
- count = 1;
- srcw[0] = PRIVATE_DATA(cc);
- SLJIT_ASSERT(PRIVATE_DATA(cc + 1) != 0);
- cc += PRIVATE_DATA(cc + 1);
- }
- cc += 1 + LINK_SIZE;
- break;
-
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- case OP_ONCE:
- case OP_ONCE_NC:
- case OP_BRAPOS:
- case OP_SBRA:
- case OP_SBRAPOS:
- case OP_SCOND:
- count = 1;
- srcw[0] = PRIVATE_DATA(cc);
- SLJIT_ASSERT(srcw[0] != 0);
- cc += 1 + LINK_SIZE;
- break;
-
- case OP_CBRA:
- case OP_SCBRA:
- if (common->optimized_cbracket[GET2(cc, 1 + LINK_SIZE)] == 0)
- {
- count = 1;
- srcw[0] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));
- }
- cc += 1 + LINK_SIZE + IMM2_SIZE;
- break;
-
- case OP_CBRAPOS:
- case OP_SCBRAPOS:
- count = 2;
- srcw[0] = PRIVATE_DATA(cc);
- srcw[1] = OVECTOR_PRIV(GET2(cc, 1 + LINK_SIZE));
- SLJIT_ASSERT(srcw[0] != 0 && srcw[1] != 0);
- cc += 1 + LINK_SIZE + IMM2_SIZE;
- break;
-
- case OP_COND:
- /* Might be a hidden SCOND. */
- alternative = cc + GET(cc, 1);
- if (*alternative == OP_KETRMAX || *alternative == OP_KETRMIN)
- {
- count = 1;
- srcw[0] = PRIVATE_DATA(cc);
- SLJIT_ASSERT(srcw[0] != 0);
- }
- cc += 1 + LINK_SIZE;
- break;
-
- CASE_ITERATOR_PRIVATE_DATA_1
- if (PRIVATE_DATA(cc))
- {
- count = 1;
- srcw[0] = PRIVATE_DATA(cc);
- }
- cc += 2;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- break;
-
- CASE_ITERATOR_PRIVATE_DATA_2A
- if (PRIVATE_DATA(cc))
- {
- count = 2;
- srcw[0] = PRIVATE_DATA(cc);
- srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_sw);
- }
- cc += 2;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- break;
-
- CASE_ITERATOR_PRIVATE_DATA_2B
- if (PRIVATE_DATA(cc))
- {
- count = 2;
- srcw[0] = PRIVATE_DATA(cc);
- srcw[1] = PRIVATE_DATA(cc) + sizeof(sljit_sw);
- }
- cc += 2 + IMM2_SIZE;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- break;
-
- CASE_ITERATOR_TYPE_PRIVATE_DATA_1
- if (PRIVATE_DATA(cc))
- {
- count = 1;
- srcw[0] = PRIVATE_DATA(cc);
- }
- cc += 1;
- break;
-
- CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
- if (PRIVATE_DATA(cc))
- {
- count = 2;
- srcw[0] = PRIVATE_DATA(cc);
- srcw[1] = srcw[0] + sizeof(sljit_sw);
- }
- cc += 1;
- break;
-
- CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
- if (PRIVATE_DATA(cc))
- {
- count = 2;
- srcw[0] = PRIVATE_DATA(cc);
- srcw[1] = srcw[0] + sizeof(sljit_sw);
- }
- cc += 1 + IMM2_SIZE;
- break;
-
- case OP_CLASS:
- case OP_NCLASS:
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- size = (*cc == OP_XCLASS) ? GET(cc, 1) : 1 + 32 / (int)sizeof(pcre_uchar);
-#else
- size = 1 + 32 / (int)sizeof(pcre_uchar);
-#endif
- if (PRIVATE_DATA(cc))
- switch(get_class_iterator_size(cc + size))
- {
- case 1:
- count = 1;
- srcw[0] = PRIVATE_DATA(cc);
- break;
-
- case 2:
- count = 2;
- srcw[0] = PRIVATE_DATA(cc);
- srcw[1] = srcw[0] + sizeof(sljit_sw);
- break;
-
- default:
- SLJIT_ASSERT_STOP();
- break;
- }
- cc += size;
- break;
-
- default:
- cc = next_opcode(common, cc);
- SLJIT_ASSERT(cc != NULL);
- break;
- }
- break;
-
- case end:
- SLJIT_ASSERT_STOP();
- break;
- }
-
- while (count > 0)
- {
- count--;
- if (save)
- {
- if (tmp1next)
- {
- if (!tmp1empty)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);
- stackptr += sizeof(sljit_sw);
- }
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), srcw[count]);
- tmp1empty = FALSE;
- tmp1next = FALSE;
- }
- else
- {
- if (!tmp2empty)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);
- stackptr += sizeof(sljit_sw);
- }
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), srcw[count]);
- tmp2empty = FALSE;
- tmp1next = TRUE;
- }
- }
- else
- {
- if (tmp1next)
- {
- SLJIT_ASSERT(!tmp1empty);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), srcw[count], TMP1, 0);
- tmp1empty = stackptr >= stacktop;
- if (!tmp1empty)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), stackptr);
- stackptr += sizeof(sljit_sw);
- }
- tmp1next = FALSE;
- }
- else
- {
- SLJIT_ASSERT(!tmp2empty);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), srcw[count], TMP2, 0);
- tmp2empty = stackptr >= stacktop;
- if (!tmp2empty)
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), stackptr);
- stackptr += sizeof(sljit_sw);
- }
- tmp1next = TRUE;
- }
- }
- }
- }
-while (status != end);
-
-if (save)
- {
- if (tmp1next)
- {
- if (!tmp1empty)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);
- stackptr += sizeof(sljit_sw);
- }
- if (!tmp2empty)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);
- stackptr += sizeof(sljit_sw);
- }
- }
- else
- {
- if (!tmp2empty)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP2, 0);
- stackptr += sizeof(sljit_sw);
- }
- if (!tmp1empty)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), stackptr, TMP1, 0);
- stackptr += sizeof(sljit_sw);
- }
- }
- }
-SLJIT_ASSERT(cc == ccend && stackptr == stacktop && (save || (tmp1empty && tmp2empty)));
-}
-
-static SLJIT_INLINE pcre_uchar *set_then_offsets(compiler_common *common, pcre_uchar *cc, pcre_uint8 *current_offset)
-{
-pcre_uchar *end = bracketend(cc);
-BOOL has_alternatives = cc[GET(cc, 1)] == OP_ALT;
-
-/* Assert captures then. */
-if (*cc >= OP_ASSERT && *cc <= OP_ASSERTBACK_NOT)
- current_offset = NULL;
-/* Conditional block does not. */
-if (*cc == OP_COND || *cc == OP_SCOND)
- has_alternatives = FALSE;
-
-cc = next_opcode(common, cc);
-if (has_alternatives)
- current_offset = common->then_offsets + (cc - common->start);
-
-while (cc < end)
- {
- if ((*cc >= OP_ASSERT && *cc <= OP_ASSERTBACK_NOT) || (*cc >= OP_ONCE && *cc <= OP_SCOND))
- cc = set_then_offsets(common, cc, current_offset);
- else
- {
- if (*cc == OP_ALT && has_alternatives)
- current_offset = common->then_offsets + (cc + 1 + LINK_SIZE - common->start);
- if (*cc >= OP_THEN && *cc <= OP_THEN_ARG && current_offset != NULL)
- *current_offset = 1;
- cc = next_opcode(common, cc);
- }
- }
-
-return end;
-}
-
-#undef CASE_ITERATOR_PRIVATE_DATA_1
-#undef CASE_ITERATOR_PRIVATE_DATA_2A
-#undef CASE_ITERATOR_PRIVATE_DATA_2B
-#undef CASE_ITERATOR_TYPE_PRIVATE_DATA_1
-#undef CASE_ITERATOR_TYPE_PRIVATE_DATA_2A
-#undef CASE_ITERATOR_TYPE_PRIVATE_DATA_2B
-
-static SLJIT_INLINE BOOL is_powerof2(unsigned int value)
-{
-return (value & (value - 1)) == 0;
-}
-
-static SLJIT_INLINE void set_jumps(jump_list *list, struct sljit_label *label)
-{
-while (list)
- {
- /* sljit_set_label is clever enough to do nothing
- if either the jump or the label is NULL. */
- SET_LABEL(list->jump, label);
- list = list->next;
- }
-}
-
-static SLJIT_INLINE void add_jump(struct sljit_compiler *compiler, jump_list **list, struct sljit_jump *jump)
-{
-jump_list *list_item = sljit_alloc_memory(compiler, sizeof(jump_list));
-if (list_item)
- {
- list_item->next = *list;
- list_item->jump = jump;
- *list = list_item;
- }
-}
-
-static void add_stub(compiler_common *common, struct sljit_jump *start)
-{
-DEFINE_COMPILER;
-stub_list *list_item = sljit_alloc_memory(compiler, sizeof(stub_list));
-
-if (list_item)
- {
- list_item->start = start;
- list_item->quit = LABEL();
- list_item->next = common->stubs;
- common->stubs = list_item;
- }
-}
-
-static void flush_stubs(compiler_common *common)
-{
-DEFINE_COMPILER;
-stub_list *list_item = common->stubs;
-
-while (list_item)
- {
- JUMPHERE(list_item->start);
- add_jump(compiler, &common->stackalloc, JUMP(SLJIT_FAST_CALL));
- JUMPTO(SLJIT_JUMP, list_item->quit);
- list_item = list_item->next;
- }
-common->stubs = NULL;
-}
-
-static void add_label_addr(compiler_common *common, sljit_uw *update_addr)
-{
-DEFINE_COMPILER;
-label_addr_list *label_addr;
-
-label_addr = sljit_alloc_memory(compiler, sizeof(label_addr_list));
-if (label_addr == NULL)
- return;
-label_addr->label = LABEL();
-label_addr->update_addr = update_addr;
-label_addr->next = common->label_addrs;
-common->label_addrs = label_addr;
-}
-
-static SLJIT_INLINE void count_match(compiler_common *common)
-{
-DEFINE_COMPILER;
-
-OP2(SLJIT_SUB | SLJIT_SET_E, COUNT_MATCH, 0, COUNT_MATCH, 0, SLJIT_IMM, 1);
-add_jump(compiler, &common->calllimit, JUMP(SLJIT_ZERO));
-}
-
-static SLJIT_INLINE void allocate_stack(compiler_common *common, int size)
-{
-/* May destroy all locals and registers except TMP2. */
-DEFINE_COMPILER;
-
-OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw));
-#ifdef DESTROY_REGISTERS
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 12345);
-OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
-OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, TMP1, 0);
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, TMP1, 0);
-#endif
-add_stub(common, CMP(SLJIT_GREATER, STACK_TOP, 0, STACK_LIMIT, 0));
-}
-
-static SLJIT_INLINE void free_stack(compiler_common *common, int size)
-{
-DEFINE_COMPILER;
-OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, size * sizeof(sljit_sw));
-}
-
-static sljit_uw * allocate_read_only_data(compiler_common *common, sljit_uw size)
-{
-DEFINE_COMPILER;
-sljit_uw *result;
-
-if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- return NULL;
-
-result = (sljit_uw *)SLJIT_MALLOC(size + sizeof(sljit_uw), compiler->allocator_data);
-if (SLJIT_UNLIKELY(result == NULL))
- {
- sljit_set_compiler_memory_error(compiler);
- return NULL;
- }
-
-*(void**)result = common->read_only_data_head;
-common->read_only_data_head = (void *)result;
-return result + 1;
-}
-
-static void free_read_only_data(void *current, void *allocator_data)
-{
-void *next;
-
-SLJIT_UNUSED_ARG(allocator_data);
-
-while (current != NULL)
- {
- next = *(void**)current;
- SLJIT_FREE(current, allocator_data);
- current = next;
- }
-}
-
-static SLJIT_INLINE void reset_ovector(compiler_common *common, int length)
-{
-DEFINE_COMPILER;
-struct sljit_label *loop;
-int i;
-
-/* At this point we can freely use all temporary registers. */
-SLJIT_ASSERT(length > 1);
-/* TMP1 returns with begin - 1. */
-OP2(SLJIT_SUB, SLJIT_R0, 0, SLJIT_MEM1(SLJIT_S0), SLJIT_OFFSETOF(jit_arguments, begin), SLJIT_IMM, IN_UCHARS(1));
-if (length < 8)
- {
- for (i = 1; i < length; i++)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(i), SLJIT_R0, 0);
- }
-else
- {
- GET_LOCAL_BASE(SLJIT_R1, 0, OVECTOR_START);
- OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, length - 1);
- loop = LABEL();
- OP1(SLJIT_MOVU, SLJIT_MEM1(SLJIT_R1), sizeof(sljit_sw), SLJIT_R0, 0);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, 1);
- JUMPTO(SLJIT_NOT_ZERO, loop);
- }
-}
-
-static SLJIT_INLINE void do_reset_match(compiler_common *common, int length)
-{
-DEFINE_COMPILER;
-struct sljit_label *loop;
-int i;
-
-SLJIT_ASSERT(length > 1);
-/* OVECTOR(1) contains the "string begin - 1" constant. */
-if (length > 2)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(1));
-if (length < 8)
- {
- for (i = 2; i < length; i++)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(i), TMP1, 0);
- }
-else
- {
- GET_LOCAL_BASE(TMP2, 0, OVECTOR_START + sizeof(sljit_sw));
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_IMM, length - 2);
- loop = LABEL();
- OP1(SLJIT_MOVU, SLJIT_MEM1(TMP2), sizeof(sljit_sw), TMP1, 0);
- OP2(SLJIT_SUB | SLJIT_SET_E, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 1);
- JUMPTO(SLJIT_NOT_ZERO, loop);
- }
-
-OP1(SLJIT_MOV, STACK_TOP, 0, ARGUMENTS, 0);
-if (common->mark_ptr != 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->mark_ptr, SLJIT_IMM, 0);
-if (common->control_head_ptr != 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_IMM, 0);
-OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(jit_arguments, stack));
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->start_ptr);
-OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), SLJIT_OFFSETOF(struct sljit_stack, base));
-}
-
-static sljit_sw SLJIT_CALL do_search_mark(sljit_sw *current, const pcre_uchar *skip_arg)
-{
-while (current != NULL)
- {
- switch (current[-2])
- {
- case type_then_trap:
- break;
-
- case type_mark:
- if (STRCMP_UC_UC(skip_arg, (pcre_uchar *)current[-3]) == 0)
- return current[-4];
- break;
-
- default:
- SLJIT_ASSERT_STOP();
- break;
- }
- SLJIT_ASSERT(current > (sljit_sw*)current[-1]);
- current = (sljit_sw*)current[-1];
- }
-return -1;
-}
-
-static SLJIT_INLINE void copy_ovector(compiler_common *common, int topbracket)
-{
-DEFINE_COMPILER;
-struct sljit_label *loop;
-struct sljit_jump *early_quit;
-
-/* At this point we can freely use all registers. */
-OP1(SLJIT_MOV, SLJIT_S2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(1));
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(1), STR_PTR, 0);
-
-OP1(SLJIT_MOV, SLJIT_R0, 0, ARGUMENTS, 0);
-if (common->mark_ptr != 0)
- OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), common->mark_ptr);
-OP1(SLJIT_MOV_SI, SLJIT_R1, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, offset_count));
-if (common->mark_ptr != 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, mark_ptr), SLJIT_R2, 0);
-OP2(SLJIT_SUB, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, offsets), SLJIT_IMM, sizeof(int));
-OP1(SLJIT_MOV, SLJIT_R0, 0, SLJIT_MEM1(SLJIT_R0), SLJIT_OFFSETOF(jit_arguments, begin));
-GET_LOCAL_BASE(SLJIT_S0, 0, OVECTOR_START);
-/* Unlikely, but possible */
-early_quit = CMP(SLJIT_EQUAL, SLJIT_R1, 0, SLJIT_IMM, 0);
-loop = LABEL();
-OP2(SLJIT_SUB, SLJIT_S1, 0, SLJIT_MEM1(SLJIT_S0), 0, SLJIT_R0, 0);
-OP2(SLJIT_ADD, SLJIT_S0, 0, SLJIT_S0, 0, SLJIT_IMM, sizeof(sljit_sw));
-/* Copy the integer value to the output buffer */
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-OP2(SLJIT_ASHR, SLJIT_S1, 0, SLJIT_S1, 0, SLJIT_IMM, UCHAR_SHIFT);
-#endif
-OP1(SLJIT_MOVU_SI, SLJIT_MEM1(SLJIT_R2), sizeof(int), SLJIT_S1, 0);
-OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_R1, 0, SLJIT_R1, 0, SLJIT_IMM, 1);
-JUMPTO(SLJIT_NOT_ZERO, loop);
-JUMPHERE(early_quit);
-
-/* Calculate the return value, which is the maximum ovector value. */
-if (topbracket > 1)
- {
- GET_LOCAL_BASE(SLJIT_R0, 0, OVECTOR_START + topbracket * 2 * sizeof(sljit_sw));
- OP1(SLJIT_MOV, SLJIT_R1, 0, SLJIT_IMM, topbracket + 1);
-
- /* OVECTOR(0) is never equal to SLJIT_S2. */
- loop = LABEL();
- OP1(SLJIT_MOVU, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R0), -(2 * (sljit_sw)sizeof(sljit_sw)));
- OP2(SLJIT_SUB, SLJIT_R1, 0, SLJIT_R1, 0, SLJIT_IMM, 1);
- CMPTO(SLJIT_EQUAL, SLJIT_R2, 0, SLJIT_S2, 0, loop);
- OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_R1, 0);
- }
-else
- OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1);
-}
-
-static SLJIT_INLINE void return_with_partial_match(compiler_common *common, struct sljit_label *quit)
-{
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-
-SLJIT_COMPILE_ASSERT(STR_END == SLJIT_S1, str_end_must_be_saved_reg2);
-SLJIT_ASSERT(common->start_used_ptr != 0 && common->start_ptr != 0
- && (common->mode == JIT_PARTIAL_SOFT_COMPILE ? common->hit_start != 0 : common->hit_start == 0));
-
-OP1(SLJIT_MOV, SLJIT_R1, 0, ARGUMENTS, 0);
-OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_PARTIAL);
-OP1(SLJIT_MOV_SI, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, real_offset_count));
-CMPTO(SLJIT_SIG_LESS, SLJIT_R2, 0, SLJIT_IMM, 2, quit);
-
-/* Store match begin and end. */
-OP1(SLJIT_MOV, SLJIT_S0, 0, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, begin));
-OP1(SLJIT_MOV, SLJIT_R1, 0, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, offsets));
-
-jump = CMP(SLJIT_SIG_LESS, SLJIT_R2, 0, SLJIT_IMM, 3);
-OP2(SLJIT_SUB, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), common->mode == JIT_PARTIAL_HARD_COMPILE ? common->start_ptr : (common->hit_start + (int)sizeof(sljit_sw)), SLJIT_S0, 0);
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-OP2(SLJIT_ASHR, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, UCHAR_SHIFT);
-#endif
-OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_R1), 2 * sizeof(int), SLJIT_R2, 0);
-JUMPHERE(jump);
-
-OP1(SLJIT_MOV, SLJIT_R2, 0, SLJIT_MEM1(SLJIT_SP), common->mode == JIT_PARTIAL_HARD_COMPILE ? common->start_used_ptr : common->hit_start);
-OP2(SLJIT_SUB, SLJIT_S1, 0, STR_END, 0, SLJIT_S0, 0);
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-OP2(SLJIT_ASHR, SLJIT_S1, 0, SLJIT_S1, 0, SLJIT_IMM, UCHAR_SHIFT);
-#endif
-OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_R1), sizeof(int), SLJIT_S1, 0);
-
-OP2(SLJIT_SUB, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_S0, 0);
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-OP2(SLJIT_ASHR, SLJIT_R2, 0, SLJIT_R2, 0, SLJIT_IMM, UCHAR_SHIFT);
-#endif
-OP1(SLJIT_MOV_SI, SLJIT_MEM1(SLJIT_R1), 0, SLJIT_R2, 0);
-
-JUMPTO(SLJIT_JUMP, quit);
-}
-
-static SLJIT_INLINE void check_start_used_ptr(compiler_common *common)
-{
-/* May destroy TMP1. */
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-
-if (common->mode == JIT_PARTIAL_SOFT_COMPILE)
- {
- /* The value of -1 must be kept for start_used_ptr! */
- OP2(SLJIT_ADD, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, SLJIT_IMM, 1);
- /* Jumps if start_used_ptr < STR_PTR, or start_used_ptr == -1. Although overwriting
- is not necessary if start_used_ptr == STR_PTR, it does not hurt as well. */
- jump = CMP(SLJIT_LESS_EQUAL, TMP1, 0, STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0);
- JUMPHERE(jump);
- }
-else if (common->mode == JIT_PARTIAL_HARD_COMPILE)
- {
- jump = CMP(SLJIT_LESS_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0);
- JUMPHERE(jump);
- }
-}
-
-static SLJIT_INLINE BOOL char_has_othercase(compiler_common *common, pcre_uchar *cc)
-{
-/* Detects if the character has an othercase. */
-unsigned int c;
-
-#ifdef SUPPORT_UTF
-if (common->utf)
- {
- GETCHAR(c, cc);
- if (c > 127)
- {
-#ifdef SUPPORT_UCP
- return c != UCD_OTHERCASE(c);
-#else
- return FALSE;
-#endif
- }
-#ifndef COMPILE_PCRE8
- return common->fcc[c] != c;
-#endif
- }
-else
-#endif
- c = *cc;
-return MAX_255(c) ? common->fcc[c] != c : FALSE;
-}
-
-static SLJIT_INLINE unsigned int char_othercase(compiler_common *common, unsigned int c)
-{
-/* Returns with the othercase. */
-#ifdef SUPPORT_UTF
-if (common->utf && c > 127)
- {
-#ifdef SUPPORT_UCP
- return UCD_OTHERCASE(c);
-#else
- return c;
-#endif
- }
-#endif
-return TABLE_GET(c, common->fcc, c);
-}
-
-static unsigned int char_get_othercase_bit(compiler_common *common, pcre_uchar *cc)
-{
-/* Detects if the character and its othercase has only 1 bit difference. */
-unsigned int c, oc, bit;
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
-int n;
-#endif
-
-#ifdef SUPPORT_UTF
-if (common->utf)
- {
- GETCHAR(c, cc);
- if (c <= 127)
- oc = common->fcc[c];
- else
- {
-#ifdef SUPPORT_UCP
- oc = UCD_OTHERCASE(c);
-#else
- oc = c;
-#endif
- }
- }
-else
- {
- c = *cc;
- oc = TABLE_GET(c, common->fcc, c);
- }
-#else
-c = *cc;
-oc = TABLE_GET(c, common->fcc, c);
-#endif
-
-SLJIT_ASSERT(c != oc);
-
-bit = c ^ oc;
-/* Optimized for English alphabet. */
-if (c <= 127 && bit == 0x20)
- return (0 << 8) | 0x20;
-
-/* Since c != oc, they must have at least 1 bit difference. */
-if (!is_powerof2(bit))
- return 0;
-
-#if defined COMPILE_PCRE8
-
-#ifdef SUPPORT_UTF
-if (common->utf && c > 127)
- {
- n = GET_EXTRALEN(*cc);
- while ((bit & 0x3f) == 0)
- {
- n--;
- bit >>= 6;
- }
- return (n << 8) | bit;
- }
-#endif /* SUPPORT_UTF */
-return (0 << 8) | bit;
-
-#elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-
-#ifdef SUPPORT_UTF
-if (common->utf && c > 65535)
- {
- if (bit >= (1 << 10))
- bit >>= 10;
- else
- return (bit < 256) ? ((2 << 8) | bit) : ((3 << 8) | (bit >> 8));
- }
-#endif /* SUPPORT_UTF */
-return (bit < 256) ? ((0 << 8) | bit) : ((1 << 8) | (bit >> 8));
-
-#endif /* COMPILE_PCRE[8|16|32] */
-}
-
-static void check_partial(compiler_common *common, BOOL force)
-{
-/* Checks whether a partial matching is occurred. Does not modify registers. */
-DEFINE_COMPILER;
-struct sljit_jump *jump = NULL;
-
-SLJIT_ASSERT(!force || common->mode != JIT_COMPILE);
-
-if (common->mode == JIT_COMPILE)
- return;
-
-if (!force)
- jump = CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0);
-else if (common->mode == JIT_PARTIAL_SOFT_COMPILE)
- jump = CMP(SLJIT_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, SLJIT_IMM, -1);
-
-if (common->mode == JIT_PARTIAL_SOFT_COMPILE)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, 0);
-else
- {
- if (common->partialmatchlabel != NULL)
- JUMPTO(SLJIT_JUMP, common->partialmatchlabel);
- else
- add_jump(compiler, &common->partialmatch, JUMP(SLJIT_JUMP));
- }
-
-if (jump != NULL)
- JUMPHERE(jump);
-}
-
-static void check_str_end(compiler_common *common, jump_list **end_reached)
-{
-/* Does not affect registers. Usually used in a tight spot. */
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-
-if (common->mode == JIT_COMPILE)
- {
- add_jump(compiler, end_reached, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));
- return;
- }
-
-jump = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);
-if (common->mode == JIT_PARTIAL_SOFT_COMPILE)
- {
- add_jump(compiler, end_reached, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, 0);
- add_jump(compiler, end_reached, JUMP(SLJIT_JUMP));
- }
-else
- {
- add_jump(compiler, end_reached, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0));
- if (common->partialmatchlabel != NULL)
- JUMPTO(SLJIT_JUMP, common->partialmatchlabel);
- else
- add_jump(compiler, &common->partialmatch, JUMP(SLJIT_JUMP));
- }
-JUMPHERE(jump);
-}
-
-static void detect_partial_match(compiler_common *common, jump_list **backtracks)
-{
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-
-if (common->mode == JIT_COMPILE)
- {
- add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));
- return;
- }
-
-/* Partial matching mode. */
-jump = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);
-add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0));
-if (common->mode == JIT_PARTIAL_SOFT_COMPILE)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, 0);
- add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
- }
-else
- {
- if (common->partialmatchlabel != NULL)
- JUMPTO(SLJIT_JUMP, common->partialmatchlabel);
- else
- add_jump(compiler, &common->partialmatch, JUMP(SLJIT_JUMP));
- }
-JUMPHERE(jump);
-}
-
-static void peek_char(compiler_common *common, pcre_uint32 max)
-{
-/* Reads the character into TMP1, keeps STR_PTR.
-Does not check STR_END. TMP2 Destroyed. */
-DEFINE_COMPILER;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
-struct sljit_jump *jump;
-#endif
-
-SLJIT_UNUSED_ARG(max);
-
-OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
-if (common->utf)
- {
- if (max < 128) return;
-
- jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- add_jump(compiler, &common->utfreadchar, JUMP(SLJIT_FAST_CALL));
- OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
- JUMPHERE(jump);
- }
-#endif /* SUPPORT_UTF && !COMPILE_PCRE32 */
-
-#if defined SUPPORT_UTF && defined COMPILE_PCRE16
-if (common->utf)
- {
- if (max < 0xd800) return;
-
- OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800);
- jump = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1);
- /* TMP2 contains the high surrogate. */
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
- OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x40);
- OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 10);
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3ff);
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
- JUMPHERE(jump);
- }
-#endif
-}
-
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
-
-static BOOL is_char7_bitset(const pcre_uint8 *bitset, BOOL nclass)
-{
-/* Tells whether the character codes below 128 are enough
-to determine a match. */
-const pcre_uint8 value = nclass ? 0xff : 0;
-const pcre_uint8 *end = bitset + 32;
-
-bitset += 16;
-do
- {
- if (*bitset++ != value)
- return FALSE;
- }
-while (bitset < end);
-return TRUE;
-}
-
-static void read_char7_type(compiler_common *common, BOOL full_read)
-{
-/* Reads the precise character type of a character into TMP1, if the character
-is less than 128. Otherwise it returns with zero. Does not check STR_END. The
-full_read argument tells whether characters above max are accepted or not. */
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-
-SLJIT_ASSERT(common->utf);
-
-OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-
-OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
-
-if (full_read)
- {
- jump = CMP(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0xc0);
- OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
- JUMPHERE(jump);
- }
-}
-
-#endif /* SUPPORT_UTF && COMPILE_PCRE8 */
-
-static void read_char_range(compiler_common *common, pcre_uint32 min, pcre_uint32 max, BOOL update_str_ptr)
-{
-/* Reads the precise value of a character into TMP1, if the character is
-between min and max (c >= min && c <= max). Otherwise it returns with a value
-outside the range. Does not check STR_END. */
-DEFINE_COMPILER;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
-struct sljit_jump *jump;
-#endif
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
-struct sljit_jump *jump2;
-#endif
-
-SLJIT_UNUSED_ARG(update_str_ptr);
-SLJIT_UNUSED_ARG(min);
-SLJIT_UNUSED_ARG(max);
-SLJIT_ASSERT(min <= max);
-
-OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
-if (common->utf)
- {
- if (max < 128 && !update_str_ptr) return;
-
- jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
- if (min >= 0x10000)
- {
- OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xf0);
- if (update_str_ptr)
- OP1(SLJIT_MOV_UB, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
- jump2 = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 0x7);
- OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
- OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
- OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
- OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
- OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(2));
- if (!update_str_ptr)
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(3));
- OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
- OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
- JUMPHERE(jump2);
- if (update_str_ptr)
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, RETURN_ADDR, 0);
- }
- else if (min >= 0x800 && max <= 0xffff)
- {
- OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xe0);
- if (update_str_ptr)
- OP1(SLJIT_MOV_UB, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
- jump2 = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 0xf);
- OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
- OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
- if (!update_str_ptr)
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
- OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
- OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
- JUMPHERE(jump2);
- if (update_str_ptr)
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, RETURN_ADDR, 0);
- }
- else if (max >= 0x800)
- add_jump(compiler, (max < 0x10000) ? &common->utfreadchar16 : &common->utfreadchar, JUMP(SLJIT_FAST_CALL));
- else if (max < 128)
- {
- OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
- }
- else
- {
- OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
- if (!update_str_ptr)
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- else
- OP1(SLJIT_MOV_UB, RETURN_ADDR, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);
- OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
- OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
- if (update_str_ptr)
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, RETURN_ADDR, 0);
- }
- JUMPHERE(jump);
- }
-#endif
-
-#if defined SUPPORT_UTF && defined COMPILE_PCRE16
-if (common->utf)
- {
- if (max >= 0x10000)
- {
- OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800);
- jump = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1);
- /* TMP2 contains the high surrogate. */
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
- OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x40);
- OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 10);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3ff);
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
- JUMPHERE(jump);
- return;
- }
-
- if (max < 0xd800 && !update_str_ptr) return;
-
- /* Skip low surrogate if necessary. */
- OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, 0xd800);
- jump = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1);
- if (update_str_ptr)
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- if (max >= 0xd800)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0x10000);
- JUMPHERE(jump);
- }
-#endif
-}
-
-static SLJIT_INLINE void read_char(compiler_common *common)
-{
-read_char_range(common, 0, READ_CHAR_MAX, TRUE);
-}
-
-static void read_char8_type(compiler_common *common, BOOL update_str_ptr)
-{
-/* Reads the character type into TMP1, updates STR_PTR. Does not check STR_END. */
-DEFINE_COMPILER;
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
-struct sljit_jump *jump;
-#endif
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
-struct sljit_jump *jump2;
-#endif
-
-SLJIT_UNUSED_ARG(update_str_ptr);
-
-OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
-if (common->utf)
- {
- /* This can be an extra read in some situations, but hopefully
- it is needed in most cases. */
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
- jump = CMP(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0xc0);
- if (!update_str_ptr)
- {
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
- OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);
- OP2(SLJIT_OR, TMP2, 0, TMP2, 0, TMP1, 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
- jump2 = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 255);
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
- JUMPHERE(jump2);
- }
- else
- add_jump(compiler, &common->utfreadtype8, JUMP(SLJIT_FAST_CALL));
- JUMPHERE(jump);
- return;
- }
-#endif /* SUPPORT_UTF && COMPILE_PCRE8 */
-
-#if !defined COMPILE_PCRE8
-/* The ctypes array contains only 256 values. */
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
-jump = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 255);
-#endif
-OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
-#if !defined COMPILE_PCRE8
-JUMPHERE(jump);
-#endif
-
-#if defined SUPPORT_UTF && defined COMPILE_PCRE16
-if (common->utf && update_str_ptr)
- {
- /* Skip low surrogate if necessary. */
- OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, SLJIT_IMM, 0xd800);
- jump = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 0xdc00 - 0xd800 - 1);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- JUMPHERE(jump);
- }
-#endif /* SUPPORT_UTF && COMPILE_PCRE16 */
-}
-
-static void skip_char_back(compiler_common *common)
-{
-/* Goes one character back. Affects STR_PTR and TMP1. Does not check begin. */
-DEFINE_COMPILER;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
-#if defined COMPILE_PCRE8
-struct sljit_label *label;
-
-if (common->utf)
- {
- label = LABEL();
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));
- OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xc0);
- CMPTO(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0x80, label);
- return;
- }
-#elif defined COMPILE_PCRE16
-if (common->utf)
- {
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), -IN_UCHARS(1));
- OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- /* Skip low surrogate if necessary. */
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xdc00);
- OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
- OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
- OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
- return;
- }
-#endif /* COMPILE_PCRE[8|16] */
-#endif /* SUPPORT_UTF && !COMPILE_PCRE32 */
-OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-}
-
-static void check_newlinechar(compiler_common *common, int nltype, jump_list **backtracks, BOOL jumpifmatch)
-{
-/* Character comes in TMP1. Checks if it is a newline. TMP2 may be destroyed. */
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-
-if (nltype == NLTYPE_ANY)
- {
- add_jump(compiler, &common->anynewline, JUMP(SLJIT_FAST_CALL));
- add_jump(compiler, backtracks, JUMP(jumpifmatch ? SLJIT_NOT_ZERO : SLJIT_ZERO));
- }
-else if (nltype == NLTYPE_ANYCRLF)
- {
- if (jumpifmatch)
- {
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR));
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL));
- }
- else
- {
- jump = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL));
- JUMPHERE(jump);
- }
- }
-else
- {
- SLJIT_ASSERT(nltype == NLTYPE_FIXED && common->newline < 256);
- add_jump(compiler, backtracks, CMP(jumpifmatch ? SLJIT_EQUAL : SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, common->newline));
- }
-}
-
-#ifdef SUPPORT_UTF
-
-#if defined COMPILE_PCRE8
-static void do_utfreadchar(compiler_common *common)
-{
-/* Fast decoding a UTF-8 character. TMP1 contains the first byte
-of the character (>= 0xc0). Return char value in TMP1, length in TMP2. */
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-
-sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
-OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
-OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);
-OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
-OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
-OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
-
-/* Searching for the first zero. */
-OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x800);
-jump = JUMP(SLJIT_NOT_ZERO);
-/* Two byte sequence. */
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(2));
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-
-JUMPHERE(jump);
-OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
-OP2(SLJIT_XOR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x800);
-OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
-OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
-OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
-
-OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x10000);
-jump = JUMP(SLJIT_NOT_ZERO);
-/* Three byte sequence. */
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(3));
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-
-/* Four byte sequence. */
-JUMPHERE(jump);
-OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(2));
-OP2(SLJIT_XOR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x10000);
-OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(3));
-OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
-OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, IN_UCHARS(4));
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-}
-
-static void do_utfreadchar16(compiler_common *common)
-{
-/* Fast decoding a UTF-8 character. TMP1 contains the first byte
-of the character (>= 0xc0). Return value in TMP1. */
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-
-sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
-OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
-OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);
-OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
-OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
-OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
-
-/* Searching for the first zero. */
-OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x800);
-jump = JUMP(SLJIT_NOT_ZERO);
-/* Two byte sequence. */
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-
-JUMPHERE(jump);
-OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x400);
-OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_NOT_ZERO);
-/* This code runs only in 8 bit mode. No need to shift the value. */
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
-OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
-OP2(SLJIT_XOR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x800);
-OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 6);
-OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x3f);
-OP2(SLJIT_OR, TMP1, 0, TMP1, 0, TMP2, 0);
-/* Three byte sequence. */
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-}
-
-static void do_utfreadtype8(compiler_common *common)
-{
-/* Fast decoding a UTF-8 character type. TMP2 contains the first byte
-of the character (>= 0xc0). Return value in TMP1. */
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-struct sljit_jump *compare;
-
-sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
-
-OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0x20);
-jump = JUMP(SLJIT_NOT_ZERO);
-/* Two byte sequence. */
-OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 0x1f);
-/* The upper 5 bits are known at this point. */
-compare = CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, 0x3);
-OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 6);
-OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x3f);
-OP2(SLJIT_OR, TMP2, 0, TMP2, 0, TMP1, 0);
-OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-
-JUMPHERE(compare);
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-
-/* We only have types for characters less than 256. */
-JUMPHERE(jump);
-OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0);
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-}
-
-#endif /* COMPILE_PCRE8 */
-
-#endif /* SUPPORT_UTF */
-
-#ifdef SUPPORT_UCP
-
-/* UCD_BLOCK_SIZE must be 128 (see the assert below). */
-#define UCD_BLOCK_MASK 127
-#define UCD_BLOCK_SHIFT 7
-
-static void do_getucd(compiler_common *common)
-{
-/* Search the UCD record for the character comes in TMP1.
-Returns chartype in TMP1 and UCD offset in TMP2. */
-DEFINE_COMPILER;
-
-SLJIT_ASSERT(UCD_BLOCK_SIZE == 128 && sizeof(ucd_record) == 8);
-
-sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
-OP2(SLJIT_LSHR, TMP2, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
-OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(ucd_stage1));
-OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, UCD_BLOCK_MASK);
-OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCD_BLOCK_SHIFT);
-OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP2, 0);
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_stage2));
-OP1(SLJIT_MOV_UH, TMP2, 0, SLJIT_MEM2(TMP2, TMP1), 1);
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, chartype));
-OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(TMP1, TMP2), 3);
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-}
-#endif
-
-static SLJIT_INLINE struct sljit_label *mainloop_entry(compiler_common *common, BOOL hascrorlf, BOOL firstline)
-{
-DEFINE_COMPILER;
-struct sljit_label *mainloop;
-struct sljit_label *newlinelabel = NULL;
-struct sljit_jump *start;
-struct sljit_jump *end = NULL;
-struct sljit_jump *nl = NULL;
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
-struct sljit_jump *singlechar;
-#endif
-jump_list *newline = NULL;
-BOOL newlinecheck = FALSE;
-BOOL readuchar = FALSE;
-
-if (!(hascrorlf || firstline) && (common->nltype == NLTYPE_ANY ||
- common->nltype == NLTYPE_ANYCRLF || common->newline > 255))
- newlinecheck = TRUE;
-
-if (firstline)
- {
- /* Search for the end of the first line. */
- SLJIT_ASSERT(common->first_line_end != 0);
- OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);
-
- if (common->nltype == NLTYPE_FIXED && common->newline > 255)
- {
- mainloop = LABEL();
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- end = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
- OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
- CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, mainloop);
- CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, mainloop);
- JUMPHERE(end);
- OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_SP), common->first_line_end, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- }
- else
- {
- end = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
- mainloop = LABEL();
- /* Continual stores does not cause data dependency. */
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->first_line_end, STR_PTR, 0);
- read_char_range(common, common->nlmin, common->nlmax, TRUE);
- check_newlinechar(common, common->nltype, &newline, TRUE);
- CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, mainloop);
- JUMPHERE(end);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->first_line_end, STR_PTR, 0);
- set_jumps(newline, LABEL());
- }
-
- OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);
- }
-
-start = JUMP(SLJIT_JUMP);
-
-if (newlinecheck)
- {
- newlinelabel = LABEL();
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- end = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, common->newline & 0xff);
- OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, UCHAR_SHIFT);
-#endif
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
- nl = JUMP(SLJIT_JUMP);
- }
-
-mainloop = LABEL();
-
-/* Increasing the STR_PTR here requires one less jump in the most common case. */
-#ifdef SUPPORT_UTF
-if (common->utf) readuchar = TRUE;
-#endif
-if (newlinecheck) readuchar = TRUE;
-
-if (readuchar)
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
-
-if (newlinecheck)
- CMPTO(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, newlinelabel);
-
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
-#if defined COMPILE_PCRE8
-if (common->utf)
- {
- singlechar = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
- JUMPHERE(singlechar);
- }
-#elif defined COMPILE_PCRE16
-if (common->utf)
- {
- singlechar = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xd800);
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);
- OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
- OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
- JUMPHERE(singlechar);
- }
-#endif /* COMPILE_PCRE[8|16] */
-#endif /* SUPPORT_UTF && !COMPILE_PCRE32 */
-JUMPHERE(start);
-
-if (newlinecheck)
- {
- JUMPHERE(end);
- JUMPHERE(nl);
- }
-
-return mainloop;
-}
-
-#define MAX_N_CHARS 16
-#define MAX_N_BYTES 8
-
-static SLJIT_INLINE void add_prefix_byte(pcre_uint8 byte, pcre_uint8 *bytes)
-{
-pcre_uint8 len = bytes[0];
-int i;
-
-if (len == 255)
- return;
-
-if (len == 0)
- {
- bytes[0] = 1;
- bytes[1] = byte;
- return;
- }
-
-for (i = len; i > 0; i--)
- if (bytes[i] == byte)
- return;
-
-if (len >= MAX_N_BYTES - 1)
- {
- bytes[0] = 255;
- return;
- }
-
-len++;
-bytes[len] = byte;
-bytes[0] = len;
-}
-
-static int scan_prefix(compiler_common *common, pcre_uchar *cc, pcre_uint32 *chars, pcre_uint8 *bytes, int max_chars, pcre_uint32 *rec_count)
-{
-/* Recursive function, which scans prefix literals. */
-BOOL last, any, caseless;
-int len, repeat, len_save, consumed = 0;
-pcre_uint32 chr, mask;
-pcre_uchar *alternative, *cc_save, *oc;
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
-pcre_uchar othercase[8];
-#elif defined SUPPORT_UTF && defined COMPILE_PCRE16
-pcre_uchar othercase[2];
-#else
-pcre_uchar othercase[1];
-#endif
-
-repeat = 1;
-while (TRUE)
- {
- if (*rec_count == 0)
- return 0;
- (*rec_count)--;
-
- last = TRUE;
- any = FALSE;
- caseless = FALSE;
-
- switch (*cc)
- {
- case OP_CHARI:
- caseless = TRUE;
- case OP_CHAR:
- last = FALSE;
- cc++;
- break;
-
- case OP_SOD:
- case OP_SOM:
- case OP_SET_SOM:
- case OP_NOT_WORD_BOUNDARY:
- case OP_WORD_BOUNDARY:
- case OP_EODN:
- case OP_EOD:
- case OP_CIRC:
- case OP_CIRCM:
- case OP_DOLL:
- case OP_DOLLM:
- /* Zero width assertions. */
- cc++;
- continue;
-
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- cc = bracketend(cc);
- continue;
-
- case OP_PLUSI:
- case OP_MINPLUSI:
- case OP_POSPLUSI:
- caseless = TRUE;
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_POSPLUS:
- cc++;
- break;
-
- case OP_EXACTI:
- caseless = TRUE;
- case OP_EXACT:
- repeat = GET2(cc, 1);
- last = FALSE;
- cc += 1 + IMM2_SIZE;
- break;
-
- case OP_QUERYI:
- case OP_MINQUERYI:
- case OP_POSQUERYI:
- caseless = TRUE;
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_POSQUERY:
- len = 1;
- cc++;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(*cc)) len += GET_EXTRALEN(*cc);
-#endif
- max_chars = scan_prefix(common, cc + len, chars, bytes, max_chars, rec_count);
- if (max_chars == 0)
- return consumed;
- last = FALSE;
- break;
-
- case OP_KET:
- cc += 1 + LINK_SIZE;
- continue;
-
- case OP_ALT:
- cc += GET(cc, 1);
- continue;
-
- case OP_ONCE:
- case OP_ONCE_NC:
- case OP_BRA:
- case OP_BRAPOS:
- case OP_CBRA:
- case OP_CBRAPOS:
- alternative = cc + GET(cc, 1);
- while (*alternative == OP_ALT)
- {
- max_chars = scan_prefix(common, alternative + 1 + LINK_SIZE, chars, bytes, max_chars, rec_count);
- if (max_chars == 0)
- return consumed;
- alternative += GET(alternative, 1);
- }
-
- if (*cc == OP_CBRA || *cc == OP_CBRAPOS)
- cc += IMM2_SIZE;
- cc += 1 + LINK_SIZE;
- continue;
-
- case OP_CLASS:
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- if (common->utf && !is_char7_bitset((const pcre_uint8 *)(cc + 1), FALSE)) return consumed;
-#endif
- any = TRUE;
- cc += 1 + 32 / sizeof(pcre_uchar);
- break;
-
- case OP_NCLASS:
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (common->utf) return consumed;
-#endif
- any = TRUE;
- cc += 1 + 32 / sizeof(pcre_uchar);
- break;
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (common->utf) return consumed;
-#endif
- any = TRUE;
- cc += GET(cc, 1);
- break;
-#endif
-
- case OP_DIGIT:
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- if (common->utf && !is_char7_bitset((const pcre_uint8 *)common->ctypes - cbit_length + cbit_digit, FALSE))
- return consumed;
-#endif
- any = TRUE;
- cc++;
- break;
-
- case OP_WHITESPACE:
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- if (common->utf && !is_char7_bitset((const pcre_uint8 *)common->ctypes - cbit_length + cbit_space, FALSE))
- return consumed;
-#endif
- any = TRUE;
- cc++;
- break;
-
- case OP_WORDCHAR:
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- if (common->utf && !is_char7_bitset((const pcre_uint8 *)common->ctypes - cbit_length + cbit_word, FALSE))
- return consumed;
-#endif
- any = TRUE;
- cc++;
- break;
-
- case OP_NOT:
- case OP_NOTI:
- cc++;
- /* Fall through. */
- case OP_NOT_DIGIT:
- case OP_NOT_WHITESPACE:
- case OP_NOT_WORDCHAR:
- case OP_ANY:
- case OP_ALLANY:
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (common->utf) return consumed;
-#endif
- any = TRUE;
- cc++;
- break;
-
-#ifdef SUPPORT_UCP
- case OP_NOTPROP:
- case OP_PROP:
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (common->utf) return consumed;
-#endif
- any = TRUE;
- cc += 1 + 2;
- break;
-#endif
-
- case OP_TYPEEXACT:
- repeat = GET2(cc, 1);
- cc += 1 + IMM2_SIZE;
- continue;
-
- case OP_NOTEXACT:
- case OP_NOTEXACTI:
-#if defined SUPPORT_UTF && !defined COMPILE_PCRE32
- if (common->utf) return consumed;
-#endif
- any = TRUE;
- repeat = GET2(cc, 1);
- cc += 1 + IMM2_SIZE + 1;
- break;
-
- default:
- return consumed;
- }
-
- if (any)
- {
-#if defined COMPILE_PCRE8
- mask = 0xff;
-#elif defined COMPILE_PCRE16
- mask = 0xffff;
-#elif defined COMPILE_PCRE32
- mask = 0xffffffff;
-#else
- SLJIT_ASSERT_STOP();
-#endif
-
- do
- {
- chars[0] = mask;
- chars[1] = mask;
- bytes[0] = 255;
-
- consumed++;
- if (--max_chars == 0)
- return consumed;
- chars += 2;
- bytes += MAX_N_BYTES;
- }
- while (--repeat > 0);
-
- repeat = 1;
- continue;
- }
-
- len = 1;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(*cc)) len += GET_EXTRALEN(*cc);
-#endif
-
- if (caseless && char_has_othercase(common, cc))
- {
-#ifdef SUPPORT_UTF
- if (common->utf)
- {
- GETCHAR(chr, cc);
- if ((int)PRIV(ord2utf)(char_othercase(common, chr), othercase) != len)
- return consumed;
- }
- else
-#endif
- {
- chr = *cc;
- othercase[0] = TABLE_GET(chr, common->fcc, chr);
- }
- }
- else
- caseless = FALSE;
-
- len_save = len;
- cc_save = cc;
- while (TRUE)
- {
- oc = othercase;
- do
- {
- chr = *cc;
-#ifdef COMPILE_PCRE32
- if (SLJIT_UNLIKELY(chr == NOTACHAR))
- return consumed;
-#endif
- add_prefix_byte((pcre_uint8)chr, bytes);
-
- mask = 0;
- if (caseless)
- {
- add_prefix_byte((pcre_uint8)*oc, bytes);
- mask = *cc ^ *oc;
- chr |= mask;
- }
-
-#ifdef COMPILE_PCRE32
- if (chars[0] == NOTACHAR && chars[1] == 0)
-#else
- if (chars[0] == NOTACHAR)
-#endif
- {
- chars[0] = chr;
- chars[1] = mask;
- }
- else
- {
- mask |= chars[0] ^ chr;
- chr |= mask;
- chars[0] = chr;
- chars[1] |= mask;
- }
-
- len--;
- consumed++;
- if (--max_chars == 0)
- return consumed;
- chars += 2;
- bytes += MAX_N_BYTES;
- cc++;
- oc++;
- }
- while (len > 0);
-
- if (--repeat == 0)
- break;
-
- len = len_save;
- cc = cc_save;
- }
-
- repeat = 1;
- if (last)
- return consumed;
- }
-}
-
-static SLJIT_INLINE BOOL fast_forward_first_n_chars(compiler_common *common, BOOL firstline)
-{
-DEFINE_COMPILER;
-struct sljit_label *start;
-struct sljit_jump *quit;
-pcre_uint32 chars[MAX_N_CHARS * 2];
-pcre_uint8 bytes[MAX_N_CHARS * MAX_N_BYTES];
-pcre_uint8 ones[MAX_N_CHARS];
-int offsets[3];
-pcre_uint32 mask;
-pcre_uint8 *byte_set, *byte_set_end;
-int i, max, from;
-int range_right = -1, range_len = 3 - 1;
-sljit_ub *update_table = NULL;
-BOOL in_range;
-pcre_uint32 rec_count;
-
-for (i = 0; i < MAX_N_CHARS; i++)
- {
- chars[i << 1] = NOTACHAR;
- chars[(i << 1) + 1] = 0;
- bytes[i * MAX_N_BYTES] = 0;
- }
-
-rec_count = 10000;
-max = scan_prefix(common, common->start, chars, bytes, MAX_N_CHARS, &rec_count);
-
-if (max <= 1)
- return FALSE;
-
-for (i = 0; i < max; i++)
- {
- mask = chars[(i << 1) + 1];
- ones[i] = ones_in_half_byte[mask & 0xf];
- mask >>= 4;
- while (mask != 0)
- {
- ones[i] += ones_in_half_byte[mask & 0xf];
- mask >>= 4;
- }
- }
-
-in_range = FALSE;
-from = 0; /* Prevent compiler "uninitialized" warning */
-for (i = 0; i <= max; i++)
- {
- if (in_range && (i - from) > range_len && (bytes[(i - 1) * MAX_N_BYTES] <= 4))
- {
- range_len = i - from;
- range_right = i - 1;
- }
-
- if (i < max && bytes[i * MAX_N_BYTES] < 255)
- {
- if (!in_range)
- {
- in_range = TRUE;
- from = i;
- }
- }
- else if (in_range)
- in_range = FALSE;
- }
-
-if (range_right >= 0)
- {
- update_table = (sljit_ub *)allocate_read_only_data(common, 256);
- if (update_table == NULL)
- return TRUE;
- memset(update_table, IN_UCHARS(range_len), 256);
-
- for (i = 0; i < range_len; i++)
- {
- byte_set = bytes + ((range_right - i) * MAX_N_BYTES);
- SLJIT_ASSERT(byte_set[0] > 0 && byte_set[0] < 255);
- byte_set_end = byte_set + byte_set[0];
- byte_set++;
- while (byte_set <= byte_set_end)
- {
- if (update_table[*byte_set] > IN_UCHARS(i))
- update_table[*byte_set] = IN_UCHARS(i);
- byte_set++;
- }
- }
- }
-
-offsets[0] = -1;
-/* Scan forward. */
-for (i = 0; i < max; i++)
- if (ones[i] <= 2) {
- offsets[0] = i;
- break;
- }
-
-if (offsets[0] < 0 && range_right < 0)
- return FALSE;
-
-if (offsets[0] >= 0)
- {
- /* Scan backward. */
- offsets[1] = -1;
- for (i = max - 1; i > offsets[0]; i--)
- if (ones[i] <= 2 && i != range_right)
- {
- offsets[1] = i;
- break;
- }
-
- /* This case is handled better by fast_forward_first_char. */
- if (offsets[1] == -1 && offsets[0] == 0 && range_right < 0)
- return FALSE;
-
- offsets[2] = -1;
- /* We only search for a middle character if there is no range check. */
- if (offsets[1] >= 0 && range_right == -1)
- {
- /* Scan from middle. */
- for (i = (offsets[0] + offsets[1]) / 2 + 1; i < offsets[1]; i++)
- if (ones[i] <= 2)
- {
- offsets[2] = i;
- break;
- }
-
- if (offsets[2] == -1)
- {
- for (i = (offsets[0] + offsets[1]) / 2; i > offsets[0]; i--)
- if (ones[i] <= 2)
- {
- offsets[2] = i;
- break;
- }
- }
- }
-
- SLJIT_ASSERT(offsets[1] == -1 || (offsets[0] < offsets[1]));
- SLJIT_ASSERT(offsets[2] == -1 || (offsets[0] < offsets[2] && offsets[1] > offsets[2]));
-
- chars[0] = chars[offsets[0] << 1];
- chars[1] = chars[(offsets[0] << 1) + 1];
- if (offsets[2] >= 0)
- {
- chars[2] = chars[offsets[2] << 1];
- chars[3] = chars[(offsets[2] << 1) + 1];
- }
- if (offsets[1] >= 0)
- {
- chars[4] = chars[offsets[1] << 1];
- chars[5] = chars[(offsets[1] << 1) + 1];
- }
- }
-
-max -= 1;
-if (firstline)
- {
- SLJIT_ASSERT(common->first_line_end != 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);
- OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
- OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max));
- quit = CMP(SLJIT_LESS_EQUAL, STR_END, 0, TMP1, 0);
- OP1(SLJIT_MOV, STR_END, 0, TMP1, 0);
- JUMPHERE(quit);
- }
-else
- OP2(SLJIT_SUB, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max));
-
-#if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-if (range_right >= 0)
- OP1(SLJIT_MOV, RETURN_ADDR, 0, SLJIT_IMM, (sljit_sw)update_table);
-#endif
-
-start = LABEL();
-quit = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
-
-SLJIT_ASSERT(range_right >= 0 || offsets[0] >= 0);
-
-if (range_right >= 0)
- {
-#if defined COMPILE_PCRE8 || (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right));
-#else
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(range_right + 1) - 1);
-#endif
-
-#if !(defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM2(RETURN_ADDR, TMP1), 0);
-#else
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)update_table);
-#endif
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
- CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0, start);
- }
-
-if (offsets[0] >= 0)
- {
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[0]));
- if (offsets[1] >= 0)
- OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[1]));
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-
- if (chars[1] != 0)
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[1]);
- CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[0], start);
- if (offsets[2] >= 0)
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(offsets[2] - 1));
-
- if (offsets[1] >= 0)
- {
- if (chars[5] != 0)
- OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, chars[5]);
- CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, chars[4], start);
- }
-
- if (offsets[2] >= 0)
- {
- if (chars[3] != 0)
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, chars[3]);
- CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, chars[2], start);
- }
- OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- }
-
-JUMPHERE(quit);
-
-if (firstline)
- {
- if (range_right >= 0)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);
- OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
- if (range_right >= 0)
- {
- quit = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP1, 0);
- OP1(SLJIT_MOV, STR_PTR, 0, TMP1, 0);
- JUMPHERE(quit);
- }
- }
-else
- OP2(SLJIT_ADD, STR_END, 0, STR_END, 0, SLJIT_IMM, IN_UCHARS(max));
-return TRUE;
-}
-
-#undef MAX_N_CHARS
-#undef MAX_N_BYTES
-
-static SLJIT_INLINE void fast_forward_first_char(compiler_common *common, pcre_uchar first_char, BOOL caseless, BOOL firstline)
-{
-DEFINE_COMPILER;
-struct sljit_label *start;
-struct sljit_jump *quit;
-struct sljit_jump *found;
-pcre_uchar oc, bit;
-
-if (firstline)
- {
- SLJIT_ASSERT(common->first_line_end != 0);
- OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
- OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);
- }
-
-start = LABEL();
-quit = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
-OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
-
-oc = first_char;
-if (caseless)
- {
- oc = TABLE_GET(first_char, common->fcc, first_char);
-#if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)
- if (first_char > 127 && common->utf)
- oc = UCD_OTHERCASE(first_char);
-#endif
- }
-if (first_char == oc)
- found = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, first_char);
-else
- {
- bit = first_char ^ oc;
- if (is_powerof2(bit))
- {
- OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, bit);
- found = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, first_char | bit);
- }
- else
- {
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, first_char);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, oc);
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- found = JUMP(SLJIT_NOT_ZERO);
- }
- }
-
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-JUMPTO(SLJIT_JUMP, start);
-JUMPHERE(found);
-JUMPHERE(quit);
-
-if (firstline)
- OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
-}
-
-static SLJIT_INLINE void fast_forward_newline(compiler_common *common, BOOL firstline)
-{
-DEFINE_COMPILER;
-struct sljit_label *loop;
-struct sljit_jump *lastchar;
-struct sljit_jump *firstchar;
-struct sljit_jump *quit;
-struct sljit_jump *foundcr = NULL;
-struct sljit_jump *notfoundnl;
-jump_list *newline = NULL;
-
-if (firstline)
- {
- SLJIT_ASSERT(common->first_line_end != 0);
- OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
- OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);
- }
-
-if (common->nltype == NLTYPE_FIXED && common->newline > 255)
- {
- lastchar = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
- OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));
- firstchar = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP2, 0);
-
- OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(2));
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, STR_PTR, 0, TMP1, 0);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_GREATER_EQUAL);
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, UCHAR_SHIFT);
-#endif
- OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
-
- loop = LABEL();
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- quit = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
- OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
- CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, loop);
- CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, loop);
-
- JUMPHERE(quit);
- JUMPHERE(firstchar);
- JUMPHERE(lastchar);
-
- if (firstline)
- OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
- return;
- }
-
-OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
-firstchar = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP2, 0);
-skip_char_back(common);
-
-loop = LABEL();
-common->ff_newline_shortcut = loop;
-
-read_char_range(common, common->nlmin, common->nlmax, TRUE);
-lastchar = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
-if (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF)
- foundcr = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);
-check_newlinechar(common, common->nltype, &newline, FALSE);
-set_jumps(newline, loop);
-
-if (common->nltype == NLTYPE_ANY || common->nltype == NLTYPE_ANYCRLF)
- {
- quit = JUMP(SLJIT_JUMP);
- JUMPHERE(foundcr);
- notfoundnl = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, CHAR_NL);
- OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, UCHAR_SHIFT);
-#endif
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
- JUMPHERE(notfoundnl);
- JUMPHERE(quit);
- }
-JUMPHERE(lastchar);
-JUMPHERE(firstchar);
-
-if (firstline)
- OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
-}
-
-static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks);
-
-static SLJIT_INLINE void fast_forward_start_bits(compiler_common *common, pcre_uint8 *start_bits, BOOL firstline)
-{
-DEFINE_COMPILER;
-struct sljit_label *start;
-struct sljit_jump *quit;
-struct sljit_jump *found = NULL;
-jump_list *matches = NULL;
-#ifndef COMPILE_PCRE8
-struct sljit_jump *jump;
-#endif
-
-if (firstline)
- {
- SLJIT_ASSERT(common->first_line_end != 0);
- OP1(SLJIT_MOV, RETURN_ADDR, 0, STR_END, 0);
- OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);
- }
-
-start = LABEL();
-quit = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
-OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
-#ifdef SUPPORT_UTF
-if (common->utf)
- OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
-#endif
-
-if (!check_class_ranges(common, start_bits, (start_bits[31] & 0x80) != 0, TRUE, &matches))
- {
-#ifndef COMPILE_PCRE8
- jump = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 255);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 255);
- JUMPHERE(jump);
-#endif
- OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
- OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)start_bits);
- OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
- OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);
- found = JUMP(SLJIT_NOT_ZERO);
- }
-
-#ifdef SUPPORT_UTF
-if (common->utf)
- OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
-#endif
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-#ifdef SUPPORT_UTF
-#if defined COMPILE_PCRE8
-if (common->utf)
- {
- CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0, start);
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
- }
-#elif defined COMPILE_PCRE16
-if (common->utf)
- {
- CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xd800, start);
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);
- OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
- OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
- }
-#endif /* COMPILE_PCRE[8|16] */
-#endif /* SUPPORT_UTF */
-JUMPTO(SLJIT_JUMP, start);
-if (found != NULL)
- JUMPHERE(found);
-if (matches != NULL)
- set_jumps(matches, LABEL());
-JUMPHERE(quit);
-
-if (firstline)
- OP1(SLJIT_MOV, STR_END, 0, RETURN_ADDR, 0);
-}
-
-static SLJIT_INLINE struct sljit_jump *search_requested_char(compiler_common *common, pcre_uchar req_char, BOOL caseless, BOOL has_firstchar)
-{
-DEFINE_COMPILER;
-struct sljit_label *loop;
-struct sljit_jump *toolong;
-struct sljit_jump *alreadyfound;
-struct sljit_jump *found;
-struct sljit_jump *foundoc = NULL;
-struct sljit_jump *notfound;
-pcre_uint32 oc, bit;
-
-SLJIT_ASSERT(common->req_char_ptr != 0);
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->req_char_ptr);
-OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, REQ_BYTE_MAX);
-toolong = CMP(SLJIT_LESS, TMP1, 0, STR_END, 0);
-alreadyfound = CMP(SLJIT_LESS, STR_PTR, 0, TMP2, 0);
-
-if (has_firstchar)
- OP2(SLJIT_ADD, TMP1, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-else
- OP1(SLJIT_MOV, TMP1, 0, STR_PTR, 0);
-
-loop = LABEL();
-notfound = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, STR_END, 0);
-
-OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(TMP1), 0);
-oc = req_char;
-if (caseless)
- {
- oc = TABLE_GET(req_char, common->fcc, req_char);
-#if defined SUPPORT_UCP && !(defined COMPILE_PCRE8)
- if (req_char > 127 && common->utf)
- oc = UCD_OTHERCASE(req_char);
-#endif
- }
-if (req_char == oc)
- found = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, req_char);
-else
- {
- bit = req_char ^ oc;
- if (is_powerof2(bit))
- {
- OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, bit);
- found = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, req_char | bit);
- }
- else
- {
- found = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, req_char);
- foundoc = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, oc);
- }
- }
-OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1));
-JUMPTO(SLJIT_JUMP, loop);
-
-JUMPHERE(found);
-if (foundoc)
- JUMPHERE(foundoc);
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->req_char_ptr, TMP1, 0);
-JUMPHERE(alreadyfound);
-JUMPHERE(toolong);
-return notfound;
-}
-
-static void do_revertframes(compiler_common *common)
-{
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-struct sljit_label *mainloop;
-
-sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
-OP1(SLJIT_MOV, TMP1, 0, STACK_TOP, 0);
-GET_LOCAL_BASE(TMP3, 0, 0);
-
-/* Drop frames until we reach STACK_TOP. */
-mainloop = LABEL();
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), 0);
-OP2(SLJIT_SUB | SLJIT_SET_S, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, 0);
-jump = JUMP(SLJIT_SIG_LESS_EQUAL);
-
-OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP3, 0);
-OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), 0, SLJIT_MEM1(TMP1), sizeof(sljit_sw));
-OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), sizeof(sljit_sw), SLJIT_MEM1(TMP1), 2 * sizeof(sljit_sw));
-OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 3 * sizeof(sljit_sw));
-JUMPTO(SLJIT_JUMP, mainloop);
-
-JUMPHERE(jump);
-jump = JUMP(SLJIT_SIG_LESS);
-/* End of dropping frames. */
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-
-JUMPHERE(jump);
-OP1(SLJIT_NEG, TMP2, 0, TMP2, 0);
-OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP3, 0);
-OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), 0, SLJIT_MEM1(TMP1), sizeof(sljit_sw));
-OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_sw));
-JUMPTO(SLJIT_JUMP, mainloop);
-}
-
-static void check_wordboundary(compiler_common *common)
-{
-DEFINE_COMPILER;
-struct sljit_jump *skipread;
-jump_list *skipread_list = NULL;
-#if !(defined COMPILE_PCRE8) || defined SUPPORT_UTF
-struct sljit_jump *jump;
-#endif
-
-SLJIT_COMPILE_ASSERT(ctype_word == 0x10, ctype_word_must_be_16);
-
-sljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_SP), LOCALS0);
-/* Get type of the previous char, and put it to LOCALS1. */
-OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, SLJIT_IMM, 0);
-skipread = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP1, 0);
-skip_char_back(common);
-check_start_used_ptr(common);
-read_char(common);
-
-/* Testing char type. */
-#ifdef SUPPORT_UCP
-if (common->use_ucp)
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 1);
- jump = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_UNDERSCORE);
- add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Ll);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_Lu - ucp_Ll);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_LESS_EQUAL);
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Nd - ucp_Ll);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_No - ucp_Nd);
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_LESS_EQUAL);
- JUMPHERE(jump);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, TMP2, 0);
- }
-else
-#endif
- {
-#ifndef COMPILE_PCRE8
- jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
-#elif defined SUPPORT_UTF
- /* Here LOCALS1 has already been zeroed. */
- jump = NULL;
- if (common->utf)
- jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
-#endif /* COMPILE_PCRE8 */
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), common->ctypes);
- OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 4 /* ctype_word */);
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, TMP1, 0);
-#ifndef COMPILE_PCRE8
- JUMPHERE(jump);
-#elif defined SUPPORT_UTF
- if (jump != NULL)
- JUMPHERE(jump);
-#endif /* COMPILE_PCRE8 */
- }
-JUMPHERE(skipread);
-
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 0);
-check_str_end(common, &skipread_list);
-peek_char(common, READ_CHAR_MAX);
-
-/* Testing char type. This is a code duplication. */
-#ifdef SUPPORT_UCP
-if (common->use_ucp)
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 1);
- jump = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_UNDERSCORE);
- add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Ll);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_Lu - ucp_Ll);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_LESS_EQUAL);
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ucp_Nd - ucp_Ll);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ucp_No - ucp_Nd);
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_LESS_EQUAL);
- JUMPHERE(jump);
- }
-else
-#endif
- {
-#ifndef COMPILE_PCRE8
- /* TMP2 may be destroyed by peek_char. */
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 0);
- jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
-#elif defined SUPPORT_UTF
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, 0);
- jump = NULL;
- if (common->utf)
- jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
-#endif
- OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), common->ctypes);
- OP2(SLJIT_LSHR, TMP2, 0, TMP2, 0, SLJIT_IMM, 4 /* ctype_word */);
- OP2(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_IMM, 1);
-#ifndef COMPILE_PCRE8
- JUMPHERE(jump);
-#elif defined SUPPORT_UTF
- if (jump != NULL)
- JUMPHERE(jump);
-#endif /* COMPILE_PCRE8 */
- }
-set_jumps(skipread_list, LABEL());
-
-OP2(SLJIT_XOR | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_MEM1(SLJIT_SP), LOCALS1);
-sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_SP), LOCALS0);
-}
-
-static BOOL check_class_ranges(compiler_common *common, const pcre_uint8 *bits, BOOL nclass, BOOL invert, jump_list **backtracks)
-{
-DEFINE_COMPILER;
-int ranges[MAX_RANGE_SIZE];
-pcre_uint8 bit, cbit, all;
-int i, byte, length = 0;
-
-bit = bits[0] & 0x1;
-/* All bits will be zero or one (since bit is zero or one). */
-all = -bit;
-
-for (i = 0; i < 256; )
- {
- byte = i >> 3;
- if ((i & 0x7) == 0 && bits[byte] == all)
- i += 8;
- else
- {
- cbit = (bits[byte] >> (i & 0x7)) & 0x1;
- if (cbit != bit)
- {
- if (length >= MAX_RANGE_SIZE)
- return FALSE;
- ranges[length] = i;
- length++;
- bit = cbit;
- all = -cbit;
- }
- i++;
- }
- }
-
-if (((bit == 0) && nclass) || ((bit == 1) && !nclass))
- {
- if (length >= MAX_RANGE_SIZE)
- return FALSE;
- ranges[length] = 256;
- length++;
- }
-
-if (length < 0 || length > 4)
- return FALSE;
-
-bit = bits[0] & 0x1;
-if (invert) bit ^= 0x1;
-
-/* No character is accepted. */
-if (length == 0 && bit == 0)
- add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
-
-switch(length)
- {
- case 0:
- /* When bit != 0, all characters are accepted. */
- return TRUE;
-
- case 1:
- add_jump(compiler, backtracks, CMP(bit == 0 ? SLJIT_LESS : SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));
- return TRUE;
-
- case 2:
- if (ranges[0] + 1 != ranges[1])
- {
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);
- add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_LESS : SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));
- }
- else
- add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_EQUAL : SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));
- return TRUE;
-
- case 3:
- if (bit != 0)
- {
- add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));
- if (ranges[0] + 1 != ranges[1])
- {
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);
- add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));
- }
- else
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));
- return TRUE;
- }
-
- add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[0]));
- if (ranges[1] + 1 != ranges[2])
- {
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[1]);
- add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[1]));
- }
- else
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1]));
- return TRUE;
-
- case 4:
- if ((ranges[1] - ranges[0]) == (ranges[3] - ranges[2])
- && (ranges[0] | (ranges[2] - ranges[0])) == ranges[2]
- && (ranges[1] & (ranges[2] - ranges[0])) == 0
- && is_powerof2(ranges[2] - ranges[0]))
- {
- SLJIT_ASSERT((ranges[0] & (ranges[2] - ranges[0])) == 0 && (ranges[2] & ranges[3] & (ranges[2] - ranges[0])) != 0);
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[0]);
- if (ranges[2] + 1 != ranges[3])
- {
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2]);
- add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_LESS : SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));
- }
- else
- add_jump(compiler, backtracks, CMP(bit != 0 ? SLJIT_EQUAL : SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2]));
- return TRUE;
- }
-
- if (bit != 0)
- {
- i = 0;
- if (ranges[0] + 1 != ranges[1])
- {
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);
- add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));
- i = ranges[0];
- }
- else
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[0]));
-
- if (ranges[2] + 1 != ranges[3])
- {
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[2] - i);
- add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[2]));
- }
- else
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[2] - i));
- return TRUE;
- }
-
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[0]);
- add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, ranges[3] - ranges[0]));
- if (ranges[1] + 1 != ranges[2])
- {
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]);
- add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, ranges[2] - ranges[1]));
- }
- else
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, ranges[1] - ranges[0]));
- return TRUE;
-
- default:
- SLJIT_ASSERT_STOP();
- return FALSE;
- }
-}
-
-static void check_anynewline(compiler_common *common)
-{
-/* Check whether TMP1 contains a newline character. TMP2 destroyed. */
-DEFINE_COMPILER;
-
-sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
-
-OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x0a);
-OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x0d - 0x0a);
-OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_LESS_EQUAL);
-OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x0a);
-#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-#ifdef COMPILE_PCRE8
-if (common->utf)
- {
-#endif
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2029 - 0x0a);
-#ifdef COMPILE_PCRE8
- }
-#endif
-#endif /* SUPPORT_UTF || COMPILE_PCRE16 || COMPILE_PCRE32 */
-OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-}
-
-static void check_hspace(compiler_common *common)
-{
-/* Check whether TMP1 contains a newline character. TMP2 destroyed. */
-DEFINE_COMPILER;
-
-sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
-
-OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x09);
-OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
-OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x20);
-OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
-OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xa0);
-#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-#ifdef COMPILE_PCRE8
-if (common->utf)
- {
-#endif
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x1680);
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x180e);
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x2000);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x200A - 0x2000);
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_LESS_EQUAL);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x202f - 0x2000);
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x205f - 0x2000);
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x3000 - 0x2000);
-#ifdef COMPILE_PCRE8
- }
-#endif
-#endif /* SUPPORT_UTF || COMPILE_PCRE16 || COMPILE_PCRE32 */
-OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
-
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-}
-
-static void check_vspace(compiler_common *common)
-{
-/* Check whether TMP1 contains a newline character. TMP2 destroyed. */
-DEFINE_COMPILER;
-
-sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
-
-OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x0a);
-OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x0d - 0x0a);
-OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_LESS_EQUAL);
-OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x0a);
-#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-#ifdef COMPILE_PCRE8
-if (common->utf)
- {
-#endif
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, 0x1);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2029 - 0x0a);
-#ifdef COMPILE_PCRE8
- }
-#endif
-#endif /* SUPPORT_UTF || COMPILE_PCRE16 || COMPILE_PCRE32 */
-OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
-
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-}
-
-#define CHAR1 STR_END
-#define CHAR2 STACK_TOP
-
-static void do_casefulcmp(compiler_common *common)
-{
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-struct sljit_label *label;
-
-sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
-OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
-OP1(SLJIT_MOV, TMP3, 0, CHAR1, 0);
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, CHAR2, 0);
-OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1));
-OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-
-label = LABEL();
-OP1(MOVU_UCHAR, CHAR1, 0, SLJIT_MEM1(TMP1), IN_UCHARS(1));
-OP1(MOVU_UCHAR, CHAR2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
-jump = CMP(SLJIT_NOT_EQUAL, CHAR1, 0, CHAR2, 0);
-OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(1));
-JUMPTO(SLJIT_NOT_ZERO, label);
-
-JUMPHERE(jump);
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-OP1(SLJIT_MOV, CHAR1, 0, TMP3, 0);
-OP1(SLJIT_MOV, CHAR2, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0);
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-}
-
-#define LCC_TABLE STACK_LIMIT
-
-static void do_caselesscmp(compiler_common *common)
-{
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-struct sljit_label *label;
-
-sljit_emit_fast_enter(compiler, RETURN_ADDR, 0);
-OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
-
-OP1(SLJIT_MOV, TMP3, 0, LCC_TABLE, 0);
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, CHAR1, 0);
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, CHAR2, 0);
-OP1(SLJIT_MOV, LCC_TABLE, 0, SLJIT_IMM, common->lcc);
-OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, IN_UCHARS(1));
-OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-
-label = LABEL();
-OP1(MOVU_UCHAR, CHAR1, 0, SLJIT_MEM1(TMP1), IN_UCHARS(1));
-OP1(MOVU_UCHAR, CHAR2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
-#ifndef COMPILE_PCRE8
-jump = CMP(SLJIT_GREATER, CHAR1, 0, SLJIT_IMM, 255);
-#endif
-OP1(SLJIT_MOV_UB, CHAR1, 0, SLJIT_MEM2(LCC_TABLE, CHAR1), 0);
-#ifndef COMPILE_PCRE8
-JUMPHERE(jump);
-jump = CMP(SLJIT_GREATER, CHAR2, 0, SLJIT_IMM, 255);
-#endif
-OP1(SLJIT_MOV_UB, CHAR2, 0, SLJIT_MEM2(LCC_TABLE, CHAR2), 0);
-#ifndef COMPILE_PCRE8
-JUMPHERE(jump);
-#endif
-jump = CMP(SLJIT_NOT_EQUAL, CHAR1, 0, CHAR2, 0);
-OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_IMM, IN_UCHARS(1));
-JUMPTO(SLJIT_NOT_ZERO, label);
-
-JUMPHERE(jump);
-OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-OP1(SLJIT_MOV, LCC_TABLE, 0, TMP3, 0);
-OP1(SLJIT_MOV, CHAR1, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0);
-OP1(SLJIT_MOV, CHAR2, 0, SLJIT_MEM1(SLJIT_SP), LOCALS1);
-sljit_emit_fast_return(compiler, RETURN_ADDR, 0);
-}
-
-#undef LCC_TABLE
-#undef CHAR1
-#undef CHAR2
-
-#if defined SUPPORT_UTF && defined SUPPORT_UCP
-
-static const pcre_uchar * SLJIT_CALL do_utf_caselesscmp(pcre_uchar *src1, jit_arguments *args, pcre_uchar *end1)
-{
-/* This function would be ineffective to do in JIT level. */
-pcre_uint32 c1, c2;
-const pcre_uchar *src2 = args->uchar_ptr;
-const pcre_uchar *end2 = args->end;
-const ucd_record *ur;
-const pcre_uint32 *pp;
-
-while (src1 < end1)
- {
- if (src2 >= end2)
- return (pcre_uchar*)1;
- GETCHARINC(c1, src1);
- GETCHARINC(c2, src2);
- ur = GET_UCD(c2);
- if (c1 != c2 && c1 != c2 + ur->other_case)
- {
- pp = PRIV(ucd_caseless_sets) + ur->caseset;
- for (;;)
- {
- if (c1 < *pp) return NULL;
- if (c1 == *pp++) break;
- }
- }
- }
-return src2;
-}
-
-#endif /* SUPPORT_UTF && SUPPORT_UCP */
-
-static pcre_uchar *byte_sequence_compare(compiler_common *common, BOOL caseless, pcre_uchar *cc,
- compare_context *context, jump_list **backtracks)
-{
-DEFINE_COMPILER;
-unsigned int othercasebit = 0;
-pcre_uchar *othercasechar = NULL;
-#ifdef SUPPORT_UTF
-int utflength;
-#endif
-
-if (caseless && char_has_othercase(common, cc))
- {
- othercasebit = char_get_othercase_bit(common, cc);
- SLJIT_ASSERT(othercasebit);
- /* Extracting bit difference info. */
-#if defined COMPILE_PCRE8
- othercasechar = cc + (othercasebit >> 8);
- othercasebit &= 0xff;
-#elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- /* Note that this code only handles characters in the BMP. If there
- ever are characters outside the BMP whose othercase differs in only one
- bit from itself (there currently are none), this code will need to be
- revised for COMPILE_PCRE32. */
- othercasechar = cc + (othercasebit >> 9);
- if ((othercasebit & 0x100) != 0)
- othercasebit = (othercasebit & 0xff) << 8;
- else
- othercasebit &= 0xff;
-#endif /* COMPILE_PCRE[8|16|32] */
- }
-
-if (context->sourcereg == -1)
- {
-#if defined COMPILE_PCRE8
-#if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
- if (context->length >= 4)
- OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
- else if (context->length >= 2)
- OP1(SLJIT_MOV_UH, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
- else
-#endif
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
-#elif defined COMPILE_PCRE16
-#if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
- if (context->length >= 4)
- OP1(SLJIT_MOV_SI, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
- else
-#endif
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
-#elif defined COMPILE_PCRE32
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), -context->length);
-#endif /* COMPILE_PCRE[8|16|32] */
- context->sourcereg = TMP2;
- }
-
-#ifdef SUPPORT_UTF
-utflength = 1;
-if (common->utf && HAS_EXTRALEN(*cc))
- utflength += GET_EXTRALEN(*cc);
-
-do
- {
-#endif
-
- context->length -= IN_UCHARS(1);
-#if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED) && (defined COMPILE_PCRE8 || defined COMPILE_PCRE16)
-
- /* Unaligned read is supported. */
- if (othercasebit != 0 && othercasechar == cc)
- {
- context->c.asuchars[context->ucharptr] = *cc | othercasebit;
- context->oc.asuchars[context->ucharptr] = othercasebit;
- }
- else
- {
- context->c.asuchars[context->ucharptr] = *cc;
- context->oc.asuchars[context->ucharptr] = 0;
- }
- context->ucharptr++;
-
-#if defined COMPILE_PCRE8
- if (context->ucharptr >= 4 || context->length == 0 || (context->ucharptr == 2 && context->length == 1))
-#else
- if (context->ucharptr >= 2 || context->length == 0)
-#endif
- {
- if (context->length >= 4)
- OP1(SLJIT_MOV_SI, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
- else if (context->length >= 2)
- OP1(SLJIT_MOV_UH, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
-#if defined COMPILE_PCRE8
- else if (context->length >= 1)
- OP1(SLJIT_MOV_UB, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
-#endif /* COMPILE_PCRE8 */
- context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
-
- switch(context->ucharptr)
- {
- case 4 / sizeof(pcre_uchar):
- if (context->oc.asint != 0)
- OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asint);
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asint | context->oc.asint));
- break;
-
- case 2 / sizeof(pcre_uchar):
- if (context->oc.asushort != 0)
- OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asushort);
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asushort | context->oc.asushort));
- break;
-
-#ifdef COMPILE_PCRE8
- case 1:
- if (context->oc.asbyte != 0)
- OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, context->oc.asbyte);
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, context->c.asbyte | context->oc.asbyte));
- break;
-#endif
-
- default:
- SLJIT_ASSERT_STOP();
- break;
- }
- context->ucharptr = 0;
- }
-
-#else
-
- /* Unaligned read is unsupported or in 32 bit mode. */
- if (context->length >= 1)
- OP1(MOV_UCHAR, context->sourcereg, 0, SLJIT_MEM1(STR_PTR), -context->length);
-
- context->sourcereg = context->sourcereg == TMP1 ? TMP2 : TMP1;
-
- if (othercasebit != 0 && othercasechar == cc)
- {
- OP2(SLJIT_OR, context->sourcereg, 0, context->sourcereg, 0, SLJIT_IMM, othercasebit);
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, *cc | othercasebit));
- }
- else
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, context->sourcereg, 0, SLJIT_IMM, *cc));
-
-#endif
-
- cc++;
-#ifdef SUPPORT_UTF
- utflength--;
- }
-while (utflength > 0);
-#endif
-
-return cc;
-}
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
-
-#define SET_TYPE_OFFSET(value) \
- if ((value) != typeoffset) \
- { \
- if ((value) < typeoffset) \
- OP2(SLJIT_ADD, typereg, 0, typereg, 0, SLJIT_IMM, typeoffset - (value)); \
- else \
- OP2(SLJIT_SUB, typereg, 0, typereg, 0, SLJIT_IMM, (value) - typeoffset); \
- } \
- typeoffset = (value);
-
-#define SET_CHAR_OFFSET(value) \
- if ((value) != charoffset) \
- { \
- if ((value) < charoffset) \
- OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(charoffset - (value))); \
- else \
- OP2(SLJIT_SUB, TMP1, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)((value) - charoffset)); \
- } \
- charoffset = (value);
-
-static void compile_xclass_matchingpath(compiler_common *common, pcre_uchar *cc, jump_list **backtracks)
-{
-DEFINE_COMPILER;
-jump_list *found = NULL;
-jump_list **list = (cc[0] & XCL_NOT) == 0 ? &found : backtracks;
-sljit_uw c, charoffset, max = 256, min = READ_CHAR_MAX;
-struct sljit_jump *jump = NULL;
-pcre_uchar *ccbegin;
-int compares, invertcmp, numberofcmps;
-#if defined SUPPORT_UTF && (defined COMPILE_PCRE8 || defined COMPILE_PCRE16)
-BOOL utf = common->utf;
-#endif
-
-#ifdef SUPPORT_UCP
-BOOL needstype = FALSE, needsscript = FALSE, needschar = FALSE;
-BOOL charsaved = FALSE;
-int typereg = TMP1, scriptreg = TMP1;
-const pcre_uint32 *other_cases;
-sljit_uw typeoffset;
-#endif
-
-/* Scanning the necessary info. */
-cc++;
-ccbegin = cc;
-compares = 0;
-if (cc[-1] & XCL_MAP)
- {
- min = 0;
- cc += 32 / sizeof(pcre_uchar);
- }
-
-while (*cc != XCL_END)
- {
- compares++;
- if (*cc == XCL_SINGLE)
- {
- cc ++;
- GETCHARINCTEST(c, cc);
- if (c > max) max = c;
- if (c < min) min = c;
-#ifdef SUPPORT_UCP
- needschar = TRUE;
-#endif
- }
- else if (*cc == XCL_RANGE)
- {
- cc ++;
- GETCHARINCTEST(c, cc);
- if (c < min) min = c;
- GETCHARINCTEST(c, cc);
- if (c > max) max = c;
-#ifdef SUPPORT_UCP
- needschar = TRUE;
-#endif
- }
-#ifdef SUPPORT_UCP
- else
- {
- SLJIT_ASSERT(*cc == XCL_PROP || *cc == XCL_NOTPROP);
- cc++;
- if (*cc == PT_CLIST)
- {
- other_cases = PRIV(ucd_caseless_sets) + cc[1];
- while (*other_cases != NOTACHAR)
- {
- if (*other_cases > max) max = *other_cases;
- if (*other_cases < min) min = *other_cases;
- other_cases++;
- }
- }
- else
- {
- max = READ_CHAR_MAX;
- min = 0;
- }
-
- switch(*cc)
- {
- case PT_ANY:
- break;
-
- case PT_LAMP:
- case PT_GC:
- case PT_PC:
- case PT_ALNUM:
- needstype = TRUE;
- break;
-
- case PT_SC:
- needsscript = TRUE;
- break;
-
- case PT_SPACE:
- case PT_PXSPACE:
- case PT_WORD:
- case PT_PXGRAPH:
- case PT_PXPRINT:
- case PT_PXPUNCT:
- needstype = TRUE;
- needschar = TRUE;
- break;
-
- case PT_CLIST:
- case PT_UCNC:
- needschar = TRUE;
- break;
-
- default:
- SLJIT_ASSERT_STOP();
- break;
- }
- cc += 2;
- }
-#endif
- }
-
-/* We are not necessary in utf mode even in 8 bit mode. */
-cc = ccbegin;
-detect_partial_match(common, backtracks);
-read_char_range(common, min, max, (cc[-1] & XCL_NOT) != 0);
-
-if ((cc[-1] & XCL_HASPROP) == 0)
- {
- if ((cc[-1] & XCL_MAP) != 0)
- {
- jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
- if (!check_class_ranges(common, (const pcre_uint8 *)cc, (((const pcre_uint8 *)cc)[31] & 0x80) != 0, TRUE, &found))
- {
- OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
- OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);
- OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
- OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);
- add_jump(compiler, &found, JUMP(SLJIT_NOT_ZERO));
- }
-
- add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
- JUMPHERE(jump);
-
- cc += 32 / sizeof(pcre_uchar);
- }
- else
- {
- OP2(SLJIT_SUB, TMP2, 0, TMP1, 0, SLJIT_IMM, min);
- add_jump(compiler, (cc[-1] & XCL_NOT) == 0 ? backtracks : &found, CMP(SLJIT_GREATER, TMP2, 0, SLJIT_IMM, max - min));
- }
- }
-else if ((cc[-1] & XCL_MAP) != 0)
- {
- OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
-#ifdef SUPPORT_UCP
- charsaved = TRUE;
-#endif
- if (!check_class_ranges(common, (const pcre_uint8 *)cc, FALSE, TRUE, list))
- {
-#ifdef COMPILE_PCRE8
- jump = NULL;
- if (common->utf)
-#endif
- jump = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
-
- OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
- OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);
- OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
- OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);
- add_jump(compiler, list, JUMP(SLJIT_NOT_ZERO));
-
-#ifdef COMPILE_PCRE8
- if (common->utf)
-#endif
- JUMPHERE(jump);
- }
-
- OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
- cc += 32 / sizeof(pcre_uchar);
- }
-
-#ifdef SUPPORT_UCP
-/* Simple register allocation. TMP1 is preferred if possible. */
-if (needstype || needsscript)
- {
- if (needschar && !charsaved)
- OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
- add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
- if (needschar)
- {
- if (needstype)
- {
- OP1(SLJIT_MOV, RETURN_ADDR, 0, TMP1, 0);
- typereg = RETURN_ADDR;
- }
-
- if (needsscript)
- scriptreg = TMP3;
- OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
- }
- else if (needstype && needsscript)
- scriptreg = TMP3;
- /* In all other cases only one of them was specified, and that can goes to TMP1. */
-
- if (needsscript)
- {
- if (scriptreg == TMP1)
- {
- OP1(SLJIT_MOV, scriptreg, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));
- OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM2(scriptreg, TMP2), 3);
- }
- else
- {
- OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);
- OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, script));
- OP1(SLJIT_MOV_UB, scriptreg, 0, SLJIT_MEM1(TMP2), 0);
- }
- }
- }
-#endif
-
-/* Generating code. */
-charoffset = 0;
-numberofcmps = 0;
-#ifdef SUPPORT_UCP
-typeoffset = 0;
-#endif
-
-while (*cc != XCL_END)
- {
- compares--;
- invertcmp = (compares == 0 && list != backtracks);
- jump = NULL;
-
- if (*cc == XCL_SINGLE)
- {
- cc ++;
- GETCHARINCTEST(c, cc);
-
- if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE))
- {
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));
- OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, numberofcmps == 0 ? SLJIT_UNUSED : TMP2, 0, SLJIT_EQUAL);
- numberofcmps++;
- }
- else if (numberofcmps > 0)
- {
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);
- numberofcmps = 0;
- }
- else
- {
- jump = CMP(SLJIT_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));
- numberofcmps = 0;
- }
- }
- else if (*cc == XCL_RANGE)
- {
- cc ++;
- GETCHARINCTEST(c, cc);
- SET_CHAR_OFFSET(c);
- GETCHARINCTEST(c, cc);
-
- if (numberofcmps < 3 && (*cc == XCL_SINGLE || *cc == XCL_RANGE))
- {
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));
- OP_FLAGS(numberofcmps == 0 ? SLJIT_MOV : SLJIT_OR, TMP2, 0, numberofcmps == 0 ? SLJIT_UNUSED : TMP2, 0, SLJIT_LESS_EQUAL);
- numberofcmps++;
- }
- else if (numberofcmps > 0)
- {
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_LESS_EQUAL);
- jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);
- numberofcmps = 0;
- }
- else
- {
- jump = CMP(SLJIT_LESS_EQUAL ^ invertcmp, TMP1, 0, SLJIT_IMM, (sljit_sw)(c - charoffset));
- numberofcmps = 0;
- }
- }
-#ifdef SUPPORT_UCP
- else
- {
- if (*cc == XCL_NOTPROP)
- invertcmp ^= 0x1;
- cc++;
- switch(*cc)
- {
- case PT_ANY:
- if (list != backtracks)
- {
- if ((cc[-1] == XCL_NOTPROP && compares > 0) || (cc[-1] == XCL_PROP && compares == 0))
- continue;
- }
- else if (cc[-1] == XCL_NOTPROP)
- continue;
- jump = JUMP(SLJIT_JUMP);
- break;
-
- case PT_LAMP:
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Lu - typeoffset);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Ll - typeoffset);
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Lt - typeoffset);
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);
- break;
-
- case PT_GC:
- c = PRIV(ucp_typerange)[(int)cc[1] * 2];
- SET_TYPE_OFFSET(c);
- jump = CMP(SLJIT_LESS_EQUAL ^ invertcmp, typereg, 0, SLJIT_IMM, PRIV(ucp_typerange)[(int)cc[1] * 2 + 1] - c);
- break;
-
- case PT_PC:
- jump = CMP(SLJIT_EQUAL ^ invertcmp, typereg, 0, SLJIT_IMM, (int)cc[1] - typeoffset);
- break;
-
- case PT_SC:
- jump = CMP(SLJIT_EQUAL ^ invertcmp, scriptreg, 0, SLJIT_IMM, (int)cc[1]);
- break;
-
- case PT_SPACE:
- case PT_PXSPACE:
- SET_CHAR_OFFSET(9);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd - 0x9);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_LESS_EQUAL);
-
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x85 - 0x9);
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
-
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x180e - 0x9);
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
-
- SET_TYPE_OFFSET(ucp_Zl);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Zs - ucp_Zl);
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_LESS_EQUAL);
- jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);
- break;
-
- case PT_WORD:
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_UNDERSCORE - charoffset));
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
- /* Fall through. */
-
- case PT_ALNUM:
- SET_TYPE_OFFSET(ucp_Ll);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Lu - ucp_Ll);
- OP_FLAGS((*cc == PT_ALNUM) ? SLJIT_MOV : SLJIT_OR, TMP2, 0, (*cc == PT_ALNUM) ? SLJIT_UNUSED : TMP2, 0, SLJIT_LESS_EQUAL);
- SET_TYPE_OFFSET(ucp_Nd);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_No - ucp_Nd);
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_LESS_EQUAL);
- jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);
- break;
-
- case PT_CLIST:
- other_cases = PRIV(ucd_caseless_sets) + cc[1];
-
- /* At least three characters are required.
- Otherwise this case would be handled by the normal code path. */
- SLJIT_ASSERT(other_cases[0] != NOTACHAR && other_cases[1] != NOTACHAR && other_cases[2] != NOTACHAR);
- SLJIT_ASSERT(other_cases[0] < other_cases[1] && other_cases[1] < other_cases[2]);
-
- /* Optimizing character pairs, if their difference is power of 2. */
- if (is_powerof2(other_cases[1] ^ other_cases[0]))
- {
- if (charoffset == 0)
- OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
- else
- {
- OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset);
- OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
- }
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[1]);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
- other_cases += 2;
- }
- else if (is_powerof2(other_cases[2] ^ other_cases[1]))
- {
- if (charoffset == 0)
- OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, other_cases[2] ^ other_cases[1]);
- else
- {
- OP2(SLJIT_ADD, TMP2, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)charoffset);
- OP2(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_IMM, other_cases[1] ^ other_cases[0]);
- }
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP2, 0, SLJIT_IMM, other_cases[2]);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
-
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(other_cases[0] - charoffset));
- OP_FLAGS(SLJIT_OR | ((other_cases[3] == NOTACHAR) ? SLJIT_SET_E : 0), TMP2, 0, TMP2, 0, SLJIT_EQUAL);
-
- other_cases += 3;
- }
- else
- {
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(*other_cases++ - charoffset));
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
- }
-
- while (*other_cases != NOTACHAR)
- {
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(*other_cases++ - charoffset));
- OP_FLAGS(SLJIT_OR | ((*other_cases == NOTACHAR) ? SLJIT_SET_E : 0), TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- }
- jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);
- break;
-
- case PT_UCNC:
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_DOLLAR_SIGN - charoffset));
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_COMMERCIAL_AT - charoffset));
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(CHAR_GRAVE_ACCENT - charoffset));
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
-
- SET_CHAR_OFFSET(0xa0);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (sljit_sw)(0xd7ff - charoffset));
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_LESS_EQUAL);
- SET_CHAR_OFFSET(0);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xe000 - 0);
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_GREATER_EQUAL);
- jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);
- break;
-
- case PT_PXGRAPH:
- /* C and Z groups are the farthest two groups. */
- SET_TYPE_OFFSET(ucp_Ll);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_So - ucp_Ll);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_GREATER);
-
- jump = CMP(SLJIT_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll);
-
- /* In case of ucp_Cf, we overwrite the result. */
- SET_CHAR_OFFSET(0x2066);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_LESS_EQUAL);
-
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066);
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
-
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x180e - 0x2066);
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
-
- JUMPHERE(jump);
- jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0);
- break;
-
- case PT_PXPRINT:
- /* C and Z groups are the farthest two groups. */
- SET_TYPE_OFFSET(ucp_Ll);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_So - ucp_Ll);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_GREATER);
-
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Zs - ucp_Ll);
- OP_FLAGS(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_NOT_EQUAL);
-
- jump = CMP(SLJIT_NOT_EQUAL, typereg, 0, SLJIT_IMM, ucp_Cf - ucp_Ll);
-
- /* In case of ucp_Cf, we overwrite the result. */
- SET_CHAR_OFFSET(0x2066);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x2069 - 0x2066);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_LESS_EQUAL);
-
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x061c - 0x2066);
- OP_FLAGS(SLJIT_OR, TMP2, 0, TMP2, 0, SLJIT_EQUAL);
-
- JUMPHERE(jump);
- jump = CMP(SLJIT_ZERO ^ invertcmp, TMP2, 0, SLJIT_IMM, 0);
- break;
-
- case PT_PXPUNCT:
- SET_TYPE_OFFSET(ucp_Sc);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_So - ucp_Sc);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_LESS_EQUAL);
-
- SET_CHAR_OFFSET(0);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0x7f);
- OP_FLAGS(SLJIT_AND, TMP2, 0, TMP2, 0, SLJIT_LESS_EQUAL);
-
- SET_TYPE_OFFSET(ucp_Pc);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, typereg, 0, SLJIT_IMM, ucp_Ps - ucp_Pc);
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_LESS_EQUAL);
- jump = JUMP(SLJIT_NOT_ZERO ^ invertcmp);
- break;
- }
- cc += 2;
- }
-#endif
-
- if (jump != NULL)
- add_jump(compiler, compares > 0 ? list : backtracks, jump);
- }
-
-if (found != NULL)
- set_jumps(found, LABEL());
-}
-
-#undef SET_TYPE_OFFSET
-#undef SET_CHAR_OFFSET
-
-#endif
-
-static pcre_uchar *compile_char1_matchingpath(compiler_common *common, pcre_uchar type, pcre_uchar *cc, jump_list **backtracks)
-{
-DEFINE_COMPILER;
-int length;
-unsigned int c, oc, bit;
-compare_context context;
-struct sljit_jump *jump[4];
-jump_list *end_list;
-#ifdef SUPPORT_UTF
-struct sljit_label *label;
-#ifdef SUPPORT_UCP
-pcre_uchar propdata[5];
-#endif
-#endif /* SUPPORT_UTF */
-
-switch(type)
- {
- case OP_SOD:
- OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, TMP1, 0));
- return cc;
-
- case OP_SOM:
- OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, TMP1, 0));
- return cc;
-
- case OP_NOT_WORD_BOUNDARY:
- case OP_WORD_BOUNDARY:
- add_jump(compiler, &common->wordboundary, JUMP(SLJIT_FAST_CALL));
- add_jump(compiler, backtracks, JUMP(type == OP_NOT_WORD_BOUNDARY ? SLJIT_NOT_ZERO : SLJIT_ZERO));
- return cc;
-
- case OP_NOT_DIGIT:
- case OP_DIGIT:
- /* Digits are usually 0-9, so it is worth to optimize them. */
- detect_partial_match(common, backtracks);
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_digit, FALSE))
- read_char7_type(common, type == OP_NOT_DIGIT);
- else
-#endif
- read_char8_type(common, type == OP_NOT_DIGIT);
- /* Flip the starting bit in the negative case. */
- OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_digit);
- add_jump(compiler, backtracks, JUMP(type == OP_DIGIT ? SLJIT_ZERO : SLJIT_NOT_ZERO));
- return cc;
-
- case OP_NOT_WHITESPACE:
- case OP_WHITESPACE:
- detect_partial_match(common, backtracks);
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_space, FALSE))
- read_char7_type(common, type == OP_NOT_WHITESPACE);
- else
-#endif
- read_char8_type(common, type == OP_NOT_WHITESPACE);
- OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_space);
- add_jump(compiler, backtracks, JUMP(type == OP_WHITESPACE ? SLJIT_ZERO : SLJIT_NOT_ZERO));
- return cc;
-
- case OP_NOT_WORDCHAR:
- case OP_WORDCHAR:
- detect_partial_match(common, backtracks);
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- if (common->utf && is_char7_bitset((const pcre_uint8*)common->ctypes - cbit_length + cbit_word, FALSE))
- read_char7_type(common, type == OP_NOT_WORDCHAR);
- else
-#endif
- read_char8_type(common, type == OP_NOT_WORDCHAR);
- OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, ctype_word);
- add_jump(compiler, backtracks, JUMP(type == OP_WORDCHAR ? SLJIT_ZERO : SLJIT_NOT_ZERO));
- return cc;
-
- case OP_ANY:
- detect_partial_match(common, backtracks);
- read_char_range(common, common->nlmin, common->nlmax, TRUE);
- if (common->nltype == NLTYPE_FIXED && common->newline > 255)
- {
- jump[0] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff);
- end_list = NULL;
- if (common->mode != JIT_PARTIAL_HARD_COMPILE)
- add_jump(compiler, &end_list, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));
- else
- check_str_end(common, &end_list);
-
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, common->newline & 0xff));
- set_jumps(end_list, LABEL());
- JUMPHERE(jump[0]);
- }
- else
- check_newlinechar(common, common->nltype, backtracks, TRUE);
- return cc;
-
- case OP_ALLANY:
- detect_partial_match(common, backtracks);
-#ifdef SUPPORT_UTF
- if (common->utf)
- {
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
-#if defined COMPILE_PCRE8 || defined COMPILE_PCRE16
-#if defined COMPILE_PCRE8
- jump[0] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
-#elif defined COMPILE_PCRE16
- jump[0] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xd800);
- OP2(SLJIT_AND, TMP1, 0, TMP1, 0, SLJIT_IMM, 0xfc00);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, 0xd800);
- OP_FLAGS(SLJIT_MOV, TMP1, 0, SLJIT_UNUSED, 0, SLJIT_EQUAL);
- OP2(SLJIT_SHL, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
-#endif
- JUMPHERE(jump[0]);
-#endif /* COMPILE_PCRE[8|16] */
- return cc;
- }
-#endif
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- return cc;
-
- case OP_ANYBYTE:
- detect_partial_match(common, backtracks);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- return cc;
-
-#ifdef SUPPORT_UTF
-#ifdef SUPPORT_UCP
- case OP_NOTPROP:
- case OP_PROP:
- propdata[0] = XCL_HASPROP;
- propdata[1] = type == OP_NOTPROP ? XCL_NOTPROP : XCL_PROP;
- propdata[2] = cc[0];
- propdata[3] = cc[1];
- propdata[4] = XCL_END;
- compile_xclass_matchingpath(common, propdata, backtracks);
- return cc + 2;
-#endif
-#endif
-
- case OP_ANYNL:
- detect_partial_match(common, backtracks);
- read_char_range(common, common->bsr_nlmin, common->bsr_nlmax, FALSE);
- jump[0] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);
- /* We don't need to handle soft partial matching case. */
- end_list = NULL;
- if (common->mode != JIT_PARTIAL_HARD_COMPILE)
- add_jump(compiler, &end_list, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));
- else
- check_str_end(common, &end_list);
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
- jump[1] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- jump[2] = JUMP(SLJIT_JUMP);
- JUMPHERE(jump[0]);
- check_newlinechar(common, common->bsr_nltype, backtracks, FALSE);
- set_jumps(end_list, LABEL());
- JUMPHERE(jump[1]);
- JUMPHERE(jump[2]);
- return cc;
-
- case OP_NOT_HSPACE:
- case OP_HSPACE:
- detect_partial_match(common, backtracks);
- read_char_range(common, 0x9, 0x3000, type == OP_NOT_HSPACE);
- add_jump(compiler, &common->hspace, JUMP(SLJIT_FAST_CALL));
- add_jump(compiler, backtracks, JUMP(type == OP_NOT_HSPACE ? SLJIT_NOT_ZERO : SLJIT_ZERO));
- return cc;
-
- case OP_NOT_VSPACE:
- case OP_VSPACE:
- detect_partial_match(common, backtracks);
- read_char_range(common, 0xa, 0x2029, type == OP_NOT_VSPACE);
- add_jump(compiler, &common->vspace, JUMP(SLJIT_FAST_CALL));
- add_jump(compiler, backtracks, JUMP(type == OP_NOT_VSPACE ? SLJIT_NOT_ZERO : SLJIT_ZERO));
- return cc;
-
-#ifdef SUPPORT_UCP
- case OP_EXTUNI:
- detect_partial_match(common, backtracks);
- read_char(common);
- add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop));
- /* Optimize register allocation: use a real register. */
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STACK_TOP, 0);
- OP1(SLJIT_MOV_UB, STACK_TOP, 0, SLJIT_MEM2(TMP1, TMP2), 3);
-
- label = LABEL();
- jump[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
- OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);
- read_char(common);
- add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records) + SLJIT_OFFSETOF(ucd_record, gbprop));
- OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM2(TMP1, TMP2), 3);
-
- OP2(SLJIT_SHL, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, 2);
- OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(STACK_TOP), (sljit_sw)PRIV(ucp_gbtable));
- OP1(SLJIT_MOV, STACK_TOP, 0, TMP2, 0);
- OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
- OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);
- JUMPTO(SLJIT_NOT_ZERO, label);
-
- OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);
- JUMPHERE(jump[0]);
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0);
-
- if (common->mode == JIT_PARTIAL_HARD_COMPILE)
- {
- jump[0] = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);
- /* Since we successfully read a char above, partial matching must occure. */
- check_partial(common, TRUE);
- JUMPHERE(jump[0]);
- }
- return cc;
-#endif
-
- case OP_EODN:
- /* Requires rather complex checks. */
- jump[0] = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
- if (common->nltype == NLTYPE_FIXED && common->newline > 255)
- {
- OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
- if (common->mode == JIT_COMPILE)
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, STR_END, 0));
- else
- {
- jump[1] = CMP(SLJIT_EQUAL, TMP2, 0, STR_END, 0);
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP2, 0, STR_END, 0);
- OP_FLAGS(SLJIT_MOV, TMP2, 0, SLJIT_UNUSED, 0, SLJIT_LESS);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff);
- OP_FLAGS(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_NOT_EQUAL);
- add_jump(compiler, backtracks, JUMP(SLJIT_NOT_EQUAL));
- check_partial(common, TRUE);
- add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
- JUMPHERE(jump[1]);
- }
- OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff));
- }
- else if (common->nltype == NLTYPE_FIXED)
- {
- OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, STR_END, 0));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, common->newline));
- }
- else
- {
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
- jump[1] = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_CR);
- OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
- OP2(SLJIT_SUB | SLJIT_SET_U, SLJIT_UNUSED, 0, TMP2, 0, STR_END, 0);
- jump[2] = JUMP(SLJIT_GREATER);
- add_jump(compiler, backtracks, JUMP(SLJIT_LESS));
- /* Equal. */
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
- jump[3] = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL);
- add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
-
- JUMPHERE(jump[1]);
- if (common->nltype == NLTYPE_ANYCRLF)
- {
- OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP2, 0, STR_END, 0));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, CHAR_NL));
- }
- else
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, STR_PTR, 0);
- read_char_range(common, common->nlmin, common->nlmax, TRUE);
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, STR_END, 0));
- add_jump(compiler, &common->anynewline, JUMP(SLJIT_FAST_CALL));
- add_jump(compiler, backtracks, JUMP(SLJIT_ZERO));
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), LOCALS1);
- }
- JUMPHERE(jump[2]);
- JUMPHERE(jump[3]);
- }
- JUMPHERE(jump[0]);
- check_partial(common, FALSE);
- return cc;
-
- case OP_EOD:
- add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0));
- check_partial(common, FALSE);
- return cc;
-
- case OP_CIRC:
- OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin));
- add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0));
- OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, notbol));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
- return cc;
-
- case OP_CIRCM:
- OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, begin));
- jump[1] = CMP(SLJIT_GREATER, STR_PTR, 0, TMP1, 0);
- OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, notbol));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
- jump[0] = JUMP(SLJIT_JUMP);
- JUMPHERE(jump[1]);
-
- add_jump(compiler, backtracks, CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0));
- if (common->nltype == NLTYPE_FIXED && common->newline > 255)
- {
- OP2(SLJIT_SUB, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
- add_jump(compiler, backtracks, CMP(SLJIT_LESS, TMP2, 0, TMP1, 0));
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-2));
- OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(-1));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff));
- }
- else
- {
- skip_char_back(common);
- read_char_range(common, common->nlmin, common->nlmax, TRUE);
- check_newlinechar(common, common->nltype, backtracks, FALSE);
- }
- JUMPHERE(jump[0]);
- return cc;
-
- case OP_DOLL:
- OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, noteol));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
-
- if (!common->endonly)
- compile_char1_matchingpath(common, OP_EODN, cc, backtracks);
- else
- {
- add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0));
- check_partial(common, FALSE);
- }
- return cc;
-
- case OP_DOLLM:
- jump[1] = CMP(SLJIT_LESS, STR_PTR, 0, STR_END, 0);
- OP1(SLJIT_MOV, TMP2, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(jit_arguments, noteol));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
- check_partial(common, FALSE);
- jump[0] = JUMP(SLJIT_JUMP);
- JUMPHERE(jump[1]);
-
- if (common->nltype == NLTYPE_FIXED && common->newline > 255)
- {
- OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(2));
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
- if (common->mode == JIT_COMPILE)
- add_jump(compiler, backtracks, CMP(SLJIT_GREATER, TMP2, 0, STR_END, 0));
- else
- {
- jump[1] = CMP(SLJIT_LESS_EQUAL, TMP2, 0, STR_END, 0);
- /* STR_PTR = STR_END - IN_UCHARS(1) */
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));
- check_partial(common, TRUE);
- add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
- JUMPHERE(jump[1]);
- }
-
- OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(1));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff));
- }
- else
- {
- peek_char(common, common->nlmax);
- check_newlinechar(common, common->nltype, backtracks, FALSE);
- }
- JUMPHERE(jump[0]);
- return cc;
-
- case OP_CHAR:
- case OP_CHARI:
- length = 1;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(*cc)) length += GET_EXTRALEN(*cc);
-#endif
- if (common->mode == JIT_COMPILE && (type == OP_CHAR || !char_has_othercase(common, cc) || char_get_othercase_bit(common, cc) != 0))
- {
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(length));
- add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, STR_END, 0));
-
- context.length = IN_UCHARS(length);
- context.sourcereg = -1;
-#if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
- context.ucharptr = 0;
-#endif
- return byte_sequence_compare(common, type == OP_CHARI, cc, &context, backtracks);
- }
-
- detect_partial_match(common, backtracks);
-#ifdef SUPPORT_UTF
- if (common->utf)
- {
- GETCHAR(c, cc);
- }
- else
-#endif
- c = *cc;
-
- if (type == OP_CHAR || !char_has_othercase(common, cc))
- {
- read_char_range(common, c, c, FALSE);
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, c));
- return cc + length;
- }
- oc = char_othercase(common, c);
- read_char_range(common, c < oc ? c : oc, c > oc ? c : oc, FALSE);
- bit = c ^ oc;
- if (is_powerof2(bit))
- {
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, bit);
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, c | bit));
- return cc + length;
- }
- jump[0] = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, c);
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, oc));
- JUMPHERE(jump[0]);
- return cc + length;
-
- case OP_NOT:
- case OP_NOTI:
- detect_partial_match(common, backtracks);
- length = 1;
-#ifdef SUPPORT_UTF
- if (common->utf)
- {
-#ifdef COMPILE_PCRE8
- c = *cc;
- if (c < 128)
- {
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(STR_PTR), 0);
- if (type == OP_NOT || !char_has_othercase(common, cc))
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, c));
- else
- {
- /* Since UTF8 code page is fixed, we know that c is in [a-z] or [A-Z] range. */
- OP2(SLJIT_OR, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x20);
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, c | 0x20));
- }
- /* Skip the variable-length character. */
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
- jump[0] = CMP(SLJIT_LESS, TMP1, 0, SLJIT_IMM, 0xc0);
- OP1(MOV_UCHAR, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)PRIV(utf8_table4) - 0xc0);
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP1, 0);
- JUMPHERE(jump[0]);
- return cc + 1;
- }
- else
-#endif /* COMPILE_PCRE8 */
- {
- GETCHARLEN(c, cc, length);
- }
- }
- else
-#endif /* SUPPORT_UTF */
- c = *cc;
-
- if (type == OP_NOT || !char_has_othercase(common, cc))
- {
- read_char_range(common, c, c, TRUE);
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, c));
- }
- else
- {
- oc = char_othercase(common, c);
- read_char_range(common, c < oc ? c : oc, c > oc ? c : oc, TRUE);
- bit = c ^ oc;
- if (is_powerof2(bit))
- {
- OP2(SLJIT_OR, TMP1, 0, TMP1, 0, SLJIT_IMM, bit);
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, c | bit));
- }
- else
- {
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, c));
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, oc));
- }
- }
- return cc + length;
-
- case OP_CLASS:
- case OP_NCLASS:
- detect_partial_match(common, backtracks);
-
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- bit = (common->utf && is_char7_bitset((const pcre_uint8 *)cc, type == OP_NCLASS)) ? 127 : 255;
- read_char_range(common, 0, bit, type == OP_NCLASS);
-#else
- read_char_range(common, 0, 255, type == OP_NCLASS);
-#endif
-
- if (check_class_ranges(common, (const pcre_uint8 *)cc, type == OP_NCLASS, FALSE, backtracks))
- return cc + 32 / sizeof(pcre_uchar);
-
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- jump[0] = NULL;
- if (common->utf)
- {
- jump[0] = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, bit);
- if (type == OP_CLASS)
- {
- add_jump(compiler, backtracks, jump[0]);
- jump[0] = NULL;
- }
- }
-#elif !defined COMPILE_PCRE8
- jump[0] = CMP(SLJIT_GREATER, TMP1, 0, SLJIT_IMM, 255);
- if (type == OP_CLASS)
- {
- add_jump(compiler, backtracks, jump[0]);
- jump[0] = NULL;
- }
-#endif /* SUPPORT_UTF && COMPILE_PCRE8 */
-
- OP2(SLJIT_AND, TMP2, 0, TMP1, 0, SLJIT_IMM, 0x7);
- OP2(SLJIT_LSHR, TMP1, 0, TMP1, 0, SLJIT_IMM, 3);
- OP1(SLJIT_MOV_UB, TMP1, 0, SLJIT_MEM1(TMP1), (sljit_sw)cc);
- OP2(SLJIT_SHL, TMP2, 0, SLJIT_IMM, 1, TMP2, 0);
- OP2(SLJIT_AND | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, TMP2, 0);
- add_jump(compiler, backtracks, JUMP(SLJIT_ZERO));
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- if (jump[0] != NULL)
- JUMPHERE(jump[0]);
-#endif
-
- return cc + 32 / sizeof(pcre_uchar);
-
-#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- case OP_XCLASS:
- compile_xclass_matchingpath(common, cc + LINK_SIZE, backtracks);
- return cc + GET(cc, 0) - 1;
-#endif
-
- case OP_REVERSE:
- length = GET(cc, 0);
- if (length == 0)
- return cc + LINK_SIZE;
- OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
-#ifdef SUPPORT_UTF
- if (common->utf)
- {
- OP1(SLJIT_MOV, TMP3, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, length);
- label = LABEL();
- add_jump(compiler, backtracks, CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, TMP3, 0));
- skip_char_back(common);
- OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, TMP2, 0, SLJIT_IMM, 1);
- JUMPTO(SLJIT_NOT_ZERO, label);
- }
- else
-#endif
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, begin));
- OP2(SLJIT_SUB, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(length));
- add_jump(compiler, backtracks, CMP(SLJIT_LESS, STR_PTR, 0, TMP1, 0));
- }
- check_start_used_ptr(common);
- return cc + LINK_SIZE;
- }
-SLJIT_ASSERT_STOP();
-return cc;
-}
-
-static SLJIT_INLINE pcre_uchar *compile_charn_matchingpath(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, jump_list **backtracks)
-{
-/* This function consumes at least one input character. */
-/* To decrease the number of length checks, we try to concatenate the fixed length character sequences. */
-DEFINE_COMPILER;
-pcre_uchar *ccbegin = cc;
-compare_context context;
-int size;
-
-context.length = 0;
-do
- {
- if (cc >= ccend)
- break;
-
- if (*cc == OP_CHAR)
- {
- size = 1;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(cc[1]))
- size += GET_EXTRALEN(cc[1]);
-#endif
- }
- else if (*cc == OP_CHARI)
- {
- size = 1;
-#ifdef SUPPORT_UTF
- if (common->utf)
- {
- if (char_has_othercase(common, cc + 1) && char_get_othercase_bit(common, cc + 1) == 0)
- size = 0;
- else if (HAS_EXTRALEN(cc[1]))
- size += GET_EXTRALEN(cc[1]);
- }
- else
-#endif
- if (char_has_othercase(common, cc + 1) && char_get_othercase_bit(common, cc + 1) == 0)
- size = 0;
- }
- else
- size = 0;
-
- cc += 1 + size;
- context.length += IN_UCHARS(size);
- }
-while (size > 0 && context.length <= 128);
-
-cc = ccbegin;
-if (context.length > 0)
- {
- /* We have a fixed-length byte sequence. */
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, context.length);
- add_jump(compiler, backtracks, CMP(SLJIT_GREATER, STR_PTR, 0, STR_END, 0));
-
- context.sourcereg = -1;
-#if defined SLJIT_UNALIGNED && SLJIT_UNALIGNED
- context.ucharptr = 0;
-#endif
- do cc = byte_sequence_compare(common, *cc == OP_CHARI, cc + 1, &context, backtracks); while (context.length > 0);
- return cc;
- }
-
-/* A non-fixed length character will be checked if length == 0. */
-return compile_char1_matchingpath(common, *cc, cc + 1, backtracks);
-}
-
-/* Forward definitions. */
-static void compile_matchingpath(compiler_common *, pcre_uchar *, pcre_uchar *, backtrack_common *);
-static void compile_backtrackingpath(compiler_common *, struct backtrack_common *);
-
-#define PUSH_BACKTRACK(size, ccstart, error) \
- do \
- { \
- backtrack = sljit_alloc_memory(compiler, (size)); \
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler))) \
- return error; \
- memset(backtrack, 0, size); \
- backtrack->prev = parent->top; \
- backtrack->cc = (ccstart); \
- parent->top = backtrack; \
- } \
- while (0)
-
-#define PUSH_BACKTRACK_NOVALUE(size, ccstart) \
- do \
- { \
- backtrack = sljit_alloc_memory(compiler, (size)); \
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler))) \
- return; \
- memset(backtrack, 0, size); \
- backtrack->prev = parent->top; \
- backtrack->cc = (ccstart); \
- parent->top = backtrack; \
- } \
- while (0)
-
-#define BACKTRACK_AS(type) ((type *)backtrack)
-
-static void compile_dnref_search(compiler_common *common, pcre_uchar *cc, jump_list **backtracks)
-{
-/* The OVECTOR offset goes to TMP2. */
-DEFINE_COMPILER;
-int count = GET2(cc, 1 + IMM2_SIZE);
-pcre_uchar *slot = common->name_table + GET2(cc, 1) * common->name_entry_size;
-unsigned int offset;
-jump_list *found = NULL;
-
-SLJIT_ASSERT(*cc == OP_DNREF || *cc == OP_DNREFI);
-
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(1));
-
-count--;
-while (count-- > 0)
- {
- offset = GET2(slot, 0) << 1;
- GET_LOCAL_BASE(TMP2, 0, OVECTOR(offset));
- add_jump(compiler, &found, CMP(SLJIT_NOT_EQUAL, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset), TMP1, 0));
- slot += common->name_entry_size;
- }
-
-offset = GET2(slot, 0) << 1;
-GET_LOCAL_BASE(TMP2, 0, OVECTOR(offset));
-if (backtracks != NULL && !common->jscript_compat)
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset), TMP1, 0));
-
-set_jumps(found, LABEL());
-}
-
-static void compile_ref_matchingpath(compiler_common *common, pcre_uchar *cc, jump_list **backtracks, BOOL withchecks, BOOL emptyfail)
-{
-DEFINE_COMPILER;
-BOOL ref = (*cc == OP_REF || *cc == OP_REFI);
-int offset = 0;
-struct sljit_jump *jump = NULL;
-struct sljit_jump *partial;
-struct sljit_jump *nopartial;
-
-if (ref)
- {
- offset = GET2(cc, 1) << 1;
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset));
- /* OVECTOR(1) contains the "string begin - 1" constant. */
- if (withchecks && !common->jscript_compat)
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(1)));
- }
-else
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);
-
-#if defined SUPPORT_UTF && defined SUPPORT_UCP
-if (common->utf && *cc == OP_REFI)
- {
- SLJIT_ASSERT(TMP1 == SLJIT_R0 && STACK_TOP == SLJIT_R1 && TMP2 == SLJIT_R2);
- if (ref)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1));
- else
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));
-
- if (withchecks)
- jump = CMP(SLJIT_EQUAL, TMP1, 0, TMP2, 0);
-
- /* Needed to save important temporary registers. */
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STACK_TOP, 0);
- OP1(SLJIT_MOV, SLJIT_R1, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_R1), SLJIT_OFFSETOF(jit_arguments, uchar_ptr), STR_PTR, 0);
- sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_utf_caselesscmp));
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0);
- if (common->mode == JIT_COMPILE)
- add_jump(compiler, backtracks, CMP(SLJIT_LESS_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1));
- else
- {
- add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0));
- nopartial = CMP(SLJIT_NOT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 1);
- check_partial(common, FALSE);
- add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
- JUMPHERE(nopartial);
- }
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_RETURN_REG, 0);
- }
-else
-#endif /* SUPPORT_UTF && SUPPORT_UCP */
- {
- if (ref)
- OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), TMP1, 0);
- else
- OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw), TMP1, 0);
-
- if (withchecks)
- jump = JUMP(SLJIT_ZERO);
-
- OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
- partial = CMP(SLJIT_GREATER, STR_PTR, 0, STR_END, 0);
- if (common->mode == JIT_COMPILE)
- add_jump(compiler, backtracks, partial);
-
- add_jump(compiler, *cc == OP_REF ? &common->casefulcmp : &common->caselesscmp, JUMP(SLJIT_FAST_CALL));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
-
- if (common->mode != JIT_COMPILE)
- {
- nopartial = JUMP(SLJIT_JUMP);
- JUMPHERE(partial);
- /* TMP2 -= STR_END - STR_PTR */
- OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, STR_PTR, 0);
- OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, STR_END, 0);
- partial = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0);
- OP1(SLJIT_MOV, STR_PTR, 0, STR_END, 0);
- add_jump(compiler, *cc == OP_REF ? &common->casefulcmp : &common->caselesscmp, JUMP(SLJIT_FAST_CALL));
- add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
- JUMPHERE(partial);
- check_partial(common, FALSE);
- add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
- JUMPHERE(nopartial);
- }
- }
-
-if (jump != NULL)
- {
- if (emptyfail)
- add_jump(compiler, backtracks, jump);
- else
- JUMPHERE(jump);
- }
-}
-
-static SLJIT_INLINE pcre_uchar *compile_ref_iterator_matchingpath(compiler_common *common, pcre_uchar *cc, backtrack_common *parent)
-{
-DEFINE_COMPILER;
-BOOL ref = (*cc == OP_REF || *cc == OP_REFI);
-backtrack_common *backtrack;
-pcre_uchar type;
-int offset = 0;
-struct sljit_label *label;
-struct sljit_jump *zerolength;
-struct sljit_jump *jump = NULL;
-pcre_uchar *ccbegin = cc;
-int min = 0, max = 0;
-BOOL minimize;
-
-PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);
-
-if (ref)
- offset = GET2(cc, 1) << 1;
-else
- cc += IMM2_SIZE;
-type = cc[1 + IMM2_SIZE];
-
-SLJIT_COMPILE_ASSERT((OP_CRSTAR & 0x1) == 0, crstar_opcode_must_be_even);
-minimize = (type & 0x1) != 0;
-switch(type)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- min = 0;
- max = 0;
- cc += 1 + IMM2_SIZE + 1;
- break;
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- min = 1;
- max = 0;
- cc += 1 + IMM2_SIZE + 1;
- break;
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- min = 0;
- max = 1;
- cc += 1 + IMM2_SIZE + 1;
- break;
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- min = GET2(cc, 1 + IMM2_SIZE + 1);
- max = GET2(cc, 1 + IMM2_SIZE + 1 + IMM2_SIZE);
- cc += 1 + IMM2_SIZE + 1 + 2 * IMM2_SIZE;
- break;
- default:
- SLJIT_ASSERT_STOP();
- break;
- }
-
-if (!minimize)
- {
- if (min == 0)
- {
- allocate_stack(common, 2);
- if (ref)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);
- /* Temporary release of STR_PTR. */
- OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
- /* Handles both invalid and empty cases. Since the minimum repeat,
- is zero the invalid case is basically the same as an empty case. */
- if (ref)
- zerolength = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1));
- else
- {
- compile_dnref_search(common, ccbegin, NULL);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, TMP2, 0);
- zerolength = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));
- }
- /* Restore if not zero length. */
- OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
- }
- else
- {
- allocate_stack(common, 1);
- if (ref)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- if (ref)
- {
- add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(1)));
- zerolength = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1));
- }
- else
- {
- compile_dnref_search(common, ccbegin, &backtrack->topbacktracks);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, TMP2, 0);
- zerolength = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));
- }
- }
-
- if (min > 1 || max > 1)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0, SLJIT_IMM, 0);
-
- label = LABEL();
- if (!ref)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1);
- compile_ref_matchingpath(common, ccbegin, &backtrack->topbacktracks, FALSE, FALSE);
-
- if (min > 1 || max > 1)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0);
- OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0, TMP1, 0);
- if (min > 1)
- CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, min, label);
- if (max > 1)
- {
- jump = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, max);
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- JUMPTO(SLJIT_JUMP, label);
- JUMPHERE(jump);
- }
- }
-
- if (max == 0)
- {
- /* Includes min > 1 case as well. */
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- JUMPTO(SLJIT_JUMP, label);
- }
-
- JUMPHERE(zerolength);
- BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();
-
- count_match(common);
- return cc;
- }
-
-allocate_stack(common, ref ? 2 : 3);
-if (ref)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset));
-OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
-if (type != OP_CRMINSTAR)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);
-
-if (min == 0)
- {
- /* Handles both invalid and empty cases. Since the minimum repeat,
- is zero the invalid case is basically the same as an empty case. */
- if (ref)
- zerolength = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1));
- else
- {
- compile_dnref_search(common, ccbegin, NULL);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP2, 0);
- zerolength = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));
- }
- /* Length is non-zero, we can match real repeats. */
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- jump = JUMP(SLJIT_JUMP);
- }
-else
- {
- if (ref)
- {
- add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(1)));
- zerolength = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1));
- }
- else
- {
- compile_dnref_search(common, ccbegin, &backtrack->topbacktracks);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP2, 0);
- zerolength = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));
- }
- }
-
-BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();
-if (max > 0)
- add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_GREATER_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, max));
-
-if (!ref)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(2));
-compile_ref_matchingpath(common, ccbegin, &backtrack->topbacktracks, TRUE, TRUE);
-OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
-
-if (min > 1)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
- OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);
- CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, min, BACKTRACK_AS(iterator_backtrack)->matchingpath);
- }
-else if (max > 0)
- OP2(SLJIT_ADD, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 1);
-
-if (jump != NULL)
- JUMPHERE(jump);
-JUMPHERE(zerolength);
-
-count_match(common);
-return cc;
-}
-
-static SLJIT_INLINE pcre_uchar *compile_recurse_matchingpath(compiler_common *common, pcre_uchar *cc, backtrack_common *parent)
-{
-DEFINE_COMPILER;
-backtrack_common *backtrack;
-recurse_entry *entry = common->entries;
-recurse_entry *prev = NULL;
-sljit_sw start = GET(cc, 1);
-pcre_uchar *start_cc;
-BOOL needs_control_head;
-
-PUSH_BACKTRACK(sizeof(recurse_backtrack), cc, NULL);
-
-/* Inlining simple patterns. */
-if (get_framesize(common, common->start + start, NULL, TRUE, &needs_control_head) == no_stack)
- {
- start_cc = common->start + start;
- compile_matchingpath(common, next_opcode(common, start_cc), bracketend(start_cc) - (1 + LINK_SIZE), backtrack);
- BACKTRACK_AS(recurse_backtrack)->inlined_pattern = TRUE;
- return cc + 1 + LINK_SIZE;
- }
-
-while (entry != NULL)
- {
- if (entry->start == start)
- break;
- prev = entry;
- entry = entry->next;
- }
-
-if (entry == NULL)
- {
- entry = sljit_alloc_memory(compiler, sizeof(recurse_entry));
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- return NULL;
- entry->next = NULL;
- entry->entry = NULL;
- entry->calls = NULL;
- entry->start = start;
-
- if (prev != NULL)
- prev->next = entry;
- else
- common->entries = entry;
- }
-
-if (common->has_set_som && common->mark_ptr != 0)
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0));
- allocate_stack(common, 2);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->mark_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);
- }
-else if (common->has_set_som || common->mark_ptr != 0)
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->has_set_som ? (int)(OVECTOR(0)) : common->mark_ptr);
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
- }
-
-if (entry->entry == NULL)
- add_jump(compiler, &entry->calls, JUMP(SLJIT_FAST_CALL));
-else
- JUMPTO(SLJIT_FAST_CALL, entry->entry);
-/* Leave if the match is failed. */
-add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0));
-return cc + 1 + LINK_SIZE;
-}
-
-static int SLJIT_CALL do_callout(struct jit_arguments *arguments, PUBL(callout_block) *callout_block, pcre_uchar **jit_ovector)
-{
-const pcre_uchar *begin = arguments->begin;
-int *offset_vector = arguments->offsets;
-int offset_count = arguments->offset_count;
-int i;
-
-if (PUBL(callout) == NULL)
- return 0;
-
-callout_block->version = 2;
-callout_block->callout_data = arguments->callout_data;
-
-/* Offsets in subject. */
-callout_block->subject_length = arguments->end - arguments->begin;
-callout_block->start_match = (pcre_uchar*)callout_block->subject - arguments->begin;
-callout_block->current_position = (pcre_uchar*)callout_block->offset_vector - arguments->begin;
-#if defined COMPILE_PCRE8
-callout_block->subject = (PCRE_SPTR)begin;
-#elif defined COMPILE_PCRE16
-callout_block->subject = (PCRE_SPTR16)begin;
-#elif defined COMPILE_PCRE32
-callout_block->subject = (PCRE_SPTR32)begin;
-#endif
-
-/* Convert and copy the JIT offset vector to the offset_vector array. */
-callout_block->capture_top = 0;
-callout_block->offset_vector = offset_vector;
-for (i = 2; i < offset_count; i += 2)
- {
- offset_vector[i] = jit_ovector[i] - begin;
- offset_vector[i + 1] = jit_ovector[i + 1] - begin;
- if (jit_ovector[i] >= begin)
- callout_block->capture_top = i;
- }
-
-callout_block->capture_top = (callout_block->capture_top >> 1) + 1;
-if (offset_count > 0)
- offset_vector[0] = -1;
-if (offset_count > 1)
- offset_vector[1] = -1;
-return (*PUBL(callout))(callout_block);
-}
-
-/* Aligning to 8 byte. */
-#define CALLOUT_ARG_SIZE \
- (((int)sizeof(PUBL(callout_block)) + 7) & ~7)
-
-#define CALLOUT_ARG_OFFSET(arg) \
- (-CALLOUT_ARG_SIZE + SLJIT_OFFSETOF(PUBL(callout_block), arg))
-
-static SLJIT_INLINE pcre_uchar *compile_callout_matchingpath(compiler_common *common, pcre_uchar *cc, backtrack_common *parent)
-{
-DEFINE_COMPILER;
-backtrack_common *backtrack;
-
-PUSH_BACKTRACK(sizeof(backtrack_common), cc, NULL);
-
-allocate_stack(common, CALLOUT_ARG_SIZE / sizeof(sljit_sw));
-
-SLJIT_ASSERT(common->capture_last_ptr != 0);
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr);
-OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
-OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(callout_number), SLJIT_IMM, cc[1]);
-OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(capture_last), TMP2, 0);
-
-/* These pointer sized fields temporarly stores internal variables. */
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0));
-OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(offset_vector), STR_PTR, 0);
-OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(subject), TMP2, 0);
-
-if (common->mark_ptr != 0)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr));
-OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(pattern_position), SLJIT_IMM, GET(cc, 2));
-OP1(SLJIT_MOV_SI, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(next_item_length), SLJIT_IMM, GET(cc, 2 + LINK_SIZE));
-OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), CALLOUT_ARG_OFFSET(mark), (common->mark_ptr != 0) ? TMP2 : SLJIT_IMM, 0);
-
-/* Needed to save important temporary registers. */
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STACK_TOP, 0);
-OP2(SLJIT_SUB, SLJIT_R1, 0, STACK_TOP, 0, SLJIT_IMM, CALLOUT_ARG_SIZE);
-GET_LOCAL_BASE(SLJIT_R2, 0, OVECTOR_START);
-sljit_emit_ijump(compiler, SLJIT_CALL3, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_callout));
-OP1(SLJIT_MOV_SI, SLJIT_RETURN_REG, 0, SLJIT_RETURN_REG, 0);
-OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0);
-free_stack(common, CALLOUT_ARG_SIZE / sizeof(sljit_sw));
-
-/* Check return value. */
-OP2(SLJIT_SUB | SLJIT_SET_S, SLJIT_UNUSED, 0, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0);
-add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_SIG_GREATER));
-if (common->forced_quit_label == NULL)
- add_jump(compiler, &common->forced_quit, JUMP(SLJIT_SIG_LESS));
-else
- JUMPTO(SLJIT_SIG_LESS, common->forced_quit_label);
-return cc + 2 + 2 * LINK_SIZE;
-}
-
-#undef CALLOUT_ARG_SIZE
-#undef CALLOUT_ARG_OFFSET
-
-static pcre_uchar *compile_assert_matchingpath(compiler_common *common, pcre_uchar *cc, assert_backtrack *backtrack, BOOL conditional)
-{
-DEFINE_COMPILER;
-int framesize;
-int extrasize;
-BOOL needs_control_head;
-int private_data_ptr;
-backtrack_common altbacktrack;
-pcre_uchar *ccbegin;
-pcre_uchar opcode;
-pcre_uchar bra = OP_BRA;
-jump_list *tmp = NULL;
-jump_list **target = (conditional) ? &backtrack->condfailed : &backtrack->common.topbacktracks;
-jump_list **found;
-/* Saving previous accept variables. */
-BOOL save_local_exit = common->local_exit;
-BOOL save_positive_assert = common->positive_assert;
-then_trap_backtrack *save_then_trap = common->then_trap;
-struct sljit_label *save_quit_label = common->quit_label;
-struct sljit_label *save_accept_label = common->accept_label;
-jump_list *save_quit = common->quit;
-jump_list *save_positive_assert_quit = common->positive_assert_quit;
-jump_list *save_accept = common->accept;
-struct sljit_jump *jump;
-struct sljit_jump *brajump = NULL;
-
-/* Assert captures then. */
-common->then_trap = NULL;
-
-if (*cc == OP_BRAZERO || *cc == OP_BRAMINZERO)
- {
- SLJIT_ASSERT(!conditional);
- bra = *cc;
- cc++;
- }
-private_data_ptr = PRIVATE_DATA(cc);
-SLJIT_ASSERT(private_data_ptr != 0);
-framesize = get_framesize(common, cc, NULL, FALSE, &needs_control_head);
-backtrack->framesize = framesize;
-backtrack->private_data_ptr = private_data_ptr;
-opcode = *cc;
-SLJIT_ASSERT(opcode >= OP_ASSERT && opcode <= OP_ASSERTBACK_NOT);
-found = (opcode == OP_ASSERT || opcode == OP_ASSERTBACK) ? &tmp : target;
-ccbegin = cc;
-cc += GET(cc, 1);
-
-if (bra == OP_BRAMINZERO)
- {
- /* This is a braminzero backtrack path. */
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
- brajump = CMP(SLJIT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0);
- }
-
-if (framesize < 0)
- {
- extrasize = needs_control_head ? 2 : 1;
- if (framesize == no_frame)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STACK_TOP, 0);
- allocate_stack(common, extrasize);
- if (needs_control_head)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- if (needs_control_head)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_IMM, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);
- }
- }
-else
- {
- extrasize = needs_control_head ? 3 : 2;
- allocate_stack(common, framesize + extrasize);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + extrasize) * sizeof(sljit_sw));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, TMP2, 0);
- if (needs_control_head)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- if (needs_control_head)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP1, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_IMM, 0);
- }
- else
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP1, 0);
- init_frame(common, ccbegin, NULL, framesize + extrasize - 1, extrasize, FALSE);
- }
-
-memset(&altbacktrack, 0, sizeof(backtrack_common));
-if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
- {
- /* Negative assert is stronger than positive assert. */
- common->local_exit = TRUE;
- common->quit_label = NULL;
- common->quit = NULL;
- common->positive_assert = FALSE;
- }
-else
- common->positive_assert = TRUE;
-common->positive_assert_quit = NULL;
-
-while (1)
- {
- common->accept_label = NULL;
- common->accept = NULL;
- altbacktrack.top = NULL;
- altbacktrack.topbacktracks = NULL;
-
- if (*ccbegin == OP_ALT)
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
-
- altbacktrack.cc = ccbegin;
- compile_matchingpath(common, ccbegin + 1 + LINK_SIZE, cc, &altbacktrack);
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- {
- if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
- {
- common->local_exit = save_local_exit;
- common->quit_label = save_quit_label;
- common->quit = save_quit;
- }
- common->positive_assert = save_positive_assert;
- common->then_trap = save_then_trap;
- common->accept_label = save_accept_label;
- common->positive_assert_quit = save_positive_assert_quit;
- common->accept = save_accept;
- return NULL;
- }
- common->accept_label = LABEL();
- if (common->accept != NULL)
- set_jumps(common->accept, common->accept_label);
-
- /* Reset stack. */
- if (framesize < 0)
- {
- if (framesize == no_frame)
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- else
- free_stack(common, extrasize);
- if (needs_control_head)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), 0);
- }
- else
- {
- if ((opcode != OP_ASSERT_NOT && opcode != OP_ASSERTBACK_NOT) || conditional)
- {
- /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
- OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_sw));
- if (needs_control_head)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), 0);
- }
- else
- {
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- if (needs_control_head)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), (framesize + 1) * sizeof(sljit_sw));
- add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
- }
- }
-
- if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
- {
- /* We know that STR_PTR was stored on the top of the stack. */
- if (conditional)
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), needs_control_head ? sizeof(sljit_sw) : 0);
- else if (bra == OP_BRAZERO)
- {
- if (framesize < 0)
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (extrasize - 1) * sizeof(sljit_sw));
- else
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_sw));
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (framesize + extrasize - 1) * sizeof(sljit_sw));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, TMP1, 0);
- }
- OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- }
- else if (framesize >= 0)
- {
- /* For OP_BRA and OP_BRAMINZERO. */
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_sw));
- }
- }
- add_jump(compiler, found, JUMP(SLJIT_JUMP));
-
- compile_backtrackingpath(common, altbacktrack.top);
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- {
- if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
- {
- common->local_exit = save_local_exit;
- common->quit_label = save_quit_label;
- common->quit = save_quit;
- }
- common->positive_assert = save_positive_assert;
- common->then_trap = save_then_trap;
- common->accept_label = save_accept_label;
- common->positive_assert_quit = save_positive_assert_quit;
- common->accept = save_accept;
- return NULL;
- }
- set_jumps(altbacktrack.topbacktracks, LABEL());
-
- if (*cc != OP_ALT)
- break;
-
- ccbegin = cc;
- cc += GET(cc, 1);
- }
-
-if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
- {
- SLJIT_ASSERT(common->positive_assert_quit == NULL);
- /* Makes the check less complicated below. */
- common->positive_assert_quit = common->quit;
- }
-
-/* None of them matched. */
-if (common->positive_assert_quit != NULL)
- {
- jump = JUMP(SLJIT_JUMP);
- set_jumps(common->positive_assert_quit, LABEL());
- SLJIT_ASSERT(framesize != no_stack);
- if (framesize < 0)
- OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_IMM, extrasize * sizeof(sljit_sw));
- else
- {
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
- OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + extrasize) * sizeof(sljit_sw));
- }
- JUMPHERE(jump);
- }
-
-if (needs_control_head)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(1));
-
-if (opcode == OP_ASSERT || opcode == OP_ASSERTBACK)
- {
- /* Assert is failed. */
- if (conditional || bra == OP_BRAZERO)
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
-
- if (framesize < 0)
- {
- /* The topmost item should be 0. */
- if (bra == OP_BRAZERO)
- {
- if (extrasize == 2)
- free_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- }
- else
- free_stack(common, extrasize);
- }
- else
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(extrasize - 1));
- /* The topmost item should be 0. */
- if (bra == OP_BRAZERO)
- {
- free_stack(common, framesize + extrasize - 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- }
- else
- free_stack(common, framesize + extrasize);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, TMP1, 0);
- }
- jump = JUMP(SLJIT_JUMP);
- if (bra != OP_BRAZERO)
- add_jump(compiler, target, jump);
-
- /* Assert is successful. */
- set_jumps(tmp, LABEL());
- if (framesize < 0)
- {
- /* We know that STR_PTR was stored on the top of the stack. */
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (extrasize - 1) * sizeof(sljit_sw));
- /* Keep the STR_PTR on the top of the stack. */
- if (bra == OP_BRAZERO)
- {
- OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
- if (extrasize == 2)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- }
- else if (bra == OP_BRAMINZERO)
- {
- OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- }
- }
- else
- {
- if (bra == OP_BRA)
- {
- /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
- OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_IMM, (framesize + 1) * sizeof(sljit_sw));
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), (extrasize - 2) * sizeof(sljit_sw));
- }
- else
- {
- /* We don't need to keep the STR_PTR, only the previous private_data_ptr. */
- OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_IMM, (framesize + 2) * sizeof(sljit_sw));
- if (extrasize == 2)
- {
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- if (bra == OP_BRAMINZERO)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- }
- else
- {
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), bra == OP_BRAZERO ? STR_PTR : SLJIT_IMM, 0);
- }
- }
- }
-
- if (bra == OP_BRAZERO)
- {
- backtrack->matchingpath = LABEL();
- SET_LABEL(jump, backtrack->matchingpath);
- }
- else if (bra == OP_BRAMINZERO)
- {
- JUMPTO(SLJIT_JUMP, backtrack->matchingpath);
- JUMPHERE(brajump);
- if (framesize >= 0)
- {
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_MEM1(STACK_TOP), framesize * sizeof(sljit_sw));
- }
- set_jumps(backtrack->common.topbacktracks, LABEL());
- }
- }
-else
- {
- /* AssertNot is successful. */
- if (framesize < 0)
- {
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- if (bra != OP_BRA)
- {
- if (extrasize == 2)
- free_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- }
- else
- free_stack(common, extrasize);
- }
- else
- {
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(extrasize - 1));
- /* The topmost item should be 0. */
- if (bra != OP_BRA)
- {
- free_stack(common, framesize + extrasize - 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- }
- else
- free_stack(common, framesize + extrasize);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, TMP1, 0);
- }
-
- if (bra == OP_BRAZERO)
- backtrack->matchingpath = LABEL();
- else if (bra == OP_BRAMINZERO)
- {
- JUMPTO(SLJIT_JUMP, backtrack->matchingpath);
- JUMPHERE(brajump);
- }
-
- if (bra != OP_BRA)
- {
- SLJIT_ASSERT(found == &backtrack->common.topbacktracks);
- set_jumps(backtrack->common.topbacktracks, LABEL());
- backtrack->common.topbacktracks = NULL;
- }
- }
-
-if (opcode == OP_ASSERT_NOT || opcode == OP_ASSERTBACK_NOT)
- {
- common->local_exit = save_local_exit;
- common->quit_label = save_quit_label;
- common->quit = save_quit;
- }
-common->positive_assert = save_positive_assert;
-common->then_trap = save_then_trap;
-common->accept_label = save_accept_label;
-common->positive_assert_quit = save_positive_assert_quit;
-common->accept = save_accept;
-return cc + 1 + LINK_SIZE;
-}
-
-static SLJIT_INLINE void match_once_common(compiler_common *common, pcre_uchar ket, int framesize, int private_data_ptr, BOOL has_alternatives, BOOL needs_control_head)
-{
-DEFINE_COMPILER;
-int stacksize;
-
-if (framesize < 0)
- {
- if (framesize == no_frame)
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- else
- {
- stacksize = needs_control_head ? 1 : 0;
- if (ket != OP_KET || has_alternatives)
- stacksize++;
- free_stack(common, stacksize);
- }
-
- if (needs_control_head)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), (ket != OP_KET || has_alternatives) ? sizeof(sljit_sw) : 0);
-
- /* TMP2 which is set here used by OP_KETRMAX below. */
- if (ket == OP_KETRMAX)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), 0);
- else if (ket == OP_KETRMIN)
- {
- /* Move the STR_PTR to the private_data_ptr. */
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_MEM1(STACK_TOP), 0);
- }
- }
-else
- {
- stacksize = (ket != OP_KET || has_alternatives) ? 2 : 1;
- OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_IMM, (framesize + stacksize) * sizeof(sljit_sw));
- if (needs_control_head)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), 0);
-
- if (ket == OP_KETRMAX)
- {
- /* TMP2 which is set here used by OP_KETRMAX below. */
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- }
- }
-if (needs_control_head)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, TMP1, 0);
-}
-
-static SLJIT_INLINE int match_capture_common(compiler_common *common, int stacksize, int offset, int private_data_ptr)
-{
-DEFINE_COMPILER;
-
-if (common->capture_last_ptr != 0)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr, SLJIT_IMM, offset >> 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), TMP1, 0);
- stacksize++;
- }
-if (common->optimized_cbracket[offset >> 1] == 0)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset));
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), TMP1, 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize + 1), TMP2, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset), TMP1, 0);
- stacksize += 2;
- }
-return stacksize;
-}
-
-/*
- Handling bracketed expressions is probably the most complex part.
-
- Stack layout naming characters:
- S - Push the current STR_PTR
- 0 - Push a 0 (NULL)
- A - Push the current STR_PTR. Needed for restoring the STR_PTR
- before the next alternative. Not pushed if there are no alternatives.
- M - Any values pushed by the current alternative. Can be empty, or anything.
- C - Push the previous OVECTOR(i), OVECTOR(i+1) and OVECTOR_PRIV(i) to the stack.
- L - Push the previous local (pointed by localptr) to the stack
- () - opional values stored on the stack
- ()* - optonal, can be stored multiple times
-
- The following list shows the regular expression templates, their PCRE byte codes
- and stack layout supported by pcre-sljit.
-
- (?:) OP_BRA | OP_KET A M
- () OP_CBRA | OP_KET C M
- (?:)+ OP_BRA | OP_KETRMAX 0 A M S ( A M S )*
- OP_SBRA | OP_KETRMAX 0 L M S ( L M S )*
- (?:)+? OP_BRA | OP_KETRMIN 0 A M S ( A M S )*
- OP_SBRA | OP_KETRMIN 0 L M S ( L M S )*
- ()+ OP_CBRA | OP_KETRMAX 0 C M S ( C M S )*
- OP_SCBRA | OP_KETRMAX 0 C M S ( C M S )*
- ()+? OP_CBRA | OP_KETRMIN 0 C M S ( C M S )*
- OP_SCBRA | OP_KETRMIN 0 C M S ( C M S )*
- (?:)? OP_BRAZERO | OP_BRA | OP_KET S ( A M 0 )
- (?:)?? OP_BRAMINZERO | OP_BRA | OP_KET S ( A M 0 )
- ()? OP_BRAZERO | OP_CBRA | OP_KET S ( C M 0 )
- ()?? OP_BRAMINZERO | OP_CBRA | OP_KET S ( C M 0 )
- (?:)* OP_BRAZERO | OP_BRA | OP_KETRMAX S 0 ( A M S )*
- OP_BRAZERO | OP_SBRA | OP_KETRMAX S 0 ( L M S )*
- (?:)*? OP_BRAMINZERO | OP_BRA | OP_KETRMIN S 0 ( A M S )*
- OP_BRAMINZERO | OP_SBRA | OP_KETRMIN S 0 ( L M S )*
- ()* OP_BRAZERO | OP_CBRA | OP_KETRMAX S 0 ( C M S )*
- OP_BRAZERO | OP_SCBRA | OP_KETRMAX S 0 ( C M S )*
- ()*? OP_BRAMINZERO | OP_CBRA | OP_KETRMIN S 0 ( C M S )*
- OP_BRAMINZERO | OP_SCBRA | OP_KETRMIN S 0 ( C M S )*
-
-
- Stack layout naming characters:
- A - Push the alternative index (starting from 0) on the stack.
- Not pushed if there is no alternatives.
- M - Any values pushed by the current alternative. Can be empty, or anything.
-
- The next list shows the possible content of a bracket:
- (|) OP_*BRA | OP_ALT ... M A
- (?()|) OP_*COND | OP_ALT M A
- (?>|) OP_ONCE | OP_ALT ... [stack trace] M A
- (?>|) OP_ONCE_NC | OP_ALT ... [stack trace] M A
- Or nothing, if trace is unnecessary
-*/
-
-static pcre_uchar *compile_bracket_matchingpath(compiler_common *common, pcre_uchar *cc, backtrack_common *parent)
-{
-DEFINE_COMPILER;
-backtrack_common *backtrack;
-pcre_uchar opcode;
-int private_data_ptr = 0;
-int offset = 0;
-int i, stacksize;
-int repeat_ptr = 0, repeat_length = 0;
-int repeat_type = 0, repeat_count = 0;
-pcre_uchar *ccbegin;
-pcre_uchar *matchingpath;
-pcre_uchar *slot;
-pcre_uchar bra = OP_BRA;
-pcre_uchar ket;
-assert_backtrack *assert;
-BOOL has_alternatives;
-BOOL needs_control_head = FALSE;
-struct sljit_jump *jump;
-struct sljit_jump *skip;
-struct sljit_label *rmax_label = NULL;
-struct sljit_jump *braminzero = NULL;
-
-PUSH_BACKTRACK(sizeof(bracket_backtrack), cc, NULL);
-
-if (*cc == OP_BRAZERO || *cc == OP_BRAMINZERO)
- {
- bra = *cc;
- cc++;
- opcode = *cc;
- }
-
-opcode = *cc;
-ccbegin = cc;
-matchingpath = bracketend(cc) - 1 - LINK_SIZE;
-ket = *matchingpath;
-if (ket == OP_KET && PRIVATE_DATA(matchingpath) != 0)
- {
- repeat_ptr = PRIVATE_DATA(matchingpath);
- repeat_length = PRIVATE_DATA(matchingpath + 1);
- repeat_type = PRIVATE_DATA(matchingpath + 2);
- repeat_count = PRIVATE_DATA(matchingpath + 3);
- SLJIT_ASSERT(repeat_length != 0 && repeat_type != 0 && repeat_count != 0);
- if (repeat_type == OP_UPTO)
- ket = OP_KETRMAX;
- if (repeat_type == OP_MINUPTO)
- ket = OP_KETRMIN;
- }
-
-if ((opcode == OP_COND || opcode == OP_SCOND) && cc[1 + LINK_SIZE] == OP_DEF)
- {
- /* Drop this bracket_backtrack. */
- parent->top = backtrack->prev;
- return matchingpath + 1 + LINK_SIZE + repeat_length;
- }
-
-matchingpath = ccbegin + 1 + LINK_SIZE;
-SLJIT_ASSERT(ket == OP_KET || ket == OP_KETRMAX || ket == OP_KETRMIN);
-SLJIT_ASSERT(!((bra == OP_BRAZERO && ket == OP_KETRMIN) || (bra == OP_BRAMINZERO && ket == OP_KETRMAX)));
-cc += GET(cc, 1);
-
-has_alternatives = *cc == OP_ALT;
-if (SLJIT_UNLIKELY(opcode == OP_COND || opcode == OP_SCOND))
- has_alternatives = (*matchingpath == OP_RREF || *matchingpath == OP_DNRREF || *matchingpath == OP_FAIL) ? FALSE : TRUE;
-
-if (SLJIT_UNLIKELY(opcode == OP_COND) && (*cc == OP_KETRMAX || *cc == OP_KETRMIN))
- opcode = OP_SCOND;
-if (SLJIT_UNLIKELY(opcode == OP_ONCE_NC))
- opcode = OP_ONCE;
-
-if (opcode == OP_CBRA || opcode == OP_SCBRA)
- {
- /* Capturing brackets has a pre-allocated space. */
- offset = GET2(ccbegin, 1 + LINK_SIZE);
- if (common->optimized_cbracket[offset] == 0)
- {
- private_data_ptr = OVECTOR_PRIV(offset);
- offset <<= 1;
- }
- else
- {
- offset <<= 1;
- private_data_ptr = OVECTOR(offset);
- }
- BACKTRACK_AS(bracket_backtrack)->private_data_ptr = private_data_ptr;
- matchingpath += IMM2_SIZE;
- }
-else if (opcode == OP_ONCE || opcode == OP_SBRA || opcode == OP_SCOND)
- {
- /* Other brackets simply allocate the next entry. */
- private_data_ptr = PRIVATE_DATA(ccbegin);
- SLJIT_ASSERT(private_data_ptr != 0);
- BACKTRACK_AS(bracket_backtrack)->private_data_ptr = private_data_ptr;
- if (opcode == OP_ONCE)
- BACKTRACK_AS(bracket_backtrack)->u.framesize = get_framesize(common, ccbegin, NULL, FALSE, &needs_control_head);
- }
-
-/* Instructions before the first alternative. */
-stacksize = 0;
-if (ket == OP_KETRMAX || (ket == OP_KETRMIN && bra != OP_BRAMINZERO))
- stacksize++;
-if (bra == OP_BRAZERO)
- stacksize++;
-
-if (stacksize > 0)
- allocate_stack(common, stacksize);
-
-stacksize = 0;
-if (ket == OP_KETRMAX || (ket == OP_KETRMIN && bra != OP_BRAMINZERO))
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, 0);
- stacksize++;
- }
-
-if (bra == OP_BRAZERO)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), STR_PTR, 0);
-
-if (bra == OP_BRAMINZERO)
- {
- /* This is a backtrack path! (Since the try-path of OP_BRAMINZERO matches to the empty string) */
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- if (ket != OP_KETRMIN)
- {
- free_stack(common, 1);
- braminzero = CMP(SLJIT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0);
- }
- else
- {
- if (opcode == OP_ONCE || opcode >= OP_SBRA)
- {
- jump = CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0);
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
- /* Nothing stored during the first run. */
- skip = JUMP(SLJIT_JUMP);
- JUMPHERE(jump);
- /* Checking zero-length iteration. */
- if (opcode != OP_ONCE || BACKTRACK_AS(bracket_backtrack)->u.framesize < 0)
- {
- /* When we come from outside, private_data_ptr contains the previous STR_PTR. */
- braminzero = CMP(SLJIT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- }
- else
- {
- /* Except when the whole stack frame must be saved. */
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- braminzero = CMP(SLJIT_EQUAL, STR_PTR, 0, SLJIT_MEM1(TMP1), (BACKTRACK_AS(bracket_backtrack)->u.framesize + 1) * sizeof(sljit_sw));
- }
- JUMPHERE(skip);
- }
- else
- {
- jump = CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0);
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
- JUMPHERE(jump);
- }
- }
- }
-
-if (repeat_type != 0)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), repeat_ptr, SLJIT_IMM, repeat_count);
- if (repeat_type == OP_EXACT)
- rmax_label = LABEL();
- }
-
-if (ket == OP_KETRMIN)
- BACKTRACK_AS(bracket_backtrack)->recursive_matchingpath = LABEL();
-
-if (ket == OP_KETRMAX)
- {
- rmax_label = LABEL();
- if (has_alternatives && opcode != OP_ONCE && opcode < OP_SBRA && repeat_type == 0)
- BACKTRACK_AS(bracket_backtrack)->alternative_matchingpath = rmax_label;
- }
-
-/* Handling capturing brackets and alternatives. */
-if (opcode == OP_ONCE)
- {
- stacksize = 0;
- if (needs_control_head)
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);
- stacksize++;
- }
-
- if (BACKTRACK_AS(bracket_backtrack)->u.framesize < 0)
- {
- /* Neither capturing brackets nor recursions are found in the block. */
- if (ket == OP_KETRMIN)
- {
- stacksize += 2;
- if (!needs_control_head)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- }
- else
- {
- if (BACKTRACK_AS(bracket_backtrack)->u.framesize == no_frame)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STACK_TOP, 0);
- if (ket == OP_KETRMAX || has_alternatives)
- stacksize++;
- }
-
- if (stacksize > 0)
- allocate_stack(common, stacksize);
-
- stacksize = 0;
- if (needs_control_head)
- {
- stacksize++;
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
- }
-
- if (ket == OP_KETRMIN)
- {
- if (needs_control_head)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), STR_PTR, 0);
- if (BACKTRACK_AS(bracket_backtrack)->u.framesize == no_frame)
- OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STACK_TOP, 0, SLJIT_IMM, needs_control_head ? (2 * sizeof(sljit_sw)) : sizeof(sljit_sw));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize + 1), TMP2, 0);
- }
- else if (ket == OP_KETRMAX || has_alternatives)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), STR_PTR, 0);
- }
- else
- {
- if (ket != OP_KET || has_alternatives)
- stacksize++;
-
- stacksize += BACKTRACK_AS(bracket_backtrack)->u.framesize + 1;
- allocate_stack(common, stacksize);
-
- if (needs_control_head)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
-
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- OP2(SLJIT_SUB, TMP2, 0, STACK_TOP, 0, SLJIT_IMM, stacksize * sizeof(sljit_sw));
-
- stacksize = needs_control_head ? 1 : 0;
- if (ket != OP_KET || has_alternatives)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, TMP2, 0);
- stacksize++;
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), TMP1, 0);
- }
- else
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, TMP2, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), TMP1, 0);
- }
- init_frame(common, ccbegin, NULL, BACKTRACK_AS(bracket_backtrack)->u.framesize + stacksize, stacksize + 1, FALSE);
- }
- }
-else if (opcode == OP_CBRA || opcode == OP_SCBRA)
- {
- /* Saving the previous values. */
- if (common->optimized_cbracket[offset >> 1] != 0)
- {
- SLJIT_ASSERT(private_data_ptr == OVECTOR(offset));
- allocate_stack(common, 2);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr + sizeof(sljit_sw));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);
- }
- else
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
- }
- }
-else if (opcode == OP_SBRA || opcode == OP_SCOND)
- {
- /* Saving the previous value. */
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
- }
-else if (has_alternatives)
- {
- /* Pushing the starting string pointer. */
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- }
-
-/* Generating code for the first alternative. */
-if (opcode == OP_COND || opcode == OP_SCOND)
- {
- if (*matchingpath == OP_CREF)
- {
- SLJIT_ASSERT(has_alternatives);
- add_jump(compiler, &(BACKTRACK_AS(bracket_backtrack)->u.condfailed),
- CMP(SLJIT_EQUAL, SLJIT_MEM1(SLJIT_SP), OVECTOR(GET2(matchingpath, 1) << 1), SLJIT_MEM1(SLJIT_SP), OVECTOR(1)));
- matchingpath += 1 + IMM2_SIZE;
- }
- else if (*matchingpath == OP_DNCREF)
- {
- SLJIT_ASSERT(has_alternatives);
-
- i = GET2(matchingpath, 1 + IMM2_SIZE);
- slot = common->name_table + GET2(matchingpath, 1) * common->name_entry_size;
- OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(1));
- OP2(SLJIT_SUB | SLJIT_SET_E, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(GET2(slot, 0) << 1), TMP1, 0);
- slot += common->name_entry_size;
- i--;
- while (i-- > 0)
- {
- OP2(SLJIT_SUB, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(GET2(slot, 0) << 1), TMP1, 0);
- OP2(SLJIT_OR | SLJIT_SET_E, TMP2, 0, TMP2, 0, STR_PTR, 0);
- slot += common->name_entry_size;
- }
- OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);
- add_jump(compiler, &(BACKTRACK_AS(bracket_backtrack)->u.condfailed), JUMP(SLJIT_ZERO));
- matchingpath += 1 + 2 * IMM2_SIZE;
- }
- else if (*matchingpath == OP_RREF || *matchingpath == OP_DNRREF || *matchingpath == OP_FAIL)
- {
- /* Never has other case. */
- BACKTRACK_AS(bracket_backtrack)->u.condfailed = NULL;
- SLJIT_ASSERT(!has_alternatives);
-
- if (*matchingpath == OP_FAIL)
- stacksize = 0;
- if (*matchingpath == OP_RREF)
- {
- stacksize = GET2(matchingpath, 1);
- if (common->currententry == NULL)
- stacksize = 0;
- else if (stacksize == RREF_ANY)
- stacksize = 1;
- else if (common->currententry->start == 0)
- stacksize = stacksize == 0;
- else
- stacksize = stacksize == (int)GET2(common->start, common->currententry->start + 1 + LINK_SIZE);
-
- if (stacksize != 0)
- matchingpath += 1 + IMM2_SIZE;
- }
- else
- {
- if (common->currententry == NULL || common->currententry->start == 0)
- stacksize = 0;
- else
- {
- stacksize = GET2(matchingpath, 1 + IMM2_SIZE);
- slot = common->name_table + GET2(matchingpath, 1) * common->name_entry_size;
- i = (int)GET2(common->start, common->currententry->start + 1 + LINK_SIZE);
- while (stacksize > 0)
- {
- if ((int)GET2(slot, 0) == i)
- break;
- slot += common->name_entry_size;
- stacksize--;
- }
- }
-
- if (stacksize != 0)
- matchingpath += 1 + 2 * IMM2_SIZE;
- }
-
- /* The stacksize == 0 is a common "else" case. */
- if (stacksize == 0)
- {
- if (*cc == OP_ALT)
- {
- matchingpath = cc + 1 + LINK_SIZE;
- cc += GET(cc, 1);
- }
- else
- matchingpath = cc;
- }
- }
- else
- {
- SLJIT_ASSERT(has_alternatives && *matchingpath >= OP_ASSERT && *matchingpath <= OP_ASSERTBACK_NOT);
- /* Similar code as PUSH_BACKTRACK macro. */
- assert = sljit_alloc_memory(compiler, sizeof(assert_backtrack));
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- return NULL;
- memset(assert, 0, sizeof(assert_backtrack));
- assert->common.cc = matchingpath;
- BACKTRACK_AS(bracket_backtrack)->u.assert = assert;
- matchingpath = compile_assert_matchingpath(common, matchingpath, assert, TRUE);
- }
- }
-
-compile_matchingpath(common, matchingpath, cc, backtrack);
-if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- return NULL;
-
-if (opcode == OP_ONCE)
- match_once_common(common, ket, BACKTRACK_AS(bracket_backtrack)->u.framesize, private_data_ptr, has_alternatives, needs_control_head);
-
-stacksize = 0;
-if (repeat_type == OP_MINUPTO)
- {
- /* We need to preserve the counter. TMP2 will be used below. */
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), repeat_ptr);
- stacksize++;
- }
-if (ket != OP_KET || bra != OP_BRA)
- stacksize++;
-if (offset != 0)
- {
- if (common->capture_last_ptr != 0)
- stacksize++;
- if (common->optimized_cbracket[offset >> 1] == 0)
- stacksize += 2;
- }
-if (has_alternatives && opcode != OP_ONCE)
- stacksize++;
-
-if (stacksize > 0)
- allocate_stack(common, stacksize);
-
-stacksize = 0;
-if (repeat_type == OP_MINUPTO)
- {
- /* TMP2 was set above. */
- OP2(SLJIT_SUB, SLJIT_MEM1(STACK_TOP), STACK(stacksize), TMP2, 0, SLJIT_IMM, 1);
- stacksize++;
- }
-
-if (ket != OP_KET || bra != OP_BRA)
- {
- if (ket != OP_KET)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), STR_PTR, 0);
- else
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, 0);
- stacksize++;
- }
-
-if (offset != 0)
- stacksize = match_capture_common(common, stacksize, offset, private_data_ptr);
-
-if (has_alternatives)
- {
- if (opcode != OP_ONCE)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, 0);
- if (ket != OP_KETRMAX)
- BACKTRACK_AS(bracket_backtrack)->alternative_matchingpath = LABEL();
- }
-
-/* Must be after the matchingpath label. */
-if (offset != 0 && common->optimized_cbracket[offset >> 1] != 0)
- {
- SLJIT_ASSERT(private_data_ptr == OVECTOR(offset + 0));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), STR_PTR, 0);
- }
-
-if (ket == OP_KETRMAX)
- {
- if (repeat_type != 0)
- {
- if (has_alternatives)
- BACKTRACK_AS(bracket_backtrack)->alternative_matchingpath = LABEL();
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_MEM1(SLJIT_SP), repeat_ptr, SLJIT_MEM1(SLJIT_SP), repeat_ptr, SLJIT_IMM, 1);
- JUMPTO(SLJIT_NOT_ZERO, rmax_label);
- /* Drop STR_PTR for greedy plus quantifier. */
- if (opcode != OP_ONCE)
- free_stack(common, 1);
- }
- else if (opcode == OP_ONCE || opcode >= OP_SBRA)
- {
- if (has_alternatives)
- BACKTRACK_AS(bracket_backtrack)->alternative_matchingpath = LABEL();
- /* Checking zero-length iteration. */
- if (opcode != OP_ONCE)
- {
- CMPTO(SLJIT_NOT_EQUAL, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STR_PTR, 0, rmax_label);
- /* Drop STR_PTR for greedy plus quantifier. */
- if (bra != OP_BRAZERO)
- free_stack(common, 1);
- }
- else
- /* TMP2 must contain the starting STR_PTR. */
- CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, STR_PTR, 0, rmax_label);
- }
- else
- JUMPTO(SLJIT_JUMP, rmax_label);
- BACKTRACK_AS(bracket_backtrack)->recursive_matchingpath = LABEL();
- }
-
-if (repeat_type == OP_EXACT)
- {
- count_match(common);
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_MEM1(SLJIT_SP), repeat_ptr, SLJIT_MEM1(SLJIT_SP), repeat_ptr, SLJIT_IMM, 1);
- JUMPTO(SLJIT_NOT_ZERO, rmax_label);
- }
-else if (repeat_type == OP_UPTO)
- {
- /* We need to preserve the counter. */
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), repeat_ptr);
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
- }
-
-if (bra == OP_BRAZERO)
- BACKTRACK_AS(bracket_backtrack)->zero_matchingpath = LABEL();
-
-if (bra == OP_BRAMINZERO)
- {
- /* This is a backtrack path! (From the viewpoint of OP_BRAMINZERO) */
- JUMPTO(SLJIT_JUMP, ((braminzero_backtrack *)parent)->matchingpath);
- if (braminzero != NULL)
- {
- JUMPHERE(braminzero);
- /* We need to release the end pointer to perform the
- backtrack for the zero-length iteration. When
- framesize is < 0, OP_ONCE will do the release itself. */
- if (opcode == OP_ONCE && BACKTRACK_AS(bracket_backtrack)->u.framesize >= 0)
- {
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
- }
- else if (ket == OP_KETRMIN && opcode != OP_ONCE)
- free_stack(common, 1);
- }
- /* Continue to the normal backtrack. */
- }
-
-if ((ket != OP_KET && bra != OP_BRAMINZERO) || bra == OP_BRAZERO)
- count_match(common);
-
-/* Skip the other alternatives. */
-while (*cc == OP_ALT)
- cc += GET(cc, 1);
-cc += 1 + LINK_SIZE;
-
-/* Temporarily encoding the needs_control_head in framesize. */
-if (opcode == OP_ONCE)
- BACKTRACK_AS(bracket_backtrack)->u.framesize = (BACKTRACK_AS(bracket_backtrack)->u.framesize << 1) | (needs_control_head ? 1 : 0);
-return cc + repeat_length;
-}
-
-static pcre_uchar *compile_bracketpos_matchingpath(compiler_common *common, pcre_uchar *cc, backtrack_common *parent)
-{
-DEFINE_COMPILER;
-backtrack_common *backtrack;
-pcre_uchar opcode;
-int private_data_ptr;
-int cbraprivptr = 0;
-BOOL needs_control_head;
-int framesize;
-int stacksize;
-int offset = 0;
-BOOL zero = FALSE;
-pcre_uchar *ccbegin = NULL;
-int stack; /* Also contains the offset of control head. */
-struct sljit_label *loop = NULL;
-struct jump_list *emptymatch = NULL;
-
-PUSH_BACKTRACK(sizeof(bracketpos_backtrack), cc, NULL);
-if (*cc == OP_BRAPOSZERO)
- {
- zero = TRUE;
- cc++;
- }
-
-opcode = *cc;
-private_data_ptr = PRIVATE_DATA(cc);
-SLJIT_ASSERT(private_data_ptr != 0);
-BACKTRACK_AS(bracketpos_backtrack)->private_data_ptr = private_data_ptr;
-switch(opcode)
- {
- case OP_BRAPOS:
- case OP_SBRAPOS:
- ccbegin = cc + 1 + LINK_SIZE;
- break;
-
- case OP_CBRAPOS:
- case OP_SCBRAPOS:
- offset = GET2(cc, 1 + LINK_SIZE);
- /* This case cannot be optimized in the same was as
- normal capturing brackets. */
- SLJIT_ASSERT(common->optimized_cbracket[offset] == 0);
- cbraprivptr = OVECTOR_PRIV(offset);
- offset <<= 1;
- ccbegin = cc + 1 + LINK_SIZE + IMM2_SIZE;
- break;
-
- default:
- SLJIT_ASSERT_STOP();
- break;
- }
-
-framesize = get_framesize(common, cc, NULL, FALSE, &needs_control_head);
-BACKTRACK_AS(bracketpos_backtrack)->framesize = framesize;
-if (framesize < 0)
- {
- if (offset != 0)
- {
- stacksize = 2;
- if (common->capture_last_ptr != 0)
- stacksize++;
- }
- else
- stacksize = 1;
-
- if (needs_control_head)
- stacksize++;
- if (!zero)
- stacksize++;
-
- BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;
- allocate_stack(common, stacksize);
- if (framesize == no_frame)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STACK_TOP, 0);
-
- stack = 0;
- if (offset != 0)
- {
- stack = 2;
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset));
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);
- if (common->capture_last_ptr != 0)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), TMP2, 0);
- if (needs_control_head)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);
- if (common->capture_last_ptr != 0)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), TMP1, 0);
- stack = 3;
- }
- }
- else
- {
- if (needs_control_head)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- stack = 1;
- }
-
- if (needs_control_head)
- stack++;
- if (!zero)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stack), SLJIT_IMM, 1);
- if (needs_control_head)
- {
- stack--;
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stack), TMP2, 0);
- }
- }
-else
- {
- stacksize = framesize + 1;
- if (!zero)
- stacksize++;
- if (needs_control_head)
- stacksize++;
- if (offset == 0)
- stacksize++;
- BACKTRACK_AS(bracketpos_backtrack)->stacksize = stacksize;
-
- allocate_stack(common, stacksize);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- if (needs_control_head)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);
- OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_SP), private_data_ptr, STACK_TOP, 0, SLJIT_IMM, -STACK(stacksize - 1));
-
- stack = 0;
- if (!zero)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 1);
- stack = 1;
- }
- if (needs_control_head)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stack), TMP2, 0);
- stack++;
- }
- if (offset == 0)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stack), STR_PTR, 0);
- stack++;
- }
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stack), TMP1, 0);
- init_frame(common, cc, NULL, stacksize - 1, stacksize - framesize, FALSE);
- stack -= 1 + (offset == 0);
- }
-
-if (offset != 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), cbraprivptr, STR_PTR, 0);
-
-loop = LABEL();
-while (*cc != OP_KETRPOS)
- {
- backtrack->top = NULL;
- backtrack->topbacktracks = NULL;
- cc += GET(cc, 1);
-
- compile_matchingpath(common, ccbegin, cc, backtrack);
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- return NULL;
-
- if (framesize < 0)
- {
- if (framesize == no_frame)
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
-
- if (offset != 0)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), cbraprivptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), cbraprivptr, STR_PTR, 0);
- if (common->capture_last_ptr != 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr, SLJIT_IMM, offset >> 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset), TMP1, 0);
- }
- else
- {
- if (opcode == OP_SBRAPOS)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- }
-
- /* Even if the match is empty, we need to reset the control head. */
- if (needs_control_head)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(stack));
-
- if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)
- add_jump(compiler, &emptymatch, CMP(SLJIT_EQUAL, TMP1, 0, STR_PTR, 0));
-
- if (!zero)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize - 1), SLJIT_IMM, 0);
- }
- else
- {
- if (offset != 0)
- {
- OP2(SLJIT_ADD, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_IMM, stacksize * sizeof(sljit_sw));
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), cbraprivptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), cbraprivptr, STR_PTR, 0);
- if (common->capture_last_ptr != 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr, SLJIT_IMM, offset >> 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset), TMP1, 0);
- }
- else
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- OP2(SLJIT_ADD, STACK_TOP, 0, TMP2, 0, SLJIT_IMM, stacksize * sizeof(sljit_sw));
- if (opcode == OP_SBRAPOS)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw));
- OP1(SLJIT_MOV, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw), STR_PTR, 0);
- }
-
- /* Even if the match is empty, we need to reset the control head. */
- if (needs_control_head)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_MEM1(STACK_TOP), STACK(stack));
-
- if (opcode == OP_SBRAPOS || opcode == OP_SCBRAPOS)
- add_jump(compiler, &emptymatch, CMP(SLJIT_EQUAL, TMP1, 0, STR_PTR, 0));
-
- if (!zero)
- {
- if (framesize < 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize - 1), SLJIT_IMM, 0);
- else
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- }
- }
-
- JUMPTO(SLJIT_JUMP, loop);
- flush_stubs(common);
-
- compile_backtrackingpath(common, backtrack->top);
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- return NULL;
- set_jumps(backtrack->topbacktracks, LABEL());
-
- if (framesize < 0)
- {
- if (offset != 0)
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), cbraprivptr);
- else
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- }
- else
- {
- if (offset != 0)
- {
- /* Last alternative. */
- if (*cc == OP_KETRPOS)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), cbraprivptr);
- }
- else
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP2), (framesize + 1) * sizeof(sljit_sw));
- }
- }
-
- if (*cc == OP_KETRPOS)
- break;
- ccbegin = cc + 1 + LINK_SIZE;
- }
-
-/* We don't have to restore the control head in case of a failed match. */
-
-backtrack->topbacktracks = NULL;
-if (!zero)
- {
- if (framesize < 0)
- add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), STACK(stacksize - 1), SLJIT_IMM, 0));
- else /* TMP2 is set to [private_data_ptr] above. */
- add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_NOT_EQUAL, SLJIT_MEM1(TMP2), (stacksize - 1) * sizeof(sljit_sw), SLJIT_IMM, 0));
- }
-
-/* None of them matched. */
-set_jumps(emptymatch, LABEL());
-count_match(common);
-return cc + 1 + LINK_SIZE;
-}
-
-static SLJIT_INLINE pcre_uchar *get_iterator_parameters(compiler_common *common, pcre_uchar *cc, pcre_uchar *opcode, pcre_uchar *type, int *max, int *min, pcre_uchar **end)
-{
-int class_len;
-
-*opcode = *cc;
-if (*opcode >= OP_STAR && *opcode <= OP_POSUPTO)
- {
- cc++;
- *type = OP_CHAR;
- }
-else if (*opcode >= OP_STARI && *opcode <= OP_POSUPTOI)
- {
- cc++;
- *type = OP_CHARI;
- *opcode -= OP_STARI - OP_STAR;
- }
-else if (*opcode >= OP_NOTSTAR && *opcode <= OP_NOTPOSUPTO)
- {
- cc++;
- *type = OP_NOT;
- *opcode -= OP_NOTSTAR - OP_STAR;
- }
-else if (*opcode >= OP_NOTSTARI && *opcode <= OP_NOTPOSUPTOI)
- {
- cc++;
- *type = OP_NOTI;
- *opcode -= OP_NOTSTARI - OP_STAR;
- }
-else if (*opcode >= OP_TYPESTAR && *opcode <= OP_TYPEPOSUPTO)
- {
- cc++;
- *opcode -= OP_TYPESTAR - OP_STAR;
- *type = 0;
- }
-else
- {
- SLJIT_ASSERT(*opcode == OP_CLASS || *opcode == OP_NCLASS || *opcode == OP_XCLASS);
- *type = *opcode;
- cc++;
- class_len = (*type < OP_XCLASS) ? (int)(1 + (32 / sizeof(pcre_uchar))) : GET(cc, 0);
- *opcode = cc[class_len - 1];
- if (*opcode >= OP_CRSTAR && *opcode <= OP_CRMINQUERY)
- {
- *opcode -= OP_CRSTAR - OP_STAR;
- if (end != NULL)
- *end = cc + class_len;
- }
- else if (*opcode >= OP_CRPOSSTAR && *opcode <= OP_CRPOSQUERY)
- {
- *opcode -= OP_CRPOSSTAR - OP_POSSTAR;
- if (end != NULL)
- *end = cc + class_len;
- }
- else
- {
- SLJIT_ASSERT(*opcode == OP_CRRANGE || *opcode == OP_CRMINRANGE || *opcode == OP_CRPOSRANGE);
- *max = GET2(cc, (class_len + IMM2_SIZE));
- *min = GET2(cc, class_len);
-
- if (*min == 0)
- {
- SLJIT_ASSERT(*max != 0);
- *opcode = (*opcode == OP_CRRANGE) ? OP_UPTO : (*opcode == OP_CRMINRANGE ? OP_MINUPTO : OP_POSUPTO);
- }
- if (*max == *min)
- *opcode = OP_EXACT;
-
- if (end != NULL)
- *end = cc + class_len + 2 * IMM2_SIZE;
- }
- return cc;
- }
-
-if (*opcode == OP_UPTO || *opcode == OP_MINUPTO || *opcode == OP_EXACT || *opcode == OP_POSUPTO)
- {
- *max = GET2(cc, 0);
- cc += IMM2_SIZE;
- }
-
-if (*type == 0)
- {
- *type = *cc;
- if (end != NULL)
- *end = next_opcode(common, cc);
- cc++;
- return cc;
- }
-
-if (end != NULL)
- {
- *end = cc + 1;
-#ifdef SUPPORT_UTF
- if (common->utf && HAS_EXTRALEN(*cc)) *end += GET_EXTRALEN(*cc);
-#endif
- }
-return cc;
-}
-
-static pcre_uchar *compile_iterator_matchingpath(compiler_common *common, pcre_uchar *cc, backtrack_common *parent)
-{
-DEFINE_COMPILER;
-backtrack_common *backtrack;
-pcre_uchar opcode;
-pcre_uchar type;
-int max = -1, min = -1;
-pcre_uchar *end;
-jump_list *nomatch = NULL;
-struct sljit_jump *jump = NULL;
-struct sljit_label *label;
-int private_data_ptr = PRIVATE_DATA(cc);
-int base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_SP);
-int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;
-int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_sw);
-int tmp_base, tmp_offset;
-
-PUSH_BACKTRACK(sizeof(iterator_backtrack), cc, NULL);
-
-cc = get_iterator_parameters(common, cc, &opcode, &type, &max, &min, &end);
-
-switch(type)
- {
- case OP_NOT_DIGIT:
- case OP_DIGIT:
- case OP_NOT_WHITESPACE:
- case OP_WHITESPACE:
- case OP_NOT_WORDCHAR:
- case OP_WORDCHAR:
- case OP_ANY:
- case OP_ALLANY:
- case OP_ANYBYTE:
- case OP_ANYNL:
- case OP_NOT_HSPACE:
- case OP_HSPACE:
- case OP_NOT_VSPACE:
- case OP_VSPACE:
- case OP_CHAR:
- case OP_CHARI:
- case OP_NOT:
- case OP_NOTI:
- case OP_CLASS:
- case OP_NCLASS:
- tmp_base = TMP3;
- tmp_offset = 0;
- break;
-
- default:
- SLJIT_ASSERT_STOP();
- /* Fall through. */
-
- case OP_EXTUNI:
- case OP_XCLASS:
- case OP_NOTPROP:
- case OP_PROP:
- tmp_base = SLJIT_MEM1(SLJIT_SP);
- tmp_offset = POSSESSIVE0;
- break;
- }
-
-switch(opcode)
- {
- case OP_STAR:
- case OP_PLUS:
- case OP_UPTO:
- case OP_CRRANGE:
- if (type == OP_ANYNL || type == OP_EXTUNI)
- {
- SLJIT_ASSERT(private_data_ptr == 0);
- if (opcode == OP_STAR || opcode == OP_UPTO)
- {
- allocate_stack(common, 2);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, 0);
- }
- else
- {
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- }
-
- if (opcode == OP_UPTO || opcode == OP_CRRANGE)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0, SLJIT_IMM, 0);
-
- label = LABEL();
- compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
- if (opcode == OP_UPTO || opcode == OP_CRRANGE)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0);
- OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
- if (opcode == OP_CRRANGE && min > 0)
- CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, min, label);
- if (opcode == OP_UPTO || (opcode == OP_CRRANGE && max > 0))
- jump = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, max);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE0, TMP1, 0);
- }
-
- /* We cannot use TMP3 because of this allocate_stack. */
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- JUMPTO(SLJIT_JUMP, label);
- if (jump != NULL)
- JUMPHERE(jump);
- }
- else
- {
- if (opcode == OP_PLUS)
- compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
- if (private_data_ptr == 0)
- allocate_stack(common, 2);
- OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
- if (opcode <= OP_PLUS)
- OP1(SLJIT_MOV, base, offset1, STR_PTR, 0);
- else
- OP1(SLJIT_MOV, base, offset1, SLJIT_IMM, 1);
- label = LABEL();
- compile_char1_matchingpath(common, type, cc, &nomatch);
- OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
- if (opcode <= OP_PLUS)
- JUMPTO(SLJIT_JUMP, label);
- else if (opcode == OP_CRRANGE && max == 0)
- {
- OP2(SLJIT_ADD, base, offset1, base, offset1, SLJIT_IMM, 1);
- JUMPTO(SLJIT_JUMP, label);
- }
- else
- {
- OP1(SLJIT_MOV, TMP1, 0, base, offset1);
- OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
- OP1(SLJIT_MOV, base, offset1, TMP1, 0);
- CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, max + 1, label);
- }
- set_jumps(nomatch, LABEL());
- if (opcode == OP_CRRANGE)
- add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_LESS, base, offset1, SLJIT_IMM, min + 1));
- OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
- }
- BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();
- break;
-
- case OP_MINSTAR:
- case OP_MINPLUS:
- if (opcode == OP_MINPLUS)
- compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
- if (private_data_ptr == 0)
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
- BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();
- break;
-
- case OP_MINUPTO:
- case OP_CRMINRANGE:
- if (private_data_ptr == 0)
- allocate_stack(common, 2);
- OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
- OP1(SLJIT_MOV, base, offset1, SLJIT_IMM, 1);
- if (opcode == OP_CRMINRANGE)
- add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_JUMP));
- BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();
- break;
-
- case OP_QUERY:
- case OP_MINQUERY:
- if (private_data_ptr == 0)
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
- if (opcode == OP_QUERY)
- compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
- BACKTRACK_AS(iterator_backtrack)->matchingpath = LABEL();
- break;
-
- case OP_EXACT:
- OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, max);
- label = LABEL();
- compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
- OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);
- JUMPTO(SLJIT_NOT_ZERO, label);
- break;
-
- case OP_POSSTAR:
- case OP_POSPLUS:
- case OP_POSUPTO:
- if (opcode == OP_POSPLUS)
- compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
- if (opcode == OP_POSUPTO)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_IMM, max);
- OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
- label = LABEL();
- compile_char1_matchingpath(common, type, cc, &nomatch);
- OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
- if (opcode != OP_POSUPTO)
- JUMPTO(SLJIT_JUMP, label);
- else
- {
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_IMM, 1);
- JUMPTO(SLJIT_NOT_ZERO, label);
- }
- set_jumps(nomatch, LABEL());
- OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);
- break;
-
- case OP_POSQUERY:
- OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
- compile_char1_matchingpath(common, type, cc, &nomatch);
- OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
- set_jumps(nomatch, LABEL());
- OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);
- break;
-
- case OP_CRPOSRANGE:
- /* Combination of OP_EXACT and OP_POSSTAR or OP_POSUPTO */
- OP1(SLJIT_MOV, tmp_base, tmp_offset, SLJIT_IMM, min);
- label = LABEL();
- compile_char1_matchingpath(common, type, cc, &backtrack->topbacktracks);
- OP2(SLJIT_SUB | SLJIT_SET_E, tmp_base, tmp_offset, tmp_base, tmp_offset, SLJIT_IMM, 1);
- JUMPTO(SLJIT_NOT_ZERO, label);
-
- if (max != 0)
- {
- SLJIT_ASSERT(max - min > 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_IMM, max - min);
- }
- OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
- label = LABEL();
- compile_char1_matchingpath(common, type, cc, &nomatch);
- OP1(SLJIT_MOV, tmp_base, tmp_offset, STR_PTR, 0);
- if (max == 0)
- JUMPTO(SLJIT_JUMP, label);
- else
- {
- OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_MEM1(SLJIT_SP), POSSESSIVE1, SLJIT_IMM, 1);
- JUMPTO(SLJIT_NOT_ZERO, label);
- }
- set_jumps(nomatch, LABEL());
- OP1(SLJIT_MOV, STR_PTR, 0, tmp_base, tmp_offset);
- break;
-
- default:
- SLJIT_ASSERT_STOP();
- break;
- }
-
-count_match(common);
-return end;
-}
-
-static SLJIT_INLINE pcre_uchar *compile_fail_accept_matchingpath(compiler_common *common, pcre_uchar *cc, backtrack_common *parent)
-{
-DEFINE_COMPILER;
-backtrack_common *backtrack;
-
-PUSH_BACKTRACK(sizeof(backtrack_common), cc, NULL);
-
-if (*cc == OP_FAIL)
- {
- add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_JUMP));
- return cc + 1;
- }
-
-if (*cc == OP_ASSERT_ACCEPT || common->currententry != NULL || !common->might_be_empty)
- {
- /* No need to check notempty conditions. */
- if (common->accept_label == NULL)
- add_jump(compiler, &common->accept, JUMP(SLJIT_JUMP));
- else
- JUMPTO(SLJIT_JUMP, common->accept_label);
- return cc + 1;
- }
-
-if (common->accept_label == NULL)
- add_jump(compiler, &common->accept, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0)));
-else
- CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0), common->accept_label);
-OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
-OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty));
-add_jump(compiler, &backtrack->topbacktracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
-OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart));
-if (common->accept_label == NULL)
- add_jump(compiler, &common->accept, CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
-else
- CMPTO(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0, common->accept_label);
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
-if (common->accept_label == NULL)
- add_jump(compiler, &common->accept, CMP(SLJIT_NOT_EQUAL, TMP2, 0, STR_PTR, 0));
-else
- CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, STR_PTR, 0, common->accept_label);
-add_jump(compiler, &backtrack->topbacktracks, JUMP(SLJIT_JUMP));
-return cc + 1;
-}
-
-static SLJIT_INLINE pcre_uchar *compile_close_matchingpath(compiler_common *common, pcre_uchar *cc)
-{
-DEFINE_COMPILER;
-int offset = GET2(cc, 1);
-BOOL optimized_cbracket = common->optimized_cbracket[offset] != 0;
-
-/* Data will be discarded anyway... */
-if (common->currententry != NULL)
- return cc + 1 + IMM2_SIZE;
-
-if (!optimized_cbracket)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR_PRIV(offset));
-offset <<= 1;
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), STR_PTR, 0);
-if (!optimized_cbracket)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset), TMP1, 0);
-return cc + 1 + IMM2_SIZE;
-}
-
-static SLJIT_INLINE pcre_uchar *compile_control_verb_matchingpath(compiler_common *common, pcre_uchar *cc, backtrack_common *parent)
-{
-DEFINE_COMPILER;
-backtrack_common *backtrack;
-pcre_uchar opcode = *cc;
-pcre_uchar *ccend = cc + 1;
-
-if (opcode == OP_PRUNE_ARG || opcode == OP_SKIP_ARG || opcode == OP_THEN_ARG)
- ccend += 2 + cc[1];
-
-PUSH_BACKTRACK(sizeof(backtrack_common), cc, NULL);
-
-if (opcode == OP_SKIP)
- {
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- return ccend;
- }
-
-if (opcode == OP_PRUNE_ARG || opcode == OP_THEN_ARG)
- {
- OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->mark_ptr, TMP2, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);
- }
-
-return ccend;
-}
-
-static pcre_uchar then_trap_opcode[1] = { OP_THEN_TRAP };
-
-static SLJIT_INLINE void compile_then_trap_matchingpath(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, backtrack_common *parent)
-{
-DEFINE_COMPILER;
-backtrack_common *backtrack;
-BOOL needs_control_head;
-int size;
-
-PUSH_BACKTRACK_NOVALUE(sizeof(then_trap_backtrack), cc);
-common->then_trap = BACKTRACK_AS(then_trap_backtrack);
-BACKTRACK_AS(then_trap_backtrack)->common.cc = then_trap_opcode;
-BACKTRACK_AS(then_trap_backtrack)->start = (sljit_sw)(cc - common->start);
-BACKTRACK_AS(then_trap_backtrack)->framesize = get_framesize(common, cc, ccend, FALSE, &needs_control_head);
-
-size = BACKTRACK_AS(then_trap_backtrack)->framesize;
-size = 3 + (size < 0 ? 0 : size);
-
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);
-allocate_stack(common, size);
-if (size > 3)
- OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, STACK_TOP, 0, SLJIT_IMM, (size - 3) * sizeof(sljit_sw));
-else
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, STACK_TOP, 0);
-OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(size - 1), SLJIT_IMM, BACKTRACK_AS(then_trap_backtrack)->start);
-OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(size - 2), SLJIT_IMM, type_then_trap);
-OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(size - 3), TMP2, 0);
-
-size = BACKTRACK_AS(then_trap_backtrack)->framesize;
-if (size >= 0)
- init_frame(common, cc, ccend, size - 1, 0, FALSE);
-}
-
-static void compile_matchingpath(compiler_common *common, pcre_uchar *cc, pcre_uchar *ccend, backtrack_common *parent)
-{
-DEFINE_COMPILER;
-backtrack_common *backtrack;
-BOOL has_then_trap = FALSE;
-then_trap_backtrack *save_then_trap = NULL;
-
-SLJIT_ASSERT(*ccend == OP_END || (*ccend >= OP_ALT && *ccend <= OP_KETRPOS));
-
-if (common->has_then && common->then_offsets[cc - common->start] != 0)
- {
- SLJIT_ASSERT(*ccend != OP_END && common->control_head_ptr != 0);
- has_then_trap = TRUE;
- save_then_trap = common->then_trap;
- /* Tail item on backtrack. */
- compile_then_trap_matchingpath(common, cc, ccend, parent);
- }
-
-while (cc < ccend)
- {
- switch(*cc)
- {
- case OP_SOD:
- case OP_SOM:
- case OP_NOT_WORD_BOUNDARY:
- case OP_WORD_BOUNDARY:
- case OP_NOT_DIGIT:
- case OP_DIGIT:
- case OP_NOT_WHITESPACE:
- case OP_WHITESPACE:
- case OP_NOT_WORDCHAR:
- case OP_WORDCHAR:
- case OP_ANY:
- case OP_ALLANY:
- case OP_ANYBYTE:
- case OP_NOTPROP:
- case OP_PROP:
- case OP_ANYNL:
- case OP_NOT_HSPACE:
- case OP_HSPACE:
- case OP_NOT_VSPACE:
- case OP_VSPACE:
- case OP_EXTUNI:
- case OP_EODN:
- case OP_EOD:
- case OP_CIRC:
- case OP_CIRCM:
- case OP_DOLL:
- case OP_DOLLM:
- case OP_NOT:
- case OP_NOTI:
- case OP_REVERSE:
- cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);
- break;
-
- case OP_SET_SOM:
- PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0));
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(0), STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP2, 0);
- cc++;
- break;
-
- case OP_CHAR:
- case OP_CHARI:
- if (common->mode == JIT_COMPILE)
- cc = compile_charn_matchingpath(common, cc, ccend, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);
- else
- cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);
- break;
-
- case OP_STAR:
- case OP_MINSTAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_UPTO:
- case OP_MINUPTO:
- case OP_EXACT:
- case OP_POSSTAR:
- case OP_POSPLUS:
- case OP_POSQUERY:
- case OP_POSUPTO:
- case OP_STARI:
- case OP_MINSTARI:
- case OP_PLUSI:
- case OP_MINPLUSI:
- case OP_QUERYI:
- case OP_MINQUERYI:
- case OP_UPTOI:
- case OP_MINUPTOI:
- case OP_EXACTI:
- case OP_POSSTARI:
- case OP_POSPLUSI:
- case OP_POSQUERYI:
- case OP_POSUPTOI:
- case OP_NOTSTAR:
- case OP_NOTMINSTAR:
- case OP_NOTPLUS:
- case OP_NOTMINPLUS:
- case OP_NOTQUERY:
- case OP_NOTMINQUERY:
- case OP_NOTUPTO:
- case OP_NOTMINUPTO:
- case OP_NOTEXACT:
- case OP_NOTPOSSTAR:
- case OP_NOTPOSPLUS:
- case OP_NOTPOSQUERY:
- case OP_NOTPOSUPTO:
- case OP_NOTSTARI:
- case OP_NOTMINSTARI:
- case OP_NOTPLUSI:
- case OP_NOTMINPLUSI:
- case OP_NOTQUERYI:
- case OP_NOTMINQUERYI:
- case OP_NOTUPTOI:
- case OP_NOTMINUPTOI:
- case OP_NOTEXACTI:
- case OP_NOTPOSSTARI:
- case OP_NOTPOSPLUSI:
- case OP_NOTPOSQUERYI:
- case OP_NOTPOSUPTOI:
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- case OP_TYPEEXACT:
- case OP_TYPEPOSSTAR:
- case OP_TYPEPOSPLUS:
- case OP_TYPEPOSQUERY:
- case OP_TYPEPOSUPTO:
- cc = compile_iterator_matchingpath(common, cc, parent);
- break;
-
- case OP_CLASS:
- case OP_NCLASS:
- if (cc[1 + (32 / sizeof(pcre_uchar))] >= OP_CRSTAR && cc[1 + (32 / sizeof(pcre_uchar))] <= OP_CRPOSRANGE)
- cc = compile_iterator_matchingpath(common, cc, parent);
- else
- cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);
- break;
-
-#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- case OP_XCLASS:
- if (*(cc + GET(cc, 1)) >= OP_CRSTAR && *(cc + GET(cc, 1)) <= OP_CRPOSRANGE)
- cc = compile_iterator_matchingpath(common, cc, parent);
- else
- cc = compile_char1_matchingpath(common, *cc, cc + 1, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);
- break;
-#endif
-
- case OP_REF:
- case OP_REFI:
- if (cc[1 + IMM2_SIZE] >= OP_CRSTAR && cc[1 + IMM2_SIZE] <= OP_CRPOSRANGE)
- cc = compile_ref_iterator_matchingpath(common, cc, parent);
- else
- {
- compile_ref_matchingpath(common, cc, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE, FALSE);
- cc += 1 + IMM2_SIZE;
- }
- break;
-
- case OP_DNREF:
- case OP_DNREFI:
- if (cc[1 + 2 * IMM2_SIZE] >= OP_CRSTAR && cc[1 + 2 * IMM2_SIZE] <= OP_CRPOSRANGE)
- cc = compile_ref_iterator_matchingpath(common, cc, parent);
- else
- {
- compile_dnref_search(common, cc, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks);
- compile_ref_matchingpath(common, cc, parent->top != NULL ? &parent->top->nextbacktracks : &parent->topbacktracks, TRUE, FALSE);
- cc += 1 + 2 * IMM2_SIZE;
- }
- break;
-
- case OP_RECURSE:
- cc = compile_recurse_matchingpath(common, cc, parent);
- break;
-
- case OP_CALLOUT:
- cc = compile_callout_matchingpath(common, cc, parent);
- break;
-
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- PUSH_BACKTRACK_NOVALUE(sizeof(assert_backtrack), cc);
- cc = compile_assert_matchingpath(common, cc, BACKTRACK_AS(assert_backtrack), FALSE);
- break;
-
- case OP_BRAMINZERO:
- PUSH_BACKTRACK_NOVALUE(sizeof(braminzero_backtrack), cc);
- cc = bracketend(cc + 1);
- if (*(cc - 1 - LINK_SIZE) != OP_KETRMIN)
- {
- allocate_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
- }
- else
- {
- allocate_stack(common, 2);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), STR_PTR, 0);
- }
- BACKTRACK_AS(braminzero_backtrack)->matchingpath = LABEL();
- count_match(common);
- break;
-
- case OP_ONCE:
- case OP_ONCE_NC:
- case OP_BRA:
- case OP_CBRA:
- case OP_COND:
- case OP_SBRA:
- case OP_SCBRA:
- case OP_SCOND:
- cc = compile_bracket_matchingpath(common, cc, parent);
- break;
-
- case OP_BRAZERO:
- if (cc[1] > OP_ASSERTBACK_NOT)
- cc = compile_bracket_matchingpath(common, cc, parent);
- else
- {
- PUSH_BACKTRACK_NOVALUE(sizeof(assert_backtrack), cc);
- cc = compile_assert_matchingpath(common, cc, BACKTRACK_AS(assert_backtrack), FALSE);
- }
- break;
-
- case OP_BRAPOS:
- case OP_CBRAPOS:
- case OP_SBRAPOS:
- case OP_SCBRAPOS:
- case OP_BRAPOSZERO:
- cc = compile_bracketpos_matchingpath(common, cc, parent);
- break;
-
- case OP_MARK:
- PUSH_BACKTRACK_NOVALUE(sizeof(backtrack_common), cc);
- SLJIT_ASSERT(common->mark_ptr != 0);
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), common->mark_ptr);
- allocate_stack(common, common->has_skip_arg ? 5 : 1);
- OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(common->has_skip_arg ? 4 : 0), TMP2, 0);
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, (sljit_sw)(cc + 2));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->mark_ptr, TMP2, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, mark_ptr), TMP2, 0);
- if (common->has_skip_arg)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, STACK_TOP, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(1), SLJIT_IMM, type_mark);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(2), SLJIT_IMM, (sljit_sw)(cc + 2));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(3), STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), TMP1, 0);
- }
- cc += 1 + 2 + cc[1];
- break;
-
- case OP_PRUNE:
- case OP_PRUNE_ARG:
- case OP_SKIP:
- case OP_SKIP_ARG:
- case OP_THEN:
- case OP_THEN_ARG:
- case OP_COMMIT:
- cc = compile_control_verb_matchingpath(common, cc, parent);
- break;
-
- case OP_FAIL:
- case OP_ACCEPT:
- case OP_ASSERT_ACCEPT:
- cc = compile_fail_accept_matchingpath(common, cc, parent);
- break;
-
- case OP_CLOSE:
- cc = compile_close_matchingpath(common, cc);
- break;
-
- case OP_SKIPZERO:
- cc = bracketend(cc + 1);
- break;
-
- default:
- SLJIT_ASSERT_STOP();
- return;
- }
- if (cc == NULL)
- return;
- }
-
-if (has_then_trap)
- {
- /* Head item on backtrack. */
- PUSH_BACKTRACK_NOVALUE(sizeof(then_trap_backtrack), cc);
- BACKTRACK_AS(then_trap_backtrack)->common.cc = then_trap_opcode;
- BACKTRACK_AS(then_trap_backtrack)->then_trap = common->then_trap;
- common->then_trap = save_then_trap;
- }
-SLJIT_ASSERT(cc == ccend);
-}
-
-#undef PUSH_BACKTRACK
-#undef PUSH_BACKTRACK_NOVALUE
-#undef BACKTRACK_AS
-
-#define COMPILE_BACKTRACKINGPATH(current) \
- do \
- { \
- compile_backtrackingpath(common, (current)); \
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler))) \
- return; \
- } \
- while (0)
-
-#define CURRENT_AS(type) ((type *)current)
-
-static void compile_iterator_backtrackingpath(compiler_common *common, struct backtrack_common *current)
-{
-DEFINE_COMPILER;
-pcre_uchar *cc = current->cc;
-pcre_uchar opcode;
-pcre_uchar type;
-int max = -1, min = -1;
-struct sljit_label *label = NULL;
-struct sljit_jump *jump = NULL;
-jump_list *jumplist = NULL;
-int private_data_ptr = PRIVATE_DATA(cc);
-int base = (private_data_ptr == 0) ? SLJIT_MEM1(STACK_TOP) : SLJIT_MEM1(SLJIT_SP);
-int offset0 = (private_data_ptr == 0) ? STACK(0) : private_data_ptr;
-int offset1 = (private_data_ptr == 0) ? STACK(1) : private_data_ptr + (int)sizeof(sljit_sw);
-
-cc = get_iterator_parameters(common, cc, &opcode, &type, &max, &min, NULL);
-
-switch(opcode)
- {
- case OP_STAR:
- case OP_PLUS:
- case OP_UPTO:
- case OP_CRRANGE:
- if (type == OP_ANYNL || type == OP_EXTUNI)
- {
- SLJIT_ASSERT(private_data_ptr == 0);
- set_jumps(current->topbacktracks, LABEL());
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
- CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(iterator_backtrack)->matchingpath);
- }
- else
- {
- if (opcode == OP_UPTO)
- min = 0;
- if (opcode <= OP_PLUS)
- {
- OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
- jump = CMP(SLJIT_LESS_EQUAL, STR_PTR, 0, base, offset1);
- }
- else
- {
- OP1(SLJIT_MOV, TMP1, 0, base, offset1);
- OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
- jump = CMP(SLJIT_LESS_EQUAL, TMP1, 0, SLJIT_IMM, min + 1);
- OP2(SLJIT_SUB, base, offset1, TMP1, 0, SLJIT_IMM, 1);
- }
- skip_char_back(common);
- OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
- JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);
- if (opcode == OP_CRRANGE)
- set_jumps(current->topbacktracks, LABEL());
- JUMPHERE(jump);
- if (private_data_ptr == 0)
- free_stack(common, 2);
- if (opcode == OP_PLUS)
- set_jumps(current->topbacktracks, LABEL());
- }
- break;
-
- case OP_MINSTAR:
- case OP_MINPLUS:
- OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
- compile_char1_matchingpath(common, type, cc, &jumplist);
- OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
- JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);
- set_jumps(jumplist, LABEL());
- if (private_data_ptr == 0)
- free_stack(common, 1);
- if (opcode == OP_MINPLUS)
- set_jumps(current->topbacktracks, LABEL());
- break;
-
- case OP_MINUPTO:
- case OP_CRMINRANGE:
- if (opcode == OP_CRMINRANGE)
- {
- label = LABEL();
- set_jumps(current->topbacktracks, label);
- }
- OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
- compile_char1_matchingpath(common, type, cc, &jumplist);
-
- OP1(SLJIT_MOV, TMP1, 0, base, offset1);
- OP1(SLJIT_MOV, base, offset0, STR_PTR, 0);
- OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
- OP1(SLJIT_MOV, base, offset1, TMP1, 0);
-
- if (opcode == OP_CRMINRANGE)
- CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, min + 1, label);
-
- if (opcode == OP_CRMINRANGE && max == 0)
- JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);
- else
- CMPTO(SLJIT_LESS, TMP1, 0, SLJIT_IMM, max + 2, CURRENT_AS(iterator_backtrack)->matchingpath);
-
- set_jumps(jumplist, LABEL());
- if (private_data_ptr == 0)
- free_stack(common, 2);
- break;
-
- case OP_QUERY:
- OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
- OP1(SLJIT_MOV, base, offset0, SLJIT_IMM, 0);
- CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(iterator_backtrack)->matchingpath);
- jump = JUMP(SLJIT_JUMP);
- set_jumps(current->topbacktracks, LABEL());
- OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
- OP1(SLJIT_MOV, base, offset0, SLJIT_IMM, 0);
- JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);
- JUMPHERE(jump);
- if (private_data_ptr == 0)
- free_stack(common, 1);
- break;
-
- case OP_MINQUERY:
- OP1(SLJIT_MOV, STR_PTR, 0, base, offset0);
- OP1(SLJIT_MOV, base, offset0, SLJIT_IMM, 0);
- jump = CMP(SLJIT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0);
- compile_char1_matchingpath(common, type, cc, &jumplist);
- JUMPTO(SLJIT_JUMP, CURRENT_AS(iterator_backtrack)->matchingpath);
- set_jumps(jumplist, LABEL());
- JUMPHERE(jump);
- if (private_data_ptr == 0)
- free_stack(common, 1);
- break;
-
- case OP_EXACT:
- case OP_POSPLUS:
- case OP_CRPOSRANGE:
- set_jumps(current->topbacktracks, LABEL());
- break;
-
- case OP_POSSTAR:
- case OP_POSQUERY:
- case OP_POSUPTO:
- break;
-
- default:
- SLJIT_ASSERT_STOP();
- break;
- }
-}
-
-static SLJIT_INLINE void compile_ref_iterator_backtrackingpath(compiler_common *common, struct backtrack_common *current)
-{
-DEFINE_COMPILER;
-pcre_uchar *cc = current->cc;
-BOOL ref = (*cc == OP_REF || *cc == OP_REFI);
-pcre_uchar type;
-
-type = cc[ref ? 1 + IMM2_SIZE : 1 + 2 * IMM2_SIZE];
-
-if ((type & 0x1) == 0)
- {
- /* Maximize case. */
- set_jumps(current->topbacktracks, LABEL());
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
- CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(iterator_backtrack)->matchingpath);
- return;
- }
-
-OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
-CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(iterator_backtrack)->matchingpath);
-set_jumps(current->topbacktracks, LABEL());
-free_stack(common, ref ? 2 : 3);
-}
-
-static SLJIT_INLINE void compile_recurse_backtrackingpath(compiler_common *common, struct backtrack_common *current)
-{
-DEFINE_COMPILER;
-
-if (CURRENT_AS(recurse_backtrack)->inlined_pattern)
- compile_backtrackingpath(common, current->top);
-set_jumps(current->topbacktracks, LABEL());
-if (CURRENT_AS(recurse_backtrack)->inlined_pattern)
- return;
-
-if (common->has_set_som && common->mark_ptr != 0)
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
- free_stack(common, 2);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(0), TMP2, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->mark_ptr, TMP1, 0);
- }
-else if (common->has_set_som || common->mark_ptr != 0)
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->has_set_som ? (int)(OVECTOR(0)) : common->mark_ptr, TMP2, 0);
- }
-}
-
-static void compile_assert_backtrackingpath(compiler_common *common, struct backtrack_common *current)
-{
-DEFINE_COMPILER;
-pcre_uchar *cc = current->cc;
-pcre_uchar bra = OP_BRA;
-struct sljit_jump *brajump = NULL;
-
-SLJIT_ASSERT(*cc != OP_BRAMINZERO);
-if (*cc == OP_BRAZERO)
- {
- bra = *cc;
- cc++;
- }
-
-if (bra == OP_BRAZERO)
- {
- SLJIT_ASSERT(current->topbacktracks == NULL);
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- }
-
-if (CURRENT_AS(assert_backtrack)->framesize < 0)
- {
- set_jumps(current->topbacktracks, LABEL());
-
- if (bra == OP_BRAZERO)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(assert_backtrack)->matchingpath);
- free_stack(common, 1);
- }
- return;
- }
-
-if (bra == OP_BRAZERO)
- {
- if (*cc == OP_ASSERT_NOT || *cc == OP_ASSERTBACK_NOT)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(assert_backtrack)->matchingpath);
- free_stack(common, 1);
- return;
- }
- free_stack(common, 1);
- brajump = CMP(SLJIT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0);
- }
-
-if (*cc == OP_ASSERT || *cc == OP_ASSERTBACK)
- {
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), CURRENT_AS(assert_backtrack)->private_data_ptr);
- add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), CURRENT_AS(assert_backtrack)->private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(assert_backtrack)->framesize * sizeof(sljit_sw));
-
- set_jumps(current->topbacktracks, LABEL());
- }
-else
- set_jumps(current->topbacktracks, LABEL());
-
-if (bra == OP_BRAZERO)
- {
- /* We know there is enough place on the stack. */
- OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, sizeof(sljit_sw));
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), SLJIT_IMM, 0);
- JUMPTO(SLJIT_JUMP, CURRENT_AS(assert_backtrack)->matchingpath);
- JUMPHERE(brajump);
- }
-}
-
-static void compile_bracket_backtrackingpath(compiler_common *common, struct backtrack_common *current)
-{
-DEFINE_COMPILER;
-int opcode, stacksize, alt_count, alt_max;
-int offset = 0;
-int private_data_ptr = CURRENT_AS(bracket_backtrack)->private_data_ptr;
-int repeat_ptr = 0, repeat_type = 0, repeat_count = 0;
-pcre_uchar *cc = current->cc;
-pcre_uchar *ccbegin;
-pcre_uchar *ccprev;
-pcre_uchar bra = OP_BRA;
-pcre_uchar ket;
-assert_backtrack *assert;
-sljit_uw *next_update_addr = NULL;
-BOOL has_alternatives;
-BOOL needs_control_head = FALSE;
-struct sljit_jump *brazero = NULL;
-struct sljit_jump *alt1 = NULL;
-struct sljit_jump *alt2 = NULL;
-struct sljit_jump *once = NULL;
-struct sljit_jump *cond = NULL;
-struct sljit_label *rmin_label = NULL;
-struct sljit_label *exact_label = NULL;
-
-if (*cc == OP_BRAZERO || *cc == OP_BRAMINZERO)
- {
- bra = *cc;
- cc++;
- }
-
-opcode = *cc;
-ccbegin = bracketend(cc) - 1 - LINK_SIZE;
-ket = *ccbegin;
-if (ket == OP_KET && PRIVATE_DATA(ccbegin) != 0)
- {
- repeat_ptr = PRIVATE_DATA(ccbegin);
- repeat_type = PRIVATE_DATA(ccbegin + 2);
- repeat_count = PRIVATE_DATA(ccbegin + 3);
- SLJIT_ASSERT(repeat_type != 0 && repeat_count != 0);
- if (repeat_type == OP_UPTO)
- ket = OP_KETRMAX;
- if (repeat_type == OP_MINUPTO)
- ket = OP_KETRMIN;
- }
-ccbegin = cc;
-cc += GET(cc, 1);
-has_alternatives = *cc == OP_ALT;
-if (SLJIT_UNLIKELY(opcode == OP_COND) || SLJIT_UNLIKELY(opcode == OP_SCOND))
- has_alternatives = (ccbegin[1 + LINK_SIZE] >= OP_ASSERT && ccbegin[1 + LINK_SIZE] <= OP_ASSERTBACK_NOT) || CURRENT_AS(bracket_backtrack)->u.condfailed != NULL;
-if (opcode == OP_CBRA || opcode == OP_SCBRA)
- offset = (GET2(ccbegin, 1 + LINK_SIZE)) << 1;
-if (SLJIT_UNLIKELY(opcode == OP_COND) && (*cc == OP_KETRMAX || *cc == OP_KETRMIN))
- opcode = OP_SCOND;
-if (SLJIT_UNLIKELY(opcode == OP_ONCE_NC))
- opcode = OP_ONCE;
-
-alt_max = has_alternatives ? no_alternatives(ccbegin) : 0;
-
-/* Decoding the needs_control_head in framesize. */
-if (opcode == OP_ONCE)
- {
- needs_control_head = (CURRENT_AS(bracket_backtrack)->u.framesize & 0x1) != 0;
- CURRENT_AS(bracket_backtrack)->u.framesize >>= 1;
- }
-
-if (ket != OP_KET && repeat_type != 0)
- {
- /* TMP1 is used in OP_KETRMIN below. */
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
- if (repeat_type == OP_UPTO)
- OP2(SLJIT_ADD, SLJIT_MEM1(SLJIT_SP), repeat_ptr, TMP1, 0, SLJIT_IMM, 1);
- else
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), repeat_ptr, TMP1, 0);
- }
-
-if (ket == OP_KETRMAX)
- {
- if (bra == OP_BRAZERO)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
- brazero = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, 0);
- }
- }
-else if (ket == OP_KETRMIN)
- {
- if (bra != OP_BRAMINZERO)
- {
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- if (repeat_type != 0)
- {
- /* TMP1 was set a few lines above. */
- CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0, CURRENT_AS(bracket_backtrack)->recursive_matchingpath);
- /* Drop STR_PTR for non-greedy plus quantifier. */
- if (opcode != OP_ONCE)
- free_stack(common, 1);
- }
- else if (opcode >= OP_SBRA || opcode == OP_ONCE)
- {
- /* Checking zero-length iteration. */
- if (opcode != OP_ONCE || CURRENT_AS(bracket_backtrack)->u.framesize < 0)
- CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr, CURRENT_AS(bracket_backtrack)->recursive_matchingpath);
- else
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_MEM1(TMP1), (CURRENT_AS(bracket_backtrack)->u.framesize + 1) * sizeof(sljit_sw), CURRENT_AS(bracket_backtrack)->recursive_matchingpath);
- }
- /* Drop STR_PTR for non-greedy plus quantifier. */
- if (opcode != OP_ONCE)
- free_stack(common, 1);
- }
- else
- JUMPTO(SLJIT_JUMP, CURRENT_AS(bracket_backtrack)->recursive_matchingpath);
- }
- rmin_label = LABEL();
- if (repeat_type != 0)
- OP2(SLJIT_ADD, SLJIT_MEM1(SLJIT_SP), repeat_ptr, SLJIT_MEM1(SLJIT_SP), repeat_ptr, SLJIT_IMM, 1);
- }
-else if (bra == OP_BRAZERO)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
- brazero = CMP(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0);
- }
-else if (repeat_type == OP_EXACT)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), repeat_ptr, SLJIT_IMM, 1);
- exact_label = LABEL();
- }
-
-if (offset != 0)
- {
- if (common->capture_last_ptr != 0)
- {
- SLJIT_ASSERT(common->optimized_cbracket[offset >> 1] == 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr, TMP1, 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(2));
- free_stack(common, 3);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset), TMP2, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), TMP1, 0);
- }
- else if (common->optimized_cbracket[offset >> 1] == 0)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
- free_stack(common, 2);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset), TMP1, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), TMP2, 0);
- }
- }
-
-if (SLJIT_UNLIKELY(opcode == OP_ONCE))
- {
- if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)
- {
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
- }
- once = JUMP(SLJIT_JUMP);
- }
-else if (SLJIT_UNLIKELY(opcode == OP_COND) || SLJIT_UNLIKELY(opcode == OP_SCOND))
- {
- if (has_alternatives)
- {
- /* Always exactly one alternative. */
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
-
- alt_max = 2;
- alt1 = CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, sizeof(sljit_uw));
- }
- }
-else if (has_alternatives)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
-
- if (alt_max > 4)
- {
- /* Table jump if alt_max is greater than 4. */
- next_update_addr = allocate_read_only_data(common, alt_max * sizeof(sljit_uw));
- if (SLJIT_UNLIKELY(next_update_addr == NULL))
- return;
- sljit_emit_ijump(compiler, SLJIT_JUMP, SLJIT_MEM1(TMP1), (sljit_sw)next_update_addr);
- add_label_addr(common, next_update_addr++);
- }
- else
- {
- if (alt_max == 4)
- alt2 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_uw));
- alt1 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, sizeof(sljit_uw));
- }
- }
-
-COMPILE_BACKTRACKINGPATH(current->top);
-if (current->topbacktracks)
- set_jumps(current->topbacktracks, LABEL());
-
-if (SLJIT_UNLIKELY(opcode == OP_COND) || SLJIT_UNLIKELY(opcode == OP_SCOND))
- {
- /* Conditional block always has at most one alternative. */
- if (ccbegin[1 + LINK_SIZE] >= OP_ASSERT && ccbegin[1 + LINK_SIZE] <= OP_ASSERTBACK_NOT)
- {
- SLJIT_ASSERT(has_alternatives);
- assert = CURRENT_AS(bracket_backtrack)->u.assert;
- if (assert->framesize >= 0 && (ccbegin[1 + LINK_SIZE] == OP_ASSERT || ccbegin[1 + LINK_SIZE] == OP_ASSERTBACK))
- {
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), assert->private_data_ptr);
- add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), assert->private_data_ptr, SLJIT_MEM1(STACK_TOP), assert->framesize * sizeof(sljit_sw));
- }
- cond = JUMP(SLJIT_JUMP);
- set_jumps(CURRENT_AS(bracket_backtrack)->u.assert->condfailed, LABEL());
- }
- else if (CURRENT_AS(bracket_backtrack)->u.condfailed != NULL)
- {
- SLJIT_ASSERT(has_alternatives);
- cond = JUMP(SLJIT_JUMP);
- set_jumps(CURRENT_AS(bracket_backtrack)->u.condfailed, LABEL());
- }
- else
- SLJIT_ASSERT(!has_alternatives);
- }
-
-if (has_alternatives)
- {
- alt_count = sizeof(sljit_uw);
- do
- {
- current->top = NULL;
- current->topbacktracks = NULL;
- current->nextbacktracks = NULL;
- /* Conditional blocks always have an additional alternative, even if it is empty. */
- if (*cc == OP_ALT)
- {
- ccprev = cc + 1 + LINK_SIZE;
- cc += GET(cc, 1);
- if (opcode != OP_COND && opcode != OP_SCOND)
- {
- if (opcode != OP_ONCE)
- {
- if (private_data_ptr != 0)
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), private_data_ptr);
- else
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- }
- else
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(needs_control_head ? 1 : 0));
- }
- compile_matchingpath(common, ccprev, cc, current);
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- return;
- }
-
- /* Instructions after the current alternative is successfully matched. */
- /* There is a similar code in compile_bracket_matchingpath. */
- if (opcode == OP_ONCE)
- match_once_common(common, ket, CURRENT_AS(bracket_backtrack)->u.framesize, private_data_ptr, has_alternatives, needs_control_head);
-
- stacksize = 0;
- if (repeat_type == OP_MINUPTO)
- {
- /* We need to preserve the counter. TMP2 will be used below. */
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), repeat_ptr);
- stacksize++;
- }
- if (ket != OP_KET || bra != OP_BRA)
- stacksize++;
- if (offset != 0)
- {
- if (common->capture_last_ptr != 0)
- stacksize++;
- if (common->optimized_cbracket[offset >> 1] == 0)
- stacksize += 2;
- }
- if (opcode != OP_ONCE)
- stacksize++;
-
- if (stacksize > 0)
- allocate_stack(common, stacksize);
-
- stacksize = 0;
- if (repeat_type == OP_MINUPTO)
- {
- /* TMP2 was set above. */
- OP2(SLJIT_SUB, SLJIT_MEM1(STACK_TOP), STACK(stacksize), TMP2, 0, SLJIT_IMM, 1);
- stacksize++;
- }
-
- if (ket != OP_KET || bra != OP_BRA)
- {
- if (ket != OP_KET)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), STR_PTR, 0);
- else
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, 0);
- stacksize++;
- }
-
- if (offset != 0)
- stacksize = match_capture_common(common, stacksize, offset, private_data_ptr);
-
- if (opcode != OP_ONCE)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(stacksize), SLJIT_IMM, alt_count);
-
- if (offset != 0 && ket == OP_KETRMAX && common->optimized_cbracket[offset >> 1] != 0)
- {
- /* If ket is not OP_KETRMAX, this code path is executed after the jump to alternative_matchingpath. */
- SLJIT_ASSERT(private_data_ptr == OVECTOR(offset + 0));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), STR_PTR, 0);
- }
-
- JUMPTO(SLJIT_JUMP, CURRENT_AS(bracket_backtrack)->alternative_matchingpath);
-
- if (opcode != OP_ONCE)
- {
- if (alt_max > 4)
- add_label_addr(common, next_update_addr++);
- else
- {
- if (alt_count != 2 * sizeof(sljit_uw))
- {
- JUMPHERE(alt1);
- if (alt_max == 3 && alt_count == sizeof(sljit_uw))
- alt2 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 2 * sizeof(sljit_uw));
- }
- else
- {
- JUMPHERE(alt2);
- if (alt_max == 4)
- alt1 = CMP(SLJIT_GREATER_EQUAL, TMP1, 0, SLJIT_IMM, 3 * sizeof(sljit_uw));
- }
- }
- alt_count += sizeof(sljit_uw);
- }
-
- COMPILE_BACKTRACKINGPATH(current->top);
- if (current->topbacktracks)
- set_jumps(current->topbacktracks, LABEL());
- SLJIT_ASSERT(!current->nextbacktracks);
- }
- while (*cc == OP_ALT);
-
- if (cond != NULL)
- {
- SLJIT_ASSERT(opcode == OP_COND || opcode == OP_SCOND);
- assert = CURRENT_AS(bracket_backtrack)->u.assert;
- if ((ccbegin[1 + LINK_SIZE] == OP_ASSERT_NOT || ccbegin[1 + LINK_SIZE] == OP_ASSERTBACK_NOT) && assert->framesize >= 0)
- {
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), assert->private_data_ptr);
- add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), assert->private_data_ptr, SLJIT_MEM1(STACK_TOP), assert->framesize * sizeof(sljit_sw));
- }
- JUMPHERE(cond);
- }
-
- /* Free the STR_PTR. */
- if (private_data_ptr == 0)
- free_stack(common, 1);
- }
-
-if (offset != 0)
- {
- /* Using both tmp register is better for instruction scheduling. */
- if (common->optimized_cbracket[offset >> 1] != 0)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
- free_stack(common, 2);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset), TMP1, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), TMP2, 0);
- }
- else
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, TMP1, 0);
- }
- }
-else if (opcode == OP_SBRA || opcode == OP_SCOND)
- {
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
- }
-else if (opcode == OP_ONCE)
- {
- cc = ccbegin + GET(ccbegin, 1);
- stacksize = needs_control_head ? 1 : 0;
-
- if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)
- {
- /* Reset head and drop saved frame. */
- stacksize += CURRENT_AS(bracket_backtrack)->u.framesize + ((ket != OP_KET || *cc == OP_ALT) ? 2 : 1);
- }
- else if (ket == OP_KETRMAX || (*cc == OP_ALT && ket != OP_KETRMIN))
- {
- /* The STR_PTR must be released. */
- stacksize++;
- }
- free_stack(common, stacksize);
-
- JUMPHERE(once);
- /* Restore previous private_data_ptr */
- if (CURRENT_AS(bracket_backtrack)->u.framesize >= 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(bracket_backtrack)->u.framesize * sizeof(sljit_sw));
- else if (ket == OP_KETRMIN)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
- /* See the comment below. */
- free_stack(common, 2);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), private_data_ptr, TMP1, 0);
- }
- }
-
-if (repeat_type == OP_EXACT)
- {
- OP2(SLJIT_ADD, TMP1, 0, SLJIT_MEM1(SLJIT_SP), repeat_ptr, SLJIT_IMM, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), repeat_ptr, TMP1, 0);
- CMPTO(SLJIT_LESS_EQUAL, TMP1, 0, SLJIT_IMM, repeat_count, exact_label);
- }
-else if (ket == OP_KETRMAX)
- {
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- if (bra != OP_BRAZERO)
- free_stack(common, 1);
-
- CMPTO(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, 0, CURRENT_AS(bracket_backtrack)->recursive_matchingpath);
- if (bra == OP_BRAZERO)
- {
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
- JUMPTO(SLJIT_JUMP, CURRENT_AS(bracket_backtrack)->zero_matchingpath);
- JUMPHERE(brazero);
- free_stack(common, 1);
- }
- }
-else if (ket == OP_KETRMIN)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
-
- /* OP_ONCE removes everything in case of a backtrack, so we don't
- need to explicitly release the STR_PTR. The extra release would
- affect badly the free_stack(2) above. */
- if (opcode != OP_ONCE)
- free_stack(common, 1);
- CMPTO(SLJIT_NOT_EQUAL, TMP1, 0, SLJIT_IMM, 0, rmin_label);
- if (opcode == OP_ONCE)
- free_stack(common, bra == OP_BRAMINZERO ? 2 : 1);
- else if (bra == OP_BRAMINZERO)
- free_stack(common, 1);
- }
-else if (bra == OP_BRAZERO)
- {
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- JUMPTO(SLJIT_JUMP, CURRENT_AS(bracket_backtrack)->zero_matchingpath);
- JUMPHERE(brazero);
- }
-}
-
-static SLJIT_INLINE void compile_bracketpos_backtrackingpath(compiler_common *common, struct backtrack_common *current)
-{
-DEFINE_COMPILER;
-int offset;
-struct sljit_jump *jump;
-
-if (CURRENT_AS(bracketpos_backtrack)->framesize < 0)
- {
- if (*current->cc == OP_CBRAPOS || *current->cc == OP_SCBRAPOS)
- {
- offset = (GET2(current->cc, 1 + LINK_SIZE)) << 1;
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(1));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset), TMP1, 0);
- if (common->capture_last_ptr != 0)
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(2));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), TMP2, 0);
- if (common->capture_last_ptr != 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr, TMP1, 0);
- }
- set_jumps(current->topbacktracks, LABEL());
- free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);
- return;
- }
-
-OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), CURRENT_AS(bracketpos_backtrack)->private_data_ptr);
-add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
-
-if (current->topbacktracks)
- {
- jump = JUMP(SLJIT_JUMP);
- set_jumps(current->topbacktracks, LABEL());
- /* Drop the stack frame. */
- free_stack(common, CURRENT_AS(bracketpos_backtrack)->stacksize);
- JUMPHERE(jump);
- }
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), CURRENT_AS(bracketpos_backtrack)->private_data_ptr, SLJIT_MEM1(STACK_TOP), CURRENT_AS(bracketpos_backtrack)->framesize * sizeof(sljit_sw));
-}
-
-static SLJIT_INLINE void compile_braminzero_backtrackingpath(compiler_common *common, struct backtrack_common *current)
-{
-assert_backtrack backtrack;
-
-current->top = NULL;
-current->topbacktracks = NULL;
-current->nextbacktracks = NULL;
-if (current->cc[1] > OP_ASSERTBACK_NOT)
- {
- /* Manual call of compile_bracket_matchingpath and compile_bracket_backtrackingpath. */
- compile_bracket_matchingpath(common, current->cc, current);
- compile_bracket_backtrackingpath(common, current->top);
- }
-else
- {
- memset(&backtrack, 0, sizeof(backtrack));
- backtrack.common.cc = current->cc;
- backtrack.matchingpath = CURRENT_AS(braminzero_backtrack)->matchingpath;
- /* Manual call of compile_assert_matchingpath. */
- compile_assert_matchingpath(common, current->cc, &backtrack, FALSE);
- }
-SLJIT_ASSERT(!current->nextbacktracks && !current->topbacktracks);
-}
-
-static SLJIT_INLINE void compile_control_verb_backtrackingpath(compiler_common *common, struct backtrack_common *current)
-{
-DEFINE_COMPILER;
-pcre_uchar opcode = *current->cc;
-struct sljit_label *loop;
-struct sljit_jump *jump;
-
-if (opcode == OP_THEN || opcode == OP_THEN_ARG)
- {
- if (common->then_trap != NULL)
- {
- SLJIT_ASSERT(common->control_head_ptr != 0);
-
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, type_then_trap);
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_IMM, common->then_trap->start);
- jump = JUMP(SLJIT_JUMP);
-
- loop = LABEL();
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(STACK_TOP), -(int)sizeof(sljit_sw));
- JUMPHERE(jump);
- CMPTO(SLJIT_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), -(int)(2 * sizeof(sljit_sw)), TMP1, 0, loop);
- CMPTO(SLJIT_NOT_EQUAL, SLJIT_MEM1(STACK_TOP), -(int)(3 * sizeof(sljit_sw)), TMP2, 0, loop);
- add_jump(compiler, &common->then_trap->quit, JUMP(SLJIT_JUMP));
- return;
- }
- else if (common->positive_assert)
- {
- add_jump(compiler, &common->positive_assert_quit, JUMP(SLJIT_JUMP));
- return;
- }
- }
-
-if (common->local_exit)
- {
- if (common->quit_label == NULL)
- add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));
- else
- JUMPTO(SLJIT_JUMP, common->quit_label);
- return;
- }
-
-if (opcode == OP_SKIP_ARG)
- {
- SLJIT_ASSERT(common->control_head_ptr != 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS0, STACK_TOP, 0);
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_IMM, (sljit_sw)(current->cc + 2));
- sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(do_search_mark));
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), LOCALS0);
-
- OP1(SLJIT_MOV, STR_PTR, 0, TMP1, 0);
- add_jump(compiler, &common->reset_match, CMP(SLJIT_NOT_EQUAL, STR_PTR, 0, SLJIT_IMM, -1));
- return;
- }
-
-if (opcode == OP_SKIP)
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
-else
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_IMM, 0);
-add_jump(compiler, &common->reset_match, JUMP(SLJIT_JUMP));
-}
-
-static SLJIT_INLINE void compile_then_trap_backtrackingpath(compiler_common *common, struct backtrack_common *current)
-{
-DEFINE_COMPILER;
-struct sljit_jump *jump;
-int size;
-
-if (CURRENT_AS(then_trap_backtrack)->then_trap)
- {
- common->then_trap = CURRENT_AS(then_trap_backtrack)->then_trap;
- return;
- }
-
-size = CURRENT_AS(then_trap_backtrack)->framesize;
-size = 3 + (size < 0 ? 0 : size);
-
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(size - 3));
-free_stack(common, size);
-jump = JUMP(SLJIT_JUMP);
-
-set_jumps(CURRENT_AS(then_trap_backtrack)->quit, LABEL());
-/* STACK_TOP is set by THEN. */
-if (CURRENT_AS(then_trap_backtrack)->framesize >= 0)
- add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
-free_stack(common, 3);
-
-JUMPHERE(jump);
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, TMP1, 0);
-}
-
-static void compile_backtrackingpath(compiler_common *common, struct backtrack_common *current)
-{
-DEFINE_COMPILER;
-then_trap_backtrack *save_then_trap = common->then_trap;
-
-while (current)
- {
- if (current->nextbacktracks != NULL)
- set_jumps(current->nextbacktracks, LABEL());
- switch(*current->cc)
- {
- case OP_SET_SOM:
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(0), TMP1, 0);
- break;
-
- case OP_STAR:
- case OP_MINSTAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_UPTO:
- case OP_MINUPTO:
- case OP_EXACT:
- case OP_POSSTAR:
- case OP_POSPLUS:
- case OP_POSQUERY:
- case OP_POSUPTO:
- case OP_STARI:
- case OP_MINSTARI:
- case OP_PLUSI:
- case OP_MINPLUSI:
- case OP_QUERYI:
- case OP_MINQUERYI:
- case OP_UPTOI:
- case OP_MINUPTOI:
- case OP_EXACTI:
- case OP_POSSTARI:
- case OP_POSPLUSI:
- case OP_POSQUERYI:
- case OP_POSUPTOI:
- case OP_NOTSTAR:
- case OP_NOTMINSTAR:
- case OP_NOTPLUS:
- case OP_NOTMINPLUS:
- case OP_NOTQUERY:
- case OP_NOTMINQUERY:
- case OP_NOTUPTO:
- case OP_NOTMINUPTO:
- case OP_NOTEXACT:
- case OP_NOTPOSSTAR:
- case OP_NOTPOSPLUS:
- case OP_NOTPOSQUERY:
- case OP_NOTPOSUPTO:
- case OP_NOTSTARI:
- case OP_NOTMINSTARI:
- case OP_NOTPLUSI:
- case OP_NOTMINPLUSI:
- case OP_NOTQUERYI:
- case OP_NOTMINQUERYI:
- case OP_NOTUPTOI:
- case OP_NOTMINUPTOI:
- case OP_NOTEXACTI:
- case OP_NOTPOSSTARI:
- case OP_NOTPOSPLUSI:
- case OP_NOTPOSQUERYI:
- case OP_NOTPOSUPTOI:
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- case OP_TYPEEXACT:
- case OP_TYPEPOSSTAR:
- case OP_TYPEPOSPLUS:
- case OP_TYPEPOSQUERY:
- case OP_TYPEPOSUPTO:
- case OP_CLASS:
- case OP_NCLASS:
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
-#endif
- compile_iterator_backtrackingpath(common, current);
- break;
-
- case OP_REF:
- case OP_REFI:
- case OP_DNREF:
- case OP_DNREFI:
- compile_ref_iterator_backtrackingpath(common, current);
- break;
-
- case OP_RECURSE:
- compile_recurse_backtrackingpath(common, current);
- break;
-
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- compile_assert_backtrackingpath(common, current);
- break;
-
- case OP_ONCE:
- case OP_ONCE_NC:
- case OP_BRA:
- case OP_CBRA:
- case OP_COND:
- case OP_SBRA:
- case OP_SCBRA:
- case OP_SCOND:
- compile_bracket_backtrackingpath(common, current);
- break;
-
- case OP_BRAZERO:
- if (current->cc[1] > OP_ASSERTBACK_NOT)
- compile_bracket_backtrackingpath(common, current);
- else
- compile_assert_backtrackingpath(common, current);
- break;
-
- case OP_BRAPOS:
- case OP_CBRAPOS:
- case OP_SBRAPOS:
- case OP_SCBRAPOS:
- case OP_BRAPOSZERO:
- compile_bracketpos_backtrackingpath(common, current);
- break;
-
- case OP_BRAMINZERO:
- compile_braminzero_backtrackingpath(common, current);
- break;
-
- case OP_MARK:
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), STACK(common->has_skip_arg ? 4 : 0));
- if (common->has_skip_arg)
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
- free_stack(common, common->has_skip_arg ? 5 : 1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->mark_ptr, TMP1, 0);
- if (common->has_skip_arg)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, TMP2, 0);
- break;
-
- case OP_THEN:
- case OP_THEN_ARG:
- case OP_PRUNE:
- case OP_PRUNE_ARG:
- case OP_SKIP:
- case OP_SKIP_ARG:
- compile_control_verb_backtrackingpath(common, current);
- break;
-
- case OP_COMMIT:
- if (!common->local_exit)
- OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
- if (common->quit_label == NULL)
- add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));
- else
- JUMPTO(SLJIT_JUMP, common->quit_label);
- break;
-
- case OP_CALLOUT:
- case OP_FAIL:
- case OP_ACCEPT:
- case OP_ASSERT_ACCEPT:
- set_jumps(current->topbacktracks, LABEL());
- break;
-
- case OP_THEN_TRAP:
- /* A virtual opcode for then traps. */
- compile_then_trap_backtrackingpath(common, current);
- break;
-
- default:
- SLJIT_ASSERT_STOP();
- break;
- }
- current = current->prev;
- }
-common->then_trap = save_then_trap;
-}
-
-static SLJIT_INLINE void compile_recurse(compiler_common *common)
-{
-DEFINE_COMPILER;
-pcre_uchar *cc = common->start + common->currententry->start;
-pcre_uchar *ccbegin = cc + 1 + LINK_SIZE + (*cc == OP_BRA ? 0 : IMM2_SIZE);
-pcre_uchar *ccend = bracketend(cc) - (1 + LINK_SIZE);
-BOOL needs_control_head;
-int framesize = get_framesize(common, cc, NULL, TRUE, &needs_control_head);
-int private_data_size = get_private_data_copy_length(common, ccbegin, ccend, needs_control_head);
-int alternativesize;
-BOOL needs_frame;
-backtrack_common altbacktrack;
-struct sljit_jump *jump;
-
-/* Recurse captures then. */
-common->then_trap = NULL;
-
-SLJIT_ASSERT(*cc == OP_BRA || *cc == OP_CBRA || *cc == OP_CBRAPOS || *cc == OP_SCBRA || *cc == OP_SCBRAPOS);
-needs_frame = framesize >= 0;
-if (!needs_frame)
- framesize = 0;
-alternativesize = *(cc + GET(cc, 1)) == OP_ALT ? 1 : 0;
-
-SLJIT_ASSERT(common->currententry->entry == NULL && common->recursive_head_ptr != 0);
-common->currententry->entry = LABEL();
-set_jumps(common->currententry->calls, common->currententry->entry);
-
-sljit_emit_fast_enter(compiler, TMP2, 0);
-allocate_stack(common, private_data_size + framesize + alternativesize);
-count_match(common);
-OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(private_data_size + framesize + alternativesize - 1), TMP2, 0);
-copy_private_data(common, ccbegin, ccend, TRUE, private_data_size + framesize + alternativesize, framesize + alternativesize, needs_control_head);
-if (needs_control_head)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_IMM, 0);
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->recursive_head_ptr, STACK_TOP, 0);
-if (needs_frame)
- init_frame(common, cc, NULL, framesize + alternativesize - 1, alternativesize, TRUE);
-
-if (alternativesize > 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(STACK_TOP), STACK(0), STR_PTR, 0);
-
-memset(&altbacktrack, 0, sizeof(backtrack_common));
-common->quit_label = NULL;
-common->accept_label = NULL;
-common->quit = NULL;
-common->accept = NULL;
-altbacktrack.cc = ccbegin;
-cc += GET(cc, 1);
-while (1)
- {
- altbacktrack.top = NULL;
- altbacktrack.topbacktracks = NULL;
-
- if (altbacktrack.cc != ccbegin)
- OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(STACK_TOP), STACK(0));
-
- compile_matchingpath(common, altbacktrack.cc, cc, &altbacktrack);
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- return;
-
- add_jump(compiler, &common->accept, JUMP(SLJIT_JUMP));
-
- compile_backtrackingpath(common, altbacktrack.top);
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- return;
- set_jumps(altbacktrack.topbacktracks, LABEL());
-
- if (*cc != OP_ALT)
- break;
-
- altbacktrack.cc = cc + 1 + LINK_SIZE;
- cc += GET(cc, 1);
- }
-
-/* None of them matched. */
-OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 0);
-jump = JUMP(SLJIT_JUMP);
-
-if (common->quit != NULL)
- {
- set_jumps(common->quit, LABEL());
- OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), common->recursive_head_ptr);
- if (needs_frame)
- {
- OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));
- add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
- OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));
- }
- OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 0);
- common->quit = NULL;
- add_jump(compiler, &common->quit, JUMP(SLJIT_JUMP));
- }
-
-set_jumps(common->accept, LABEL());
-OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(SLJIT_SP), common->recursive_head_ptr);
-if (needs_frame)
- {
- OP2(SLJIT_SUB, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));
- add_jump(compiler, &common->revertframes, JUMP(SLJIT_FAST_CALL));
- OP2(SLJIT_ADD, STACK_TOP, 0, STACK_TOP, 0, SLJIT_IMM, (framesize + alternativesize) * sizeof(sljit_sw));
- }
-OP1(SLJIT_MOV, TMP3, 0, SLJIT_IMM, 1);
-
-JUMPHERE(jump);
-if (common->quit != NULL)
- set_jumps(common->quit, LABEL());
-copy_private_data(common, ccbegin, ccend, FALSE, private_data_size + framesize + alternativesize, framesize + alternativesize, needs_control_head);
-free_stack(common, private_data_size + framesize + alternativesize);
-if (needs_control_head)
- {
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(STACK_TOP), 2 * sizeof(sljit_sw));
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), sizeof(sljit_sw));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->recursive_head_ptr, TMP1, 0);
- OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, TMP2, 0);
- }
-else
- {
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(STACK_TOP), sizeof(sljit_sw));
- OP1(SLJIT_MOV, TMP1, 0, TMP3, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->recursive_head_ptr, TMP2, 0);
- }
-sljit_emit_fast_return(compiler, SLJIT_MEM1(STACK_TOP), 0);
-}
-
-#undef COMPILE_BACKTRACKINGPATH
-#undef CURRENT_AS
-
-void
-PRIV(jit_compile)(const REAL_PCRE *re, PUBL(extra) *extra, int mode)
-{
-struct sljit_compiler *compiler;
-backtrack_common rootbacktrack;
-compiler_common common_data;
-compiler_common *common = &common_data;
-const pcre_uint8 *tables = re->tables;
-pcre_study_data *study;
-int private_data_size;
-pcre_uchar *ccend;
-executable_functions *functions;
-void *executable_func;
-sljit_uw executable_size;
-sljit_uw total_length;
-label_addr_list *label_addr;
-struct sljit_label *mainloop_label = NULL;
-struct sljit_label *continue_match_label;
-struct sljit_label *empty_match_found_label = NULL;
-struct sljit_label *empty_match_backtrack_label = NULL;
-struct sljit_label *reset_match_label;
-struct sljit_label *quit_label;
-struct sljit_jump *jump;
-struct sljit_jump *minlength_check_failed = NULL;
-struct sljit_jump *reqbyte_notfound = NULL;
-struct sljit_jump *empty_match = NULL;
-
-SLJIT_ASSERT((extra->flags & PCRE_EXTRA_STUDY_DATA) != 0);
-study = extra->study_data;
-
-if (!tables)
- tables = PRIV(default_tables);
-
-memset(&rootbacktrack, 0, sizeof(backtrack_common));
-memset(common, 0, sizeof(compiler_common));
-rootbacktrack.cc = (pcre_uchar *)re + re->name_table_offset + re->name_count * re->name_entry_size;
-
-common->start = rootbacktrack.cc;
-common->read_only_data_head = NULL;
-common->fcc = tables + fcc_offset;
-common->lcc = (sljit_sw)(tables + lcc_offset);
-common->mode = mode;
-common->might_be_empty = study->minlength == 0;
-common->nltype = NLTYPE_FIXED;
-switch(re->options & PCRE_NEWLINE_BITS)
- {
- case 0:
- /* Compile-time default */
- switch(NEWLINE)
- {
- case -1: common->newline = (CHAR_CR << 8) | CHAR_NL; common->nltype = NLTYPE_ANY; break;
- case -2: common->newline = (CHAR_CR << 8) | CHAR_NL; common->nltype = NLTYPE_ANYCRLF; break;
- default: common->newline = NEWLINE; break;
- }
- break;
- case PCRE_NEWLINE_CR: common->newline = CHAR_CR; break;
- case PCRE_NEWLINE_LF: common->newline = CHAR_NL; break;
- case PCRE_NEWLINE_CR+
- PCRE_NEWLINE_LF: common->newline = (CHAR_CR << 8) | CHAR_NL; break;
- case PCRE_NEWLINE_ANY: common->newline = (CHAR_CR << 8) | CHAR_NL; common->nltype = NLTYPE_ANY; break;
- case PCRE_NEWLINE_ANYCRLF: common->newline = (CHAR_CR << 8) | CHAR_NL; common->nltype = NLTYPE_ANYCRLF; break;
- default: return;
- }
-common->nlmax = READ_CHAR_MAX;
-common->nlmin = 0;
-if ((re->options & PCRE_BSR_ANYCRLF) != 0)
- common->bsr_nltype = NLTYPE_ANYCRLF;
-else if ((re->options & PCRE_BSR_UNICODE) != 0)
- common->bsr_nltype = NLTYPE_ANY;
-else
- {
-#ifdef BSR_ANYCRLF
- common->bsr_nltype = NLTYPE_ANYCRLF;
-#else
- common->bsr_nltype = NLTYPE_ANY;
-#endif
- }
-common->bsr_nlmax = READ_CHAR_MAX;
-common->bsr_nlmin = 0;
-common->endonly = (re->options & PCRE_DOLLAR_ENDONLY) != 0;
-common->ctypes = (sljit_sw)(tables + ctypes_offset);
-common->name_table = ((pcre_uchar *)re) + re->name_table_offset;
-common->name_count = re->name_count;
-common->name_entry_size = re->name_entry_size;
-common->jscript_compat = (re->options & PCRE_JAVASCRIPT_COMPAT) != 0;
-#ifdef SUPPORT_UTF
-/* PCRE_UTF[16|32] have the same value as PCRE_UTF8. */
-common->utf = (re->options & PCRE_UTF8) != 0;
-#ifdef SUPPORT_UCP
-common->use_ucp = (re->options & PCRE_UCP) != 0;
-#endif
-if (common->utf)
- {
- if (common->nltype == NLTYPE_ANY)
- common->nlmax = 0x2029;
- else if (common->nltype == NLTYPE_ANYCRLF)
- common->nlmax = (CHAR_CR > CHAR_NL) ? CHAR_CR : CHAR_NL;
- else
- {
- /* We only care about the first newline character. */
- common->nlmax = common->newline & 0xff;
- }
-
- if (common->nltype == NLTYPE_FIXED)
- common->nlmin = common->newline & 0xff;
- else
- common->nlmin = (CHAR_CR < CHAR_NL) ? CHAR_CR : CHAR_NL;
-
- if (common->bsr_nltype == NLTYPE_ANY)
- common->bsr_nlmax = 0x2029;
- else
- common->bsr_nlmax = (CHAR_CR > CHAR_NL) ? CHAR_CR : CHAR_NL;
- common->bsr_nlmin = (CHAR_CR < CHAR_NL) ? CHAR_CR : CHAR_NL;
- }
-#endif /* SUPPORT_UTF */
-ccend = bracketend(common->start);
-
-/* Calculate the local space size on the stack. */
-common->ovector_start = LIMIT_MATCH + sizeof(sljit_sw);
-common->optimized_cbracket = (pcre_uint8 *)SLJIT_MALLOC(re->top_bracket + 1, compiler->allocator_data);
-if (!common->optimized_cbracket)
- return;
-#if defined DEBUG_FORCE_UNOPTIMIZED_CBRAS && DEBUG_FORCE_UNOPTIMIZED_CBRAS == 1
-memset(common->optimized_cbracket, 0, re->top_bracket + 1);
-#else
-memset(common->optimized_cbracket, 1, re->top_bracket + 1);
-#endif
-
-SLJIT_ASSERT(*common->start == OP_BRA && ccend[-(1 + LINK_SIZE)] == OP_KET);
-#if defined DEBUG_FORCE_UNOPTIMIZED_CBRAS && DEBUG_FORCE_UNOPTIMIZED_CBRAS == 2
-common->capture_last_ptr = common->ovector_start;
-common->ovector_start += sizeof(sljit_sw);
-#endif
-if (!check_opcode_types(common, common->start, ccend))
- {
- SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
- return;
- }
-
-/* Checking flags and updating ovector_start. */
-if (mode == JIT_COMPILE && (re->flags & PCRE_REQCHSET) != 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)
- {
- common->req_char_ptr = common->ovector_start;
- common->ovector_start += sizeof(sljit_sw);
- }
-if (mode != JIT_COMPILE)
- {
- common->start_used_ptr = common->ovector_start;
- common->ovector_start += sizeof(sljit_sw);
- if (mode == JIT_PARTIAL_SOFT_COMPILE)
- {
- common->hit_start = common->ovector_start;
- common->ovector_start += 2 * sizeof(sljit_sw);
- }
- else
- {
- SLJIT_ASSERT(mode == JIT_PARTIAL_HARD_COMPILE);
- common->needs_start_ptr = TRUE;
- }
- }
-if ((re->options & PCRE_FIRSTLINE) != 0)
- {
- common->first_line_end = common->ovector_start;
- common->ovector_start += sizeof(sljit_sw);
- }
-#if defined DEBUG_FORCE_CONTROL_HEAD && DEBUG_FORCE_CONTROL_HEAD
-common->control_head_ptr = 1;
-#endif
-if (common->control_head_ptr != 0)
- {
- common->control_head_ptr = common->ovector_start;
- common->ovector_start += sizeof(sljit_sw);
- }
-if (common->needs_start_ptr && common->has_set_som)
- {
- /* Saving the real start pointer is necessary. */
- common->start_ptr = common->ovector_start;
- common->ovector_start += sizeof(sljit_sw);
- }
-else
- common->needs_start_ptr = FALSE;
-
-/* Aligning ovector to even number of sljit words. */
-if ((common->ovector_start & sizeof(sljit_sw)) != 0)
- common->ovector_start += sizeof(sljit_sw);
-
-if (common->start_ptr == 0)
- common->start_ptr = OVECTOR(0);
-
-/* Capturing brackets cannot be optimized if callouts are allowed. */
-if (common->capture_last_ptr != 0)
- memset(common->optimized_cbracket, 0, re->top_bracket + 1);
-
-SLJIT_ASSERT(!(common->req_char_ptr != 0 && common->start_used_ptr != 0));
-common->cbra_ptr = OVECTOR_START + (re->top_bracket + 1) * 2 * sizeof(sljit_sw);
-
-total_length = ccend - common->start;
-common->private_data_ptrs = (sljit_si *)SLJIT_MALLOC(total_length * (sizeof(sljit_si) + (common->has_then ? 1 : 0)), compiler->allocator_data);
-if (!common->private_data_ptrs)
- {
- SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
- return;
- }
-memset(common->private_data_ptrs, 0, total_length * sizeof(sljit_si));
-
-private_data_size = common->cbra_ptr + (re->top_bracket + 1) * sizeof(sljit_sw);
-set_private_data_ptrs(common, &private_data_size, ccend);
-if (private_data_size > SLJIT_MAX_LOCAL_SIZE)
- {
- SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
- SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
- return;
- }
-
-if (common->has_then)
- {
- common->then_offsets = (pcre_uint8 *)(common->private_data_ptrs + total_length);
- memset(common->then_offsets, 0, total_length);
- set_then_offsets(common, common->start, NULL);
- }
-
-compiler = sljit_create_compiler(NULL);
-if (!compiler)
- {
- SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
- SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
- return;
- }
-common->compiler = compiler;
-
-/* Main pcre_jit_exec entry. */
-sljit_emit_enter(compiler, 0, 1, 5, 5, 0, 0, private_data_size);
-
-/* Register init. */
-reset_ovector(common, (re->top_bracket + 1) * 2);
-if (common->req_char_ptr != 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->req_char_ptr, SLJIT_R0, 0);
-
-OP1(SLJIT_MOV, ARGUMENTS, 0, SLJIT_S0, 0);
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_S0, 0);
-OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
-OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, end));
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack));
-OP1(SLJIT_MOV_UI, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, limit_match));
-OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, base));
-OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(struct sljit_stack, limit));
-OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, SLJIT_IMM, 1);
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LIMIT_MATCH, TMP1, 0);
-
-if (mode == JIT_PARTIAL_SOFT_COMPILE)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, -1);
-if (common->mark_ptr != 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->mark_ptr, SLJIT_IMM, 0);
-if (common->control_head_ptr != 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->control_head_ptr, SLJIT_IMM, 0);
-
-/* Main part of the matching */
-if ((re->options & PCRE_ANCHORED) == 0)
- {
- mainloop_label = mainloop_entry(common, (re->flags & PCRE_HASCRORLF) != 0, (re->options & PCRE_FIRSTLINE) != 0);
- continue_match_label = LABEL();
- /* Forward search if possible. */
- if ((re->options & PCRE_NO_START_OPTIMIZE) == 0)
- {
- if (mode == JIT_COMPILE && fast_forward_first_n_chars(common, (re->options & PCRE_FIRSTLINE) != 0))
- ;
- else if ((re->flags & PCRE_FIRSTSET) != 0)
- fast_forward_first_char(common, (pcre_uchar)re->first_char, (re->flags & PCRE_FCH_CASELESS) != 0, (re->options & PCRE_FIRSTLINE) != 0);
- else if ((re->flags & PCRE_STARTLINE) != 0)
- fast_forward_newline(common, (re->options & PCRE_FIRSTLINE) != 0);
- else if (study != NULL && (study->flags & PCRE_STUDY_MAPPED) != 0)
- fast_forward_start_bits(common, study->start_bits, (re->options & PCRE_FIRSTLINE) != 0);
- }
- }
-else
- continue_match_label = LABEL();
-
-if (mode == JIT_COMPILE && study->minlength > 0 && (re->options & PCRE_NO_START_OPTIMIZE) == 0)
- {
- OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
- OP2(SLJIT_ADD, TMP2, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(study->minlength));
- minlength_check_failed = CMP(SLJIT_GREATER, TMP2, 0, STR_END, 0);
- }
-if (common->req_char_ptr != 0)
- reqbyte_notfound = search_requested_char(common, (pcre_uchar)re->req_char, (re->flags & PCRE_RCH_CASELESS) != 0, (re->flags & PCRE_FIRSTSET) != 0);
-
-/* Store the current STR_PTR in OVECTOR(0). */
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), OVECTOR(0), STR_PTR, 0);
-/* Copy the limit of allowed recursions. */
-OP1(SLJIT_MOV, COUNT_MATCH, 0, SLJIT_MEM1(SLJIT_SP), LIMIT_MATCH);
-if (common->capture_last_ptr != 0)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->capture_last_ptr, SLJIT_IMM, -1);
-
-if (common->needs_start_ptr)
- {
- SLJIT_ASSERT(common->start_ptr != OVECTOR(0));
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->start_ptr, STR_PTR, 0);
- }
-else
- SLJIT_ASSERT(common->start_ptr == OVECTOR(0));
-
-/* Copy the beginning of the string. */
-if (mode == JIT_PARTIAL_SOFT_COMPILE)
- {
- jump = CMP(SLJIT_NOT_EQUAL, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, -1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start + sizeof(sljit_sw), STR_PTR, 0);
- JUMPHERE(jump);
- }
-else if (mode == JIT_PARTIAL_HARD_COMPILE)
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, STR_PTR, 0);
-
-compile_matchingpath(common, common->start, ccend, &rootbacktrack);
-if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- {
- sljit_free_compiler(compiler);
- SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
- SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
- free_read_only_data(common->read_only_data_head, compiler->allocator_data);
- return;
- }
-
-if (common->might_be_empty)
- {
- empty_match = CMP(SLJIT_EQUAL, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(0));
- empty_match_found_label = LABEL();
- }
-
-common->accept_label = LABEL();
-if (common->accept != NULL)
- set_jumps(common->accept, common->accept_label);
-
-/* This means we have a match. Update the ovector. */
-copy_ovector(common, re->top_bracket + 1);
-common->quit_label = common->forced_quit_label = LABEL();
-if (common->quit != NULL)
- set_jumps(common->quit, common->quit_label);
-if (common->forced_quit != NULL)
- set_jumps(common->forced_quit, common->forced_quit_label);
-if (minlength_check_failed != NULL)
- SET_LABEL(minlength_check_failed, common->forced_quit_label);
-sljit_emit_return(compiler, SLJIT_MOV, SLJIT_RETURN_REG, 0);
-
-if (mode != JIT_COMPILE)
- {
- common->partialmatchlabel = LABEL();
- set_jumps(common->partialmatch, common->partialmatchlabel);
- return_with_partial_match(common, common->quit_label);
- }
-
-if (common->might_be_empty)
- empty_match_backtrack_label = LABEL();
-compile_backtrackingpath(common, rootbacktrack.top);
-if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- {
- sljit_free_compiler(compiler);
- SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
- SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
- free_read_only_data(common->read_only_data_head, compiler->allocator_data);
- return;
- }
-
-SLJIT_ASSERT(rootbacktrack.prev == NULL);
-reset_match_label = LABEL();
-
-if (mode == JIT_PARTIAL_SOFT_COMPILE)
- {
- /* Update hit_start only in the first time. */
- jump = CMP(SLJIT_NOT_EQUAL, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->start_used_ptr, SLJIT_IMM, -1);
- OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->hit_start, TMP1, 0);
- JUMPHERE(jump);
- }
-
-/* Check we have remaining characters. */
-if ((re->options & PCRE_ANCHORED) == 0 && (re->options & PCRE_FIRSTLINE) != 0)
- {
- SLJIT_ASSERT(common->first_line_end != 0);
- OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), common->first_line_end);
- }
-
-OP1(SLJIT_MOV, STR_PTR, 0, SLJIT_MEM1(SLJIT_SP), common->start_ptr);
-
-if ((re->options & PCRE_ANCHORED) == 0)
- {
- if (common->ff_newline_shortcut != NULL)
- {
- if ((re->options & PCRE_FIRSTLINE) == 0)
- CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, common->ff_newline_shortcut);
- /* There cannot be more newlines here. */
- }
- else
- {
- if ((re->options & PCRE_FIRSTLINE) == 0)
- CMPTO(SLJIT_LESS, STR_PTR, 0, STR_END, 0, mainloop_label);
- else
- CMPTO(SLJIT_LESS, STR_PTR, 0, TMP1, 0, mainloop_label);
- }
- }
-
-/* No more remaining characters. */
-if (reqbyte_notfound != NULL)
- JUMPHERE(reqbyte_notfound);
-
-if (mode == JIT_PARTIAL_SOFT_COMPILE)
- CMPTO(SLJIT_NOT_EQUAL, SLJIT_MEM1(SLJIT_SP), common->hit_start, SLJIT_IMM, -1, common->partialmatchlabel);
-
-OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_NOMATCH);
-JUMPTO(SLJIT_JUMP, common->quit_label);
-
-flush_stubs(common);
-
-if (common->might_be_empty)
- {
- JUMPHERE(empty_match);
- OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
- OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty));
- CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_backtrack_label);
- OP1(SLJIT_MOV_UB, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, notempty_atstart));
- CMPTO(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0, empty_match_found_label);
- OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, str));
- CMPTO(SLJIT_NOT_EQUAL, TMP2, 0, STR_PTR, 0, empty_match_found_label);
- JUMPTO(SLJIT_JUMP, empty_match_backtrack_label);
- }
-
-common->currententry = common->entries;
-common->local_exit = TRUE;
-quit_label = common->quit_label;
-while (common->currententry != NULL)
- {
- /* Might add new entries. */
- compile_recurse(common);
- if (SLJIT_UNLIKELY(sljit_get_compiler_error(compiler)))
- {
- sljit_free_compiler(compiler);
- SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
- SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
- free_read_only_data(common->read_only_data_head, compiler->allocator_data);
- return;
- }
- flush_stubs(common);
- common->currententry = common->currententry->next;
- }
-common->local_exit = FALSE;
-common->quit_label = quit_label;
-
-/* Allocating stack, returns with PCRE_ERROR_JIT_STACKLIMIT if fails. */
-/* This is a (really) rare case. */
-set_jumps(common->stackalloc, LABEL());
-/* RETURN_ADDR is not a saved register. */
-sljit_emit_fast_enter(compiler, SLJIT_MEM1(SLJIT_SP), LOCALS0);
-OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), LOCALS1, TMP2, 0);
-OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack));
-OP1(SLJIT_MOV, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(struct sljit_stack, top), STACK_TOP, 0);
-OP2(SLJIT_ADD, TMP2, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(struct sljit_stack, limit), SLJIT_IMM, STACK_GROWTH_RATE);
-
-sljit_emit_ijump(compiler, SLJIT_CALL2, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_stack_resize));
-jump = CMP(SLJIT_NOT_EQUAL, SLJIT_RETURN_REG, 0, SLJIT_IMM, 0);
-OP1(SLJIT_MOV, TMP1, 0, ARGUMENTS, 0);
-OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(jit_arguments, stack));
-OP1(SLJIT_MOV, STACK_TOP, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(struct sljit_stack, top));
-OP1(SLJIT_MOV, STACK_LIMIT, 0, SLJIT_MEM1(TMP1), SLJIT_OFFSETOF(struct sljit_stack, limit));
-OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), LOCALS1);
-sljit_emit_fast_return(compiler, SLJIT_MEM1(SLJIT_SP), LOCALS0);
-
-/* Allocation failed. */
-JUMPHERE(jump);
-/* We break the return address cache here, but this is a really rare case. */
-OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_JIT_STACKLIMIT);
-JUMPTO(SLJIT_JUMP, common->quit_label);
-
-/* Call limit reached. */
-set_jumps(common->calllimit, LABEL());
-OP1(SLJIT_MOV, SLJIT_RETURN_REG, 0, SLJIT_IMM, PCRE_ERROR_MATCHLIMIT);
-JUMPTO(SLJIT_JUMP, common->quit_label);
-
-if (common->revertframes != NULL)
- {
- set_jumps(common->revertframes, LABEL());
- do_revertframes(common);
- }
-if (common->wordboundary != NULL)
- {
- set_jumps(common->wordboundary, LABEL());
- check_wordboundary(common);
- }
-if (common->anynewline != NULL)
- {
- set_jumps(common->anynewline, LABEL());
- check_anynewline(common);
- }
-if (common->hspace != NULL)
- {
- set_jumps(common->hspace, LABEL());
- check_hspace(common);
- }
-if (common->vspace != NULL)
- {
- set_jumps(common->vspace, LABEL());
- check_vspace(common);
- }
-if (common->casefulcmp != NULL)
- {
- set_jumps(common->casefulcmp, LABEL());
- do_casefulcmp(common);
- }
-if (common->caselesscmp != NULL)
- {
- set_jumps(common->caselesscmp, LABEL());
- do_caselesscmp(common);
- }
-if (common->reset_match != NULL)
- {
- set_jumps(common->reset_match, LABEL());
- do_reset_match(common, (re->top_bracket + 1) * 2);
- CMPTO(SLJIT_GREATER, STR_PTR, 0, TMP1, 0, continue_match_label);
- OP1(SLJIT_MOV, STR_PTR, 0, TMP1, 0);
- JUMPTO(SLJIT_JUMP, reset_match_label);
- }
-#ifdef SUPPORT_UTF
-#ifdef COMPILE_PCRE8
-if (common->utfreadchar != NULL)
- {
- set_jumps(common->utfreadchar, LABEL());
- do_utfreadchar(common);
- }
-if (common->utfreadchar16 != NULL)
- {
- set_jumps(common->utfreadchar16, LABEL());
- do_utfreadchar16(common);
- }
-if (common->utfreadtype8 != NULL)
- {
- set_jumps(common->utfreadtype8, LABEL());
- do_utfreadtype8(common);
- }
-#endif /* COMPILE_PCRE8 */
-#endif /* SUPPORT_UTF */
-#ifdef SUPPORT_UCP
-if (common->getucd != NULL)
- {
- set_jumps(common->getucd, LABEL());
- do_getucd(common);
- }
-#endif
-
-SLJIT_FREE(common->optimized_cbracket, compiler->allocator_data);
-SLJIT_FREE(common->private_data_ptrs, compiler->allocator_data);
-
-executable_func = sljit_generate_code(compiler);
-executable_size = sljit_get_generated_code_size(compiler);
-label_addr = common->label_addrs;
-while (label_addr != NULL)
- {
- *label_addr->update_addr = sljit_get_label_addr(label_addr->label);
- label_addr = label_addr->next;
- }
-sljit_free_compiler(compiler);
-if (executable_func == NULL)
- {
- free_read_only_data(common->read_only_data_head, compiler->allocator_data);
- return;
- }
-
-/* Reuse the function descriptor if possible. */
-if ((extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 && extra->executable_jit != NULL)
- functions = (executable_functions *)extra->executable_jit;
-else
- {
- /* Note: If your memory-checker has flagged the allocation below as a
- * memory leak, it is probably because you either forgot to call
- * pcre_free_study() (or pcre16_free_study()) on the pcre_extra (or
- * pcre16_extra) object, or you called said function after having
- * cleared the PCRE_EXTRA_EXECUTABLE_JIT bit from the "flags" field
- * of the object. (The function will only free the JIT data if the
- * bit remains set, as the bit indicates that the pointer to the data
- * is valid.)
- */
- functions = SLJIT_MALLOC(sizeof(executable_functions), compiler->allocator_data);
- if (functions == NULL)
- {
- /* This case is highly unlikely since we just recently
- freed a lot of memory. Not impossible though. */
- sljit_free_code(executable_func);
- free_read_only_data(common->read_only_data_head, compiler->allocator_data);
- return;
- }
- memset(functions, 0, sizeof(executable_functions));
- functions->top_bracket = (re->top_bracket + 1) * 2;
- functions->limit_match = (re->flags & PCRE_MLSET) != 0 ? re->limit_match : 0;
- extra->executable_jit = functions;
- extra->flags |= PCRE_EXTRA_EXECUTABLE_JIT;
- }
-
-functions->executable_funcs[mode] = executable_func;
-functions->read_only_data_heads[mode] = common->read_only_data_head;
-functions->executable_sizes[mode] = executable_size;
-}
-
-static SLJIT_NOINLINE int jit_machine_stack_exec(jit_arguments *arguments, void *executable_func)
-{
-union {
- void *executable_func;
- jit_function call_executable_func;
-} convert_executable_func;
-pcre_uint8 local_space[MACHINE_STACK_SIZE];
-struct sljit_stack local_stack;
-
-local_stack.top = (sljit_sw)&local_space;
-local_stack.base = local_stack.top;
-local_stack.limit = local_stack.base + MACHINE_STACK_SIZE;
-local_stack.max_limit = local_stack.limit;
-arguments->stack = &local_stack;
-convert_executable_func.executable_func = executable_func;
-return convert_executable_func.call_executable_func(arguments);
-}
-
-int
-PRIV(jit_exec)(const PUBL(extra) *extra_data, const pcre_uchar *subject,
- int length, int start_offset, int options, int *offsets, int offset_count)
-{
-executable_functions *functions = (executable_functions *)extra_data->executable_jit;
-union {
- void *executable_func;
- jit_function call_executable_func;
-} convert_executable_func;
-jit_arguments arguments;
-int max_offset_count;
-int retval;
-int mode = JIT_COMPILE;
-
-if ((options & PCRE_PARTIAL_HARD) != 0)
- mode = JIT_PARTIAL_HARD_COMPILE;
-else if ((options & PCRE_PARTIAL_SOFT) != 0)
- mode = JIT_PARTIAL_SOFT_COMPILE;
-
-if (functions->executable_funcs[mode] == NULL)
- return PCRE_ERROR_JIT_BADOPTION;
-
-/* Sanity checks should be handled by pcre_exec. */
-arguments.str = subject + start_offset;
-arguments.begin = subject;
-arguments.end = subject + length;
-arguments.mark_ptr = NULL;
-/* JIT decreases this value less frequently than the interpreter. */
-arguments.limit_match = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : (pcre_uint32)(extra_data->match_limit);
-if (functions->limit_match != 0 && functions->limit_match < arguments.limit_match)
- arguments.limit_match = functions->limit_match;
-arguments.notbol = (options & PCRE_NOTBOL) != 0;
-arguments.noteol = (options & PCRE_NOTEOL) != 0;
-arguments.notempty = (options & PCRE_NOTEMPTY) != 0;
-arguments.notempty_atstart = (options & PCRE_NOTEMPTY_ATSTART) != 0;
-arguments.offsets = offsets;
-arguments.callout_data = (extra_data->flags & PCRE_EXTRA_CALLOUT_DATA) != 0 ? extra_data->callout_data : NULL;
-arguments.real_offset_count = offset_count;
-
-/* pcre_exec() rounds offset_count to a multiple of 3, and then uses only 2/3 of
-the output vector for storing captured strings, with the remainder used as
-workspace. We don't need the workspace here. For compatibility, we limit the
-number of captured strings in the same way as pcre_exec(), so that the user
-gets the same result with and without JIT. */
-
-if (offset_count != 2)
- offset_count = ((offset_count - (offset_count % 3)) * 2) / 3;
-max_offset_count = functions->top_bracket;
-if (offset_count > max_offset_count)
- offset_count = max_offset_count;
-arguments.offset_count = offset_count;
-
-if (functions->callback)
- arguments.stack = (struct sljit_stack *)functions->callback(functions->userdata);
-else
- arguments.stack = (struct sljit_stack *)functions->userdata;
-
-if (arguments.stack == NULL)
- retval = jit_machine_stack_exec(&arguments, functions->executable_funcs[mode]);
-else
- {
- convert_executable_func.executable_func = functions->executable_funcs[mode];
- retval = convert_executable_func.call_executable_func(&arguments);
- }
-
-if (retval * 2 > offset_count)
- retval = 0;
-if ((extra_data->flags & PCRE_EXTRA_MARK) != 0)
- *(extra_data->mark) = arguments.mark_ptr;
-
-return retval;
-}
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_jit_exec(const pcre *argument_re, const pcre_extra *extra_data,
- PCRE_SPTR subject, int length, int start_offset, int options,
- int *offsets, int offset_count, pcre_jit_stack *stack)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_jit_exec(const pcre16 *argument_re, const pcre16_extra *extra_data,
- PCRE_SPTR16 subject, int length, int start_offset, int options,
- int *offsets, int offset_count, pcre16_jit_stack *stack)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_jit_exec(const pcre32 *argument_re, const pcre32_extra *extra_data,
- PCRE_SPTR32 subject, int length, int start_offset, int options,
- int *offsets, int offset_count, pcre32_jit_stack *stack)
-#endif
-{
-pcre_uchar *subject_ptr = (pcre_uchar *)subject;
-executable_functions *functions = (executable_functions *)extra_data->executable_jit;
-union {
- void *executable_func;
- jit_function call_executable_func;
-} convert_executable_func;
-jit_arguments arguments;
-int max_offset_count;
-int retval;
-int mode = JIT_COMPILE;
-
-SLJIT_UNUSED_ARG(argument_re);
-
-/* Plausibility checks */
-if ((options & ~PUBLIC_JIT_EXEC_OPTIONS) != 0) return PCRE_ERROR_JIT_BADOPTION;
-
-if ((options & PCRE_PARTIAL_HARD) != 0)
- mode = JIT_PARTIAL_HARD_COMPILE;
-else if ((options & PCRE_PARTIAL_SOFT) != 0)
- mode = JIT_PARTIAL_SOFT_COMPILE;
-
-if (functions->executable_funcs[mode] == NULL)
- return PCRE_ERROR_JIT_BADOPTION;
-
-/* Sanity checks should be handled by pcre_exec. */
-arguments.stack = (struct sljit_stack *)stack;
-arguments.str = subject_ptr + start_offset;
-arguments.begin = subject_ptr;
-arguments.end = subject_ptr + length;
-arguments.mark_ptr = NULL;
-/* JIT decreases this value less frequently than the interpreter. */
-arguments.limit_match = ((extra_data->flags & PCRE_EXTRA_MATCH_LIMIT) == 0) ? MATCH_LIMIT : (pcre_uint32)(extra_data->match_limit);
-if (functions->limit_match != 0 && functions->limit_match < arguments.limit_match)
- arguments.limit_match = functions->limit_match;
-arguments.notbol = (options & PCRE_NOTBOL) != 0;
-arguments.noteol = (options & PCRE_NOTEOL) != 0;
-arguments.notempty = (options & PCRE_NOTEMPTY) != 0;
-arguments.notempty_atstart = (options & PCRE_NOTEMPTY_ATSTART) != 0;
-arguments.offsets = offsets;
-arguments.callout_data = (extra_data->flags & PCRE_EXTRA_CALLOUT_DATA) != 0 ? extra_data->callout_data : NULL;
-arguments.real_offset_count = offset_count;
-
-/* pcre_exec() rounds offset_count to a multiple of 3, and then uses only 2/3 of
-the output vector for storing captured strings, with the remainder used as
-workspace. We don't need the workspace here. For compatibility, we limit the
-number of captured strings in the same way as pcre_exec(), so that the user
-gets the same result with and without JIT. */
-
-if (offset_count != 2)
- offset_count = ((offset_count - (offset_count % 3)) * 2) / 3;
-max_offset_count = functions->top_bracket;
-if (offset_count > max_offset_count)
- offset_count = max_offset_count;
-arguments.offset_count = offset_count;
-
-convert_executable_func.executable_func = functions->executable_funcs[mode];
-retval = convert_executable_func.call_executable_func(&arguments);
-
-if (retval * 2 > offset_count)
- retval = 0;
-if ((extra_data->flags & PCRE_EXTRA_MARK) != 0)
- *(extra_data->mark) = arguments.mark_ptr;
-
-return retval;
-}
-
-void
-PRIV(jit_free)(void *executable_funcs)
-{
-int i;
-executable_functions *functions = (executable_functions *)executable_funcs;
-for (i = 0; i < JIT_NUMBER_OF_COMPILE_MODES; i++)
- {
- if (functions->executable_funcs[i] != NULL)
- sljit_free_code(functions->executable_funcs[i]);
- free_read_only_data(functions->read_only_data_heads[i], NULL);
- }
-SLJIT_FREE(functions, compiler->allocator_data);
-}
-
-int
-PRIV(jit_get_size)(void *executable_funcs)
-{
-int i;
-sljit_uw size = 0;
-sljit_uw *executable_sizes = ((executable_functions *)executable_funcs)->executable_sizes;
-for (i = 0; i < JIT_NUMBER_OF_COMPILE_MODES; i++)
- size += executable_sizes[i];
-return (int)size;
-}
-
-const char*
-PRIV(jit_get_target)(void)
-{
-return sljit_get_platform_name();
-}
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DECL pcre_jit_stack *
-pcre_jit_stack_alloc(int startsize, int maxsize)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DECL pcre16_jit_stack *
-pcre16_jit_stack_alloc(int startsize, int maxsize)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DECL pcre32_jit_stack *
-pcre32_jit_stack_alloc(int startsize, int maxsize)
-#endif
-{
-if (startsize < 1 || maxsize < 1)
- return NULL;
-if (startsize > maxsize)
- startsize = maxsize;
-startsize = (startsize + STACK_GROWTH_RATE - 1) & ~(STACK_GROWTH_RATE - 1);
-maxsize = (maxsize + STACK_GROWTH_RATE - 1) & ~(STACK_GROWTH_RATE - 1);
-return (PUBL(jit_stack)*)sljit_allocate_stack(startsize, maxsize, NULL);
-}
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DECL void
-pcre_jit_stack_free(pcre_jit_stack *stack)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DECL void
-pcre16_jit_stack_free(pcre16_jit_stack *stack)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DECL void
-pcre32_jit_stack_free(pcre32_jit_stack *stack)
-#endif
-{
-sljit_free_stack((struct sljit_stack *)stack, NULL);
-}
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DECL void
-pcre_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DECL void
-pcre16_assign_jit_stack(pcre16_extra *extra, pcre16_jit_callback callback, void *userdata)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DECL void
-pcre32_assign_jit_stack(pcre32_extra *extra, pcre32_jit_callback callback, void *userdata)
-#endif
-{
-executable_functions *functions;
-if (extra != NULL &&
- (extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&
- extra->executable_jit != NULL)
- {
- functions = (executable_functions *)extra->executable_jit;
- functions->callback = callback;
- functions->userdata = userdata;
- }
-}
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DECL void
-pcre_jit_free_unused_memory(void)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DECL void
-pcre16_jit_free_unused_memory(void)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DECL void
-pcre32_jit_free_unused_memory(void)
-#endif
-{
-sljit_free_unused_memory_exec();
-}
-
-#else /* SUPPORT_JIT */
-
-/* These are dummy functions to avoid linking errors when JIT support is not
-being compiled. */
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DECL pcre_jit_stack *
-pcre_jit_stack_alloc(int startsize, int maxsize)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DECL pcre16_jit_stack *
-pcre16_jit_stack_alloc(int startsize, int maxsize)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DECL pcre32_jit_stack *
-pcre32_jit_stack_alloc(int startsize, int maxsize)
-#endif
-{
-(void)startsize;
-(void)maxsize;
-return NULL;
-}
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DECL void
-pcre_jit_stack_free(pcre_jit_stack *stack)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DECL void
-pcre16_jit_stack_free(pcre16_jit_stack *stack)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DECL void
-pcre32_jit_stack_free(pcre32_jit_stack *stack)
-#endif
-{
-(void)stack;
-}
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DECL void
-pcre_assign_jit_stack(pcre_extra *extra, pcre_jit_callback callback, void *userdata)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DECL void
-pcre16_assign_jit_stack(pcre16_extra *extra, pcre16_jit_callback callback, void *userdata)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DECL void
-pcre32_assign_jit_stack(pcre32_extra *extra, pcre32_jit_callback callback, void *userdata)
-#endif
-{
-(void)extra;
-(void)callback;
-(void)userdata;
-}
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DECL void
-pcre_jit_free_unused_memory(void)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DECL void
-pcre16_jit_free_unused_memory(void)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DECL void
-pcre32_jit_free_unused_memory(void)
-#endif
-{
-}
-
-#endif
-
-/* End of pcre_jit_compile.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_maketables.c r-base-3.3.1/src/extra/pcre/pcre_maketables.c
--- r-base-3.2.3/src/extra/pcre/pcre_maketables.c 2013-12-30 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_maketables.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,156 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2012 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains the external function pcre_maketables(), which builds
-character tables for PCRE in the current locale. The file is compiled on its
-own as part of the PCRE library. However, it is also included in the
-compilation of dftables.c, in which case the macro DFTABLES is defined. */
-
-
-#ifndef DFTABLES
-# ifdef HAVE_CONFIG_H
-# include "config.h"
-# endif
-# include "pcre_internal.h"
-#endif
-
-
-/*************************************************
-* Create PCRE character tables *
-*************************************************/
-
-/* This function builds a set of character tables for use by PCRE and returns
-a pointer to them. They are build using the ctype functions, and consequently
-their contents will depend upon the current locale setting. When compiled as
-part of the library, the store is obtained via PUBL(malloc)(), but when
-compiled inside dftables, use malloc().
-
-Arguments: none
-Returns: pointer to the contiguous block of data
-*/
-
-#if defined COMPILE_PCRE8
-const unsigned char *
-pcre_maketables(void)
-#elif defined COMPILE_PCRE16
-const unsigned char *
-pcre16_maketables(void)
-#elif defined COMPILE_PCRE32
-const unsigned char *
-pcre32_maketables(void)
-#endif
-{
-unsigned char *yield, *p;
-int i;
-
-#ifndef DFTABLES
-yield = (unsigned char*)(PUBL(malloc))(tables_length);
-#else
-yield = (unsigned char*)malloc(tables_length);
-#endif
-
-if (yield == NULL) return NULL;
-p = yield;
-
-/* First comes the lower casing table */
-
-for (i = 0; i < 256; i++) *p++ = tolower(i);
-
-/* Next the case-flipping table */
-
-for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);
-
-/* Then the character class tables. Don't try to be clever and save effort on
-exclusive ones - in some locales things may be different.
-
-Note that the table for "space" includes everything "isspace" gives, including
-VT in the default locale. This makes it work for the POSIX class [:space:].
-From release 8.34 is is also correct for Perl space, because Perl added VT at
-release 5.18.
-
-Note also that it is possible for a character to be alnum or alpha without
-being lower or upper, such as "male and female ordinals" (\xAA and \xBA) in the
-fr_FR locale (at least under Debian Linux's locales as of 12/2005). So we must
-test for alnum specially. */
-
-memset(p, 0, cbit_length);
-for (i = 0; i < 256; i++)
- {
- if (isdigit(i)) p[cbit_digit + i/8] |= 1 << (i&7);
- if (isupper(i)) p[cbit_upper + i/8] |= 1 << (i&7);
- if (islower(i)) p[cbit_lower + i/8] |= 1 << (i&7);
- if (isalnum(i)) p[cbit_word + i/8] |= 1 << (i&7);
- if (i == '_') p[cbit_word + i/8] |= 1 << (i&7);
- if (isspace(i)) p[cbit_space + i/8] |= 1 << (i&7);
- if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);
- if (isgraph(i)) p[cbit_graph + i/8] |= 1 << (i&7);
- if (isprint(i)) p[cbit_print + i/8] |= 1 << (i&7);
- if (ispunct(i)) p[cbit_punct + i/8] |= 1 << (i&7);
- if (iscntrl(i)) p[cbit_cntrl + i/8] |= 1 << (i&7);
- }
-p += cbit_length;
-
-/* Finally, the character type table. In this, we used to exclude VT from the
-white space chars, because Perl didn't recognize it as such for \s and for
-comments within regexes. However, Perl changed at release 5.18, so PCRE changed
-at release 8.34. */
-
-for (i = 0; i < 256; i++)
- {
- int x = 0;
- if (isspace(i)) x += ctype_space;
- if (isalpha(i)) x += ctype_letter;
- if (isdigit(i)) x += ctype_digit;
- if (isxdigit(i)) x += ctype_xdigit;
- if (isalnum(i) || i == '_') x += ctype_word;
-
- /* Note: strchr includes the terminating zero in the characters it considers.
- In this instance, that is ok because we want binary zero to be flagged as a
- meta-character, which in this sense is any character that terminates a run
- of data characters. */
-
- if (strchr("\\*+?{^.$|()[", i) != 0) x += ctype_meta;
- *p++ = x;
- }
-
-return yield;
-}
-
-/* End of pcre_maketables.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_newline.c r-base-3.3.1/src/extra/pcre/pcre_newline.c
--- r-base-3.2.3/src/extra/pcre/pcre_newline.c 2013-02-04 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_newline.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,210 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2012 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains internal functions for testing newlines when more than
-one kind of newline is to be recognized. When a newline is found, its length is
-returned. In principle, we could implement several newline "types", each
-referring to a different set of newline characters. At present, PCRE supports
-only NLTYPE_FIXED, which gets handled without these functions, NLTYPE_ANYCRLF,
-and NLTYPE_ANY. The full list of Unicode newline characters is taken from
-http://unicode.org/unicode/reports/tr18/. */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pcre_internal.h"
-
-
-
-/*************************************************
-* Check for newline at given position *
-*************************************************/
-
-/* It is guaranteed that the initial value of ptr is less than the end of the
-string that is being processed.
-
-Arguments:
- ptr pointer to possible newline
- type the newline type
- endptr pointer to the end of the string
- lenptr where to return the length
- utf TRUE if in utf mode
-
-Returns: TRUE or FALSE
-*/
-
-BOOL
-PRIV(is_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR endptr, int *lenptr,
- BOOL utf)
-{
-pcre_uint32 c;
-(void)utf;
-#ifdef SUPPORT_UTF
-if (utf)
- {
- GETCHAR(c, ptr);
- }
-else
-#endif /* SUPPORT_UTF */
- c = *ptr;
-
-/* Note that this function is called only for ANY or ANYCRLF. */
-
-if (type == NLTYPE_ANYCRLF) switch(c)
- {
- case CHAR_LF: *lenptr = 1; return TRUE;
- case CHAR_CR: *lenptr = (ptr < endptr - 1 && ptr[1] == CHAR_LF)? 2 : 1;
- return TRUE;
- default: return FALSE;
- }
-
-/* NLTYPE_ANY */
-
-else switch(c)
- {
-#ifdef EBCDIC
- case CHAR_NEL:
-#endif
- case CHAR_LF:
- case CHAR_VT:
- case CHAR_FF: *lenptr = 1; return TRUE;
-
- case CHAR_CR:
- *lenptr = (ptr < endptr - 1 && ptr[1] == CHAR_LF)? 2 : 1;
- return TRUE;
-
-#ifndef EBCDIC
-#ifdef COMPILE_PCRE8
- case CHAR_NEL: *lenptr = utf? 2 : 1; return TRUE;
- case 0x2028: /* LS */
- case 0x2029: *lenptr = 3; return TRUE; /* PS */
-#else /* COMPILE_PCRE16 || COMPILE_PCRE32 */
- case CHAR_NEL:
- case 0x2028: /* LS */
- case 0x2029: *lenptr = 1; return TRUE; /* PS */
-#endif /* COMPILE_PCRE8 */
-#endif /* Not EBCDIC */
-
- default: return FALSE;
- }
-}
-
-
-
-/*************************************************
-* Check for newline at previous position *
-*************************************************/
-
-/* It is guaranteed that the initial value of ptr is greater than the start of
-the string that is being processed.
-
-Arguments:
- ptr pointer to possible newline
- type the newline type
- startptr pointer to the start of the string
- lenptr where to return the length
- utf TRUE if in utf mode
-
-Returns: TRUE or FALSE
-*/
-
-BOOL
-PRIV(was_newline)(PCRE_PUCHAR ptr, int type, PCRE_PUCHAR startptr, int *lenptr,
- BOOL utf)
-{
-pcre_uint32 c;
-(void)utf;
-ptr--;
-#ifdef SUPPORT_UTF
-if (utf)
- {
- BACKCHAR(ptr);
- GETCHAR(c, ptr);
- }
-else
-#endif /* SUPPORT_UTF */
- c = *ptr;
-
-/* Note that this function is called only for ANY or ANYCRLF. */
-
-if (type == NLTYPE_ANYCRLF) switch(c)
- {
- case CHAR_LF:
- *lenptr = (ptr > startptr && ptr[-1] == CHAR_CR)? 2 : 1;
- return TRUE;
-
- case CHAR_CR: *lenptr = 1; return TRUE;
- default: return FALSE;
- }
-
-/* NLTYPE_ANY */
-
-else switch(c)
- {
- case CHAR_LF:
- *lenptr = (ptr > startptr && ptr[-1] == CHAR_CR)? 2 : 1;
- return TRUE;
-
-#ifdef EBCDIC
- case CHAR_NEL:
-#endif
- case CHAR_VT:
- case CHAR_FF:
- case CHAR_CR: *lenptr = 1; return TRUE;
-
-#ifndef EBCDIC
-#ifdef COMPILE_PCRE8
- case CHAR_NEL: *lenptr = utf? 2 : 1; return TRUE;
- case 0x2028: /* LS */
- case 0x2029: *lenptr = 3; return TRUE; /* PS */
-#else /* COMPILE_PCRE16 || COMPILE_PCRE32 */
- case CHAR_NEL:
- case 0x2028: /* LS */
- case 0x2029: *lenptr = 1; return TRUE; /* PS */
-#endif /* COMPILE_PCRE8 */
-#endif /* NotEBCDIC */
-
- default: return FALSE;
- }
-}
-
-/* End of pcre_newline.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_ord2utf8.c r-base-3.3.1/src/extra/pcre/pcre_ord2utf8.c
--- r-base-3.2.3/src/extra/pcre/pcre_ord2utf8.c 2013-02-04 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_ord2utf8.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,94 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2012 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This file contains a private PCRE function that converts an ordinal
-character value into a UTF8 string. */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#define COMPILE_PCRE8
-
-#include "pcre_internal.h"
-
-/*************************************************
-* Convert character value to UTF-8 *
-*************************************************/
-
-/* This function takes an integer value in the range 0 - 0x10ffff
-and encodes it as a UTF-8 character in 1 to 4 pcre_uchars.
-
-Arguments:
- cvalue the character value
- buffer pointer to buffer for result - at least 6 pcre_uchars long
-
-Returns: number of characters placed in the buffer
-*/
-
-unsigned
-int
-PRIV(ord2utf)(pcre_uint32 cvalue, pcre_uchar *buffer)
-{
-#ifdef SUPPORT_UTF
-
-register int i, j;
-
-for (i = 0; i < PRIV(utf8_table1_size); i++)
- if ((int)cvalue <= PRIV(utf8_table1)[i]) break;
-buffer += i;
-for (j = i; j > 0; j--)
- {
- *buffer-- = 0x80 | (cvalue & 0x3f);
- cvalue >>= 6;
- }
-*buffer = PRIV(utf8_table2)[i] | cvalue;
-return i + 1;
-
-#else
-
-(void)(cvalue); /* Keep compiler happy; this function won't ever be */
-(void)(buffer); /* called when SUPPORT_UTF is not defined. */
-return 0;
-
-#endif
-}
-
-/* End of pcre_ord2utf8.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_refcount.c r-base-3.3.1/src/extra/pcre/pcre_refcount.c
--- r-base-3.2.3/src/extra/pcre/pcre_refcount.c 2013-02-04 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_refcount.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,92 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2012 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains the external function pcre_refcount(), which is an
-auxiliary function that can be used to maintain a reference count in a compiled
-pattern data block. This might be helpful in applications where the block is
-shared by different users. */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pcre_internal.h"
-
-
-/*************************************************
-* Maintain reference count *
-*************************************************/
-
-/* The reference count is a 16-bit field, initialized to zero. It is not
-possible to transfer a non-zero count from one host to a different host that
-has a different byte order - though I can't see why anyone in their right mind
-would ever want to do that!
-
-Arguments:
- argument_re points to compiled code
- adjust value to add to the count
-
-Returns: the (possibly updated) count value (a non-negative number), or
- a negative error number
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre_refcount(pcre *argument_re, int adjust)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre16_refcount(pcre16 *argument_re, int adjust)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN int PCRE_CALL_CONVENTION
-pcre32_refcount(pcre32 *argument_re, int adjust)
-#endif
-{
-REAL_PCRE *re = (REAL_PCRE *)argument_re;
-if (re == NULL) return PCRE_ERROR_NULL;
-if (re->magic_number != MAGIC_NUMBER) return PCRE_ERROR_BADMAGIC;
-if ((re->flags & PCRE_MODE) == 0) return PCRE_ERROR_BADMODE;
-re->ref_count = (-adjust > re->ref_count)? 0 :
- (adjust + re->ref_count > 65535)? 65535 :
- re->ref_count + adjust;
-return re->ref_count;
-}
-
-/* End of pcre_refcount.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_study.c r-base-3.3.1/src/extra/pcre/pcre_study.c
--- r-base-3.2.3/src/extra/pcre/pcre_study.c 2015-11-26 23:15:13.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_study.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,1686 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2012 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains the external function pcre_study(), along with local
-supporting functions. */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pcre_internal.h"
-
-#define SET_BIT(c) start_bits[c/8] |= (1 << (c&7))
-
-/* Returns from set_start_bits() */
-
-enum { SSB_FAIL, SSB_DONE, SSB_CONTINUE, SSB_UNKNOWN };
-
-
-
-/*************************************************
-* Find the minimum subject length for a group *
-*************************************************/
-
-/* Scan a parenthesized group and compute the minimum length of subject that
-is needed to match it. This is a lower bound; it does not mean there is a
-string of that length that matches. In UTF8 mode, the result is in characters
-rather than bytes.
-
-Arguments:
- re compiled pattern block
- code pointer to start of group (the bracket)
- startcode pointer to start of the whole pattern's code
- options the compiling options
- recurses chain of recurse_check to catch mutual recursion
- countptr pointer to call count (to catch over complexity)
-
-Returns: the minimum length
- -1 if \C in UTF-8 mode or (*ACCEPT) was encountered
- -2 internal error (missing capturing bracket)
- -3 internal error (opcode not listed)
-*/
-
-static int
-find_minlength(const REAL_PCRE *re, const pcre_uchar *code,
- const pcre_uchar *startcode, int options, recurse_check *recurses,
- int *countptr)
-{
-int length = -1;
-/* PCRE_UTF16 has the same value as PCRE_UTF8. */
-BOOL utf = (options & PCRE_UTF8) != 0;
-BOOL had_recurse = FALSE;
-recurse_check this_recurse;
-register int branchlength = 0;
-register pcre_uchar *cc = (pcre_uchar *)code + 1 + LINK_SIZE;
-
-if ((*countptr)++ > 1000) return -1; /* too complex */
-
-if (*code == OP_CBRA || *code == OP_SCBRA ||
- *code == OP_CBRAPOS || *code == OP_SCBRAPOS) cc += IMM2_SIZE;
-
-/* Scan along the opcodes for this branch. If we get to the end of the
-branch, check the length against that of the other branches. */
-
-for (;;)
- {
- int d, min;
- pcre_uchar *cs, *ce;
- register pcre_uchar op = *cc;
-
- switch (op)
- {
- case OP_COND:
- case OP_SCOND:
-
- /* If there is only one branch in a condition, the implied branch has zero
- length, so we don't add anything. This covers the DEFINE "condition"
- automatically. */
-
- cs = cc + GET(cc, 1);
- if (*cs != OP_ALT)
- {
- cc = cs + 1 + LINK_SIZE;
- break;
- }
-
- /* Otherwise we can fall through and treat it the same as any other
- subpattern. */
-
- case OP_CBRA:
- case OP_SCBRA:
- case OP_BRA:
- case OP_SBRA:
- case OP_CBRAPOS:
- case OP_SCBRAPOS:
- case OP_BRAPOS:
- case OP_SBRAPOS:
- case OP_ONCE:
- case OP_ONCE_NC:
- d = find_minlength(re, cc, startcode, options, recurses, countptr);
- if (d < 0) return d;
- branchlength += d;
- do cc += GET(cc, 1); while (*cc == OP_ALT);
- cc += 1 + LINK_SIZE;
- break;
-
- /* ACCEPT makes things far too complicated; we have to give up. */
-
- case OP_ACCEPT:
- case OP_ASSERT_ACCEPT:
- return -1;
-
- /* Reached end of a branch; if it's a ket it is the end of a nested
- call. If it's ALT it is an alternation in a nested call. If it is END it's
- the end of the outer call. All can be handled by the same code. If an
- ACCEPT was previously encountered, use the length that was in force at that
- time, and pass back the shortest ACCEPT length. */
-
- case OP_ALT:
- case OP_KET:
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_KETRPOS:
- case OP_END:
- if (length < 0 || (!had_recurse && branchlength < length))
- length = branchlength;
- if (op != OP_ALT) return length;
- cc += 1 + LINK_SIZE;
- branchlength = 0;
- had_recurse = FALSE;
- break;
-
- /* Skip over assertive subpatterns */
-
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- do cc += GET(cc, 1); while (*cc == OP_ALT);
- /* Fall through */
-
- /* Skip over things that don't match chars */
-
- case OP_REVERSE:
- case OP_CREF:
- case OP_DNCREF:
- case OP_RREF:
- case OP_DNRREF:
- case OP_DEF:
- case OP_CALLOUT:
- case OP_SOD:
- case OP_SOM:
- case OP_EOD:
- case OP_EODN:
- case OP_CIRC:
- case OP_CIRCM:
- case OP_DOLL:
- case OP_DOLLM:
- case OP_NOT_WORD_BOUNDARY:
- case OP_WORD_BOUNDARY:
- cc += PRIV(OP_lengths)[*cc];
- break;
-
- /* Skip over a subpattern that has a {0} or {0,x} quantifier */
-
- case OP_BRAZERO:
- case OP_BRAMINZERO:
- case OP_BRAPOSZERO:
- case OP_SKIPZERO:
- cc += PRIV(OP_lengths)[*cc];
- do cc += GET(cc, 1); while (*cc == OP_ALT);
- cc += 1 + LINK_SIZE;
- break;
-
- /* Handle literal characters and + repetitions */
-
- case OP_CHAR:
- case OP_CHARI:
- case OP_NOT:
- case OP_NOTI:
- case OP_PLUS:
- case OP_PLUSI:
- case OP_MINPLUS:
- case OP_MINPLUSI:
- case OP_POSPLUS:
- case OP_POSPLUSI:
- case OP_NOTPLUS:
- case OP_NOTPLUSI:
- case OP_NOTMINPLUS:
- case OP_NOTMINPLUSI:
- case OP_NOTPOSPLUS:
- case OP_NOTPOSPLUSI:
- branchlength++;
- cc += 2;
-#ifdef SUPPORT_UTF
- if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- break;
-
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEPOSPLUS:
- branchlength++;
- cc += (cc[1] == OP_PROP || cc[1] == OP_NOTPROP)? 4 : 2;
- break;
-
- /* Handle exact repetitions. The count is already in characters, but we
- need to skip over a multibyte character in UTF8 mode. */
-
- case OP_EXACT:
- case OP_EXACTI:
- case OP_NOTEXACT:
- case OP_NOTEXACTI:
- branchlength += GET2(cc,1);
- cc += 2 + IMM2_SIZE;
-#ifdef SUPPORT_UTF
- if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- break;
-
- case OP_TYPEEXACT:
- branchlength += GET2(cc,1);
- cc += 2 + IMM2_SIZE + ((cc[1 + IMM2_SIZE] == OP_PROP
- || cc[1 + IMM2_SIZE] == OP_NOTPROP)? 2 : 0);
- break;
-
- /* Handle single-char non-literal matchers */
-
- case OP_PROP:
- case OP_NOTPROP:
- cc += 2;
- /* Fall through */
-
- case OP_NOT_DIGIT:
- case OP_DIGIT:
- case OP_NOT_WHITESPACE:
- case OP_WHITESPACE:
- case OP_NOT_WORDCHAR:
- case OP_WORDCHAR:
- case OP_ANY:
- case OP_ALLANY:
- case OP_EXTUNI:
- case OP_HSPACE:
- case OP_NOT_HSPACE:
- case OP_VSPACE:
- case OP_NOT_VSPACE:
- branchlength++;
- cc++;
- break;
-
- /* "Any newline" might match two characters, but it also might match just
- one. */
-
- case OP_ANYNL:
- branchlength += 1;
- cc++;
- break;
-
- /* The single-byte matcher means we can't proceed in UTF-8 mode. (In
- non-UTF-8 mode \C will actually be turned into OP_ALLANY, so won't ever
- appear, but leave the code, just in case.) */
-
- case OP_ANYBYTE:
-#ifdef SUPPORT_UTF
- if (utf) return -1;
-#endif
- branchlength++;
- cc++;
- break;
-
- /* For repeated character types, we have to test for \p and \P, which have
- an extra two bytes of parameters. */
-
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- case OP_TYPEPOSSTAR:
- case OP_TYPEPOSQUERY:
- if (cc[1] == OP_PROP || cc[1] == OP_NOTPROP) cc += 2;
- cc += PRIV(OP_lengths)[op];
- break;
-
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- case OP_TYPEPOSUPTO:
- if (cc[1 + IMM2_SIZE] == OP_PROP
- || cc[1 + IMM2_SIZE] == OP_NOTPROP) cc += 2;
- cc += PRIV(OP_lengths)[op];
- break;
-
- /* Check a class for variable quantification */
-
- case OP_CLASS:
- case OP_NCLASS:
-#if defined SUPPORT_UTF || defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- case OP_XCLASS:
- /* The original code caused an unsigned overflow in 64 bit systems,
- so now we use a conditional statement. */
- if (op == OP_XCLASS)
- cc += GET(cc, 1);
- else
- cc += PRIV(OP_lengths)[OP_CLASS];
-#else
- cc += PRIV(OP_lengths)[OP_CLASS];
-#endif
-
- switch (*cc)
- {
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRPOSPLUS:
- branchlength++;
- /* Fall through */
-
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- case OP_CRPOSSTAR:
- case OP_CRPOSQUERY:
- cc++;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- case OP_CRPOSRANGE:
- branchlength += GET2(cc,1);
- cc += 1 + 2 * IMM2_SIZE;
- break;
-
- default:
- branchlength++;
- break;
- }
- break;
-
- /* Backreferences and subroutine calls are treated in the same way: we find
- the minimum length for the subpattern. A recursion, however, causes an
- a flag to be set that causes the length of this branch to be ignored. The
- logic is that a recursion can only make sense if there is another
- alternation that stops the recursing. That will provide the minimum length
- (when no recursion happens). A backreference within the group that it is
- referencing behaves in the same way.
-
- If PCRE_JAVASCRIPT_COMPAT is set, a backreference to an unset bracket
- matches an empty string (by default it causes a matching failure), so in
- that case we must set the minimum length to zero. */
-
- case OP_DNREF: /* Duplicate named pattern back reference */
- case OP_DNREFI:
- if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)
- {
- int count = GET2(cc, 1+IMM2_SIZE);
- pcre_uchar *slot = (pcre_uchar *)re +
- re->name_table_offset + GET2(cc, 1) * re->name_entry_size;
- d = INT_MAX;
- while (count-- > 0)
- {
- ce = cs = (pcre_uchar *)PRIV(find_bracket)(startcode, utf, GET2(slot, 0));
- if (cs == NULL) return -2;
- do ce += GET(ce, 1); while (*ce == OP_ALT);
- if (cc > cs && cc < ce) /* Simple recursion */
- {
- d = 0;
- had_recurse = TRUE;
- break;
- }
- else
- {
- recurse_check *r = recurses;
- for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break;
- if (r != NULL) /* Mutual recursion */
- {
- d = 0;
- had_recurse = TRUE;
- break;
- }
- else
- {
- int dd;
- this_recurse.prev = recurses;
- this_recurse.group = cs;
- dd = find_minlength(re, cs, startcode, options, &this_recurse,
- countptr);
- if (dd < d) d = dd;
- }
- }
- slot += re->name_entry_size;
- }
- }
- else d = 0;
- cc += 1 + 2*IMM2_SIZE;
- goto REPEAT_BACK_REFERENCE;
-
- case OP_REF: /* Single back reference */
- case OP_REFI:
- if ((options & PCRE_JAVASCRIPT_COMPAT) == 0)
- {
- ce = cs = (pcre_uchar *)PRIV(find_bracket)(startcode, utf, GET2(cc, 1));
- if (cs == NULL) return -2;
- do ce += GET(ce, 1); while (*ce == OP_ALT);
- if (cc > cs && cc < ce) /* Simple recursion */
- {
- d = 0;
- had_recurse = TRUE;
- }
- else
- {
- recurse_check *r = recurses;
- for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break;
- if (r != NULL) /* Mutual recursion */
- {
- d = 0;
- had_recurse = TRUE;
- }
- else
- {
- this_recurse.prev = recurses;
- this_recurse.group = cs;
- d = find_minlength(re, cs, startcode, options, &this_recurse,
- countptr);
- }
- }
- }
- else d = 0;
- cc += 1 + IMM2_SIZE;
-
- /* Handle repeated back references */
-
- REPEAT_BACK_REFERENCE:
- switch (*cc)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- case OP_CRPOSSTAR:
- case OP_CRPOSQUERY:
- min = 0;
- cc++;
- break;
-
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRPOSPLUS:
- min = 1;
- cc++;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- case OP_CRPOSRANGE:
- min = GET2(cc, 1);
- cc += 1 + 2 * IMM2_SIZE;
- break;
-
- default:
- min = 1;
- break;
- }
-
- branchlength += min * d;
- break;
-
- /* We can easily detect direct recursion, but not mutual recursion. This is
- caught by a recursion depth count. */
-
- case OP_RECURSE:
- cs = ce = (pcre_uchar *)startcode + GET(cc, 1);
- do ce += GET(ce, 1); while (*ce == OP_ALT);
- if (cc > cs && cc < ce) /* Simple recursion */
- had_recurse = TRUE;
- else
- {
- recurse_check *r = recurses;
- for (r = recurses; r != NULL; r = r->prev) if (r->group == cs) break;
- if (r != NULL) /* Mutual recursion */
- had_recurse = TRUE;
- else
- {
- this_recurse.prev = recurses;
- this_recurse.group = cs;
- branchlength += find_minlength(re, cs, startcode, options,
- &this_recurse, countptr);
- }
- }
- cc += 1 + LINK_SIZE;
- break;
-
- /* Anything else does not or need not match a character. We can get the
- item's length from the table, but for those that can match zero occurrences
- of a character, we must take special action for UTF-8 characters. As it
- happens, the "NOT" versions of these opcodes are used at present only for
- ASCII characters, so they could be omitted from this list. However, in
- future that may change, so we include them here so as not to leave a
- gotcha for a future maintainer. */
-
- case OP_UPTO:
- case OP_UPTOI:
- case OP_NOTUPTO:
- case OP_NOTUPTOI:
- case OP_MINUPTO:
- case OP_MINUPTOI:
- case OP_NOTMINUPTO:
- case OP_NOTMINUPTOI:
- case OP_POSUPTO:
- case OP_POSUPTOI:
- case OP_NOTPOSUPTO:
- case OP_NOTPOSUPTOI:
-
- case OP_STAR:
- case OP_STARI:
- case OP_NOTSTAR:
- case OP_NOTSTARI:
- case OP_MINSTAR:
- case OP_MINSTARI:
- case OP_NOTMINSTAR:
- case OP_NOTMINSTARI:
- case OP_POSSTAR:
- case OP_POSSTARI:
- case OP_NOTPOSSTAR:
- case OP_NOTPOSSTARI:
-
- case OP_QUERY:
- case OP_QUERYI:
- case OP_NOTQUERY:
- case OP_NOTQUERYI:
- case OP_MINQUERY:
- case OP_MINQUERYI:
- case OP_NOTMINQUERY:
- case OP_NOTMINQUERYI:
- case OP_POSQUERY:
- case OP_POSQUERYI:
- case OP_NOTPOSQUERY:
- case OP_NOTPOSQUERYI:
-
- cc += PRIV(OP_lengths)[op];
-#ifdef SUPPORT_UTF
- if (utf && HAS_EXTRALEN(cc[-1])) cc += GET_EXTRALEN(cc[-1]);
-#endif
- break;
-
- /* Skip these, but we need to add in the name length. */
-
- case OP_MARK:
- case OP_PRUNE_ARG:
- case OP_SKIP_ARG:
- case OP_THEN_ARG:
- cc += PRIV(OP_lengths)[op] + cc[1];
- break;
-
- /* The remaining opcodes are just skipped over. */
-
- case OP_CLOSE:
- case OP_COMMIT:
- case OP_FAIL:
- case OP_PRUNE:
- case OP_SET_SOM:
- case OP_SKIP:
- case OP_THEN:
- cc += PRIV(OP_lengths)[op];
- break;
-
- /* This should not occur: we list all opcodes explicitly so that when
- new ones get added they are properly considered. */
-
- default:
- return -3;
- }
- }
-/* Control never gets here */
-}
-
-
-
-/*************************************************
-* Set a bit and maybe its alternate case *
-*************************************************/
-
-/* Given a character, set its first byte's bit in the table, and also the
-corresponding bit for the other version of a letter if we are caseless. In
-UTF-8 mode, for characters greater than 127, we can only do the caseless thing
-when Unicode property support is available.
-
-Arguments:
- start_bits points to the bit map
- p points to the character
- caseless the caseless flag
- cd the block with char table pointers
- utf TRUE for UTF-8 / UTF-16 / UTF-32 mode
-
-Returns: pointer after the character
-*/
-
-static const pcre_uchar *
-set_table_bit(pcre_uint8 *start_bits, const pcre_uchar *p, BOOL caseless,
- compile_data *cd, BOOL utf)
-{
-pcre_uint32 c = *p;
-
-#ifdef COMPILE_PCRE8
-SET_BIT(c);
-
-#ifdef SUPPORT_UTF
-if (utf && c > 127)
- {
- GETCHARINC(c, p);
-#ifdef SUPPORT_UCP
- if (caseless)
- {
- pcre_uchar buff[6];
- c = UCD_OTHERCASE(c);
- (void)PRIV(ord2utf)(c, buff);
- SET_BIT(buff[0]);
- }
-#endif /* Not SUPPORT_UCP */
- return p;
- }
-#else /* Not SUPPORT_UTF */
-(void)(utf); /* Stops warning for unused parameter */
-#endif /* SUPPORT_UTF */
-
-/* Not UTF-8 mode, or character is less than 127. */
-
-if (caseless && (cd->ctypes[c] & ctype_letter) != 0) SET_BIT(cd->fcc[c]);
-return p + 1;
-#endif /* COMPILE_PCRE8 */
-
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
-if (c > 0xff)
- {
- c = 0xff;
- caseless = FALSE;
- }
-SET_BIT(c);
-
-#ifdef SUPPORT_UTF
-if (utf && c > 127)
- {
- GETCHARINC(c, p);
-#ifdef SUPPORT_UCP
- if (caseless)
- {
- c = UCD_OTHERCASE(c);
- if (c > 0xff)
- c = 0xff;
- SET_BIT(c);
- }
-#endif /* SUPPORT_UCP */
- return p;
- }
-#else /* Not SUPPORT_UTF */
-(void)(utf); /* Stops warning for unused parameter */
-#endif /* SUPPORT_UTF */
-
-if (caseless && (cd->ctypes[c] & ctype_letter) != 0) SET_BIT(cd->fcc[c]);
-return p + 1;
-#endif
-}
-
-
-
-/*************************************************
-* Set bits for a positive character type *
-*************************************************/
-
-/* This function sets starting bits for a character type. In UTF-8 mode, we can
-only do a direct setting for bytes less than 128, as otherwise there can be
-confusion with bytes in the middle of UTF-8 characters. In a "traditional"
-environment, the tables will only recognize ASCII characters anyway, but in at
-least one Windows environment, some higher bytes bits were set in the tables.
-So we deal with that case by considering the UTF-8 encoding.
-
-Arguments:
- start_bits the starting bitmap
- cbit type the type of character wanted
- table_limit 32 for non-UTF-8; 16 for UTF-8
- cd the block with char table pointers
-
-Returns: nothing
-*/
-
-static void
-set_type_bits(pcre_uint8 *start_bits, int cbit_type, unsigned int table_limit,
- compile_data *cd)
-{
-register pcre_uint32 c;
-for (c = 0; c < table_limit; c++) start_bits[c] |= cd->cbits[c+cbit_type];
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
-if (table_limit == 32) return;
-for (c = 128; c < 256; c++)
- {
- if ((cd->cbits[c/8] & (1 << (c&7))) != 0)
- {
- pcre_uchar buff[6];
- (void)PRIV(ord2utf)(c, buff);
- SET_BIT(buff[0]);
- }
- }
-#endif
-}
-
-
-/*************************************************
-* Set bits for a negative character type *
-*************************************************/
-
-/* This function sets starting bits for a negative character type such as \D.
-In UTF-8 mode, we can only do a direct setting for bytes less than 128, as
-otherwise there can be confusion with bytes in the middle of UTF-8 characters.
-Unlike in the positive case, where we can set appropriate starting bits for
-specific high-valued UTF-8 characters, in this case we have to set the bits for
-all high-valued characters. The lowest is 0xc2, but we overkill by starting at
-0xc0 (192) for simplicity.
-
-Arguments:
- start_bits the starting bitmap
- cbit type the type of character wanted
- table_limit 32 for non-UTF-8; 16 for UTF-8
- cd the block with char table pointers
-
-Returns: nothing
-*/
-
-static void
-set_nottype_bits(pcre_uint8 *start_bits, int cbit_type, unsigned int table_limit,
- compile_data *cd)
-{
-register pcre_uint32 c;
-for (c = 0; c < table_limit; c++) start_bits[c] |= ~cd->cbits[c+cbit_type];
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
-if (table_limit != 32) for (c = 24; c < 32; c++) start_bits[c] = 0xff;
-#endif
-}
-
-
-
-/*************************************************
-* Create bitmap of starting bytes *
-*************************************************/
-
-/* This function scans a compiled unanchored expression recursively and
-attempts to build a bitmap of the set of possible starting bytes. As time goes
-by, we may be able to get more clever at doing this. The SSB_CONTINUE return is
-useful for parenthesized groups in patterns such as (a*)b where the group
-provides some optional starting bytes but scanning must continue at the outer
-level to find at least one mandatory byte. At the outermost level, this
-function fails unless the result is SSB_DONE.
-
-Arguments:
- code points to an expression
- start_bits points to a 32-byte table, initialized to 0
- utf TRUE if in UTF-8 / UTF-16 / UTF-32 mode
- cd the block with char table pointers
-
-Returns: SSB_FAIL => Failed to find any starting bytes
- SSB_DONE => Found mandatory starting bytes
- SSB_CONTINUE => Found optional starting bytes
- SSB_UNKNOWN => Hit an unrecognized opcode
-*/
-
-static int
-set_start_bits(const pcre_uchar *code, pcre_uint8 *start_bits, BOOL utf,
- compile_data *cd)
-{
-register pcre_uint32 c;
-int yield = SSB_DONE;
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
-int table_limit = utf? 16:32;
-#else
-int table_limit = 32;
-#endif
-
-#if 0
-/* ========================================================================= */
-/* The following comment and code was inserted in January 1999. In May 2006,
-when it was observed to cause compiler warnings about unused values, I took it
-out again. If anybody is still using OS/2, they will have to put it back
-manually. */
-
-/* This next statement and the later reference to dummy are here in order to
-trick the optimizer of the IBM C compiler for OS/2 into generating correct
-code. Apparently IBM isn't going to fix the problem, and we would rather not
-disable optimization (in this module it actually makes a big difference, and
-the pcre module can use all the optimization it can get). */
-
-volatile int dummy;
-/* ========================================================================= */
-#endif
-
-do
- {
- BOOL try_next = TRUE;
- const pcre_uchar *tcode = code + 1 + LINK_SIZE;
-
- if (*code == OP_CBRA || *code == OP_SCBRA ||
- *code == OP_CBRAPOS || *code == OP_SCBRAPOS) tcode += IMM2_SIZE;
-
- while (try_next) /* Loop for items in this branch */
- {
- int rc;
-
- switch(*tcode)
- {
- /* If we reach something we don't understand, it means a new opcode has
- been created that hasn't been added to this code. Hopefully this problem
- will be discovered during testing. */
-
- default:
- return SSB_UNKNOWN;
-
- /* Fail for a valid opcode that implies no starting bits. */
-
- case OP_ACCEPT:
- case OP_ASSERT_ACCEPT:
- case OP_ALLANY:
- case OP_ANY:
- case OP_ANYBYTE:
- case OP_CIRC:
- case OP_CIRCM:
- case OP_CLOSE:
- case OP_COMMIT:
- case OP_COND:
- case OP_CREF:
- case OP_DEF:
- case OP_DNCREF:
- case OP_DNREF:
- case OP_DNREFI:
- case OP_DNRREF:
- case OP_DOLL:
- case OP_DOLLM:
- case OP_END:
- case OP_EOD:
- case OP_EODN:
- case OP_EXTUNI:
- case OP_FAIL:
- case OP_MARK:
- case OP_NOT:
- case OP_NOTEXACT:
- case OP_NOTEXACTI:
- case OP_NOTI:
- case OP_NOTMINPLUS:
- case OP_NOTMINPLUSI:
- case OP_NOTMINQUERY:
- case OP_NOTMINQUERYI:
- case OP_NOTMINSTAR:
- case OP_NOTMINSTARI:
- case OP_NOTMINUPTO:
- case OP_NOTMINUPTOI:
- case OP_NOTPLUS:
- case OP_NOTPLUSI:
- case OP_NOTPOSPLUS:
- case OP_NOTPOSPLUSI:
- case OP_NOTPOSQUERY:
- case OP_NOTPOSQUERYI:
- case OP_NOTPOSSTAR:
- case OP_NOTPOSSTARI:
- case OP_NOTPOSUPTO:
- case OP_NOTPOSUPTOI:
- case OP_NOTPROP:
- case OP_NOTQUERY:
- case OP_NOTQUERYI:
- case OP_NOTSTAR:
- case OP_NOTSTARI:
- case OP_NOTUPTO:
- case OP_NOTUPTOI:
- case OP_NOT_HSPACE:
- case OP_NOT_VSPACE:
- case OP_PRUNE:
- case OP_PRUNE_ARG:
- case OP_RECURSE:
- case OP_REF:
- case OP_REFI:
- case OP_REVERSE:
- case OP_RREF:
- case OP_SCOND:
- case OP_SET_SOM:
- case OP_SKIP:
- case OP_SKIP_ARG:
- case OP_SOD:
- case OP_SOM:
- case OP_THEN:
- case OP_THEN_ARG:
- return SSB_FAIL;
-
- /* A "real" property test implies no starting bits, but the fake property
- PT_CLIST identifies a list of characters. These lists are short, as they
- are used for characters with more than one "other case", so there is no
- point in recognizing them for OP_NOTPROP. */
-
- case OP_PROP:
- if (tcode[1] != PT_CLIST) return SSB_FAIL;
- {
- const pcre_uint32 *p = PRIV(ucd_caseless_sets) + tcode[2];
- while ((c = *p++) < NOTACHAR)
- {
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- if (utf)
- {
- pcre_uchar buff[6];
- (void)PRIV(ord2utf)(c, buff);
- c = buff[0];
- }
-#endif
- if (c > 0xff) SET_BIT(0xff); else SET_BIT(c);
- }
- }
- try_next = FALSE;
- break;
-
- /* We can ignore word boundary tests. */
-
- case OP_WORD_BOUNDARY:
- case OP_NOT_WORD_BOUNDARY:
- tcode++;
- break;
-
- /* If we hit a bracket or a positive lookahead assertion, recurse to set
- bits from within the subpattern. If it can't find anything, we have to
- give up. If it finds some mandatory character(s), we are done for this
- branch. Otherwise, carry on scanning after the subpattern. */
-
- case OP_BRA:
- case OP_SBRA:
- case OP_CBRA:
- case OP_SCBRA:
- case OP_BRAPOS:
- case OP_SBRAPOS:
- case OP_CBRAPOS:
- case OP_SCBRAPOS:
- case OP_ONCE:
- case OP_ONCE_NC:
- case OP_ASSERT:
- rc = set_start_bits(tcode, start_bits, utf, cd);
- if (rc == SSB_FAIL || rc == SSB_UNKNOWN) return rc;
- if (rc == SSB_DONE) try_next = FALSE; else
- {
- do tcode += GET(tcode, 1); while (*tcode == OP_ALT);
- tcode += 1 + LINK_SIZE;
- }
- break;
-
- /* If we hit ALT or KET, it means we haven't found anything mandatory in
- this branch, though we might have found something optional. For ALT, we
- continue with the next alternative, but we have to arrange that the final
- result from subpattern is SSB_CONTINUE rather than SSB_DONE. For KET,
- return SSB_CONTINUE: if this is the top level, that indicates failure,
- but after a nested subpattern, it causes scanning to continue. */
-
- case OP_ALT:
- yield = SSB_CONTINUE;
- try_next = FALSE;
- break;
-
- case OP_KET:
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_KETRPOS:
- return SSB_CONTINUE;
-
- /* Skip over callout */
-
- case OP_CALLOUT:
- tcode += 2 + 2*LINK_SIZE;
- break;
-
- /* Skip over lookbehind and negative lookahead assertions */
-
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- do tcode += GET(tcode, 1); while (*tcode == OP_ALT);
- tcode += 1 + LINK_SIZE;
- break;
-
- /* BRAZERO does the bracket, but carries on. */
-
- case OP_BRAZERO:
- case OP_BRAMINZERO:
- case OP_BRAPOSZERO:
- rc = set_start_bits(++tcode, start_bits, utf, cd);
- if (rc == SSB_FAIL || rc == SSB_UNKNOWN) return rc;
-/* =========================================================================
- See the comment at the head of this function concerning the next line,
- which was an old fudge for the benefit of OS/2.
- dummy = 1;
- ========================================================================= */
- do tcode += GET(tcode,1); while (*tcode == OP_ALT);
- tcode += 1 + LINK_SIZE;
- break;
-
- /* SKIPZERO skips the bracket. */
-
- case OP_SKIPZERO:
- tcode++;
- do tcode += GET(tcode,1); while (*tcode == OP_ALT);
- tcode += 1 + LINK_SIZE;
- break;
-
- /* Single-char * or ? sets the bit and tries the next item */
-
- case OP_STAR:
- case OP_MINSTAR:
- case OP_POSSTAR:
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_POSQUERY:
- tcode = set_table_bit(start_bits, tcode + 1, FALSE, cd, utf);
- break;
-
- case OP_STARI:
- case OP_MINSTARI:
- case OP_POSSTARI:
- case OP_QUERYI:
- case OP_MINQUERYI:
- case OP_POSQUERYI:
- tcode = set_table_bit(start_bits, tcode + 1, TRUE, cd, utf);
- break;
-
- /* Single-char upto sets the bit and tries the next */
-
- case OP_UPTO:
- case OP_MINUPTO:
- case OP_POSUPTO:
- tcode = set_table_bit(start_bits, tcode + 1 + IMM2_SIZE, FALSE, cd, utf);
- break;
-
- case OP_UPTOI:
- case OP_MINUPTOI:
- case OP_POSUPTOI:
- tcode = set_table_bit(start_bits, tcode + 1 + IMM2_SIZE, TRUE, cd, utf);
- break;
-
- /* At least one single char sets the bit and stops */
-
- case OP_EXACT:
- tcode += IMM2_SIZE;
- /* Fall through */
- case OP_CHAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_POSPLUS:
- (void)set_table_bit(start_bits, tcode + 1, FALSE, cd, utf);
- try_next = FALSE;
- break;
-
- case OP_EXACTI:
- tcode += IMM2_SIZE;
- /* Fall through */
- case OP_CHARI:
- case OP_PLUSI:
- case OP_MINPLUSI:
- case OP_POSPLUSI:
- (void)set_table_bit(start_bits, tcode + 1, TRUE, cd, utf);
- try_next = FALSE;
- break;
-
- /* Special spacing and line-terminating items. These recognize specific
- lists of characters. The difference between VSPACE and ANYNL is that the
- latter can match the two-character CRLF sequence, but that is not
- relevant for finding the first character, so their code here is
- identical. */
-
- case OP_HSPACE:
- SET_BIT(CHAR_HT);
- SET_BIT(CHAR_SPACE);
-#ifdef SUPPORT_UTF
- if (utf)
- {
-#ifdef COMPILE_PCRE8
- SET_BIT(0xC2); /* For U+00A0 */
- SET_BIT(0xE1); /* For U+1680, U+180E */
- SET_BIT(0xE2); /* For U+2000 - U+200A, U+202F, U+205F */
- SET_BIT(0xE3); /* For U+3000 */
-#elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- SET_BIT(0xA0);
- SET_BIT(0xFF); /* For characters > 255 */
-#endif /* COMPILE_PCRE[8|16|32] */
- }
- else
-#endif /* SUPPORT_UTF */
- {
-#ifndef EBCDIC
- SET_BIT(0xA0);
-#endif /* Not EBCDIC */
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- SET_BIT(0xFF); /* For characters > 255 */
-#endif /* COMPILE_PCRE[16|32] */
- }
- try_next = FALSE;
- break;
-
- case OP_ANYNL:
- case OP_VSPACE:
- SET_BIT(CHAR_LF);
- SET_BIT(CHAR_VT);
- SET_BIT(CHAR_FF);
- SET_BIT(CHAR_CR);
-#ifdef SUPPORT_UTF
- if (utf)
- {
-#ifdef COMPILE_PCRE8
- SET_BIT(0xC2); /* For U+0085 */
- SET_BIT(0xE2); /* For U+2028, U+2029 */
-#elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- SET_BIT(CHAR_NEL);
- SET_BIT(0xFF); /* For characters > 255 */
-#endif /* COMPILE_PCRE[8|16|32] */
- }
- else
-#endif /* SUPPORT_UTF */
- {
- SET_BIT(CHAR_NEL);
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- SET_BIT(0xFF); /* For characters > 255 */
-#endif
- }
- try_next = FALSE;
- break;
-
- /* Single character types set the bits and stop. Note that if PCRE_UCP
- is set, we do not see these op codes because \d etc are converted to
- properties. Therefore, these apply in the case when only characters less
- than 256 are recognized to match the types. */
-
- case OP_NOT_DIGIT:
- set_nottype_bits(start_bits, cbit_digit, table_limit, cd);
- try_next = FALSE;
- break;
-
- case OP_DIGIT:
- set_type_bits(start_bits, cbit_digit, table_limit, cd);
- try_next = FALSE;
- break;
-
- /* The cbit_space table has vertical tab as whitespace; we no longer
- have to play fancy tricks because Perl added VT to its whitespace at
- release 5.18. PCRE added it at release 8.34. */
-
- case OP_NOT_WHITESPACE:
- set_nottype_bits(start_bits, cbit_space, table_limit, cd);
- try_next = FALSE;
- break;
-
- case OP_WHITESPACE:
- set_type_bits(start_bits, cbit_space, table_limit, cd);
- try_next = FALSE;
- break;
-
- case OP_NOT_WORDCHAR:
- set_nottype_bits(start_bits, cbit_word, table_limit, cd);
- try_next = FALSE;
- break;
-
- case OP_WORDCHAR:
- set_type_bits(start_bits, cbit_word, table_limit, cd);
- try_next = FALSE;
- break;
-
- /* One or more character type fudges the pointer and restarts, knowing
- it will hit a single character type and stop there. */
-
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEPOSPLUS:
- tcode++;
- break;
-
- case OP_TYPEEXACT:
- tcode += 1 + IMM2_SIZE;
- break;
-
- /* Zero or more repeats of character types set the bits and then
- try again. */
-
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- case OP_TYPEPOSUPTO:
- tcode += IMM2_SIZE; /* Fall through */
-
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPOSSTAR:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- case OP_TYPEPOSQUERY:
- switch(tcode[1])
- {
- default:
- case OP_ANY:
- case OP_ALLANY:
- return SSB_FAIL;
-
- case OP_HSPACE:
- SET_BIT(CHAR_HT);
- SET_BIT(CHAR_SPACE);
-#ifdef SUPPORT_UTF
- if (utf)
- {
-#ifdef COMPILE_PCRE8
- SET_BIT(0xC2); /* For U+00A0 */
- SET_BIT(0xE1); /* For U+1680, U+180E */
- SET_BIT(0xE2); /* For U+2000 - U+200A, U+202F, U+205F */
- SET_BIT(0xE3); /* For U+3000 */
-#elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- SET_BIT(0xA0);
- SET_BIT(0xFF); /* For characters > 255 */
-#endif /* COMPILE_PCRE[8|16|32] */
- }
- else
-#endif /* SUPPORT_UTF */
-#ifndef EBCDIC
- SET_BIT(0xA0);
-#endif /* Not EBCDIC */
- break;
-
- case OP_ANYNL:
- case OP_VSPACE:
- SET_BIT(CHAR_LF);
- SET_BIT(CHAR_VT);
- SET_BIT(CHAR_FF);
- SET_BIT(CHAR_CR);
-#ifdef SUPPORT_UTF
- if (utf)
- {
-#ifdef COMPILE_PCRE8
- SET_BIT(0xC2); /* For U+0085 */
- SET_BIT(0xE2); /* For U+2028, U+2029 */
-#elif defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- SET_BIT(CHAR_NEL);
- SET_BIT(0xFF); /* For characters > 255 */
-#endif /* COMPILE_PCRE16 */
- }
- else
-#endif /* SUPPORT_UTF */
- SET_BIT(CHAR_NEL);
- break;
-
- case OP_NOT_DIGIT:
- set_nottype_bits(start_bits, cbit_digit, table_limit, cd);
- break;
-
- case OP_DIGIT:
- set_type_bits(start_bits, cbit_digit, table_limit, cd);
- break;
-
- /* The cbit_space table has vertical tab as whitespace; we no longer
- have to play fancy tricks because Perl added VT to its whitespace at
- release 5.18. PCRE added it at release 8.34. */
-
- case OP_NOT_WHITESPACE:
- set_nottype_bits(start_bits, cbit_space, table_limit, cd);
- break;
-
- case OP_WHITESPACE:
- set_type_bits(start_bits, cbit_space, table_limit, cd);
- break;
-
- case OP_NOT_WORDCHAR:
- set_nottype_bits(start_bits, cbit_word, table_limit, cd);
- break;
-
- case OP_WORDCHAR:
- set_type_bits(start_bits, cbit_word, table_limit, cd);
- break;
- }
-
- tcode += 2;
- break;
-
- /* Character class where all the information is in a bit map: set the
- bits and either carry on or not, according to the repeat count. If it was
- a negative class, and we are operating with UTF-8 characters, any byte
- with a value >= 0xc4 is a potentially valid starter because it starts a
- character with a value > 255. */
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- case OP_XCLASS:
- if ((tcode[1 + LINK_SIZE] & XCL_HASPROP) != 0)
- return SSB_FAIL;
- /* All bits are set. */
- if ((tcode[1 + LINK_SIZE] & XCL_MAP) == 0 && (tcode[1 + LINK_SIZE] & XCL_NOT) != 0)
- return SSB_FAIL;
-#endif
- /* Fall through */
-
- case OP_NCLASS:
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- if (utf)
- {
- start_bits[24] |= 0xf0; /* Bits for 0xc4 - 0xc8 */
- memset(start_bits+25, 0xff, 7); /* Bits for 0xc9 - 0xff */
- }
-#endif
-#if defined COMPILE_PCRE16 || defined COMPILE_PCRE32
- SET_BIT(0xFF); /* For characters > 255 */
-#endif
- /* Fall through */
-
- case OP_CLASS:
- {
- pcre_uint8 *map;
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- map = NULL;
- if (*tcode == OP_XCLASS)
- {
- if ((tcode[1 + LINK_SIZE] & XCL_MAP) != 0)
- map = (pcre_uint8 *)(tcode + 1 + LINK_SIZE + 1);
- tcode += GET(tcode, 1);
- }
- else
-#endif
- {
- tcode++;
- map = (pcre_uint8 *)tcode;
- tcode += 32 / sizeof(pcre_uchar);
- }
-
- /* In UTF-8 mode, the bits in a bit map correspond to character
- values, not to byte values. However, the bit map we are constructing is
- for byte values. So we have to do a conversion for characters whose
- value is > 127. In fact, there are only two possible starting bytes for
- characters in the range 128 - 255. */
-
-#if defined SUPPORT_UTF || !defined COMPILE_PCRE8
- if (map != NULL)
-#endif
- {
-#if defined SUPPORT_UTF && defined COMPILE_PCRE8
- if (utf)
- {
- for (c = 0; c < 16; c++) start_bits[c] |= map[c];
- for (c = 128; c < 256; c++)
- {
- if ((map[c/8] && (1 << (c&7))) != 0)
- {
- int d = (c >> 6) | 0xc0; /* Set bit for this starter */
- start_bits[d/8] |= (1 << (d&7)); /* and then skip on to the */
- c = (c & 0xc0) + 0x40 - 1; /* next relevant character. */
- }
- }
- }
- else
-#endif
- {
- /* In non-UTF-8 mode, the two bit maps are completely compatible. */
- for (c = 0; c < 32; c++) start_bits[c] |= map[c];
- }
- }
-
- /* Advance past the bit map, and act on what follows. For a zero
- minimum repeat, continue; otherwise stop processing. */
-
- switch (*tcode)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- case OP_CRPOSSTAR:
- case OP_CRPOSQUERY:
- tcode++;
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- case OP_CRPOSRANGE:
- if (GET2(tcode, 1) == 0) tcode += 1 + 2 * IMM2_SIZE;
- else try_next = FALSE;
- break;
-
- default:
- try_next = FALSE;
- break;
- }
- }
- break; /* End of bitmap class handling */
-
- } /* End of switch */
- } /* End of try_next loop */
-
- code += GET(code, 1); /* Advance to next branch */
- }
-while (*code == OP_ALT);
-return yield;
-}
-
-
-
-
-
-/*************************************************
-* Study a compiled expression *
-*************************************************/
-
-/* This function is handed a compiled expression that it must study to produce
-information that will speed up the matching. It returns a pcre[16]_extra block
-which then gets handed back to pcre_exec().
-
-Arguments:
- re points to the compiled expression
- options contains option bits
- errorptr points to where to place error messages;
- set NULL unless error
-
-Returns: pointer to a pcre[16]_extra block, with study_data filled in and
- the appropriate flags set;
- NULL on error or if no optimization possible
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN pcre_extra * PCRE_CALL_CONVENTION
-pcre_study(const pcre *external_re, int options, const char **errorptr)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN pcre16_extra * PCRE_CALL_CONVENTION
-pcre16_study(const pcre16 *external_re, int options, const char **errorptr)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN pcre32_extra * PCRE_CALL_CONVENTION
-pcre32_study(const pcre32 *external_re, int options, const char **errorptr)
-#endif
-{
-int min;
-int count = 0;
-BOOL bits_set = FALSE;
-pcre_uint8 start_bits[32];
-PUBL(extra) *extra = NULL;
-pcre_study_data *study;
-const pcre_uint8 *tables;
-pcre_uchar *code;
-compile_data compile_block;
-const REAL_PCRE *re = (const REAL_PCRE *)external_re;
-
-
-*errorptr = NULL;
-
-if (re == NULL || re->magic_number != MAGIC_NUMBER)
- {
- *errorptr = "argument is not a compiled regular expression";
- return NULL;
- }
-
-if ((re->flags & PCRE_MODE) == 0)
- {
-#if defined COMPILE_PCRE8
- *errorptr = "argument not compiled in 8 bit mode";
-#elif defined COMPILE_PCRE16
- *errorptr = "argument not compiled in 16 bit mode";
-#elif defined COMPILE_PCRE32
- *errorptr = "argument not compiled in 32 bit mode";
-#endif
- return NULL;
- }
-
-if ((options & ~PUBLIC_STUDY_OPTIONS) != 0)
- {
- *errorptr = "unknown or incorrect option bit(s) set";
- return NULL;
- }
-
-code = (pcre_uchar *)re + re->name_table_offset +
- (re->name_count * re->name_entry_size);
-
-/* For an anchored pattern, or an unanchored pattern that has a first char, or
-a multiline pattern that matches only at "line starts", there is no point in
-seeking a list of starting bytes. */
-
-if ((re->options & PCRE_ANCHORED) == 0 &&
- (re->flags & (PCRE_FIRSTSET|PCRE_STARTLINE)) == 0)
- {
- int rc;
-
- /* Set the character tables in the block that is passed around */
-
- tables = re->tables;
-
-#if defined COMPILE_PCRE8
- if (tables == NULL)
- (void)pcre_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
- (void *)(&tables));
-#elif defined COMPILE_PCRE16
- if (tables == NULL)
- (void)pcre16_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
- (void *)(&tables));
-#elif defined COMPILE_PCRE32
- if (tables == NULL)
- (void)pcre32_fullinfo(external_re, NULL, PCRE_INFO_DEFAULT_TABLES,
- (void *)(&tables));
-#endif
-
- compile_block.lcc = tables + lcc_offset;
- compile_block.fcc = tables + fcc_offset;
- compile_block.cbits = tables + cbits_offset;
- compile_block.ctypes = tables + ctypes_offset;
-
- /* See if we can find a fixed set of initial characters for the pattern. */
-
- memset(start_bits, 0, 32 * sizeof(pcre_uint8));
- rc = set_start_bits(code, start_bits, (re->options & PCRE_UTF8) != 0,
- &compile_block);
- bits_set = rc == SSB_DONE;
- if (rc == SSB_UNKNOWN)
- {
- *errorptr = "internal error: opcode not recognized";
- return NULL;
- }
- }
-
-/* Find the minimum length of subject string. */
-
-switch(min = find_minlength(re, code, code, re->options, NULL, &count))
- {
- case -2: *errorptr = "internal error: missing capturing bracket"; return NULL;
- case -3: *errorptr = "internal error: opcode not recognized"; return NULL;
- default: break;
- }
-
-/* If a set of starting bytes has been identified, or if the minimum length is
-greater than zero, or if JIT optimization has been requested, or if
-PCRE_STUDY_EXTRA_NEEDED is set, get a pcre[16]_extra block and a
-pcre_study_data block. The study data is put in the latter, which is pointed to
-by the former, which may also get additional data set later by the calling
-program. At the moment, the size of pcre_study_data is fixed. We nevertheless
-save it in a field for returning via the pcre_fullinfo() function so that if it
-becomes variable in the future, we don't have to change that code. */
-
-if (bits_set || min > 0 || (options & (
-#ifdef SUPPORT_JIT
- PCRE_STUDY_JIT_COMPILE | PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE |
- PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE |
-#endif
- PCRE_STUDY_EXTRA_NEEDED)) != 0)
- {
- extra = (PUBL(extra) *)(PUBL(malloc))
- (sizeof(PUBL(extra)) + sizeof(pcre_study_data));
- if (extra == NULL)
- {
- *errorptr = "failed to get memory";
- return NULL;
- }
-
- study = (pcre_study_data *)((char *)extra + sizeof(PUBL(extra)));
- extra->flags = PCRE_EXTRA_STUDY_DATA;
- extra->study_data = study;
-
- study->size = sizeof(pcre_study_data);
- study->flags = 0;
-
- /* Set the start bits always, to avoid unset memory errors if the
- study data is written to a file, but set the flag only if any of the bits
- are set, to save time looking when none are. */
-
- if (bits_set)
- {
- study->flags |= PCRE_STUDY_MAPPED;
- memcpy(study->start_bits, start_bits, sizeof(start_bits));
- }
- else memset(study->start_bits, 0, 32 * sizeof(pcre_uint8));
-
-#ifdef PCRE_DEBUG
- if (bits_set)
- {
- pcre_uint8 *ptr = start_bits;
- int i;
-
- printf("Start bits:\n");
- for (i = 0; i < 32; i++)
- printf("%3d: %02x%s", i * 8, *ptr++, ((i + 1) & 0x7) != 0? " " : "\n");
- }
-#endif
-
- /* Always set the minlength value in the block, because the JIT compiler
- makes use of it. However, don't set the bit unless the length is greater than
- zero - the interpretive pcre_exec() and pcre_dfa_exec() needn't waste time
- checking the zero case. */
-
- if (min > 0)
- {
- study->flags |= PCRE_STUDY_MINLEN;
- study->minlength = min;
- }
- else study->minlength = 0;
-
- /* If JIT support was compiled and requested, attempt the JIT compilation.
- If no starting bytes were found, and the minimum length is zero, and JIT
- compilation fails, abandon the extra block and return NULL, unless
- PCRE_STUDY_EXTRA_NEEDED is set. */
-
-#ifdef SUPPORT_JIT
- extra->executable_jit = NULL;
- if ((options & PCRE_STUDY_JIT_COMPILE) != 0)
- PRIV(jit_compile)(re, extra, JIT_COMPILE);
- if ((options & PCRE_STUDY_JIT_PARTIAL_SOFT_COMPILE) != 0)
- PRIV(jit_compile)(re, extra, JIT_PARTIAL_SOFT_COMPILE);
- if ((options & PCRE_STUDY_JIT_PARTIAL_HARD_COMPILE) != 0)
- PRIV(jit_compile)(re, extra, JIT_PARTIAL_HARD_COMPILE);
-
- if (study->flags == 0 && (extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) == 0 &&
- (options & PCRE_STUDY_EXTRA_NEEDED) == 0)
- {
-#if defined COMPILE_PCRE8
- pcre_free_study(extra);
-#elif defined COMPILE_PCRE16
- pcre16_free_study(extra);
-#elif defined COMPILE_PCRE32
- pcre32_free_study(extra);
-#endif
- extra = NULL;
- }
-#endif
- }
-
-return extra;
-}
-
-
-/*************************************************
-* Free the study data *
-*************************************************/
-
-/* This function frees the memory that was obtained by pcre_study().
-
-Argument: a pointer to the pcre[16]_extra block
-Returns: nothing
-*/
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN void
-pcre_free_study(pcre_extra *extra)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN void
-pcre16_free_study(pcre16_extra *extra)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN void
-pcre32_free_study(pcre32_extra *extra)
-#endif
-{
-if (extra == NULL)
- return;
-#ifdef SUPPORT_JIT
-if ((extra->flags & PCRE_EXTRA_EXECUTABLE_JIT) != 0 &&
- extra->executable_jit != NULL)
- PRIV(jit_free)(extra->executable_jit);
-#endif
-PUBL(free)(extra);
-}
-
-/* End of pcre_study.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_tables.c r-base-3.3.1/src/extra/pcre/pcre_tables.c
--- r-base-3.2.3/src/extra/pcre/pcre_tables.c 2014-11-12 23:15:06.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_tables.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,727 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2012 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-#ifndef PCRE_INCLUDED
-
-/* This module contains some fixed tables that are used by more than one of the
-PCRE code modules. The tables are also #included by the pcretest program, which
-uses macros to change their names from _pcre_xxx to xxxx, thereby avoiding name
-clashes with the library. */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pcre_internal.h"
-
-#endif /* PCRE_INCLUDED */
-
-/* Table of sizes for the fixed-length opcodes. It's defined in a macro so that
-the definition is next to the definition of the opcodes in pcre_internal.h. */
-
-const pcre_uint8 PRIV(OP_lengths)[] = { OP_LENGTHS };
-
-/* Tables of horizontal and vertical whitespace characters, suitable for
-adding to classes. */
-
-const pcre_uint32 PRIV(hspace_list)[] = { HSPACE_LIST };
-const pcre_uint32 PRIV(vspace_list)[] = { VSPACE_LIST };
-
-
-
-/*************************************************
-* Tables for UTF-8 support *
-*************************************************/
-
-/* These are the breakpoints for different numbers of bytes in a UTF-8
-character. */
-
-#if (defined SUPPORT_UTF && defined COMPILE_PCRE8) \
- || (defined PCRE_INCLUDED && (defined SUPPORT_PCRE16 || defined SUPPORT_PCRE32))
-
-/* These tables are also required by pcretest in 16- or 32-bit mode. */
-
-const int PRIV(utf8_table1)[] =
- { 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};
-
-const int PRIV(utf8_table1_size) = sizeof(PRIV(utf8_table1)) / sizeof(int);
-
-/* These are the indicator bits and the mask for the data bits to set in the
-first byte of a character, indexed by the number of additional bytes. */
-
-const int PRIV(utf8_table2)[] = { 0, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
-const int PRIV(utf8_table3)[] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
-
-/* Table of the number of extra bytes, indexed by the first byte masked with
-0x3f. The highest number for a valid UTF-8 first byte is in fact 0x3d. */
-
-const pcre_uint8 PRIV(utf8_table4)[] = {
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };
-
-#endif /* (SUPPORT_UTF && COMPILE_PCRE8) || (PCRE_INCLUDED && SUPPORT_PCRE[16|32])*/
-
-#ifdef SUPPORT_UTF
-
-/* Table to translate from particular type value to the general value. */
-
-const pcre_uint32 PRIV(ucp_gentype)[] = {
- ucp_C, ucp_C, ucp_C, ucp_C, ucp_C, /* Cc, Cf, Cn, Co, Cs */
- ucp_L, ucp_L, ucp_L, ucp_L, ucp_L, /* Ll, Lu, Lm, Lo, Lt */
- ucp_M, ucp_M, ucp_M, /* Mc, Me, Mn */
- ucp_N, ucp_N, ucp_N, /* Nd, Nl, No */
- ucp_P, ucp_P, ucp_P, ucp_P, ucp_P, /* Pc, Pd, Pe, Pf, Pi */
- ucp_P, ucp_P, /* Ps, Po */
- ucp_S, ucp_S, ucp_S, ucp_S, /* Sc, Sk, Sm, So */
- ucp_Z, ucp_Z, ucp_Z /* Zl, Zp, Zs */
-};
-
-/* This table encodes the rules for finding the end of an extended grapheme
-cluster. Every code point has a grapheme break property which is one of the
-ucp_gbXX values defined in ucp.h. The 2-dimensional table is indexed by the
-properties of two adjacent code points. The left property selects a word from
-the table, and the right property selects a bit from that word like this:
-
- ucp_gbtable[left-property] & (1 << right-property)
-
-The value is non-zero if a grapheme break is NOT permitted between the relevant
-two code points. The breaking rules are as follows:
-
-1. Break at the start and end of text (pretty obviously).
-
-2. Do not break between a CR and LF; otherwise, break before and after
- controls.
-
-3. Do not break Hangul syllable sequences, the rules for which are:
-
- L may be followed by L, V, LV or LVT
- LV or V may be followed by V or T
- LVT or T may be followed by T
-
-4. Do not break before extending characters.
-
-The next two rules are only for extended grapheme clusters (but that's what we
-are implementing).
-
-5. Do not break before SpacingMarks.
-
-6. Do not break after Prepend characters.
-
-7. Otherwise, break everywhere.
-*/
-
-const pcre_uint32 PRIV(ucp_gbtable[]) = {
- (1< 0x10ffff is not permitted
-PCRE_UTF8_ERR14 3-byte character with value 0xd000-0xdfff is not permitted
-PCRE_UTF8_ERR15 Overlong 2-byte sequence
-PCRE_UTF8_ERR16 Overlong 3-byte sequence
-PCRE_UTF8_ERR17 Overlong 4-byte sequence
-PCRE_UTF8_ERR18 Overlong 5-byte sequence (won't ever occur)
-PCRE_UTF8_ERR19 Overlong 6-byte sequence (won't ever occur)
-PCRE_UTF8_ERR20 Isolated 0x80 byte (not within UTF-8 character)
-PCRE_UTF8_ERR21 Byte with the illegal value 0xfe or 0xff
-PCRE_UTF8_ERR22 Unused (was non-character)
-
-Arguments:
- string points to the string
- length length of string, or -1 if the string is zero-terminated
- errp pointer to an error position offset variable
-
-Returns: = 0 if the string is a valid UTF-8 string
- > 0 otherwise, setting the offset of the bad character
-*/
-
-int
-PRIV(valid_utf)(PCRE_PUCHAR string, int length, int *erroroffset)
-{
-#ifdef SUPPORT_UTF
-register PCRE_PUCHAR p;
-
-if (length < 0)
- {
- for (p = string; *p != 0; p++);
- length = (int)(p - string);
- }
-
-for (p = string; length-- > 0; p++)
- {
- register pcre_uchar ab, c, d;
-
- c = *p;
- if (c < 128) continue; /* ASCII character */
-
- if (c < 0xc0) /* Isolated 10xx xxxx byte */
- {
- *erroroffset = (int)(p - string);
- return PCRE_UTF8_ERR20;
- }
-
- if (c >= 0xfe) /* Invalid 0xfe or 0xff bytes */
- {
- *erroroffset = (int)(p - string);
- return PCRE_UTF8_ERR21;
- }
-
- ab = PRIV(utf8_table4)[c & 0x3f]; /* Number of additional bytes */
- if (length < ab)
- {
- *erroroffset = (int)(p - string); /* Missing bytes */
- return ab - length; /* Codes ERR1 to ERR5 */
- }
- length -= ab; /* Length remaining */
-
- /* Check top bits in the second byte */
-
- if (((d = *(++p)) & 0xc0) != 0x80)
- {
- *erroroffset = (int)(p - string) - 1;
- return PCRE_UTF8_ERR6;
- }
-
- /* For each length, check that the remaining bytes start with the 0x80 bit
- set and not the 0x40 bit. Then check for an overlong sequence, and for the
- excluded range 0xd800 to 0xdfff. */
-
- switch (ab)
- {
- /* 2-byte character. No further bytes to check for 0x80. Check first byte
- for for xx00 000x (overlong sequence). */
-
- case 1: if ((c & 0x3e) == 0)
- {
- *erroroffset = (int)(p - string) - 1;
- return PCRE_UTF8_ERR15;
- }
- break;
-
- /* 3-byte character. Check third byte for 0x80. Then check first 2 bytes
- for 1110 0000, xx0x xxxx (overlong sequence) or
- 1110 1101, 1010 xxxx (0xd800 - 0xdfff) */
-
- case 2:
- if ((*(++p) & 0xc0) != 0x80) /* Third byte */
- {
- *erroroffset = (int)(p - string) - 2;
- return PCRE_UTF8_ERR7;
- }
- if (c == 0xe0 && (d & 0x20) == 0)
- {
- *erroroffset = (int)(p - string) - 2;
- return PCRE_UTF8_ERR16;
- }
- if (c == 0xed && d >= 0xa0)
- {
- *erroroffset = (int)(p - string) - 2;
- return PCRE_UTF8_ERR14;
- }
- break;
-
- /* 4-byte character. Check 3rd and 4th bytes for 0x80. Then check first 2
- bytes for for 1111 0000, xx00 xxxx (overlong sequence), then check for a
- character greater than 0x0010ffff (f4 8f bf bf) */
-
- case 3:
- if ((*(++p) & 0xc0) != 0x80) /* Third byte */
- {
- *erroroffset = (int)(p - string) - 2;
- return PCRE_UTF8_ERR7;
- }
- if ((*(++p) & 0xc0) != 0x80) /* Fourth byte */
- {
- *erroroffset = (int)(p - string) - 3;
- return PCRE_UTF8_ERR8;
- }
- if (c == 0xf0 && (d & 0x30) == 0)
- {
- *erroroffset = (int)(p - string) - 3;
- return PCRE_UTF8_ERR17;
- }
- if (c > 0xf4 || (c == 0xf4 && d > 0x8f))
- {
- *erroroffset = (int)(p - string) - 3;
- return PCRE_UTF8_ERR13;
- }
- break;
-
- /* 5-byte and 6-byte characters are not allowed by RFC 3629, and will be
- rejected by the length test below. However, we do the appropriate tests
- here so that overlong sequences get diagnosed, and also in case there is
- ever an option for handling these larger code points. */
-
- /* 5-byte character. Check 3rd, 4th, and 5th bytes for 0x80. Then check for
- 1111 1000, xx00 0xxx */
-
- case 4:
- if ((*(++p) & 0xc0) != 0x80) /* Third byte */
- {
- *erroroffset = (int)(p - string) - 2;
- return PCRE_UTF8_ERR7;
- }
- if ((*(++p) & 0xc0) != 0x80) /* Fourth byte */
- {
- *erroroffset = (int)(p - string) - 3;
- return PCRE_UTF8_ERR8;
- }
- if ((*(++p) & 0xc0) != 0x80) /* Fifth byte */
- {
- *erroroffset = (int)(p - string) - 4;
- return PCRE_UTF8_ERR9;
- }
- if (c == 0xf8 && (d & 0x38) == 0)
- {
- *erroroffset = (int)(p - string) - 4;
- return PCRE_UTF8_ERR18;
- }
- break;
-
- /* 6-byte character. Check 3rd-6th bytes for 0x80. Then check for
- 1111 1100, xx00 00xx. */
-
- case 5:
- if ((*(++p) & 0xc0) != 0x80) /* Third byte */
- {
- *erroroffset = (int)(p - string) - 2;
- return PCRE_UTF8_ERR7;
- }
- if ((*(++p) & 0xc0) != 0x80) /* Fourth byte */
- {
- *erroroffset = (int)(p - string) - 3;
- return PCRE_UTF8_ERR8;
- }
- if ((*(++p) & 0xc0) != 0x80) /* Fifth byte */
- {
- *erroroffset = (int)(p - string) - 4;
- return PCRE_UTF8_ERR9;
- }
- if ((*(++p) & 0xc0) != 0x80) /* Sixth byte */
- {
- *erroroffset = (int)(p - string) - 5;
- return PCRE_UTF8_ERR10;
- }
- if (c == 0xfc && (d & 0x3c) == 0)
- {
- *erroroffset = (int)(p - string) - 5;
- return PCRE_UTF8_ERR19;
- }
- break;
- }
-
- /* Character is valid under RFC 2279, but 4-byte and 5-byte characters are
- excluded by RFC 3629. The pointer p is currently at the last byte of the
- character. */
-
- if (ab > 3)
- {
- *erroroffset = (int)(p - string) - ab;
- return (ab == 4)? PCRE_UTF8_ERR11 : PCRE_UTF8_ERR12;
- }
- }
-
-#else /* Not SUPPORT_UTF */
-(void)(string); /* Keep picky compilers happy */
-(void)(length);
-(void)(erroroffset);
-#endif
-
-return PCRE_UTF8_ERR0; /* This indicates success */
-}
-
-/* End of pcre_valid_utf8.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_version.c r-base-3.3.1/src/extra/pcre/pcre_version.c
--- r-base-3.2.3/src/extra/pcre/pcre_version.c 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_version.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,98 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2012 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains the external function pcre_version(), which returns a
-string that identifies the PCRE version that is in use. */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pcre_internal.h"
-
-
-/*************************************************
-* Return version string *
-*************************************************/
-
-/* These macros are the standard way of turning unquoted text into C strings.
-They allow macros like PCRE_MAJOR to be defined without quotes, which is
-convenient for user programs that want to test its value. */
-
-#define STRING(a) # a
-#define XSTRING(s) STRING(s)
-
-/* A problem turned up with PCRE_PRERELEASE, which is defined empty for
-production releases. Originally, it was used naively in this code:
-
- return XSTRING(PCRE_MAJOR)
- "." XSTRING(PCRE_MINOR)
- XSTRING(PCRE_PRERELEASE)
- " " XSTRING(PCRE_DATE);
-
-However, when PCRE_PRERELEASE is empty, this leads to an attempted expansion of
-STRING(). The C standard states: "If (before argument substitution) any
-argument consists of no preprocessing tokens, the behavior is undefined." It
-turns out the gcc treats this case as a single empty string - which is what we
-really want - but Visual C grumbles about the lack of an argument for the
-macro. Unfortunately, both are within their rights. To cope with both ways of
-handling this, I had resort to some messy hackery that does a test at run time.
-I could find no way of detecting that a macro is defined as an empty string at
-pre-processor time. This hack uses a standard trick for avoiding calling
-the STRING macro with an empty argument when doing the test. */
-
-#if defined COMPILE_PCRE8
-PCRE_EXP_DEFN const char * PCRE_CALL_CONVENTION
-pcre_version(void)
-#elif defined COMPILE_PCRE16
-PCRE_EXP_DEFN const char * PCRE_CALL_CONVENTION
-pcre16_version(void)
-#elif defined COMPILE_PCRE32
-PCRE_EXP_DEFN const char * PCRE_CALL_CONVENTION
-pcre32_version(void)
-#endif
-{
-return (XSTRING(Z PCRE_PRERELEASE)[1] == 0)?
- XSTRING(PCRE_MAJOR.PCRE_MINOR PCRE_DATE) :
- XSTRING(PCRE_MAJOR.PCRE_MINOR) XSTRING(PCRE_PRERELEASE PCRE_DATE);
-}
-
-/* End of pcre_version.c */
diff -Nru r-base-3.2.3/src/extra/pcre/pcre_xclass.c r-base-3.3.1/src/extra/pcre/pcre_xclass.c
--- r-base-3.2.3/src/extra/pcre/pcre_xclass.c 2015-11-26 23:15:13.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/pcre_xclass.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,268 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Copyright (c) 1997-2013 University of Cambridge
-
------------------------------------------------------------------------------
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- * Neither the name of the University of Cambridge nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains an internal function that is used to match an extended
-class. It is used by both pcre_exec() and pcre_def_exec(). */
-
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pcre_internal.h"
-
-
-/*************************************************
-* Match character against an XCLASS *
-*************************************************/
-
-/* This function is called to match a character against an extended class that
-might contain values > 255 and/or Unicode properties.
-
-Arguments:
- c the character
- data points to the flag byte of the XCLASS data
-
-Returns: TRUE if character matches, else FALSE
-*/
-
-BOOL
-PRIV(xclass)(pcre_uint32 c, const pcre_uchar *data, BOOL utf)
-{
-pcre_uchar t;
-BOOL negated = (*data & XCL_NOT) != 0;
-
-(void)utf;
-#ifdef COMPILE_PCRE8
-/* In 8 bit mode, this must always be TRUE. Help the compiler to know that. */
-utf = TRUE;
-#endif
-
-/* Character values < 256 are matched against a bitmap, if one is present. If
-not, we still carry on, because there may be ranges that start below 256 in the
-additional data. */
-
-if (c < 256)
- {
- if ((*data & XCL_HASPROP) == 0)
- {
- if ((*data & XCL_MAP) == 0) return negated;
- return (((pcre_uint8 *)(data + 1))[c/8] & (1 << (c&7))) != 0;
- }
- if ((*data & XCL_MAP) != 0 &&
- (((pcre_uint8 *)(data + 1))[c/8] & (1 << (c&7))) != 0)
- return !negated; /* char found */
- }
-
-/* First skip the bit map if present. Then match against the list of Unicode
-properties or large chars or ranges that end with a large char. We won't ever
-encounter XCL_PROP or XCL_NOTPROP when UCP support is not compiled. */
-
-if ((*data++ & XCL_MAP) != 0) data += 32 / sizeof(pcre_uchar);
-
-while ((t = *data++) != XCL_END)
- {
- pcre_uint32 x, y;
- if (t == XCL_SINGLE)
- {
-#ifdef SUPPORT_UTF
- if (utf)
- {
- GETCHARINC(x, data); /* macro generates multiple statements */
- }
- else
-#endif
- x = *data++;
- if (c == x) return !negated;
- }
- else if (t == XCL_RANGE)
- {
-#ifdef SUPPORT_UTF
- if (utf)
- {
- GETCHARINC(x, data); /* macro generates multiple statements */
- GETCHARINC(y, data); /* macro generates multiple statements */
- }
- else
-#endif
- {
- x = *data++;
- y = *data++;
- }
- if (c >= x && c <= y) return !negated;
- }
-
-#ifdef SUPPORT_UCP
- else /* XCL_PROP & XCL_NOTPROP */
- {
- const ucd_record *prop = GET_UCD(c);
- BOOL isprop = t == XCL_PROP;
-
- switch(*data)
- {
- case PT_ANY:
- if (isprop) return !negated;
- break;
-
- case PT_LAMP:
- if ((prop->chartype == ucp_Lu || prop->chartype == ucp_Ll ||
- prop->chartype == ucp_Lt) == isprop) return !negated;
- break;
-
- case PT_GC:
- if ((data[1] == PRIV(ucp_gentype)[prop->chartype]) == isprop)
- return !negated;
- break;
-
- case PT_PC:
- if ((data[1] == prop->chartype) == isprop) return !negated;
- break;
-
- case PT_SC:
- if ((data[1] == prop->script) == isprop) return !negated;
- break;
-
- case PT_ALNUM:
- if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
- PRIV(ucp_gentype)[prop->chartype] == ucp_N) == isprop)
- return !negated;
- break;
-
- /* Perl space used to exclude VT, but from Perl 5.18 it is included,
- which means that Perl space and POSIX space are now identical. PCRE
- was changed at release 8.34. */
-
- case PT_SPACE: /* Perl space */
- case PT_PXSPACE: /* POSIX space */
- switch(c)
- {
- HSPACE_CASES:
- VSPACE_CASES:
- if (isprop) return !negated;
- break;
-
- default:
- if ((PRIV(ucp_gentype)[prop->chartype] == ucp_Z) == isprop)
- return !negated;
- break;
- }
- break;
-
- case PT_WORD:
- if ((PRIV(ucp_gentype)[prop->chartype] == ucp_L ||
- PRIV(ucp_gentype)[prop->chartype] == ucp_N || c == CHAR_UNDERSCORE)
- == isprop)
- return !negated;
- break;
-
- case PT_UCNC:
- if (c < 0xa0)
- {
- if ((c == CHAR_DOLLAR_SIGN || c == CHAR_COMMERCIAL_AT ||
- c == CHAR_GRAVE_ACCENT) == isprop)
- return !negated;
- }
- else
- {
- if ((c < 0xd800 || c > 0xdfff) == isprop)
- return !negated;
- }
- break;
-
- /* The following three properties can occur only in an XCLASS, as there
- is no \p or \P coding for them. */
-
- /* Graphic character. Implement this as not Z (space or separator) and
- not C (other), except for Cf (format) with a few exceptions. This seems
- to be what Perl does. The exceptional characters are:
-
- U+061C Arabic Letter Mark
- U+180E Mongolian Vowel Separator
- U+2066 - U+2069 Various "isolate"s
- */
-
- case PT_PXGRAPH:
- if ((PRIV(ucp_gentype)[prop->chartype] != ucp_Z &&
- (PRIV(ucp_gentype)[prop->chartype] != ucp_C ||
- (prop->chartype == ucp_Cf &&
- c != 0x061c && c != 0x180e && (c < 0x2066 || c > 0x2069))
- )) == isprop)
- return !negated;
- break;
-
- /* Printable character: same as graphic, with the addition of Zs, i.e.
- not Zl and not Zp, and U+180E. */
-
- case PT_PXPRINT:
- if ((prop->chartype != ucp_Zl &&
- prop->chartype != ucp_Zp &&
- (PRIV(ucp_gentype)[prop->chartype] != ucp_C ||
- (prop->chartype == ucp_Cf &&
- c != 0x061c && (c < 0x2066 || c > 0x2069))
- )) == isprop)
- return !negated;
- break;
-
- /* Punctuation: all Unicode punctuation, plus ASCII characters that
- Unicode treats as symbols rather than punctuation, for Perl
- compatibility (these are $+<=>^`|~). */
-
- case PT_PXPUNCT:
- if ((PRIV(ucp_gentype)[prop->chartype] == ucp_P ||
- (c < 128 && PRIV(ucp_gentype)[prop->chartype] == ucp_S)) == isprop)
- return !negated;
- break;
-
- /* This should never occur, but compilers may mutter if there is no
- default. */
-
- default:
- return FALSE;
- }
-
- data += 2;
- }
-#endif /* SUPPORT_UCP */
- }
-
-return negated; /* char did not match */
-}
-
-/* End of pcre_xclass.c */
diff -Nru r-base-3.2.3/src/extra/pcre/R_changes r-base-3.3.1/src/extra/pcre/R_changes
--- r-base-3.2.3/src/extra/pcre/R_changes 2015-03-18 23:02:11.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/R_changes 1970-01-01 00:00:00.000000000 +0000
@@ -1,40 +0,0 @@
-pcre_internal.h includes the relevant definitions that configure would
-make.
-
-diff -ur pcre-8.36/pcre_internal.h ./pcre_internal.h
---- pcre-8.36/pcre_internal.h 2014-05-27 19:20:05.000000000 +0100
-+++ ./pcre_internal.h 2014-11-11 21:44:03.000000000 +0000
-@@ -46,6 +46,33 @@
- #ifndef PCRE_INTERNAL_H
- #define PCRE_INTERNAL_H
-
-+#include
-+
-+/* and those that are not in R's configure */
-/* and those that are not in R's configure:
- LINK_SIZE is set on the command line */
-+#define HAVE_MEMMOVE 1
-+#define MATCH_LIMIT 10000000
-+#define MATCH_LIMIT_RECURSION MATCH_LIMIT
-+#define MAX_NAME_COUNT 10000
-+#define MAX_NAME_SIZE 32
-+#define NEWLINE 10
-+#define PARENS_NEST_LIMIT 250
-+#define POSIX_MALLOC_THRESHOLD 10
-+#define SUPPORT_UCP
-+#define SUPPORT_UTF
-+
-+/* See http://sourceforge.net/p/predef/wiki/Architectures/
-+ SPARC_32 support added in 8.32, 'experimental'.
-+
-+ At least i386 support did not compile on Solaris Studio.
-+ */
-+#ifndef __SUNPRO_C
-+#if defined(WIN32) || defined(__i386__) || defined(__i386) || defined(__x86_64__) || defined(__ppc64__) || defined(__powerpc64__) || defined(__ppc__) || defined(__powerpc__) || defined(__sparc__)
-+# define SUPPORT_JIT
-+#endif
-+#endif
-+
- /* Define PCRE_DEBUG to get debugging output on stdout. */
-
- #if 0
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitConfig.h r-base-3.3.1/src/extra/pcre/sljit/sljitConfig.h
--- r-base-3.2.3/src/extra/pcre/sljit/sljitConfig.h 2015-11-26 23:15:10.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitConfig.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,135 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _SLJIT_CONFIG_H_
-#define _SLJIT_CONFIG_H_
-
-/* --------------------------------------------------------------------- */
-/* Custom defines */
-/* --------------------------------------------------------------------- */
-
-/* Put your custom defines here. This empty section will never change
- which helps maintaining patches (with diff / patch utilities). */
-
-/* --------------------------------------------------------------------- */
-/* Architecture */
-/* --------------------------------------------------------------------- */
-
-/* Architecture selection. */
-/* #define SLJIT_CONFIG_X86_32 1 */
-/* #define SLJIT_CONFIG_X86_64 1 */
-/* #define SLJIT_CONFIG_ARM_V5 1 */
-/* #define SLJIT_CONFIG_ARM_V7 1 */
-/* #define SLJIT_CONFIG_ARM_THUMB2 1 */
-/* #define SLJIT_CONFIG_ARM_64 1 */
-/* #define SLJIT_CONFIG_PPC_32 1 */
-/* #define SLJIT_CONFIG_PPC_64 1 */
-/* #define SLJIT_CONFIG_MIPS_32 1 */
-/* #define SLJIT_CONFIG_MIPS_64 1 */
-/* #define SLJIT_CONFIG_SPARC_32 1 */
-/* #define SLJIT_CONFIG_TILEGX 1 */
-
-/* #define SLJIT_CONFIG_AUTO 1 */
-/* #define SLJIT_CONFIG_UNSUPPORTED 1 */
-
-/* --------------------------------------------------------------------- */
-/* Utilities */
-/* --------------------------------------------------------------------- */
-
-/* Useful for thread-safe compiling of global functions. */
-#ifndef SLJIT_UTIL_GLOBAL_LOCK
-/* Enabled by default */
-#define SLJIT_UTIL_GLOBAL_LOCK 1
-#endif
-
-/* Implements a stack like data structure (by using mmap / VirtualAlloc). */
-#ifndef SLJIT_UTIL_STACK
-/* Enabled by default */
-#define SLJIT_UTIL_STACK 1
-#endif
-
-/* Single threaded application. Does not require any locks. */
-#ifndef SLJIT_SINGLE_THREADED
-/* Disabled by default. */
-#define SLJIT_SINGLE_THREADED 0
-#endif
-
-/* --------------------------------------------------------------------- */
-/* Configuration */
-/* --------------------------------------------------------------------- */
-
-/* If SLJIT_STD_MACROS_DEFINED is not defined, the application should
- define SLJIT_MALLOC, SLJIT_FREE, SLJIT_MEMMOVE, and NULL. */
-#ifndef SLJIT_STD_MACROS_DEFINED
-/* Disabled by default. */
-#define SLJIT_STD_MACROS_DEFINED 0
-#endif
-
-/* Executable code allocation:
- If SLJIT_EXECUTABLE_ALLOCATOR is not defined, the application should
- define both SLJIT_MALLOC_EXEC and SLJIT_FREE_EXEC. */
-#ifndef SLJIT_EXECUTABLE_ALLOCATOR
-/* Enabled by default. */
-#define SLJIT_EXECUTABLE_ALLOCATOR 1
-#endif
-
-/* Force cdecl calling convention even if a better calling
- convention (e.g. fastcall) is supported by the C compiler.
- If this option is enabled, C functions without
- SLJIT_CALL can also be called from JIT code. */
-#ifndef SLJIT_USE_CDECL_CALLING_CONVENTION
-/* Disabled by default */
-#define SLJIT_USE_CDECL_CALLING_CONVENTION 0
-#endif
-
-/* Return with error when an invalid argument is passed. */
-#ifndef SLJIT_ARGUMENT_CHECKS
-/* Disabled by default */
-#define SLJIT_ARGUMENT_CHECKS 0
-#endif
-
-/* Debug checks (assertions, etc.). */
-#ifndef SLJIT_DEBUG
-/* Enabled by default */
-#define SLJIT_DEBUG 1
-#endif
-
-/* Verbose operations. */
-#ifndef SLJIT_VERBOSE
-/* Enabled by default */
-#define SLJIT_VERBOSE 1
-#endif
-
-/*
- SLJIT_IS_FPU_AVAILABLE
- The availability of the FPU can be controlled by SLJIT_IS_FPU_AVAILABLE.
- zero value - FPU is NOT present.
- nonzero value - FPU is present.
-*/
-
-/* For further configurations, see the beginning of sljitConfigInternal.h */
-
-#endif
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitConfigInternal.h r-base-3.3.1/src/extra/pcre/sljit/sljitConfigInternal.h
--- r-base-3.2.3/src/extra/pcre/sljit/sljitConfigInternal.h 2015-11-26 23:15:10.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitConfigInternal.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,713 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _SLJIT_CONFIG_INTERNAL_H_
-#define _SLJIT_CONFIG_INTERNAL_H_
-
-/*
- SLJIT defines the following architecture dependent types and macros:
-
- Types:
- sljit_sb, sljit_ub : signed and unsigned 8 bit byte
- sljit_sh, sljit_uh : signed and unsigned 16 bit half-word (short) type
- sljit_si, sljit_ui : signed and unsigned 32 bit integer type
- sljit_sw, sljit_uw : signed and unsigned machine word, enough to store a pointer
- sljit_p : unsgined pointer value (usually the same as sljit_uw, but
- some 64 bit ABIs may use 32 bit pointers)
- sljit_s : single precision floating point value
- sljit_d : double precision floating point value
-
- Macros for feature detection (boolean):
- SLJIT_32BIT_ARCHITECTURE : 32 bit architecture
- SLJIT_64BIT_ARCHITECTURE : 64 bit architecture
- SLJIT_LITTLE_ENDIAN : little endian architecture
- SLJIT_BIG_ENDIAN : big endian architecture
- SLJIT_UNALIGNED : allows unaligned memory accesses for non-fpu operations (only!)
- SLJIT_INDIRECT_CALL : see SLJIT_FUNC_OFFSET() for more information
-
- Constants:
- SLJIT_NUMBER_OF_REGISTERS : number of available registers
- SLJIT_NUMBER_OF_SCRATCH_REGISTERS : number of available scratch registers
- SLJIT_NUMBER_OF_SAVED_REGISTERS : number of available saved registers
- SLJIT_NUMBER_OF_FLOAT_REGISTERS : number of available floating point registers
- SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS : number of available floating point scratch registers
- SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS : number of available floating point saved registers
- SLJIT_WORD_SHIFT : the shift required to apply when accessing a sljit_sw/sljit_uw array by index
- SLJIT_DOUBLE_SHIFT : the shift required to apply when accessing
- a double precision floating point array by index
- SLJIT_SINGLE_SHIFT : the shift required to apply when accessing
- a single precision floating point array by index
- SLJIT_LOCALS_OFFSET : local space starting offset (SLJIT_SP + SLJIT_LOCALS_OFFSET)
- SLJIT_RETURN_ADDRESS_OFFSET : a return instruction always adds this offset to the return address
-
- Other macros:
- SLJIT_CALL : C calling convention define for both calling JIT form C and C callbacks for JIT
- SLJIT_W(number) : defining 64 bit constants on 64 bit architectures (compiler independent helper)
-*/
-
-/*****************/
-/* Sanity check. */
-/*****************/
-
-#if !((defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
- || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
- || (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
- || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
- || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
- || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
- || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
- || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
- || (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
- || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
- || (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
- || (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
- || (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
- || (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED))
-#error "An architecture must be selected"
-#endif
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
- + (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
- + (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) \
- + (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
- + (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
- + (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
- + (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
- + (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
- + (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX) \
- + (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
- + (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
- + (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) \
- + (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO) \
- + (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) >= 2
-#error "Multiple architectures are selected"
-#endif
-
-/********************************************************/
-/* Automatic CPU detection (requires compiler support). */
-/********************************************************/
-
-#if (defined SLJIT_CONFIG_AUTO && SLJIT_CONFIG_AUTO)
-
-#ifndef _WIN32
-
-#if defined(__i386__) || defined(__i386)
-#define SLJIT_CONFIG_X86_32 1
-#elif defined(__x86_64__)
-#define SLJIT_CONFIG_X86_64 1
-#elif defined(__arm__) || defined(__ARM__)
-#ifdef __thumb2__
-#define SLJIT_CONFIG_ARM_THUMB2 1
-#elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__)
-#define SLJIT_CONFIG_ARM_V7 1
-#else
-#define SLJIT_CONFIG_ARM_V5 1
-#endif
-#elif defined (__aarch64__)
-#define SLJIT_CONFIG_ARM_64 1
-#elif defined(__ppc64__) || defined(__powerpc64__) || defined(_ARCH_PPC64) || (defined(_POWER) && defined(__64BIT__))
-#define SLJIT_CONFIG_PPC_64 1
-#elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC) || defined(_ARCH_PWR) || defined(_ARCH_PWR2) || defined(_POWER)
-#define SLJIT_CONFIG_PPC_32 1
-#elif defined(__mips__) && !defined(_LP64)
-#define SLJIT_CONFIG_MIPS_32 1
-#elif defined(__mips64)
-#define SLJIT_CONFIG_MIPS_64 1
-#elif defined(__sparc__) || defined(__sparc)
-#define SLJIT_CONFIG_SPARC_32 1
-#elif defined(__tilegx__)
-#define SLJIT_CONFIG_TILEGX 1
-#else
-/* Unsupported architecture */
-#define SLJIT_CONFIG_UNSUPPORTED 1
-#endif
-
-#else /* !_WIN32 */
-
-#if defined(_M_X64) || defined(__x86_64__)
-#define SLJIT_CONFIG_X86_64 1
-#elif defined(_ARM_)
-#define SLJIT_CONFIG_ARM_V5 1
-#else
-#define SLJIT_CONFIG_X86_32 1
-#endif
-
-#endif /* !WIN32 */
-#endif /* SLJIT_CONFIG_AUTO */
-
-#if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
-#undef SLJIT_EXECUTABLE_ALLOCATOR
-#endif
-
-/******************************/
-/* CPU family type detection. */
-/******************************/
-
-#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
- || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
-#define SLJIT_CONFIG_ARM_32 1
-#endif
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
-#define SLJIT_CONFIG_X86 1
-#elif (defined SLJIT_CONFIG_ARM_32 && SLJIT_CONFIG_ARM_32) || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
-#define SLJIT_CONFIG_ARM 1
-#elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-#define SLJIT_CONFIG_PPC 1
-#elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
-#define SLJIT_CONFIG_MIPS 1
-#elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32) || (defined SLJIT_CONFIG_SPARC_64 && SLJIT_CONFIG_SPARC_64)
-#define SLJIT_CONFIG_SPARC 1
-#endif
-
-/**********************************/
-/* External function definitions. */
-/**********************************/
-
-#if !(defined SLJIT_STD_MACROS_DEFINED && SLJIT_STD_MACROS_DEFINED)
-
-/* These libraries are needed for the macros below. */
-#include
-#include
-
-#endif /* SLJIT_STD_MACROS_DEFINED */
-
-/* General macros:
- Note: SLJIT is designed to be independent from them as possible.
-
- In release mode (SLJIT_DEBUG is not defined) only the following
- external functions are needed:
-*/
-
-#ifndef SLJIT_MALLOC
-#define SLJIT_MALLOC(size, allocator_data) malloc(size)
-#endif
-
-#ifndef SLJIT_FREE
-#define SLJIT_FREE(ptr, allocator_data) free(ptr)
-#endif
-
-#ifndef SLJIT_MEMMOVE
-#define SLJIT_MEMMOVE(dest, src, len) memmove(dest, src, len)
-#endif
-
-#ifndef SLJIT_ZEROMEM
-#define SLJIT_ZEROMEM(dest, len) memset(dest, 0, len)
-#endif
-
-/***************************/
-/* Compiler helper macros. */
-/***************************/
-
-#if !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY)
-
-#if defined(__GNUC__) && (__GNUC__ >= 3)
-#define SLJIT_LIKELY(x) __builtin_expect((x), 1)
-#define SLJIT_UNLIKELY(x) __builtin_expect((x), 0)
-#else
-#define SLJIT_LIKELY(x) (x)
-#define SLJIT_UNLIKELY(x) (x)
-#endif
-
-#endif /* !defined(SLJIT_LIKELY) && !defined(SLJIT_UNLIKELY) */
-
-#ifndef SLJIT_INLINE
-/* Inline functions. Some old compilers do not support them. */
-#if defined(__SUNPRO_C) && __SUNPRO_C <= 0x510
-#define SLJIT_INLINE
-#else
-#define SLJIT_INLINE __inline
-#endif
-#endif /* !SLJIT_INLINE */
-
-#ifndef SLJIT_NOINLINE
-/* Not inline functions. */
-#if defined(__GNUC__)
-#define SLJIT_NOINLINE __attribute__ ((noinline))
-#else
-#define SLJIT_NOINLINE
-#endif
-#endif /* !SLJIT_INLINE */
-
-#ifndef SLJIT_CONST
-/* Const variables. */
-#define SLJIT_CONST const
-#endif
-
-#ifndef SLJIT_UNUSED_ARG
-/* Unused arguments. */
-#define SLJIT_UNUSED_ARG(arg) (void)arg
-#endif
-
-/*********************************/
-/* Type of public API functions. */
-/*********************************/
-
-#if (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC)
-/* Static ABI functions. For all-in-one programs. */
-
-#if defined(__GNUC__)
-/* Disable unused warnings in gcc. */
-#define SLJIT_API_FUNC_ATTRIBUTE static __attribute__((unused))
-#else
-#define SLJIT_API_FUNC_ATTRIBUTE static
-#endif
-
-#else
-#define SLJIT_API_FUNC_ATTRIBUTE
-#endif /* (defined SLJIT_CONFIG_STATIC && SLJIT_CONFIG_STATIC) */
-
-/****************************/
-/* Instruction cache flush. */
-/****************************/
-
-#ifndef SLJIT_CACHE_FLUSH
-
-#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
-
-/* Not required to implement on archs with unified caches. */
-#define SLJIT_CACHE_FLUSH(from, to)
-
-#elif defined __APPLE__
-
-/* Supported by all macs since Mac OS 10.5.
- However, it does not work on non-jailbroken iOS devices,
- although the compilation is successful. */
-
-#define SLJIT_CACHE_FLUSH(from, to) \
- sys_icache_invalidate((char*)(from), (char*)(to) - (char*)(from))
-
-#elif defined __ANDROID__
-
-/* Android lacks __clear_cache; instead, cacheflush should be used. */
-
-#define SLJIT_CACHE_FLUSH(from, to) \
- cacheflush((long)(from), (long)(to), 0)
-
-#elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
-
-/* The __clear_cache() implementation of GCC is a dummy function on PowerPC. */
-#define SLJIT_CACHE_FLUSH(from, to) \
- ppc_cache_flush((from), (to))
-
-#elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
-
-/* The __clear_cache() implementation of GCC is a dummy function on Sparc. */
-#define SLJIT_CACHE_FLUSH(from, to) \
- sparc_cache_flush((from), (to))
-
-#else
-
-/* Calls __ARM_NR_cacheflush on ARM-Linux. */
-#define SLJIT_CACHE_FLUSH(from, to) \
- __clear_cache((char*)(from), (char*)(to))
-
-#endif
-
-#endif /* !SLJIT_CACHE_FLUSH */
-
-/******************************************************/
-/* Byte/half/int/word/single/double type definitions. */
-/******************************************************/
-
-/* 8 bit byte type. */
-typedef unsigned char sljit_ub;
-typedef signed char sljit_sb;
-
-/* 16 bit half-word type. */
-typedef unsigned short int sljit_uh;
-typedef signed short int sljit_sh;
-
-/* 32 bit integer type. */
-typedef unsigned int sljit_ui;
-typedef signed int sljit_si;
-
-/* Machine word type. Enough for storing a pointer.
- 32 bit for 32 bit machines.
- 64 bit for 64 bit machines. */
-#if (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
-/* Just to have something. */
-#define SLJIT_WORD_SHIFT 0
-typedef unsigned long int sljit_uw;
-typedef long int sljit_sw;
-#elif !(defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
- && !(defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
- && !(defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) \
- && !(defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64) \
- && !(defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
-#define SLJIT_32BIT_ARCHITECTURE 1
-#define SLJIT_WORD_SHIFT 2
-typedef unsigned int sljit_uw;
-typedef int sljit_sw;
-#else
-#define SLJIT_64BIT_ARCHITECTURE 1
-#define SLJIT_WORD_SHIFT 3
-#ifdef _WIN32
-typedef unsigned __int64 sljit_uw;
-typedef __int64 sljit_sw;
-#else
-typedef unsigned long int sljit_uw;
-typedef long int sljit_sw;
-#endif
-#endif
-
-typedef sljit_uw sljit_p;
-
-/* Floating point types. */
-typedef float sljit_s;
-typedef double sljit_d;
-
-/* Shift for pointer sized data. */
-#define SLJIT_POINTER_SHIFT SLJIT_WORD_SHIFT
-
-/* Shift for double precision sized data. */
-#define SLJIT_DOUBLE_SHIFT 3
-#define SLJIT_SINGLE_SHIFT 2
-
-#ifndef SLJIT_W
-
-/* Defining long constants. */
-#if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
-#define SLJIT_W(w) (w##ll)
-#else
-#define SLJIT_W(w) (w)
-#endif
-
-#endif /* !SLJIT_W */
-
-/*************************/
-/* Endianness detection. */
-/*************************/
-
-#if !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN)
-
-/* These macros are mostly useful for the applications. */
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
- || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-
-#ifdef __LITTLE_ENDIAN__
-#define SLJIT_LITTLE_ENDIAN 1
-#else
-#define SLJIT_BIG_ENDIAN 1
-#endif
-
-#elif (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32) \
- || (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
-
-#ifdef __MIPSEL__
-#define SLJIT_LITTLE_ENDIAN 1
-#else
-#define SLJIT_BIG_ENDIAN 1
-#endif
-
-#elif (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
-
-#define SLJIT_BIG_ENDIAN 1
-
-#else
-#define SLJIT_LITTLE_ENDIAN 1
-#endif
-
-#endif /* !defined(SLJIT_BIG_ENDIAN) && !defined(SLJIT_LITTLE_ENDIAN) */
-
-/* Sanity check. */
-#if (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
-#error "Exactly one endianness must be selected"
-#endif
-
-#if !(defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN) && !(defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
-#error "Exactly one endianness must be selected"
-#endif
-
-#ifndef SLJIT_UNALIGNED
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) \
- || (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) \
- || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7) \
- || (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2) \
- || (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64) \
- || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) \
- || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-#define SLJIT_UNALIGNED 1
-#endif
-
-#endif /* !SLJIT_UNALIGNED */
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-/* Auto detect SSE2 support using CPUID.
- On 64 bit x86 cpus, sse2 must be present. */
-#define SLJIT_DETECT_SSE2 1
-#endif
-
-/*****************************************************************************************/
-/* Calling convention of functions generated by SLJIT or called from the generated code. */
-/*****************************************************************************************/
-
-#ifndef SLJIT_CALL
-
-#if (defined SLJIT_USE_CDECL_CALLING_CONVENTION && SLJIT_USE_CDECL_CALLING_CONVENTION)
-
-/* Force cdecl. */
-#define SLJIT_CALL
-
-#elif (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-
-#if defined(__GNUC__) && !defined(__APPLE__)
-
-#define SLJIT_CALL __attribute__ ((fastcall))
-#define SLJIT_X86_32_FASTCALL 1
-
-#elif defined(_MSC_VER)
-
-#define SLJIT_CALL __fastcall
-#define SLJIT_X86_32_FASTCALL 1
-
-#elif defined(__BORLANDC__)
-
-#define SLJIT_CALL __msfastcall
-#define SLJIT_X86_32_FASTCALL 1
-
-#else /* Unknown compiler. */
-
-/* The cdecl attribute is the default. */
-#define SLJIT_CALL
-
-#endif
-
-#else /* Non x86-32 architectures. */
-
-#define SLJIT_CALL
-
-#endif /* SLJIT_CONFIG_X86_32 */
-
-#endif /* !SLJIT_CALL */
-
-#ifndef SLJIT_INDIRECT_CALL
-#if ((defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) && (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)) \
- || ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && defined _AIX)
-/* It seems certain ppc compilers use an indirect addressing for functions
- which makes things complicated. */
-#define SLJIT_INDIRECT_CALL 1
-#endif
-#endif /* SLJIT_INDIRECT_CALL */
-
-/* The offset which needs to be substracted from the return address to
-determine the next executed instruction after return. */
-#ifndef SLJIT_RETURN_ADDRESS_OFFSET
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
-#define SLJIT_RETURN_ADDRESS_OFFSET 8
-#else
-#define SLJIT_RETURN_ADDRESS_OFFSET 0
-#endif
-#endif /* SLJIT_RETURN_ADDRESS_OFFSET */
-
-/***************************************************/
-/* Functions of the built-in executable allocator. */
-/***************************************************/
-
-#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
-SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size);
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr);
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void);
-#define SLJIT_MALLOC_EXEC(size) sljit_malloc_exec(size)
-#define SLJIT_FREE_EXEC(ptr) sljit_free_exec(ptr)
-#endif
-
-/**********************************************/
-/* Registers and locals offset determination. */
-/**********************************************/
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-
-#define SLJIT_NUMBER_OF_REGISTERS 10
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
-#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
-#define SLJIT_LOCALS_OFFSET_BASE ((2 + 4) * sizeof(sljit_sw))
-#else
-/* Maximum 3 arguments are passed on the stack, +1 for double alignment. */
-#define SLJIT_LOCALS_OFFSET_BASE ((3 + 1 + 4) * sizeof(sljit_sw))
-#endif /* SLJIT_X86_32_FASTCALL */
-
-#elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
-
-#ifndef _WIN64
-#define SLJIT_NUMBER_OF_REGISTERS 12
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 6
-#define SLJIT_LOCALS_OFFSET_BASE (sizeof(sljit_sw))
-#else
-#define SLJIT_NUMBER_OF_REGISTERS 12
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
-#define SLJIT_LOCALS_OFFSET_BASE ((4 + 2) * sizeof(sljit_sw))
-#endif /* _WIN64 */
-
-#elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
-
-#define SLJIT_NUMBER_OF_REGISTERS 11
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
-#define SLJIT_LOCALS_OFFSET_BASE 0
-
-#elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
-
-#define SLJIT_NUMBER_OF_REGISTERS 11
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 7
-#define SLJIT_LOCALS_OFFSET_BASE 0
-
-#elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
-
-#define SLJIT_NUMBER_OF_REGISTERS 25
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 10
-#define SLJIT_LOCALS_OFFSET_BASE (2 * sizeof(sljit_sw))
-
-#elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
-
-#define SLJIT_NUMBER_OF_REGISTERS 22
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 17
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) || (defined _AIX)
-#define SLJIT_LOCALS_OFFSET_BASE ((6 + 8) * sizeof(sljit_sw))
-#elif (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
-/* Add +1 for double alignment. */
-#define SLJIT_LOCALS_OFFSET_BASE ((3 + 1) * sizeof(sljit_sw))
-#else
-#define SLJIT_LOCALS_OFFSET_BASE (3 * sizeof(sljit_sw))
-#endif /* SLJIT_CONFIG_PPC_64 || _AIX */
-
-#elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
-
-#define SLJIT_NUMBER_OF_REGISTERS 17
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 8
-#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
-#define SLJIT_LOCALS_OFFSET_BASE (4 * sizeof(sljit_sw))
-#else
-#define SLJIT_LOCALS_OFFSET_BASE 0
-#endif
-
-#elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
-
-#define SLJIT_NUMBER_OF_REGISTERS 18
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 14
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
-/* Add +1 for double alignment. */
-#define SLJIT_LOCALS_OFFSET_BASE ((23 + 1) * sizeof(sljit_sw))
-#endif
-
-#elif (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
-
-#define SLJIT_NUMBER_OF_REGISTERS 10
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 5
-#define SLJIT_LOCALS_OFFSET_BASE 0
-
-#elif (defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
-
-#define SLJIT_NUMBER_OF_REGISTERS 0
-#define SLJIT_NUMBER_OF_SAVED_REGISTERS 0
-#define SLJIT_LOCALS_OFFSET_BASE 0
-
-#endif
-
-#define SLJIT_LOCALS_OFFSET (SLJIT_LOCALS_OFFSET_BASE)
-
-#define SLJIT_NUMBER_OF_SCRATCH_REGISTERS \
- (SLJIT_NUMBER_OF_REGISTERS - SLJIT_NUMBER_OF_SAVED_REGISTERS)
-
-#define SLJIT_NUMBER_OF_FLOAT_REGISTERS 6
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && (defined _WIN64)
-#define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 1
-#else
-#define SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS 0
-#endif
-
-#define SLJIT_NUMBER_OF_SCRATCH_FLOAT_REGISTERS \
- (SLJIT_NUMBER_OF_FLOAT_REGISTERS - SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS)
-
-/*************************************/
-/* Debug and verbose related macros. */
-/*************************************/
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
-#include
-#endif
-
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
-
-#if !defined(SLJIT_ASSERT) || !defined(SLJIT_ASSERT_STOP)
-
-/* SLJIT_HALT_PROCESS must halt the process. */
-#ifndef SLJIT_HALT_PROCESS
-#include
-
-#define SLJIT_HALT_PROCESS() \
- abort();
-#endif /* !SLJIT_HALT_PROCESS */
-
-#include
-
-#endif /* !SLJIT_ASSERT || !SLJIT_ASSERT_STOP */
-
-/* Feel free to redefine these two macros. */
-#ifndef SLJIT_ASSERT
-
-#define SLJIT_ASSERT(x) \
- do { \
- if (SLJIT_UNLIKELY(!(x))) { \
- printf("Assertion failed at " __FILE__ ":%d\n", __LINE__); \
- SLJIT_HALT_PROCESS(); \
- } \
- } while (0)
-
-#endif /* !SLJIT_ASSERT */
-
-#ifndef SLJIT_ASSERT_STOP
-
-#define SLJIT_ASSERT_STOP() \
- do { \
- printf("Should never been reached " __FILE__ ":%d\n", __LINE__); \
- SLJIT_HALT_PROCESS(); \
- } while (0)
-
-#endif /* !SLJIT_ASSERT_STOP */
-
-#else /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
-
-/* Forcing empty, but valid statements. */
-#undef SLJIT_ASSERT
-#undef SLJIT_ASSERT_STOP
-
-#define SLJIT_ASSERT(x) \
- do { } while (0)
-#define SLJIT_ASSERT_STOP() \
- do { } while (0)
-
-#endif /* (defined SLJIT_DEBUG && SLJIT_DEBUG) */
-
-#ifndef SLJIT_COMPILE_ASSERT
-
-/* Should be improved eventually. */
-#define SLJIT_COMPILE_ASSERT(x, description) \
- SLJIT_ASSERT(x)
-
-#endif /* !SLJIT_COMPILE_ASSERT */
-
-#endif
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitExecAllocator.c r-base-3.3.1/src/extra/pcre/sljit/sljitExecAllocator.c
--- r-base-3.2.3/src/extra/pcre/sljit/sljitExecAllocator.c 2013-12-30 23:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitExecAllocator.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,312 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- This file contains a simple executable memory allocator
-
- It is assumed, that executable code blocks are usually medium (or sometimes
- large) memory blocks, and the allocator is not too frequently called (less
- optimized than other allocators). Thus, using it as a generic allocator is
- not suggested.
-
- How does it work:
- Memory is allocated in continuous memory areas called chunks by alloc_chunk()
- Chunk format:
- [ block ][ block ] ... [ block ][ block terminator ]
-
- All blocks and the block terminator is started with block_header. The block
- header contains the size of the previous and the next block. These sizes
- can also contain special values.
- Block size:
- 0 - The block is a free_block, with a different size member.
- 1 - The block is a block terminator.
- n - The block is used at the moment, and the value contains its size.
- Previous block size:
- 0 - This is the first block of the memory chunk.
- n - The size of the previous block.
-
- Using these size values we can go forward or backward on the block chain.
- The unused blocks are stored in a chain list pointed by free_blocks. This
- list is useful if we need to find a suitable memory area when the allocator
- is called.
-
- When a block is freed, the new free block is connected to its adjacent free
- blocks if possible.
-
- [ free block ][ used block ][ free block ]
- and "used block" is freed, the three blocks are connected together:
- [ one big free block ]
-*/
-
-/* --------------------------------------------------------------------- */
-/* System (OS) functions */
-/* --------------------------------------------------------------------- */
-
-/* 64 KByte. */
-#define CHUNK_SIZE 0x10000
-
-/*
- alloc_chunk / free_chunk :
- * allocate executable system memory chunks
- * the size is always divisible by CHUNK_SIZE
- allocator_grab_lock / allocator_release_lock :
- * make the allocator thread safe
- * can be empty if the OS (or the application) does not support threading
- * only the allocator requires this lock, sljit is fully thread safe
- as it only uses local variables
-*/
-
-#ifdef _WIN32
-
-static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
-{
- return VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
-}
-
-static SLJIT_INLINE void free_chunk(void* chunk, sljit_uw size)
-{
- SLJIT_UNUSED_ARG(size);
- VirtualFree(chunk, 0, MEM_RELEASE);
-}
-
-#else
-
-static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
-{
- void* retval;
-
-#ifdef MAP_ANON
- retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0);
-#else
- if (dev_zero < 0) {
- if (open_dev_zero())
- return NULL;
- }
- retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, dev_zero, 0);
-#endif
-
- return (retval != MAP_FAILED) ? retval : NULL;
-}
-
-static SLJIT_INLINE void free_chunk(void* chunk, sljit_uw size)
-{
- munmap(chunk, size);
-}
-
-#endif
-
-/* --------------------------------------------------------------------- */
-/* Common functions */
-/* --------------------------------------------------------------------- */
-
-#define CHUNK_MASK (~(CHUNK_SIZE - 1))
-
-struct block_header {
- sljit_uw size;
- sljit_uw prev_size;
-};
-
-struct free_block {
- struct block_header header;
- struct free_block *next;
- struct free_block *prev;
- sljit_uw size;
-};
-
-#define AS_BLOCK_HEADER(base, offset) \
- ((struct block_header*)(((sljit_ub*)base) + offset))
-#define AS_FREE_BLOCK(base, offset) \
- ((struct free_block*)(((sljit_ub*)base) + offset))
-#define MEM_START(base) ((void*)(((sljit_ub*)base) + sizeof(struct block_header)))
-#define ALIGN_SIZE(size) (((size) + sizeof(struct block_header) + 7) & ~7)
-
-static struct free_block* free_blocks;
-static sljit_uw allocated_size;
-static sljit_uw total_size;
-
-static SLJIT_INLINE void sljit_insert_free_block(struct free_block *free_block, sljit_uw size)
-{
- free_block->header.size = 0;
- free_block->size = size;
-
- free_block->next = free_blocks;
- free_block->prev = 0;
- if (free_blocks)
- free_blocks->prev = free_block;
- free_blocks = free_block;
-}
-
-static SLJIT_INLINE void sljit_remove_free_block(struct free_block *free_block)
-{
- if (free_block->next)
- free_block->next->prev = free_block->prev;
-
- if (free_block->prev)
- free_block->prev->next = free_block->next;
- else {
- SLJIT_ASSERT(free_blocks == free_block);
- free_blocks = free_block->next;
- }
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void* sljit_malloc_exec(sljit_uw size)
-{
- struct block_header *header;
- struct block_header *next_header;
- struct free_block *free_block;
- sljit_uw chunk_size;
-
- allocator_grab_lock();
- if (size < sizeof(struct free_block))
- size = sizeof(struct free_block);
- size = ALIGN_SIZE(size);
-
- free_block = free_blocks;
- while (free_block) {
- if (free_block->size >= size) {
- chunk_size = free_block->size;
- if (chunk_size > size + 64) {
- /* We just cut a block from the end of the free block. */
- chunk_size -= size;
- free_block->size = chunk_size;
- header = AS_BLOCK_HEADER(free_block, chunk_size);
- header->prev_size = chunk_size;
- AS_BLOCK_HEADER(header, size)->prev_size = size;
- }
- else {
- sljit_remove_free_block(free_block);
- header = (struct block_header*)free_block;
- size = chunk_size;
- }
- allocated_size += size;
- header->size = size;
- allocator_release_lock();
- return MEM_START(header);
- }
- free_block = free_block->next;
- }
-
- chunk_size = (size + sizeof(struct block_header) + CHUNK_SIZE - 1) & CHUNK_MASK;
- header = (struct block_header*)alloc_chunk(chunk_size);
- if (!header) {
- allocator_release_lock();
- return NULL;
- }
-
- chunk_size -= sizeof(struct block_header);
- total_size += chunk_size;
-
- header->prev_size = 0;
- if (chunk_size > size + 64) {
- /* Cut the allocated space into a free and a used block. */
- allocated_size += size;
- header->size = size;
- chunk_size -= size;
-
- free_block = AS_FREE_BLOCK(header, size);
- free_block->header.prev_size = size;
- sljit_insert_free_block(free_block, chunk_size);
- next_header = AS_BLOCK_HEADER(free_block, chunk_size);
- }
- else {
- /* All space belongs to this allocation. */
- allocated_size += chunk_size;
- header->size = chunk_size;
- next_header = AS_BLOCK_HEADER(header, chunk_size);
- }
- next_header->size = 1;
- next_header->prev_size = chunk_size;
- allocator_release_lock();
- return MEM_START(header);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_exec(void* ptr)
-{
- struct block_header *header;
- struct free_block* free_block;
-
- allocator_grab_lock();
- header = AS_BLOCK_HEADER(ptr, -(sljit_sw)sizeof(struct block_header));
- allocated_size -= header->size;
-
- /* Connecting free blocks together if possible. */
-
- /* If header->prev_size == 0, free_block will equal to header.
- In this case, free_block->header.size will be > 0. */
- free_block = AS_FREE_BLOCK(header, -(sljit_sw)header->prev_size);
- if (SLJIT_UNLIKELY(!free_block->header.size)) {
- free_block->size += header->size;
- header = AS_BLOCK_HEADER(free_block, free_block->size);
- header->prev_size = free_block->size;
- }
- else {
- free_block = (struct free_block*)header;
- sljit_insert_free_block(free_block, header->size);
- }
-
- header = AS_BLOCK_HEADER(free_block, free_block->size);
- if (SLJIT_UNLIKELY(!header->size)) {
- free_block->size += ((struct free_block*)header)->size;
- sljit_remove_free_block((struct free_block*)header);
- header = AS_BLOCK_HEADER(free_block, free_block->size);
- header->prev_size = free_block->size;
- }
-
- /* The whole chunk is free. */
- if (SLJIT_UNLIKELY(!free_block->header.prev_size && header->size == 1)) {
- /* If this block is freed, we still have (allocated_size / 2) free space. */
- if (total_size - free_block->size > (allocated_size * 3 / 2)) {
- total_size -= free_block->size;
- sljit_remove_free_block(free_block);
- free_chunk(free_block, free_block->size + sizeof(struct block_header));
- }
- }
-
- allocator_release_lock();
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_unused_memory_exec(void)
-{
- struct free_block* free_block;
- struct free_block* next_free_block;
-
- allocator_grab_lock();
-
- free_block = free_blocks;
- while (free_block) {
- next_free_block = free_block->next;
- if (!free_block->header.prev_size &&
- AS_BLOCK_HEADER(free_block, free_block->size)->size == 1) {
- total_size -= free_block->size;
- sljit_remove_free_block(free_block);
- free_chunk(free_block, free_block->size + sizeof(struct block_header));
- }
- free_block = next_free_block;
- }
-
- SLJIT_ASSERT((total_size && free_blocks) || (!total_size && !free_blocks));
- allocator_release_lock();
-}
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitLir.c r-base-3.3.1/src/extra/pcre/sljit/sljitLir.c
--- r-base-3.2.3/src/extra/pcre/sljit/sljitLir.c 2015-11-26 23:15:10.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitLir.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,2029 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "sljitLir.h"
-
-#define CHECK_ERROR() \
- do { \
- if (SLJIT_UNLIKELY(compiler->error)) \
- return compiler->error; \
- } while (0)
-
-#define CHECK_ERROR_PTR() \
- do { \
- if (SLJIT_UNLIKELY(compiler->error)) \
- return NULL; \
- } while (0)
-
-#define FAIL_IF(expr) \
- do { \
- if (SLJIT_UNLIKELY(expr)) \
- return compiler->error; \
- } while (0)
-
-#define PTR_FAIL_IF(expr) \
- do { \
- if (SLJIT_UNLIKELY(expr)) \
- return NULL; \
- } while (0)
-
-#define FAIL_IF_NULL(ptr) \
- do { \
- if (SLJIT_UNLIKELY(!(ptr))) { \
- compiler->error = SLJIT_ERR_ALLOC_FAILED; \
- return SLJIT_ERR_ALLOC_FAILED; \
- } \
- } while (0)
-
-#define PTR_FAIL_IF_NULL(ptr) \
- do { \
- if (SLJIT_UNLIKELY(!(ptr))) { \
- compiler->error = SLJIT_ERR_ALLOC_FAILED; \
- return NULL; \
- } \
- } while (0)
-
-#define PTR_FAIL_WITH_EXEC_IF(ptr) \
- do { \
- if (SLJIT_UNLIKELY(!(ptr))) { \
- compiler->error = SLJIT_ERR_EX_ALLOC_FAILED; \
- return NULL; \
- } \
- } while (0)
-
-#if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
-
-#define GET_OPCODE(op) \
- ((op) & ~(SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
-
-#define GET_FLAGS(op) \
- ((op) & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C))
-
-#define GET_ALL_FLAGS(op) \
- ((op) & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))
-
-#define TYPE_CAST_NEEDED(op) \
- (((op) >= SLJIT_MOV_UB && (op) <= SLJIT_MOV_SH) || ((op) >= SLJIT_MOVU_UB && (op) <= SLJIT_MOVU_SH))
-
-#define BUF_SIZE 4096
-
-#if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
-#define ABUF_SIZE 2048
-#else
-#define ABUF_SIZE 4096
-#endif
-
-/* Parameter parsing. */
-#define REG_MASK 0x3f
-#define OFFS_REG(reg) (((reg) >> 8) & REG_MASK)
-#define OFFS_REG_MASK (REG_MASK << 8)
-#define TO_OFFS_REG(reg) ((reg) << 8)
-/* When reg cannot be unused. */
-#define FAST_IS_REG(reg) ((reg) <= REG_MASK)
-/* When reg can be unused. */
-#define SLOW_IS_REG(reg) ((reg) > 0 && (reg) <= REG_MASK)
-
-/* Jump flags. */
-#define JUMP_LABEL 0x1
-#define JUMP_ADDR 0x2
-/* SLJIT_REWRITABLE_JUMP is 0x1000. */
-
-#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
-# define PATCH_MB 0x4
-# define PATCH_MW 0x8
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
-# define PATCH_MD 0x10
-#endif
-#endif
-
-#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
-# define IS_BL 0x4
-# define PATCH_B 0x8
-#endif
-
-#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
-# define CPOOL_SIZE 512
-#endif
-
-#if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
-# define IS_COND 0x04
-# define IS_BL 0x08
- /* conditional + imm8 */
-# define PATCH_TYPE1 0x10
- /* conditional + imm20 */
-# define PATCH_TYPE2 0x20
- /* IT + imm24 */
-# define PATCH_TYPE3 0x30
- /* imm11 */
-# define PATCH_TYPE4 0x40
- /* imm24 */
-# define PATCH_TYPE5 0x50
- /* BL + imm24 */
-# define PATCH_BL 0x60
- /* 0xf00 cc code for branches */
-#endif
-
-#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
-# define IS_COND 0x004
-# define IS_CBZ 0x008
-# define IS_BL 0x010
-# define PATCH_B 0x020
-# define PATCH_COND 0x040
-# define PATCH_ABS48 0x080
-# define PATCH_ABS64 0x100
-#endif
-
-#if (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
-# define IS_COND 0x004
-# define IS_CALL 0x008
-# define PATCH_B 0x010
-# define PATCH_ABS_B 0x020
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-# define PATCH_ABS32 0x040
-# define PATCH_ABS48 0x080
-#endif
-# define REMOVE_COND 0x100
-#endif
-
-#if (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
-# define IS_MOVABLE 0x004
-# define IS_JAL 0x008
-# define IS_CALL 0x010
-# define IS_BIT26_COND 0x020
-# define IS_BIT16_COND 0x040
-
-# define IS_COND (IS_BIT26_COND | IS_BIT16_COND)
-
-# define PATCH_B 0x080
-# define PATCH_J 0x100
-
-#if (defined SLJIT_CONFIG_MIPS_64 && SLJIT_CONFIG_MIPS_64)
-# define PATCH_ABS32 0x200
-# define PATCH_ABS48 0x400
-#endif
-
- /* instruction types */
-# define MOVABLE_INS 0
- /* 1 - 31 last destination register */
- /* no destination (i.e: store) */
-# define UNMOVABLE_INS 32
- /* FPU status register */
-# define FCSR_FCC 33
-#endif
-
-#if (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
-# define IS_JAL 0x04
-# define IS_COND 0x08
-
-# define PATCH_B 0x10
-# define PATCH_J 0x20
-#endif
-
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
-# define IS_MOVABLE 0x04
-# define IS_COND 0x08
-# define IS_CALL 0x10
-
-# define PATCH_B 0x20
-# define PATCH_CALL 0x40
-
- /* instruction types */
-# define MOVABLE_INS 0
- /* 1 - 31 last destination register */
- /* no destination (i.e: store) */
-# define UNMOVABLE_INS 32
-
-# define DST_INS_MASK 0xff
-
- /* ICC_SET is the same as SET_FLAGS. */
-# define ICC_IS_SET (1 << 23)
-# define FCC_IS_SET (1 << 24)
-#endif
-
-/* Stack management. */
-
-#define GET_SAVED_REGISTERS_SIZE(scratches, saveds, extra) \
- (((scratches < SLJIT_NUMBER_OF_SCRATCH_REGISTERS ? 0 : (scratches - SLJIT_NUMBER_OF_SCRATCH_REGISTERS)) + \
- (saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? saveds : SLJIT_NUMBER_OF_SAVED_REGISTERS) + \
- extra) * sizeof(sljit_sw))
-
-#define ADJUST_LOCAL_OFFSET(p, i) \
- if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
- (i) += SLJIT_LOCALS_OFFSET;
-
-#endif /* !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED) */
-
-/* Utils can still be used even if SLJIT_CONFIG_UNSUPPORTED is set. */
-#include "sljitUtils.c"
-
-#if !(defined SLJIT_CONFIG_UNSUPPORTED && SLJIT_CONFIG_UNSUPPORTED)
-
-#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
-#include "sljitExecAllocator.c"
-#endif
-
-/* Argument checking features. */
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
-
-/* Returns with error when an invalid argument is passed. */
-
-#define CHECK_ARGUMENT(x) \
- do { \
- if (SLJIT_UNLIKELY(!(x))) \
- return 1; \
- } while (0)
-
-#define CHECK_RETURN_TYPE sljit_si
-#define CHECK_RETURN_OK return 0
-
-#define CHECK(x) \
- do { \
- if (SLJIT_UNLIKELY(x)) { \
- compiler->error = SLJIT_ERR_BAD_ARGUMENT; \
- return SLJIT_ERR_BAD_ARGUMENT; \
- } \
- } while (0)
-
-#define CHECK_PTR(x) \
- do { \
- if (SLJIT_UNLIKELY(x)) { \
- compiler->error = SLJIT_ERR_BAD_ARGUMENT; \
- return NULL; \
- } \
- } while (0)
-
-#define CHECK_REG_INDEX(x) \
- do { \
- if (SLJIT_UNLIKELY(x)) { \
- return -2; \
- } \
- } while (0)
-
-#elif (defined SLJIT_DEBUG && SLJIT_DEBUG)
-
-/* Assertion failure occures if an invalid argument is passed. */
-#undef SLJIT_ARGUMENT_CHECKS
-#define SLJIT_ARGUMENT_CHECKS 1
-
-#define CHECK_ARGUMENT(x) SLJIT_ASSERT(x)
-#define CHECK_RETURN_TYPE void
-#define CHECK_RETURN_OK return
-#define CHECK(x) x
-#define CHECK_PTR(x) x
-#define CHECK_REG_INDEX(x) x
-
-#elif (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
-
-/* Arguments are not checked. */
-#define CHECK_RETURN_TYPE void
-#define CHECK_RETURN_OK return
-#define CHECK(x) x
-#define CHECK_PTR(x) x
-#define CHECK_REG_INDEX(x) x
-
-#else
-
-/* Arguments are not checked. */
-#define CHECK(x)
-#define CHECK_PTR(x)
-#define CHECK_REG_INDEX(x)
-
-#endif /* SLJIT_ARGUMENT_CHECKS */
-
-/* --------------------------------------------------------------------- */
-/* Public functions */
-/* --------------------------------------------------------------------- */
-
-#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
-#define SLJIT_NEEDS_COMPILER_INIT 1
-static sljit_si compiler_initialized = 0;
-/* A thread safe initialization. */
-static void init_compiler(void);
-#endif
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data)
-{
- struct sljit_compiler *compiler = (struct sljit_compiler*)SLJIT_MALLOC(sizeof(struct sljit_compiler), allocator_data);
- if (!compiler)
- return NULL;
- SLJIT_ZEROMEM(compiler, sizeof(struct sljit_compiler));
-
- SLJIT_COMPILE_ASSERT(
- sizeof(sljit_sb) == 1 && sizeof(sljit_ub) == 1
- && sizeof(sljit_sh) == 2 && sizeof(sljit_uh) == 2
- && sizeof(sljit_si) == 4 && sizeof(sljit_ui) == 4
- && (sizeof(sljit_p) == 4 || sizeof(sljit_p) == 8)
- && sizeof(sljit_p) <= sizeof(sljit_sw)
- && (sizeof(sljit_sw) == 4 || sizeof(sljit_sw) == 8)
- && (sizeof(sljit_uw) == 4 || sizeof(sljit_uw) == 8),
- invalid_integer_types);
- SLJIT_COMPILE_ASSERT(SLJIT_INT_OP == SLJIT_SINGLE_OP,
- int_op_and_single_op_must_be_the_same);
- SLJIT_COMPILE_ASSERT(SLJIT_REWRITABLE_JUMP != SLJIT_SINGLE_OP,
- rewritable_jump_and_single_op_must_not_be_the_same);
-
- /* Only the non-zero members must be set. */
- compiler->error = SLJIT_SUCCESS;
-
- compiler->allocator_data = allocator_data;
- compiler->buf = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE, allocator_data);
- compiler->abuf = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE, allocator_data);
-
- if (!compiler->buf || !compiler->abuf) {
- if (compiler->buf)
- SLJIT_FREE(compiler->buf, allocator_data);
- if (compiler->abuf)
- SLJIT_FREE(compiler->abuf, allocator_data);
- SLJIT_FREE(compiler, allocator_data);
- return NULL;
- }
-
- compiler->buf->next = NULL;
- compiler->buf->used_size = 0;
- compiler->abuf->next = NULL;
- compiler->abuf->used_size = 0;
-
- compiler->scratches = -1;
- compiler->saveds = -1;
- compiler->fscratches = -1;
- compiler->fsaveds = -1;
- compiler->local_size = -1;
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- compiler->args = -1;
-#endif
-
-#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
- compiler->cpool = (sljit_uw*)SLJIT_MALLOC(CPOOL_SIZE * sizeof(sljit_uw)
- + CPOOL_SIZE * sizeof(sljit_ub), allocator_data);
- if (!compiler->cpool) {
- SLJIT_FREE(compiler->buf, allocator_data);
- SLJIT_FREE(compiler->abuf, allocator_data);
- SLJIT_FREE(compiler, allocator_data);
- return NULL;
- }
- compiler->cpool_unique = (sljit_ub*)(compiler->cpool + CPOOL_SIZE);
- compiler->cpool_diff = 0xffffffff;
-#endif
-
-#if (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
- compiler->delay_slot = UNMOVABLE_INS;
-#endif
-
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- compiler->delay_slot = UNMOVABLE_INS;
-#endif
-
-#if (defined SLJIT_NEEDS_COMPILER_INIT && SLJIT_NEEDS_COMPILER_INIT)
- if (!compiler_initialized) {
- init_compiler();
- compiler_initialized = 1;
- }
-#endif
-
- return compiler;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler)
-{
- struct sljit_memory_fragment *buf;
- struct sljit_memory_fragment *curr;
- void *allocator_data = compiler->allocator_data;
- SLJIT_UNUSED_ARG(allocator_data);
-
- buf = compiler->buf;
- while (buf) {
- curr = buf;
- buf = buf->next;
- SLJIT_FREE(curr, allocator_data);
- }
-
- buf = compiler->abuf;
- while (buf) {
- curr = buf;
- buf = buf->next;
- SLJIT_FREE(curr, allocator_data);
- }
-
-#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
- SLJIT_FREE(compiler->cpool, allocator_data);
-#endif
- SLJIT_FREE(compiler, allocator_data);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_compiler_memory_error(struct sljit_compiler *compiler)
-{
- if (compiler->error == SLJIT_SUCCESS)
- compiler->error = SLJIT_ERR_ALLOC_FAILED;
-}
-
-#if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
-{
- /* Remove thumb mode flag. */
- SLJIT_FREE_EXEC((void*)((sljit_uw)code & ~0x1));
-}
-#elif (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
-{
- /* Resolve indirection. */
- code = (void*)(*(sljit_uw*)code);
- SLJIT_FREE_EXEC(code);
-}
-#else
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
-{
- SLJIT_FREE_EXEC(code);
-}
-#endif
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label)
-{
- if (SLJIT_LIKELY(!!jump) && SLJIT_LIKELY(!!label)) {
- jump->flags &= ~JUMP_ADDR;
- jump->flags |= JUMP_LABEL;
- jump->u.label = label;
- }
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target)
-{
- if (SLJIT_LIKELY(!!jump)) {
- jump->flags &= ~JUMP_LABEL;
- jump->flags |= JUMP_ADDR;
- jump->u.target = target;
- }
-}
-
-/* --------------------------------------------------------------------- */
-/* Private functions */
-/* --------------------------------------------------------------------- */
-
-static void* ensure_buf(struct sljit_compiler *compiler, sljit_uw size)
-{
- sljit_ub *ret;
- struct sljit_memory_fragment *new_frag;
-
- SLJIT_ASSERT(size <= 256);
- if (compiler->buf->used_size + size <= (BUF_SIZE - (sljit_uw)SLJIT_OFFSETOF(struct sljit_memory_fragment, memory))) {
- ret = compiler->buf->memory + compiler->buf->used_size;
- compiler->buf->used_size += size;
- return ret;
- }
- new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(BUF_SIZE, compiler->allocator_data);
- PTR_FAIL_IF_NULL(new_frag);
- new_frag->next = compiler->buf;
- compiler->buf = new_frag;
- new_frag->used_size = size;
- return new_frag->memory;
-}
-
-static void* ensure_abuf(struct sljit_compiler *compiler, sljit_uw size)
-{
- sljit_ub *ret;
- struct sljit_memory_fragment *new_frag;
-
- SLJIT_ASSERT(size <= 256);
- if (compiler->abuf->used_size + size <= (ABUF_SIZE - (sljit_uw)SLJIT_OFFSETOF(struct sljit_memory_fragment, memory))) {
- ret = compiler->abuf->memory + compiler->abuf->used_size;
- compiler->abuf->used_size += size;
- return ret;
- }
- new_frag = (struct sljit_memory_fragment*)SLJIT_MALLOC(ABUF_SIZE, compiler->allocator_data);
- PTR_FAIL_IF_NULL(new_frag);
- new_frag->next = compiler->abuf;
- compiler->abuf = new_frag;
- new_frag->used_size = size;
- return new_frag->memory;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, sljit_si size)
-{
- CHECK_ERROR_PTR();
-
-#if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
- if (size <= 0 || size > 128)
- return NULL;
- size = (size + 7) & ~7;
-#else
- if (size <= 0 || size > 64)
- return NULL;
- size = (size + 3) & ~3;
-#endif
- return ensure_abuf(compiler, size);
-}
-
-static SLJIT_INLINE void reverse_buf(struct sljit_compiler *compiler)
-{
- struct sljit_memory_fragment *buf = compiler->buf;
- struct sljit_memory_fragment *prev = NULL;
- struct sljit_memory_fragment *tmp;
-
- do {
- tmp = buf->next;
- buf->next = prev;
- prev = buf;
- buf = tmp;
- } while (buf != NULL);
-
- compiler->buf = prev;
-}
-
-static SLJIT_INLINE void set_emit_enter(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- SLJIT_UNUSED_ARG(args);
- SLJIT_UNUSED_ARG(local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- compiler->logical_local_size = local_size;
-#endif
-}
-
-static SLJIT_INLINE void set_set_context(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- SLJIT_UNUSED_ARG(args);
- SLJIT_UNUSED_ARG(local_size);
-
- compiler->options = options;
- compiler->scratches = scratches;
- compiler->saveds = saveds;
- compiler->fscratches = fscratches;
- compiler->fsaveds = fsaveds;
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- compiler->logical_local_size = local_size;
-#endif
-}
-
-static SLJIT_INLINE void set_label(struct sljit_label *label, struct sljit_compiler *compiler)
-{
- label->next = NULL;
- label->size = compiler->size;
- if (compiler->last_label)
- compiler->last_label->next = label;
- else
- compiler->labels = label;
- compiler->last_label = label;
-}
-
-static SLJIT_INLINE void set_jump(struct sljit_jump *jump, struct sljit_compiler *compiler, sljit_si flags)
-{
- jump->next = NULL;
- jump->flags = flags;
- if (compiler->last_jump)
- compiler->last_jump->next = jump;
- else
- compiler->jumps = jump;
- compiler->last_jump = jump;
-}
-
-static SLJIT_INLINE void set_const(struct sljit_const *const_, struct sljit_compiler *compiler)
-{
- const_->next = NULL;
- const_->addr = compiler->size;
- if (compiler->last_const)
- compiler->last_const->next = const_;
- else
- compiler->consts = const_;
- compiler->last_const = const_;
-}
-
-#define ADDRESSING_DEPENDS_ON(exp, reg) \
- (((exp) & SLJIT_MEM) && (((exp) & REG_MASK) == reg || OFFS_REG(exp) == reg))
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
-#define FUNCTION_CHECK_OP() \
- CHECK_ARGUMENT(!GET_FLAGS(op) || !(op & SLJIT_KEEP_FLAGS)); \
- switch (GET_OPCODE(op)) { \
- case SLJIT_NOT: \
- case SLJIT_CLZ: \
- case SLJIT_AND: \
- case SLJIT_OR: \
- case SLJIT_XOR: \
- case SLJIT_SHL: \
- case SLJIT_LSHR: \
- case SLJIT_ASHR: \
- CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C))); \
- break; \
- case SLJIT_NEG: \
- CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \
- break; \
- case SLJIT_MUL: \
- CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_C))); \
- break; \
- case SLJIT_ADD: \
- CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_S))); \
- break; \
- case SLJIT_SUB: \
- break; \
- case SLJIT_ADDC: \
- case SLJIT_SUBC: \
- CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O))); \
- break; \
- case SLJIT_BREAKPOINT: \
- case SLJIT_NOP: \
- case SLJIT_LUMUL: \
- case SLJIT_LSMUL: \
- case SLJIT_MOV: \
- case SLJIT_MOV_UI: \
- case SLJIT_MOV_P: \
- case SLJIT_MOVU: \
- case SLJIT_MOVU_UI: \
- case SLJIT_MOVU_P: \
- /* Nothing allowed */ \
- CHECK_ARGUMENT(!(op & (SLJIT_INT_OP | SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
- break; \
- default: \
- /* Only SLJIT_INT_OP or SLJIT_SINGLE_OP is allowed. */ \
- CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
- break; \
- }
-
-#define FUNCTION_CHECK_FOP() \
- CHECK_ARGUMENT(!GET_FLAGS(op) || !(op & SLJIT_KEEP_FLAGS)); \
- switch (GET_OPCODE(op)) { \
- case SLJIT_DCMP: \
- CHECK_ARGUMENT(!(op & (SLJIT_SET_U | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
- CHECK_ARGUMENT((op & (SLJIT_SET_E | SLJIT_SET_S))); \
- break; \
- default: \
- /* Only SLJIT_INT_OP or SLJIT_SINGLE_OP is allowed. */ \
- CHECK_ARGUMENT(!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C | SLJIT_KEEP_FLAGS))); \
- break; \
- }
-
-#define FUNCTION_CHECK_IS_REG(r) \
- (((r) >= SLJIT_R0 && (r) < (SLJIT_R0 + compiler->scratches)) || \
- ((r) > (SLJIT_S0 - compiler->saveds) && (r) <= SLJIT_S0))
-
-#define FUNCTION_CHECK_IS_REG_OR_UNUSED(r) \
- ((r) == SLJIT_UNUSED || \
- ((r) >= SLJIT_R0 && (r) < (SLJIT_R0 + compiler->scratches)) || \
- ((r) > (SLJIT_S0 - compiler->saveds) && (r) <= SLJIT_S0))
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-#define CHECK_NOT_VIRTUAL_REGISTER(p) \
- CHECK_ARGUMENT((p) < SLJIT_R3 || (p) > SLJIT_R6);
-#else
-#define CHECK_NOT_VIRTUAL_REGISTER(p)
-#endif
-
-#define FUNCTION_CHECK_SRC(p, i) \
- CHECK_ARGUMENT(compiler->scratches != -1 && compiler->saveds != -1); \
- if (FUNCTION_CHECK_IS_REG(p)) \
- CHECK_ARGUMENT((i) == 0); \
- else if ((p) == SLJIT_IMM) \
- ; \
- else if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
- CHECK_ARGUMENT((i) >= 0 && (i) < compiler->logical_local_size); \
- else { \
- CHECK_ARGUMENT((p) & SLJIT_MEM); \
- CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG_OR_UNUSED((p) & REG_MASK)); \
- CHECK_NOT_VIRTUAL_REGISTER((p) & REG_MASK); \
- if ((p) & OFFS_REG_MASK) { \
- CHECK_ARGUMENT(((p) & REG_MASK) != SLJIT_UNUSED); \
- CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
- CHECK_NOT_VIRTUAL_REGISTER(OFFS_REG(p)); \
- CHECK_ARGUMENT(!((i) & ~0x3)); \
- } \
- CHECK_ARGUMENT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
- }
-
-#define FUNCTION_CHECK_DST(p, i) \
- CHECK_ARGUMENT(compiler->scratches != -1 && compiler->saveds != -1); \
- if (FUNCTION_CHECK_IS_REG_OR_UNUSED(p)) \
- CHECK_ARGUMENT((i) == 0); \
- else if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
- CHECK_ARGUMENT((i) >= 0 && (i) < compiler->logical_local_size); \
- else { \
- CHECK_ARGUMENT((p) & SLJIT_MEM); \
- CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG_OR_UNUSED((p) & REG_MASK)); \
- CHECK_NOT_VIRTUAL_REGISTER((p) & REG_MASK); \
- if ((p) & OFFS_REG_MASK) { \
- CHECK_ARGUMENT(((p) & REG_MASK) != SLJIT_UNUSED); \
- CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
- CHECK_NOT_VIRTUAL_REGISTER(OFFS_REG(p)); \
- CHECK_ARGUMENT(!((i) & ~0x3)); \
- } \
- CHECK_ARGUMENT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
- }
-
-#define FUNCTION_FCHECK(p, i) \
- CHECK_ARGUMENT(compiler->fscratches != -1 && compiler->fsaveds != -1); \
- if (((p) >= SLJIT_FR0 && (p) < (SLJIT_FR0 + compiler->fscratches)) || \
- ((p) > (SLJIT_FS0 - compiler->fsaveds) && (p) <= SLJIT_FS0)) \
- CHECK_ARGUMENT(i == 0); \
- else if ((p) == (SLJIT_MEM1(SLJIT_SP))) \
- CHECK_ARGUMENT((i) >= 0 && (i) < compiler->logical_local_size); \
- else { \
- CHECK_ARGUMENT((p) & SLJIT_MEM); \
- CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG_OR_UNUSED((p) & REG_MASK)); \
- CHECK_NOT_VIRTUAL_REGISTER((p) & REG_MASK); \
- if ((p) & OFFS_REG_MASK) { \
- CHECK_ARGUMENT(((p) & REG_MASK) != SLJIT_UNUSED); \
- CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(OFFS_REG(p))); \
- CHECK_NOT_VIRTUAL_REGISTER(OFFS_REG(p)); \
- CHECK_ARGUMENT(((p) & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_SP) && !(i & ~0x3)); \
- } \
- CHECK_ARGUMENT(!((p) & ~(SLJIT_MEM | SLJIT_IMM | REG_MASK | OFFS_REG_MASK))); \
- }
-
-#define FUNCTION_CHECK_OP1() \
- if (GET_OPCODE(op) >= SLJIT_MOVU && GET_OPCODE(op) <= SLJIT_MOVU_P) { \
- CHECK_ARGUMENT(!(src & SLJIT_MEM) || (src & REG_MASK) != SLJIT_SP); \
- CHECK_ARGUMENT(!(dst & SLJIT_MEM) || (dst & REG_MASK) != SLJIT_SP); \
- if ((src & SLJIT_MEM) && (src & REG_MASK)) \
- CHECK_ARGUMENT((dst & REG_MASK) != (src & REG_MASK) && OFFS_REG(dst) != (src & REG_MASK)); \
- }
-
-#endif /* SLJIT_ARGUMENT_CHECKS */
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose)
-{
- compiler->verbose = verbose;
-}
-
-#if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
-#ifdef _WIN64
-# define SLJIT_PRINT_D "I64"
-#else
-# define SLJIT_PRINT_D "l"
-#endif
-#else
-# define SLJIT_PRINT_D ""
-#endif
-
-#define sljit_verbose_reg(compiler, r) \
- do { \
- if ((r) < (SLJIT_R0 + compiler->scratches)) \
- fprintf(compiler->verbose, "r%d", (r) - SLJIT_R0); \
- else \
- fprintf(compiler->verbose, "s%d", SLJIT_NUMBER_OF_REGISTERS - (r)); \
- } while (0)
-
-#define sljit_verbose_param(compiler, p, i) \
- if ((p) & SLJIT_IMM) \
- fprintf(compiler->verbose, "#%" SLJIT_PRINT_D "d", (i)); \
- else if ((p) & SLJIT_MEM) { \
- if ((p) & REG_MASK) { \
- fputc('[', compiler->verbose); \
- sljit_verbose_reg(compiler, (p) & REG_MASK); \
- if ((p) & OFFS_REG_MASK) { \
- fprintf(compiler->verbose, " + "); \
- sljit_verbose_reg(compiler, OFFS_REG(p)); \
- if (i) \
- fprintf(compiler->verbose, " * %d", 1 << (i)); \
- } \
- else if (i) \
- fprintf(compiler->verbose, " + %" SLJIT_PRINT_D "d", (i)); \
- fputc(']', compiler->verbose); \
- } \
- else \
- fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \
- } else if (p) \
- sljit_verbose_reg(compiler, p); \
- else \
- fprintf(compiler->verbose, "unused");
-
-#define sljit_verbose_fparam(compiler, p, i) \
- if ((p) & SLJIT_MEM) { \
- if ((p) & REG_MASK) { \
- fputc('[', compiler->verbose); \
- sljit_verbose_reg(compiler, (p) & REG_MASK); \
- if ((p) & OFFS_REG_MASK) { \
- fprintf(compiler->verbose, " + "); \
- sljit_verbose_reg(compiler, OFFS_REG(p)); \
- if (i) \
- fprintf(compiler->verbose, "%d", 1 << (i)); \
- } \
- else if (i) \
- fprintf(compiler->verbose, "%" SLJIT_PRINT_D "d", (i)); \
- fputc(']', compiler->verbose); \
- } \
- else \
- fprintf(compiler->verbose, "[#%" SLJIT_PRINT_D "d]", (i)); \
- } \
- else { \
- if ((p) < (SLJIT_FR0 + compiler->fscratches)) \
- fprintf(compiler->verbose, "fr%d", (p) - SLJIT_FR0); \
- else \
- fprintf(compiler->verbose, "fs%d", SLJIT_NUMBER_OF_FLOAT_REGISTERS - (p)); \
- }
-
-static SLJIT_CONST char* op0_names[] = {
- (char*)"breakpoint", (char*)"nop", (char*)"lumul", (char*)"lsmul",
- (char*)"udivmod", (char*)"sdivmod", (char*)"udivi", (char*)"sdivi"
-};
-
-static SLJIT_CONST char* op1_names[] = {
- (char*)"mov", (char*)"mov_ub", (char*)"mov_sb", (char*)"mov_uh",
- (char*)"mov_sh", (char*)"mov_ui", (char*)"mov_si", (char*)"mov_p",
- (char*)"movu", (char*)"movu_ub", (char*)"movu_sb", (char*)"movu_uh",
- (char*)"movu_sh", (char*)"movu_ui", (char*)"movu_si", (char*)"movu_p",
- (char*)"not", (char*)"neg", (char*)"clz",
-};
-
-static SLJIT_CONST char* op2_names[] = {
- (char*)"add", (char*)"addc", (char*)"sub", (char*)"subc",
- (char*)"mul", (char*)"and", (char*)"or", (char*)"xor",
- (char*)"shl", (char*)"lshr", (char*)"ashr",
-};
-
-static SLJIT_CONST char* fop1_names[] = {
- (char*)"mov", (char*)"conv", (char*)"conv", (char*)"conv",
- (char*)"conv", (char*)"conv", (char*)"cmp", (char*)"neg",
- (char*)"abs",
-};
-
-static SLJIT_CONST char* fop2_names[] = {
- (char*)"add", (char*)"sub", (char*)"mul", (char*)"div"
-};
-
-#define JUMP_PREFIX(type) \
- ((type & 0xff) <= SLJIT_MUL_NOT_OVERFLOW ? ((type & SLJIT_INT_OP) ? "i_" : "") \
- : ((type & 0xff) <= SLJIT_D_ORDERED ? ((type & SLJIT_SINGLE_OP) ? "s_" : "d_") : ""))
-
-static char* jump_names[] = {
- (char*)"equal", (char*)"not_equal",
- (char*)"less", (char*)"greater_equal",
- (char*)"greater", (char*)"less_equal",
- (char*)"sig_less", (char*)"sig_greater_equal",
- (char*)"sig_greater", (char*)"sig_less_equal",
- (char*)"overflow", (char*)"not_overflow",
- (char*)"mul_overflow", (char*)"mul_not_overflow",
- (char*)"equal", (char*)"not_equal",
- (char*)"less", (char*)"greater_equal",
- (char*)"greater", (char*)"less_equal",
- (char*)"unordered", (char*)"ordered",
- (char*)"jump", (char*)"fast_call",
- (char*)"call0", (char*)"call1", (char*)"call2", (char*)"call3"
-};
-
-#endif /* SLJIT_VERBOSE */
-
-/* --------------------------------------------------------------------- */
-/* Arch dependent */
-/* --------------------------------------------------------------------- */
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
- || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_generate_code(struct sljit_compiler *compiler)
-{
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- struct sljit_jump *jump;
-#endif
-
- SLJIT_UNUSED_ARG(compiler);
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(compiler->size > 0);
- jump = compiler->jumps;
- while (jump) {
- /* All jumps have target. */
- CHECK_ARGUMENT(jump->flags & (JUMP_LABEL | JUMP_ADDR));
- jump = jump->next;
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_enter(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- SLJIT_UNUSED_ARG(compiler);
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(!(options & ~SLJIT_DOUBLE_ALIGNMENT));
- CHECK_ARGUMENT(args >= 0 && args <= 3);
- CHECK_ARGUMENT(scratches >= 0 && scratches <= SLJIT_NUMBER_OF_REGISTERS);
- CHECK_ARGUMENT(saveds >= 0 && saveds <= SLJIT_NUMBER_OF_REGISTERS);
- CHECK_ARGUMENT(scratches + saveds <= SLJIT_NUMBER_OF_REGISTERS);
- CHECK_ARGUMENT(args <= saveds);
- CHECK_ARGUMENT(fscratches >= 0 && fscratches <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- CHECK_ARGUMENT(fsaveds >= 0 && fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- CHECK_ARGUMENT(fscratches + fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- CHECK_ARGUMENT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose))
- fprintf(compiler->verbose, " enter options:none args:%d scratches:%d saveds:%d fscratches:%d fsaveds:%d local_size:%d\n",
- args, scratches, saveds, fscratches, fsaveds, local_size);
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_set_context(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- if (SLJIT_UNLIKELY(compiler->skip_checks)) {
- compiler->skip_checks = 0;
- CHECK_RETURN_OK;
- }
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(!(options & ~SLJIT_DOUBLE_ALIGNMENT));
- CHECK_ARGUMENT(args >= 0 && args <= 3);
- CHECK_ARGUMENT(scratches >= 0 && scratches <= SLJIT_NUMBER_OF_REGISTERS);
- CHECK_ARGUMENT(saveds >= 0 && saveds <= SLJIT_NUMBER_OF_REGISTERS);
- CHECK_ARGUMENT(scratches + saveds <= SLJIT_NUMBER_OF_REGISTERS);
- CHECK_ARGUMENT(args <= saveds);
- CHECK_ARGUMENT(fscratches >= 0 && fscratches <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- CHECK_ARGUMENT(fsaveds >= 0 && fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- CHECK_ARGUMENT(fscratches + fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
- CHECK_ARGUMENT(local_size >= 0 && local_size <= SLJIT_MAX_LOCAL_SIZE);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose))
- fprintf(compiler->verbose, " set_context options:none args:%d scratches:%d saveds:%d fscratches:%d fsaveds:%d local_size:%d\n",
- args, scratches, saveds, fscratches, fsaveds, local_size);
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
-{
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(compiler->scratches >= 0);
- if (op != SLJIT_UNUSED) {
- CHECK_ARGUMENT(op >= SLJIT_MOV && op <= SLJIT_MOV_P);
- FUNCTION_CHECK_SRC(src, srcw);
- }
- else
- CHECK_ARGUMENT(src == 0 && srcw == 0);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- if (op == SLJIT_UNUSED)
- fprintf(compiler->verbose, " return\n");
- else {
- fprintf(compiler->verbose, " return.%s ", op1_names[op - SLJIT_OP1_BASE]);
- sljit_verbose_param(compiler, src, srcw);
- fprintf(compiler->verbose, "\n");
- }
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
-{
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- FUNCTION_CHECK_DST(dst, dstw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " fast_enter ");
- sljit_verbose_param(compiler, dst, dstw);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
-{
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- FUNCTION_CHECK_SRC(src, srcw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " fast_return ");
- sljit_verbose_param(compiler, src, srcw);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
-{
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT((op >= SLJIT_BREAKPOINT && op <= SLJIT_LSMUL)
- || ((op & ~SLJIT_INT_OP) >= SLJIT_UDIVMOD && (op & ~SLJIT_INT_OP) <= SLJIT_SDIVI));
- CHECK_ARGUMENT(op < SLJIT_LUMUL || compiler->scratches >= 2);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose))
- fprintf(compiler->verbose, " %s%s\n", !(op & SLJIT_INT_OP) ? "" : "i", op0_names[GET_OPCODE(op) - SLJIT_OP0_BASE]);
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- if (SLJIT_UNLIKELY(compiler->skip_checks)) {
- compiler->skip_checks = 0;
- CHECK_RETURN_OK;
- }
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_MOV && GET_OPCODE(op) <= SLJIT_CLZ);
- FUNCTION_CHECK_OP();
- FUNCTION_CHECK_SRC(src, srcw);
- FUNCTION_CHECK_DST(dst, dstw);
- FUNCTION_CHECK_OP1();
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %s%s%s%s%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i", op1_names[GET_OPCODE(op) - SLJIT_OP1_BASE],
- !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_SET_U) ? "" : ".u", !(op & SLJIT_SET_S) ? "" : ".s",
- !(op & SLJIT_SET_O) ? "" : ".o", !(op & SLJIT_SET_C) ? "" : ".c", !(op & SLJIT_KEEP_FLAGS) ? "" : ".k");
- sljit_verbose_param(compiler, dst, dstw);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_param(compiler, src, srcw);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- if (SLJIT_UNLIKELY(compiler->skip_checks)) {
- compiler->skip_checks = 0;
- CHECK_RETURN_OK;
- }
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_ADD && GET_OPCODE(op) <= SLJIT_ASHR);
- FUNCTION_CHECK_OP();
- FUNCTION_CHECK_SRC(src1, src1w);
- FUNCTION_CHECK_SRC(src2, src2w);
- FUNCTION_CHECK_DST(dst, dstw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %s%s%s%s%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i", op2_names[GET_OPCODE(op) - SLJIT_OP2_BASE],
- !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_SET_U) ? "" : ".u", !(op & SLJIT_SET_S) ? "" : ".s",
- !(op & SLJIT_SET_O) ? "" : ".o", !(op & SLJIT_SET_C) ? "" : ".c", !(op & SLJIT_KEEP_FLAGS) ? "" : ".k");
- sljit_verbose_param(compiler, dst, dstw);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_param(compiler, src1, src1w);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_param(compiler, src2, src2w);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_register_index(sljit_si reg)
-{
- SLJIT_UNUSED_ARG(reg);
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(reg > 0 && reg <= SLJIT_NUMBER_OF_REGISTERS);
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_float_register_index(sljit_si reg)
-{
- SLJIT_UNUSED_ARG(reg);
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(reg > 0 && reg <= SLJIT_NUMBER_OF_FLOAT_REGISTERS);
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op_custom(struct sljit_compiler *compiler,
- void *instruction, sljit_si size)
-{
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- int i;
-#endif
-
- SLJIT_UNUSED_ARG(compiler);
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(instruction);
-#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
- CHECK_ARGUMENT(size > 0 && size < 16);
-#elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
- CHECK_ARGUMENT((size == 2 && (((sljit_sw)instruction) & 0x1) == 0)
- || (size == 4 && (((sljit_sw)instruction) & 0x3) == 0));
-#else
- CHECK_ARGUMENT(size == 4 && (((sljit_sw)instruction) & 0x3) == 0);
-#endif
-
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " op_custom");
- for (i = 0; i < size; i++)
- fprintf(compiler->verbose, " 0x%x", ((sljit_ub*)instruction)[i]);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- if (SLJIT_UNLIKELY(compiler->skip_checks)) {
- compiler->skip_checks = 0;
- CHECK_RETURN_OK;
- }
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(sljit_is_fpu_available());
- CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_DMOV && GET_OPCODE(op) <= SLJIT_DABS);
- FUNCTION_CHECK_FOP();
- FUNCTION_FCHECK(src, srcw);
- FUNCTION_FCHECK(dst, dstw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- if (GET_OPCODE(op) == SLJIT_CONVD_FROMS)
- fprintf(compiler->verbose, " %s%s ", fop1_names[SLJIT_CONVD_FROMS - SLJIT_FOP1_BASE],
- (op & SLJIT_SINGLE_OP) ? "s.fromd" : "d.froms");
- else
- fprintf(compiler->verbose, " %s%s ", (op & SLJIT_SINGLE_OP) ? "s" : "d",
- fop1_names[GET_OPCODE(op) - SLJIT_FOP1_BASE]);
-
- sljit_verbose_fparam(compiler, dst, dstw);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_fparam(compiler, src, srcw);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_si op,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- if (SLJIT_UNLIKELY(compiler->skip_checks)) {
- compiler->skip_checks = 0;
- CHECK_RETURN_OK;
- }
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(sljit_is_fpu_available());
- CHECK_ARGUMENT(GET_OPCODE(op) == SLJIT_DCMP);
- FUNCTION_CHECK_FOP();
- FUNCTION_FCHECK(src1, src1w);
- FUNCTION_FCHECK(src2, src2w);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %s%s%s%s ", (op & SLJIT_SINGLE_OP) ? "s" : "d", fop1_names[SLJIT_DCMP - SLJIT_FOP1_BASE],
- (op & SLJIT_SET_E) ? ".e" : "", (op & SLJIT_SET_S) ? ".s" : "");
- sljit_verbose_fparam(compiler, src1, src1w);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_fparam(compiler, src2, src2w);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1_convw_fromd(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- if (SLJIT_UNLIKELY(compiler->skip_checks)) {
- compiler->skip_checks = 0;
- CHECK_RETURN_OK;
- }
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(sljit_is_fpu_available());
- CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_CONVW_FROMD && GET_OPCODE(op) <= SLJIT_CONVI_FROMD);
- FUNCTION_CHECK_FOP();
- FUNCTION_FCHECK(src, srcw);
- FUNCTION_CHECK_DST(dst, dstw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %s%s.from%s ", fop1_names[GET_OPCODE(op) - SLJIT_FOP1_BASE],
- (GET_OPCODE(op) == SLJIT_CONVI_FROMD) ? "i" : "w",
- (op & SLJIT_SINGLE_OP) ? "s" : "d");
- sljit_verbose_param(compiler, dst, dstw);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_fparam(compiler, src, srcw);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop1_convd_fromw(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- if (SLJIT_UNLIKELY(compiler->skip_checks)) {
- compiler->skip_checks = 0;
- CHECK_RETURN_OK;
- }
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(sljit_is_fpu_available());
- CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_CONVD_FROMW && GET_OPCODE(op) <= SLJIT_CONVD_FROMI);
- FUNCTION_CHECK_FOP();
- FUNCTION_CHECK_SRC(src, srcw);
- FUNCTION_FCHECK(dst, dstw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %s%s.from%s ", fop1_names[GET_OPCODE(op) - SLJIT_FOP1_BASE],
- (op & SLJIT_SINGLE_OP) ? "s" : "d",
- (GET_OPCODE(op) == SLJIT_CONVD_FROMI) ? "i" : "w");
- sljit_verbose_fparam(compiler, dst, dstw);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_param(compiler, src, srcw);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(sljit_is_fpu_available());
- CHECK_ARGUMENT(GET_OPCODE(op) >= SLJIT_DADD && GET_OPCODE(op) <= SLJIT_DDIV);
- FUNCTION_CHECK_FOP();
- FUNCTION_FCHECK(src1, src1w);
- FUNCTION_FCHECK(src2, src2w);
- FUNCTION_FCHECK(dst, dstw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " %s%s ", (op & SLJIT_SINGLE_OP) ? "s" : "d", fop2_names[GET_OPCODE(op) - SLJIT_FOP2_BASE]);
- sljit_verbose_fparam(compiler, dst, dstw);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_fparam(compiler, src1, src1w);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_fparam(compiler, src2, src2w);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_label(struct sljit_compiler *compiler)
-{
- SLJIT_UNUSED_ARG(compiler);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose))
- fprintf(compiler->verbose, "label:\n");
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_jump(struct sljit_compiler *compiler, sljit_si type)
-{
- if (SLJIT_UNLIKELY(compiler->skip_checks)) {
- compiler->skip_checks = 0;
- CHECK_RETURN_OK;
- }
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP | SLJIT_INT_OP)));
- CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_CALL3);
- CHECK_ARGUMENT((type & 0xff) < SLJIT_JUMP || !(type & SLJIT_INT_OP));
- CHECK_ARGUMENT((type & 0xff) <= SLJIT_CALL0 || ((type & 0xff) - SLJIT_CALL0) <= compiler->scratches);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose))
- fprintf(compiler->verbose, " jump%s.%s%s\n", !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r",
- JUMP_PREFIX(type), jump_names[type & 0xff]);
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_cmp(struct sljit_compiler *compiler, sljit_si type,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP | SLJIT_INT_OP)));
- CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_SIG_LESS_EQUAL);
- FUNCTION_CHECK_SRC(src1, src1w);
- FUNCTION_CHECK_SRC(src2, src2w);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " cmp%s.%s%s ", !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r",
- (type & SLJIT_INT_OP) ? "i_" : "", jump_names[type & 0xff]);
- sljit_verbose_param(compiler, src1, src1w);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_param(compiler, src2, src2w);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_fcmp(struct sljit_compiler *compiler, sljit_si type,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(sljit_is_fpu_available());
- CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_REWRITABLE_JUMP | SLJIT_SINGLE_OP)));
- CHECK_ARGUMENT((type & 0xff) >= SLJIT_D_EQUAL && (type & 0xff) <= SLJIT_D_ORDERED);
- FUNCTION_FCHECK(src1, src1w);
- FUNCTION_FCHECK(src2, src2w);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " fcmp%s.%s%s ", !(type & SLJIT_REWRITABLE_JUMP) ? "" : ".r",
- (type & SLJIT_SINGLE_OP) ? "s_" : "d_", jump_names[type & 0xff]);
- sljit_verbose_fparam(compiler, src1, src1w);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_fparam(compiler, src2, src2w);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, sljit_si src, sljit_sw srcw)
-{
- if (SLJIT_UNLIKELY(compiler->skip_checks)) {
- compiler->skip_checks = 0;
- CHECK_RETURN_OK;
- }
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(type >= SLJIT_JUMP && type <= SLJIT_CALL3);
- CHECK_ARGUMENT(type <= SLJIT_CALL0 || (type - SLJIT_CALL0) <= compiler->scratches);
- FUNCTION_CHECK_SRC(src, srcw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " ijump.%s ", jump_names[type]);
- sljit_verbose_param(compiler, src, srcw);
- fprintf(compiler->verbose, "\n");
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw,
- sljit_si type)
-{
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_INT_OP)));
- CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_D_ORDERED);
- CHECK_ARGUMENT(op == SLJIT_MOV || GET_OPCODE(op) == SLJIT_MOV_UI || GET_OPCODE(op) == SLJIT_MOV_SI
- || (GET_OPCODE(op) >= SLJIT_AND && GET_OPCODE(op) <= SLJIT_XOR));
- CHECK_ARGUMENT((op & (SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O | SLJIT_SET_C)) == 0);
- CHECK_ARGUMENT((op & (SLJIT_SET_E | SLJIT_KEEP_FLAGS)) != (SLJIT_SET_E | SLJIT_KEEP_FLAGS));
- if (GET_OPCODE(op) < SLJIT_ADD) {
- CHECK_ARGUMENT(src == SLJIT_UNUSED && srcw == 0);
- } else {
- CHECK_ARGUMENT(src == dst && srcw == dstw);
- }
- FUNCTION_CHECK_DST(dst, dstw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " flags.%s%s%s%s ", !(op & SLJIT_INT_OP) ? "" : "i",
- GET_OPCODE(op) >= SLJIT_OP2_BASE ? op2_names[GET_OPCODE(op) - SLJIT_OP2_BASE] : op1_names[GET_OPCODE(op) - SLJIT_OP1_BASE],
- !(op & SLJIT_SET_E) ? "" : ".e", !(op & SLJIT_KEEP_FLAGS) ? "" : ".k");
- sljit_verbose_param(compiler, dst, dstw);
- if (src != SLJIT_UNUSED) {
- fprintf(compiler->verbose, ", ");
- sljit_verbose_param(compiler, src, srcw);
- }
- fprintf(compiler->verbose, ", %s%s\n", JUMP_PREFIX(type), jump_names[type & 0xff]);
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_get_local_base(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw offset)
-{
- SLJIT_UNUSED_ARG(offset);
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- FUNCTION_CHECK_DST(dst, dstw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " local_base ");
- sljit_verbose_param(compiler, dst, dstw);
- fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", offset);
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-static SLJIT_INLINE CHECK_RETURN_TYPE check_sljit_emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw init_value)
-{
- SLJIT_UNUSED_ARG(init_value);
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- FUNCTION_CHECK_DST(dst, dstw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " const ");
- sljit_verbose_param(compiler, dst, dstw);
- fprintf(compiler->verbose, ", #%" SLJIT_PRINT_D "d\n", init_value);
- }
-#endif
- CHECK_RETURN_OK;
-}
-
-#endif /* SLJIT_ARGUMENT_CHECKS || SLJIT_VERBOSE */
-
-#define SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw) \
- SLJIT_COMPILE_ASSERT(!(SLJIT_CONVW_FROMD & 0x1) && !(SLJIT_CONVD_FROMW & 0x1), \
- invalid_float_opcodes); \
- if (GET_OPCODE(op) >= SLJIT_CONVW_FROMD && GET_OPCODE(op) <= SLJIT_DCMP) { \
- if (GET_OPCODE(op) == SLJIT_DCMP) { \
- CHECK(check_sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw)); \
- ADJUST_LOCAL_OFFSET(dst, dstw); \
- ADJUST_LOCAL_OFFSET(src, srcw); \
- return sljit_emit_fop1_cmp(compiler, op, dst, dstw, src, srcw); \
- } \
- if ((GET_OPCODE(op) | 0x1) == SLJIT_CONVI_FROMD) { \
- CHECK(check_sljit_emit_fop1_convw_fromd(compiler, op, dst, dstw, src, srcw)); \
- ADJUST_LOCAL_OFFSET(dst, dstw); \
- ADJUST_LOCAL_OFFSET(src, srcw); \
- return sljit_emit_fop1_convw_fromd(compiler, op, dst, dstw, src, srcw); \
- } \
- CHECK(check_sljit_emit_fop1_convd_fromw(compiler, op, dst, dstw, src, srcw)); \
- ADJUST_LOCAL_OFFSET(dst, dstw); \
- ADJUST_LOCAL_OFFSET(src, srcw); \
- return sljit_emit_fop1_convd_fromw(compiler, op, dst, dstw, src, srcw); \
- } \
- CHECK(check_sljit_emit_fop1(compiler, op, dst, dstw, src, srcw)); \
- ADJUST_LOCAL_OFFSET(dst, dstw); \
- ADJUST_LOCAL_OFFSET(src, srcw);
-
-static SLJIT_INLINE sljit_si emit_mov_before_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
-{
- /* Return if don't need to do anything. */
- if (op == SLJIT_UNUSED)
- return SLJIT_SUCCESS;
-
-#if (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
- /* At the moment the pointer size is always equal to sljit_sw. May be changed in the future. */
- if (src == SLJIT_RETURN_REG && (op == SLJIT_MOV || op == SLJIT_MOV_P))
- return SLJIT_SUCCESS;
-#else
- if (src == SLJIT_RETURN_REG && (op == SLJIT_MOV || op == SLJIT_MOV_UI || op == SLJIT_MOV_SI || op == SLJIT_MOV_P))
- return SLJIT_SUCCESS;
-#endif
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
- || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- compiler->skip_checks = 1;
-#endif
- return sljit_emit_op1(compiler, op, SLJIT_RETURN_REG, 0, src, srcw);
-}
-
-/* CPU description section */
-
-#if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
-#define SLJIT_CPUINFO_PART1 " 32bit ("
-#elif (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
-#define SLJIT_CPUINFO_PART1 " 64bit ("
-#else
-#error "Internal error: CPU type info missing"
-#endif
-
-#if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
-#define SLJIT_CPUINFO_PART2 "little endian + "
-#elif (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
-#define SLJIT_CPUINFO_PART2 "big endian + "
-#else
-#error "Internal error: CPU type info missing"
-#endif
-
-#if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED)
-#define SLJIT_CPUINFO_PART3 "unaligned)"
-#else
-#define SLJIT_CPUINFO_PART3 "aligned)"
-#endif
-
-#define SLJIT_CPUINFO SLJIT_CPUINFO_PART1 SLJIT_CPUINFO_PART2 SLJIT_CPUINFO_PART3
-
-#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
-# include "sljitNativeX86_common.c"
-#elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
-# include "sljitNativeARM_32.c"
-#elif (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
-# include "sljitNativeARM_32.c"
-#elif (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
-# include "sljitNativeARM_T2_32.c"
-#elif (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
-# include "sljitNativeARM_64.c"
-#elif (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
-# include "sljitNativePPC_common.c"
-#elif (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
-# include "sljitNativeMIPS_common.c"
-#elif (defined SLJIT_CONFIG_SPARC && SLJIT_CONFIG_SPARC)
-# include "sljitNativeSPARC_common.c"
-#elif (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
-# include "sljitNativeTILEGX_64.c"
-#endif
-
-#if !(defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, sljit_si type,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- /* Default compare for most architectures. */
- sljit_si flags, tmp_src, condition;
- sljit_sw tmp_srcw;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_emit_cmp(compiler, type, src1, src1w, src2, src2w));
-
- condition = type & 0xff;
-#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
- if ((condition == SLJIT_EQUAL || condition == SLJIT_NOT_EQUAL)) {
- if ((src1 & SLJIT_IMM) && !src1w) {
- src1 = src2;
- src1w = src2w;
- src2 = SLJIT_IMM;
- src2w = 0;
- }
- if ((src2 & SLJIT_IMM) && !src2w)
- return emit_cmp_to0(compiler, type, src1, src1w);
- }
-#endif
-
- if (SLJIT_UNLIKELY((src1 & SLJIT_IMM) && !(src2 & SLJIT_IMM))) {
- /* Immediate is prefered as second argument by most architectures. */
- switch (condition) {
- case SLJIT_LESS:
- condition = SLJIT_GREATER;
- break;
- case SLJIT_GREATER_EQUAL:
- condition = SLJIT_LESS_EQUAL;
- break;
- case SLJIT_GREATER:
- condition = SLJIT_LESS;
- break;
- case SLJIT_LESS_EQUAL:
- condition = SLJIT_GREATER_EQUAL;
- break;
- case SLJIT_SIG_LESS:
- condition = SLJIT_SIG_GREATER;
- break;
- case SLJIT_SIG_GREATER_EQUAL:
- condition = SLJIT_SIG_LESS_EQUAL;
- break;
- case SLJIT_SIG_GREATER:
- condition = SLJIT_SIG_LESS;
- break;
- case SLJIT_SIG_LESS_EQUAL:
- condition = SLJIT_SIG_GREATER_EQUAL;
- break;
- }
- type = condition | (type & (SLJIT_INT_OP | SLJIT_REWRITABLE_JUMP));
- tmp_src = src1;
- src1 = src2;
- src2 = tmp_src;
- tmp_srcw = src1w;
- src1w = src2w;
- src2w = tmp_srcw;
- }
-
- if (condition <= SLJIT_NOT_ZERO)
- flags = SLJIT_SET_E;
- else if (condition <= SLJIT_LESS_EQUAL)
- flags = SLJIT_SET_U;
- else
- flags = SLJIT_SET_S;
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
- || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- compiler->skip_checks = 1;
-#endif
- PTR_FAIL_IF(sljit_emit_op2(compiler, SLJIT_SUB | flags | (type & SLJIT_INT_OP),
- SLJIT_UNUSED, 0, src1, src1w, src2, src2w));
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
- || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- compiler->skip_checks = 1;
-#endif
- return sljit_emit_jump(compiler, condition | (type & SLJIT_REWRITABLE_JUMP));
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compiler *compiler, sljit_si type,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_si flags, condition;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_emit_fcmp(compiler, type, src1, src1w, src2, src2w));
-
- condition = type & 0xff;
- flags = (condition <= SLJIT_D_NOT_EQUAL) ? SLJIT_SET_E : SLJIT_SET_S;
- if (type & SLJIT_SINGLE_OP)
- flags |= SLJIT_SINGLE_OP;
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
- || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- compiler->skip_checks = 1;
-#endif
- sljit_emit_fop1(compiler, SLJIT_DCMP | flags, src1, src1w, src2, src2w);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
- || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- compiler->skip_checks = 1;
-#endif
- return sljit_emit_jump(compiler, condition | (type & SLJIT_REWRITABLE_JUMP));
-}
-
-#endif
-
-#if !(defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_local_base(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw offset)
-{
- CHECK_ERROR();
- CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset));
-
- ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_SP), offset);
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
- || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- compiler->skip_checks = 1;
-#endif
- if (offset != 0)
- return sljit_emit_op2(compiler, SLJIT_ADD | SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, SLJIT_IMM, offset);
- return sljit_emit_op1(compiler, SLJIT_MOV, dst, dstw, SLJIT_SP, 0);
-}
-
-#endif
-
-#else /* SLJIT_CONFIG_UNSUPPORTED */
-
-/* Empty function bodies for those machines, which are not (yet) supported. */
-
-SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void)
-{
- return "unsupported";
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
-{
- SLJIT_ASSERT_STOP();
- return NULL;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_ASSERT_STOP();
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, sljit_si size)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(size);
- SLJIT_ASSERT_STOP();
- return NULL;
-}
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
-SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(verbose);
- SLJIT_ASSERT_STOP();
-}
-#endif
-
-SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_ASSERT_STOP();
- return NULL;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
-{
- SLJIT_UNUSED_ARG(code);
- SLJIT_ASSERT_STOP();
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(options);
- SLJIT_UNUSED_ARG(args);
- SLJIT_UNUSED_ARG(scratches);
- SLJIT_UNUSED_ARG(saveds);
- SLJIT_UNUSED_ARG(fscratches);
- SLJIT_UNUSED_ARG(fsaveds);
- SLJIT_UNUSED_ARG(local_size);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(options);
- SLJIT_UNUSED_ARG(args);
- SLJIT_UNUSED_ARG(scratches);
- SLJIT_UNUSED_ARG(saveds);
- SLJIT_UNUSED_ARG(fscratches);
- SLJIT_UNUSED_ARG(fsaveds);
- SLJIT_UNUSED_ARG(local_size);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src1);
- SLJIT_UNUSED_ARG(src1w);
- SLJIT_UNUSED_ARG(src2);
- SLJIT_UNUSED_ARG(src2w);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
-{
- SLJIT_ASSERT_STOP();
- return reg;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
- void *instruction, sljit_si size)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(instruction);
- SLJIT_UNUSED_ARG(size);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void)
-{
- SLJIT_ASSERT_STOP();
- return 0;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src1);
- SLJIT_UNUSED_ARG(src1w);
- SLJIT_UNUSED_ARG(src2);
- SLJIT_UNUSED_ARG(src2w);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_ASSERT_STOP();
- return NULL;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_si type)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(type);
- SLJIT_ASSERT_STOP();
- return NULL;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_cmp(struct sljit_compiler *compiler, sljit_si type,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(type);
- SLJIT_UNUSED_ARG(src1);
- SLJIT_UNUSED_ARG(src1w);
- SLJIT_UNUSED_ARG(src2);
- SLJIT_UNUSED_ARG(src2w);
- SLJIT_ASSERT_STOP();
- return NULL;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_fcmp(struct sljit_compiler *compiler, sljit_si type,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(type);
- SLJIT_UNUSED_ARG(src1);
- SLJIT_UNUSED_ARG(src1w);
- SLJIT_UNUSED_ARG(src2);
- SLJIT_UNUSED_ARG(src2w);
- SLJIT_ASSERT_STOP();
- return NULL;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_label(struct sljit_jump *jump, struct sljit_label* label)
-{
- SLJIT_UNUSED_ARG(jump);
- SLJIT_UNUSED_ARG(label);
- SLJIT_ASSERT_STOP();
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_target(struct sljit_jump *jump, sljit_uw target)
-{
- SLJIT_UNUSED_ARG(jump);
- SLJIT_UNUSED_ARG(target);
- SLJIT_ASSERT_STOP();
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, sljit_si src, sljit_sw srcw)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(type);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw,
- sljit_si type)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(op);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(src);
- SLJIT_UNUSED_ARG(srcw);
- SLJIT_UNUSED_ARG(type);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_local_base(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw offset)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(offset);
- SLJIT_ASSERT_STOP();
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw initval)
-{
- SLJIT_UNUSED_ARG(compiler);
- SLJIT_UNUSED_ARG(dst);
- SLJIT_UNUSED_ARG(dstw);
- SLJIT_UNUSED_ARG(initval);
- SLJIT_ASSERT_STOP();
- return NULL;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr)
-{
- SLJIT_UNUSED_ARG(addr);
- SLJIT_UNUSED_ARG(new_addr);
- SLJIT_ASSERT_STOP();
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant)
-{
- SLJIT_UNUSED_ARG(addr);
- SLJIT_UNUSED_ARG(new_constant);
- SLJIT_ASSERT_STOP();
-}
-
-#endif
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitLir.h r-base-3.3.1/src/extra/pcre/sljit/sljitLir.h
--- r-base-3.2.3/src/extra/pcre/sljit/sljitLir.h 2015-11-26 23:15:10.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitLir.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,1249 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _SLJIT_LIR_H_
-#define _SLJIT_LIR_H_
-
-/*
- ------------------------------------------------------------------------
- Stack-Less JIT compiler for multiple architectures (x86, ARM, PowerPC)
- ------------------------------------------------------------------------
-
- Short description
- Advantages:
- - The execution can be continued from any LIR instruction. In other
- words, it is possible to jump to any label from anywhere, even from
- a code fragment, which is compiled later, if both compiled code
- shares the same context. See sljit_emit_enter for more details
- - Supports self modifying code: target of (conditional) jump and call
- instructions and some constant values can be dynamically modified
- during runtime
- - although it is not suggested to do it frequently
- - can be used for inline caching: save an important value once
- in the instruction stream
- - since this feature limits the optimization possibilities, a
- special flag must be passed at compile time when these
- instructions are emitted
- - A fixed stack space can be allocated for local variables
- - The compiler is thread-safe
- - The compiler is highly configurable through preprocessor macros.
- You can disable unneeded features (multithreading in single
- threaded applications), and you can use your own system functions
- (including memory allocators). See sljitConfig.h
- Disadvantages:
- - No automatic register allocation, and temporary results are
- not stored on the stack. (hence the name comes)
- In practice:
- - This approach is very effective for interpreters
- - One of the saved registers typically points to a stack interface
- - It can jump to any exception handler anytime (even if it belongs
- to another function)
- - Hot paths can be modified during runtime reflecting the changes
- of the fastest execution path of the dynamic language
- - SLJIT supports complex memory addressing modes
- - mainly position and context independent code (except some cases)
-
- For valgrind users:
- - pass --smc-check=all argument to valgrind, since JIT is a "self-modifying code"
-*/
-
-#if !(defined SLJIT_NO_DEFAULT_CONFIG && SLJIT_NO_DEFAULT_CONFIG)
-#include "sljitConfig.h"
-#endif
-
-/* The following header file defines useful macros for fine tuning
-sljit based code generators. They are listed in the beginning
-of sljitConfigInternal.h */
-
-#include "sljitConfigInternal.h"
-
-/* --------------------------------------------------------------------- */
-/* Error codes */
-/* --------------------------------------------------------------------- */
-
-/* Indicates no error. */
-#define SLJIT_SUCCESS 0
-/* After the call of sljit_generate_code(), the error code of the compiler
- is set to this value to avoid future sljit calls (in debug mode at least).
- The complier should be freed after sljit_generate_code(). */
-#define SLJIT_ERR_COMPILED 1
-/* Cannot allocate non executable memory. */
-#define SLJIT_ERR_ALLOC_FAILED 2
-/* Cannot allocate executable memory.
- Only for sljit_generate_code() */
-#define SLJIT_ERR_EX_ALLOC_FAILED 3
-/* Return value for SLJIT_CONFIG_UNSUPPORTED placeholder architecture. */
-#define SLJIT_ERR_UNSUPPORTED 4
-/* An ivalid argument is passed to any SLJIT function. */
-#define SLJIT_ERR_BAD_ARGUMENT 5
-
-/* --------------------------------------------------------------------- */
-/* Registers */
-/* --------------------------------------------------------------------- */
-
-/*
- Scratch (R) registers: registers whose may not preserve their values
- across function calls.
-
- Saved (S) registers: registers whose preserve their values across
- function calls.
-
- The scratch and saved register sets are overlap. The last scratch register
- is the first saved register, the one before the last is the second saved
- register, and so on.
-
- If an architecture provides two scratch and three saved registers,
- its scratch and saved register sets are the following:
-
- R0 | [S4] | R0 and S4 represent the same physical register
- R1 | [S3] | R1 and S3 represent the same physical register
- [R2] | S2 | R2 and S2 represent the same physical register
- [R3] | S1 | R3 and S1 represent the same physical register
- [R4] | S0 | R4 and S0 represent the same physical register
-
- Note: SLJIT_NUMBER_OF_SCRATCH_REGISTERS would be 2 and
- SLJIT_NUMBER_OF_SAVED_REGISTERS would be 3 for this architecture.
-
- Note: On all supported architectures SLJIT_NUMBER_OF_REGISTERS >= 10
- and SLJIT_NUMBER_OF_SAVED_REGISTERS >= 5. However, 4 registers
- are virtual on x86-32. See below.
-
- The purpose of this definition is convenience. Although a register
- is either scratch register or saved register, SLJIT allows accessing
- them from the other set. For example, four registers can be used as
- scratch registers and the fifth one as saved register on the architecture
- above. Of course the last two scratch registers (R2 and R3) from this
- four will be saved on the stack, because they are defined as saved
- registers in the application binary interface. Still R2 and R3 can be
- used for referencing to these registers instead of S2 and S1, which
- makes easier to write platform independent code. Scratch registers
- can be saved registers in a similar way, but these extra saved
- registers will not be preserved across function calls! Hence the
- application must save them on those platforms, where the number of
- saved registers is too low. This can be done by copy them onto
- the stack and restore them after a function call.
-
- Note: To emphasize that registers assigned to R2-R4 are saved
- registers, they are enclosed by square brackets. S3-S4
- are marked in a similar way.
-
- Note: sljit_emit_enter and sljit_set_context defines whether a register
- is S or R register. E.g: when 3 scratches and 1 saved is mapped
- by sljit_emit_enter, the allowed register set will be: R0-R2 and
- S0. Although S2 is mapped to the same position as R2, it does not
- available in the current configuration. Furthermore the R3 (S1)
- register does not available as well.
-*/
-
-/* When SLJIT_UNUSED is specified as destination, the result is discarded. */
-#define SLJIT_UNUSED 0
-
-/* Scratch registers. */
-#define SLJIT_R0 1
-#define SLJIT_R1 2
-#define SLJIT_R2 3
-/* Note: on x86-32, R3 - R6 (same as S3 - S6) are emulated (they
- are allocated on the stack). These registers are called virtual
- and cannot be used for memory addressing (cannot be part of
- any SLJIT_MEM1, SLJIT_MEM2 construct). There is no such
- limitation on other CPUs. See sljit_get_register_index(). */
-#define SLJIT_R3 4
-#define SLJIT_R4 5
-#define SLJIT_R5 6
-#define SLJIT_R6 7
-#define SLJIT_R7 8
-#define SLJIT_R8 9
-#define SLJIT_R9 10
-/* All R registers provided by the architecture can be accessed by SLJIT_R(i)
- The i parameter must be >= 0 and < SLJIT_NUMBER_OF_REGISTERS. */
-#define SLJIT_R(i) (1 + (i))
-
-/* Saved registers. */
-#define SLJIT_S0 (SLJIT_NUMBER_OF_REGISTERS)
-#define SLJIT_S1 (SLJIT_NUMBER_OF_REGISTERS - 1)
-#define SLJIT_S2 (SLJIT_NUMBER_OF_REGISTERS - 2)
-/* Note: on x86-32, S3 - S6 (same as R3 - R6) are emulated (they
- are allocated on the stack). These registers are called virtual
- and cannot be used for memory addressing (cannot be part of
- any SLJIT_MEM1, SLJIT_MEM2 construct). There is no such
- limitation on other CPUs. See sljit_get_register_index(). */
-#define SLJIT_S3 (SLJIT_NUMBER_OF_REGISTERS - 3)
-#define SLJIT_S4 (SLJIT_NUMBER_OF_REGISTERS - 4)
-#define SLJIT_S5 (SLJIT_NUMBER_OF_REGISTERS - 5)
-#define SLJIT_S6 (SLJIT_NUMBER_OF_REGISTERS - 6)
-#define SLJIT_S7 (SLJIT_NUMBER_OF_REGISTERS - 7)
-#define SLJIT_S8 (SLJIT_NUMBER_OF_REGISTERS - 8)
-#define SLJIT_S9 (SLJIT_NUMBER_OF_REGISTERS - 9)
-/* All S registers provided by the architecture can be accessed by SLJIT_S(i)
- The i parameter must be >= 0 and < SLJIT_NUMBER_OF_SAVED_REGISTERS. */
-#define SLJIT_S(i) (SLJIT_NUMBER_OF_REGISTERS - (i))
-
-/* Registers >= SLJIT_FIRST_SAVED_REG are saved registers. */
-#define SLJIT_FIRST_SAVED_REG (SLJIT_S0 - SLJIT_NUMBER_OF_SAVED_REGISTERS + 1)
-
-/* The SLJIT_SP provides direct access to the linear stack space allocated by
- sljit_emit_enter. It can only be used in the following form: SLJIT_MEM1(SLJIT_SP).
- The immediate offset is extended by the relative stack offset automatically.
- The sljit_get_local_base can be used to obtain the absolute offset. */
-#define SLJIT_SP (SLJIT_NUMBER_OF_REGISTERS + 1)
-
-/* Return with machine word. */
-
-#define SLJIT_RETURN_REG SLJIT_R0
-
-/* x86 prefers specific registers for special purposes. In case of shift
- by register it supports only SLJIT_R2 for shift argument
- (which is the src2 argument of sljit_emit_op2). If another register is
- used, sljit must exchange data between registers which cause a minor
- slowdown. Other architectures has no such limitation. */
-
-#define SLJIT_PREF_SHIFT_REG SLJIT_R2
-
-/* --------------------------------------------------------------------- */
-/* Floating point registers */
-/* --------------------------------------------------------------------- */
-
-/* Each floating point register can store a double or single precision
- value. The FR and FS register sets are overlap in the same way as R
- and S register sets. See above. */
-
-/* Note: SLJIT_UNUSED as destination is not valid for floating point
- operations, since they cannot be used for setting flags. */
-
-/* Floating point scratch registers. */
-#define SLJIT_FR0 1
-#define SLJIT_FR1 2
-#define SLJIT_FR2 3
-#define SLJIT_FR3 4
-#define SLJIT_FR4 5
-#define SLJIT_FR5 6
-/* All FR registers provided by the architecture can be accessed by SLJIT_FR(i)
- The i parameter must be >= 0 and < SLJIT_NUMBER_OF_FLOAT_REGISTERS. */
-#define SLJIT_FR(i) (1 + (i))
-
-/* Floating point saved registers. */
-#define SLJIT_FS0 (SLJIT_NUMBER_OF_FLOAT_REGISTERS)
-#define SLJIT_FS1 (SLJIT_NUMBER_OF_FLOAT_REGISTERS - 1)
-#define SLJIT_FS2 (SLJIT_NUMBER_OF_FLOAT_REGISTERS - 2)
-#define SLJIT_FS3 (SLJIT_NUMBER_OF_FLOAT_REGISTERS - 3)
-#define SLJIT_FS4 (SLJIT_NUMBER_OF_FLOAT_REGISTERS - 4)
-#define SLJIT_FS5 (SLJIT_NUMBER_OF_FLOAT_REGISTERS - 5)
-/* All S registers provided by the architecture can be accessed by SLJIT_FS(i)
- The i parameter must be >= 0 and < SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS. */
-#define SLJIT_FS(i) (SLJIT_NUMBER_OF_FLOAT_REGISTERS - (i))
-
-/* Float registers >= SLJIT_FIRST_SAVED_FLOAT_REG are saved registers. */
-#define SLJIT_FIRST_SAVED_FLOAT_REG (SLJIT_FS0 - SLJIT_NUMBER_OF_SAVED_FLOAT_REGISTERS + 1)
-
-/* --------------------------------------------------------------------- */
-/* Main structures and functions */
-/* --------------------------------------------------------------------- */
-
-/*
- The following structures are private, and can be changed in the
- future. Keeping them here allows code inlining.
-*/
-
-struct sljit_memory_fragment {
- struct sljit_memory_fragment *next;
- sljit_uw used_size;
- /* Must be aligned to sljit_sw. */
- sljit_ub memory[1];
-};
-
-struct sljit_label {
- struct sljit_label *next;
- sljit_uw addr;
- /* The maximum size difference. */
- sljit_uw size;
-};
-
-struct sljit_jump {
- struct sljit_jump *next;
- sljit_uw addr;
- sljit_sw flags;
- union {
- sljit_uw target;
- struct sljit_label* label;
- } u;
-};
-
-struct sljit_const {
- struct sljit_const *next;
- sljit_uw addr;
-};
-
-struct sljit_compiler {
- sljit_si error;
- sljit_si options;
-
- struct sljit_label *labels;
- struct sljit_jump *jumps;
- struct sljit_const *consts;
- struct sljit_label *last_label;
- struct sljit_jump *last_jump;
- struct sljit_const *last_const;
-
- void *allocator_data;
- struct sljit_memory_fragment *buf;
- struct sljit_memory_fragment *abuf;
-
- /* Used scratch registers. */
- sljit_si scratches;
- /* Used saved registers. */
- sljit_si saveds;
- /* Used float scratch registers. */
- sljit_si fscratches;
- /* Used float saved registers. */
- sljit_si fsaveds;
- /* Local stack size. */
- sljit_si local_size;
- /* Code size. */
- sljit_uw size;
- /* For statistical purposes. */
- sljit_uw executable_size;
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- sljit_si args;
-#endif
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- sljit_si mode32;
-#endif
-
-#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
- sljit_si flags_saved;
-#endif
-
-#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
- /* Constant pool handling. */
- sljit_uw *cpool;
- sljit_ub *cpool_unique;
- sljit_uw cpool_diff;
- sljit_uw cpool_fill;
- /* Other members. */
- /* Contains pointer, "ldr pc, [...]" pairs. */
- sljit_uw patches;
-#endif
-
-#if (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5) || (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
- /* Temporary fields. */
- sljit_uw shift_imm;
- sljit_si cache_arg;
- sljit_sw cache_argw;
-#endif
-
-#if (defined SLJIT_CONFIG_ARM_THUMB2 && SLJIT_CONFIG_ARM_THUMB2)
- sljit_si cache_arg;
- sljit_sw cache_argw;
-#endif
-
-#if (defined SLJIT_CONFIG_ARM_64 && SLJIT_CONFIG_ARM_64)
- sljit_si cache_arg;
- sljit_sw cache_argw;
-#endif
-
-#if (defined SLJIT_CONFIG_PPC && SLJIT_CONFIG_PPC)
- sljit_sw imm;
- sljit_si cache_arg;
- sljit_sw cache_argw;
-#endif
-
-#if (defined SLJIT_CONFIG_MIPS && SLJIT_CONFIG_MIPS)
- sljit_si delay_slot;
- sljit_si cache_arg;
- sljit_sw cache_argw;
-#endif
-
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- sljit_si delay_slot;
- sljit_si cache_arg;
- sljit_sw cache_argw;
-#endif
-
-#if (defined SLJIT_CONFIG_TILEGX && SLJIT_CONFIG_TILEGX)
- sljit_si cache_arg;
- sljit_sw cache_argw;
-#endif
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- FILE* verbose;
-#endif
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
- || (defined SLJIT_DEBUG && SLJIT_DEBUG)
- /* Local size passed to the functions. */
- sljit_si logical_local_size;
-#endif
-
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS) \
- || (defined SLJIT_DEBUG && SLJIT_DEBUG) \
- || (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- sljit_si skip_checks;
-#endif
-};
-
-/* --------------------------------------------------------------------- */
-/* Main functions */
-/* --------------------------------------------------------------------- */
-
-/* Creates an sljit compiler. The allocator_data is required by some
- custom memory managers. This pointer is passed to SLJIT_MALLOC
- and SLJIT_FREE macros. Most allocators (including the default
- one) ignores this value, and it is recommended to pass NULL
- as a dummy value for allocator_data.
-
- Returns NULL if failed. */
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data);
-
-/* Frees everything except the compiled machine code. */
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_compiler(struct sljit_compiler *compiler);
-
-/* Returns the current error code. If an error is occurred, future sljit
- calls which uses the same compiler argument returns early with the same
- error code. Thus there is no need for checking the error after every
- call, it is enough to do it before the code is compiled. Removing
- these checks increases the performance of the compiling process. */
-static SLJIT_INLINE sljit_si sljit_get_compiler_error(struct sljit_compiler *compiler) { return compiler->error; }
-
-/* Sets the compiler error code to SLJIT_ERR_ALLOC_FAILED except
- if an error was detected before. After the error code is set
- the compiler behaves as if the allocation failure happened
- during an sljit function call. This can greatly simplify error
- checking, since only the compiler status needs to be checked
- after the compilation. */
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_compiler_memory_error(struct sljit_compiler *compiler);
-
-/*
- Allocate a small amount of memory. The size must be <= 64 bytes on 32 bit,
- and <= 128 bytes on 64 bit architectures. The memory area is owned by the
- compiler, and freed by sljit_free_compiler. The returned pointer is
- sizeof(sljit_sw) aligned. Excellent for allocating small blocks during
- the compiling, and no need to worry about freeing them. The size is
- enough to contain at most 16 pointers. If the size is outside of the range,
- the function will return with NULL. However, this return value does not
- indicate that there is no more memory (does not set the current error code
- of the compiler to out-of-memory status).
-*/
-SLJIT_API_FUNC_ATTRIBUTE void* sljit_alloc_memory(struct sljit_compiler *compiler, sljit_si size);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
-/* Passing NULL disables verbose. */
-SLJIT_API_FUNC_ATTRIBUTE void sljit_compiler_verbose(struct sljit_compiler *compiler, FILE* verbose);
-#endif
-
-SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler);
-SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code);
-
-/*
- After the machine code generation is finished we can retrieve the allocated
- executable memory size, although this area may not be fully filled with
- instructions depending on some optimizations. This function is useful only
- for statistical purposes.
-
- Before a successful code generation, this function returns with 0.
-*/
-static SLJIT_INLINE sljit_uw sljit_get_generated_code_size(struct sljit_compiler *compiler) { return compiler->executable_size; }
-
-/* Instruction generation. Returns with any error code. If there is no
- error, they return with SLJIT_SUCCESS. */
-
-/*
- The executable code is a function call from the viewpoint of the C
- language. The function calls must obey to the ABI (Application
- Binary Interface) of the platform, which specify the purpose of
- all machine registers and stack handling among other things. The
- sljit_emit_enter function emits the necessary instructions for
- setting up a new context for the executable code and moves function
- arguments to the saved registers. Furthermore the options argument
- can be used to pass configuration options to the compiler. The
- available options are listed before sljit_emit_enter.
-
- The number of sljit_sw arguments passed to the generated function
- are specified in the "args" parameter. The number of arguments must
- be less than or equal to 3. The first argument goes to SLJIT_S0,
- the second goes to SLJIT_S1 and so on. The register set used by
- the function must be declared as well. The number of scratch and
- saved registers used by the function must be passed to sljit_emit_enter.
- Only R registers between R0 and "scratches" argument can be used
- later. E.g. if "scratches" is set to 2, the register set will be
- limited to R0 and R1. The S registers and the floating point
- registers ("fscratches" and "fsaveds") are specified in a similar
- way. The sljit_emit_enter is also capable of allocating a stack
- space for local variables. The "local_size" argument contains the
- size in bytes of this local area and its staring address is stored
- in SLJIT_SP. The memory area between SLJIT_SP (inclusive) and
- SLJIT_SP + local_size (exclusive) can be modified freely until
- the function returns. The stack space is not initialized.
-
- Note: the following conditions must met:
- 0 <= scratches <= SLJIT_NUMBER_OF_REGISTERS
- 0 <= saveds <= SLJIT_NUMBER_OF_REGISTERS
- scratches + saveds <= SLJIT_NUMBER_OF_REGISTERS
- 0 <= fscratches <= SLJIT_NUMBER_OF_FLOAT_REGISTERS
- 0 <= fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS
- fscratches + fsaveds <= SLJIT_NUMBER_OF_FLOAT_REGISTERS
-
- Note: every call of sljit_emit_enter and sljit_set_context
- overwrites the previous context.
-*/
-
-/* The absolute address returned by sljit_get_local_base with
-offset 0 is aligned to sljit_d. Otherwise it is aligned to sljit_uw. */
-#define SLJIT_DOUBLE_ALIGNMENT 0x00000001
-
-/* The local_size must be >= 0 and <= SLJIT_MAX_LOCAL_SIZE. */
-#define SLJIT_MAX_LOCAL_SIZE 65536
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size);
-
-/* The machine code has a context (which contains the local stack space size,
- number of used registers, etc.) which initialized by sljit_emit_enter. Several
- functions (like sljit_emit_return) requres this context to be able to generate
- the appropriate code. However, some code fragments (like inline cache) may have
- no normal entry point so their context is unknown for the compiler. Their context
- can be provided to the compiler by the sljit_set_context function.
-
- Note: every call of sljit_emit_enter and sljit_set_context overwrites
- the previous context. */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size);
-
-/* Return from machine code. The op argument can be SLJIT_UNUSED which means the
- function does not return with anything or any opcode between SLJIT_MOV and
- SLJIT_MOV_P (see sljit_emit_op1). As for src and srcw they must be 0 if op
- is SLJIT_UNUSED, otherwise see below the description about source and
- destination arguments. */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op,
- sljit_si src, sljit_sw srcw);
-
-/* Fast calling mechanism for utility functions (see SLJIT_FAST_CALL). All registers and
- even the stack frame is passed to the callee. The return address is preserved in
- dst/dstw by sljit_emit_fast_enter (the type of the value stored by this function
- is sljit_p), and sljit_emit_fast_return can use this as a return value later. */
-
-/* Note: only for sljit specific, non ABI compilant calls. Fast, since only a few machine
- instructions are needed. Excellent for small uility functions, where saving registers
- and setting up a new stack frame would cost too much performance. However, it is still
- possible to return to the address of the caller (or anywhere else). */
-
-/* Note: flags are not changed (unlike sljit_emit_enter / sljit_emit_return). */
-
-/* Note: although sljit_emit_fast_return could be replaced by an ijump, it is not suggested,
- since many architectures do clever branch prediction on call / return instruction pairs. */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw);
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw);
-
-/*
- Source and destination values for arithmetical instructions
- imm - a simple immediate value (cannot be used as a destination)
- reg - any of the registers (immediate argument must be 0)
- [imm] - absolute immediate memory address
- [reg+imm] - indirect memory address
- [reg+(reg<addr; }
-static SLJIT_INLINE sljit_uw sljit_get_jump_addr(struct sljit_jump *jump) { return jump->addr; }
-static SLJIT_INLINE sljit_uw sljit_get_const_addr(struct sljit_const *const_) { return const_->addr; }
-
-/* Only the address is required to rewrite the code. */
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr);
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant);
-
-/* --------------------------------------------------------------------- */
-/* Miscellaneous utility functions */
-/* --------------------------------------------------------------------- */
-
-#define SLJIT_MAJOR_VERSION 0
-#define SLJIT_MINOR_VERSION 93
-
-/* Get the human readable name of the platform. Can be useful on platforms
- like ARM, where ARM and Thumb2 functions can be mixed, and
- it is useful to know the type of the code generator. */
-SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void);
-
-/* Portable helper function to get an offset of a member. */
-#define SLJIT_OFFSETOF(base, member) ((sljit_sw)(&((base*)0x10)->member) - 0x10)
-
-#if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
-/* This global lock is useful to compile common functions. */
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void);
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release_lock(void);
-#endif
-
-#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
-
-/* The sljit_stack is a utiliy feature of sljit, which allocates a
- writable memory region between base (inclusive) and limit (exclusive).
- Both base and limit is a pointer, and base is always <= than limit.
- This feature uses the "address space reserve" feature
- of modern operating systems. Basically we don't need to allocate a
- huge memory block in one step for the worst case, we can start with
- a smaller chunk and extend it later. Since the address space is
- reserved, the data never copied to other regions, thus it is safe
- to store pointers here. */
-
-/* Note: The base field is aligned to PAGE_SIZE bytes (usually 4k or more).
- Note: stack growing should not happen in small steps: 4k, 16k or even
- bigger growth is better.
- Note: this structure may not be supported by all operating systems.
- Some kind of fallback mechanism is suggested when SLJIT_UTIL_STACK
- is not defined. */
-
-struct sljit_stack {
- /* User data, anything can be stored here.
- Starting with the same value as base. */
- sljit_uw top;
- /* These members are read only. */
- sljit_uw base;
- sljit_uw limit;
- sljit_uw max_limit;
-};
-
-/* Returns NULL if unsuccessful.
- Note: limit and max_limit contains the size for stack allocation.
- Note: the top field is initialized to base.
- Note: see sljit_create_compiler for the explanation of allocator_data. */
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit, void *allocator_data);
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack *stack, void *allocator_data);
-
-/* Can be used to increase (allocate) or decrease (free) the memory area.
- Returns with a non-zero value if unsuccessful. If new_limit is greater than
- max_limit, it will fail. It is very easy to implement a stack data structure,
- since the growth ratio can be added to the current limit, and sljit_stack_resize
- will do all the necessary checks. The fields of the stack are not changed if
- sljit_stack_resize fails. */
-SLJIT_API_FUNC_ATTRIBUTE sljit_sw SLJIT_CALL sljit_stack_resize(struct sljit_stack *stack, sljit_uw new_limit);
-
-#endif /* (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) */
-
-#if !(defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
-
-/* Get the entry address of a given function. */
-#define SLJIT_FUNC_OFFSET(func_name) ((sljit_sw)func_name)
-
-#else /* !(defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) */
-
-/* All JIT related code should be placed in the same context (library, binary, etc.). */
-
-#define SLJIT_FUNC_OFFSET(func_name) (*(sljit_sw*)(void*)func_name)
-
-/* For powerpc64, the function pointers point to a context descriptor. */
-struct sljit_function_context {
- sljit_sw addr;
- sljit_sw r2;
- sljit_sw r11;
-};
-
-/* Fill the context arguments using the addr and the function.
- If func_ptr is NULL, it will not be set to the address of context
- If addr is NULL, the function address also comes from the func pointer. */
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_sw addr, void* func);
-
-#endif /* !(defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL) */
-
-/* --------------------------------------------------------------------- */
-/* CPU specific functions */
-/* --------------------------------------------------------------------- */
-
-/* The following function is a helper function for sljit_emit_op_custom.
- It returns with the real machine register index ( >=0 ) of any SLJIT_R,
- SLJIT_S and SLJIT_SP registers.
-
- Note: it returns with -1 for virtual registers (only on x86-32). */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg);
-
-/* The following function is a helper function for sljit_emit_op_custom.
- It returns with the real machine register index of any SLJIT_FLOAT register.
-
- Note: the index is always an even number on ARM (except ARM-64), MIPS, and SPARC. */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg);
-
-/* Any instruction can be inserted into the instruction stream by
- sljit_emit_op_custom. It has a similar purpose as inline assembly.
- The size parameter must match to the instruction size of the target
- architecture:
-
- x86: 0 < size <= 15. The instruction argument can be byte aligned.
- Thumb2: if size == 2, the instruction argument must be 2 byte aligned.
- if size == 4, the instruction argument must be 4 byte aligned.
- Otherwise: size must be 4 and instruction argument must be 4 byte aligned. */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
- void *instruction, sljit_si size);
-
-#if (defined SLJIT_CONFIG_X86 && SLJIT_CONFIG_X86)
-
-/* Returns with non-zero if sse2 is available. */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_sse2_available(void);
-
-/* Returns with non-zero if cmov instruction is available. */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_cmov_available(void);
-
-/* Emit a conditional mov instruction on x86 CPUs. This instruction
- moves src to destination, if the condition is satisfied. Unlike
- other arithmetic instructions, destination must be a register.
- Before such instructions are emitted, cmov support should be
- checked by sljit_x86_is_cmov_available function.
- type must be between SLJIT_EQUAL and SLJIT_S_ORDERED
- dst_reg must be a valid register and it can be combined
- with SLJIT_INT_OP to perform 32 bit arithmetic
- Flags: I - (never set any flags)
- */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_emit_cmov(struct sljit_compiler *compiler,
- sljit_si type,
- sljit_si dst_reg,
- sljit_si src, sljit_sw srcw);
-
-#endif
-
-#endif /* _SLJIT_LIR_H_ */
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitNativePPC_32.c r-base-3.3.1/src/extra/pcre/sljit/sljitNativePPC_32.c
--- r-base-3.2.3/src/extra/pcre/sljit/sljitNativePPC_32.c 2014-04-20 22:15:03.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitNativePPC_32.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,269 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* ppc 32-bit arch dependent functions. */
-
-static sljit_si load_immediate(struct sljit_compiler *compiler, sljit_si reg, sljit_sw imm)
-{
- if (imm <= SIMM_MAX && imm >= SIMM_MIN)
- return push_inst(compiler, ADDI | D(reg) | A(0) | IMM(imm));
-
- if (!(imm & ~0xffff))
- return push_inst(compiler, ORI | S(TMP_ZERO) | A(reg) | IMM(imm));
-
- FAIL_IF(push_inst(compiler, ADDIS | D(reg) | A(0) | IMM(imm >> 16)));
- return (imm & 0xffff) ? push_inst(compiler, ORI | S(reg) | A(reg) | IMM(imm)) : SLJIT_SUCCESS;
-}
-
-#define INS_CLEAR_LEFT(dst, src, from) \
- (RLWINM | S(src) | A(dst) | ((from) << 6) | (31 << 1))
-
-static SLJIT_INLINE sljit_si emit_single_op(struct sljit_compiler *compiler, sljit_si op, sljit_si flags,
- sljit_si dst, sljit_si src1, sljit_si src2)
-{
- switch (op) {
- case SLJIT_MOV:
- case SLJIT_MOV_UI:
- case SLJIT_MOV_SI:
- case SLJIT_MOV_P:
- SLJIT_ASSERT(src1 == TMP_REG1);
- if (dst != src2)
- return push_inst(compiler, OR | S(src2) | A(dst) | B(src2));
- return SLJIT_SUCCESS;
-
- case SLJIT_MOV_UB:
- case SLJIT_MOV_SB:
- SLJIT_ASSERT(src1 == TMP_REG1);
- if ((flags & (REG_DEST | REG2_SOURCE)) == (REG_DEST | REG2_SOURCE)) {
- if (op == SLJIT_MOV_SB)
- return push_inst(compiler, EXTSB | S(src2) | A(dst));
- return push_inst(compiler, INS_CLEAR_LEFT(dst, src2, 24));
- }
- else if ((flags & REG_DEST) && op == SLJIT_MOV_SB)
- return push_inst(compiler, EXTSB | S(src2) | A(dst));
- else {
- SLJIT_ASSERT(dst == src2);
- }
- return SLJIT_SUCCESS;
-
- case SLJIT_MOV_UH:
- case SLJIT_MOV_SH:
- SLJIT_ASSERT(src1 == TMP_REG1);
- if ((flags & (REG_DEST | REG2_SOURCE)) == (REG_DEST | REG2_SOURCE)) {
- if (op == SLJIT_MOV_SH)
- return push_inst(compiler, EXTSH | S(src2) | A(dst));
- return push_inst(compiler, INS_CLEAR_LEFT(dst, src2, 16));
- }
- else {
- SLJIT_ASSERT(dst == src2);
- }
- return SLJIT_SUCCESS;
-
- case SLJIT_NOT:
- SLJIT_ASSERT(src1 == TMP_REG1);
- return push_inst(compiler, NOR | RC(flags) | S(src2) | A(dst) | B(src2));
-
- case SLJIT_NEG:
- SLJIT_ASSERT(src1 == TMP_REG1);
- return push_inst(compiler, NEG | OERC(flags) | D(dst) | A(src2));
-
- case SLJIT_CLZ:
- SLJIT_ASSERT(src1 == TMP_REG1);
- return push_inst(compiler, CNTLZW | RC(flags) | S(src2) | A(dst));
-
- case SLJIT_ADD:
- if (flags & ALT_FORM1) {
- /* Flags does not set: BIN_IMM_EXTS unnecessary. */
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ADDI | D(dst) | A(src1) | compiler->imm);
- }
- if (flags & ALT_FORM2) {
- /* Flags does not set: BIN_IMM_EXTS unnecessary. */
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ADDIS | D(dst) | A(src1) | compiler->imm);
- }
- if (flags & ALT_FORM3) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ADDIC | D(dst) | A(src1) | compiler->imm);
- }
- if (flags & ALT_FORM4) {
- /* Flags does not set: BIN_IMM_EXTS unnecessary. */
- FAIL_IF(push_inst(compiler, ADDI | D(dst) | A(src1) | (compiler->imm & 0xffff)));
- return push_inst(compiler, ADDIS | D(dst) | A(dst) | (((compiler->imm >> 16) & 0xffff) + ((compiler->imm >> 15) & 0x1)));
- }
- if (!(flags & ALT_SET_FLAGS))
- return push_inst(compiler, ADD | D(dst) | A(src1) | B(src2));
- return push_inst(compiler, ADDC | OERC(ALT_SET_FLAGS) | D(dst) | A(src1) | B(src2));
-
- case SLJIT_ADDC:
- if (flags & ALT_FORM1) {
- FAIL_IF(push_inst(compiler, MFXER | D(0)));
- FAIL_IF(push_inst(compiler, ADDE | D(dst) | A(src1) | B(src2)));
- return push_inst(compiler, MTXER | S(0));
- }
- return push_inst(compiler, ADDE | D(dst) | A(src1) | B(src2));
-
- case SLJIT_SUB:
- if (flags & ALT_FORM1) {
- /* Flags does not set: BIN_IMM_EXTS unnecessary. */
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, SUBFIC | D(dst) | A(src1) | compiler->imm);
- }
- if (flags & (ALT_FORM2 | ALT_FORM3)) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- if (flags & ALT_FORM2)
- FAIL_IF(push_inst(compiler, CMPI | CRD(0) | A(src1) | compiler->imm));
- if (flags & ALT_FORM3)
- return push_inst(compiler, CMPLI | CRD(4) | A(src1) | compiler->imm);
- return SLJIT_SUCCESS;
- }
- if (flags & (ALT_FORM4 | ALT_FORM5)) {
- if (flags & ALT_FORM4)
- FAIL_IF(push_inst(compiler, CMPL | CRD(4) | A(src1) | B(src2)));
- if (flags & ALT_FORM5)
- FAIL_IF(push_inst(compiler, CMP | CRD(0) | A(src1) | B(src2)));
- return SLJIT_SUCCESS;
- }
- if (!(flags & ALT_SET_FLAGS))
- return push_inst(compiler, SUBF | D(dst) | A(src2) | B(src1));
- if (flags & ALT_FORM6)
- FAIL_IF(push_inst(compiler, CMPL | CRD(4) | A(src1) | B(src2)));
- return push_inst(compiler, SUBFC | OERC(ALT_SET_FLAGS) | D(dst) | A(src2) | B(src1));
-
- case SLJIT_SUBC:
- if (flags & ALT_FORM1) {
- FAIL_IF(push_inst(compiler, MFXER | D(0)));
- FAIL_IF(push_inst(compiler, SUBFE | D(dst) | A(src2) | B(src1)));
- return push_inst(compiler, MTXER | S(0));
- }
- return push_inst(compiler, SUBFE | D(dst) | A(src2) | B(src1));
-
- case SLJIT_MUL:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, MULLI | D(dst) | A(src1) | compiler->imm);
- }
- return push_inst(compiler, MULLW | OERC(flags) | D(dst) | A(src2) | B(src1));
-
- case SLJIT_AND:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ANDI | S(src1) | A(dst) | compiler->imm);
- }
- if (flags & ALT_FORM2) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ANDIS | S(src1) | A(dst) | compiler->imm);
- }
- return push_inst(compiler, AND | RC(flags) | S(src1) | A(dst) | B(src2));
-
- case SLJIT_OR:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ORI | S(src1) | A(dst) | compiler->imm);
- }
- if (flags & ALT_FORM2) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ORIS | S(src1) | A(dst) | compiler->imm);
- }
- if (flags & ALT_FORM3) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- FAIL_IF(push_inst(compiler, ORI | S(src1) | A(dst) | IMM(compiler->imm)));
- return push_inst(compiler, ORIS | S(dst) | A(dst) | IMM(compiler->imm >> 16));
- }
- return push_inst(compiler, OR | RC(flags) | S(src1) | A(dst) | B(src2));
-
- case SLJIT_XOR:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, XORI | S(src1) | A(dst) | compiler->imm);
- }
- if (flags & ALT_FORM2) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, XORIS | S(src1) | A(dst) | compiler->imm);
- }
- if (flags & ALT_FORM3) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- FAIL_IF(push_inst(compiler, XORI | S(src1) | A(dst) | IMM(compiler->imm)));
- return push_inst(compiler, XORIS | S(dst) | A(dst) | IMM(compiler->imm >> 16));
- }
- return push_inst(compiler, XOR | RC(flags) | S(src1) | A(dst) | B(src2));
-
- case SLJIT_SHL:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- compiler->imm &= 0x1f;
- return push_inst(compiler, RLWINM | RC(flags) | S(src1) | A(dst) | (compiler->imm << 11) | ((31 - compiler->imm) << 1));
- }
- return push_inst(compiler, SLW | RC(flags) | S(src1) | A(dst) | B(src2));
-
- case SLJIT_LSHR:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- compiler->imm &= 0x1f;
- return push_inst(compiler, RLWINM | RC(flags) | S(src1) | A(dst) | (((32 - compiler->imm) & 0x1f) << 11) | (compiler->imm << 6) | (31 << 1));
- }
- return push_inst(compiler, SRW | RC(flags) | S(src1) | A(dst) | B(src2));
-
- case SLJIT_ASHR:
- if (flags & ALT_FORM3)
- FAIL_IF(push_inst(compiler, MFXER | D(0)));
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- compiler->imm &= 0x1f;
- FAIL_IF(push_inst(compiler, SRAWI | RC(flags) | S(src1) | A(dst) | (compiler->imm << 11)));
- }
- else
- FAIL_IF(push_inst(compiler, SRAW | RC(flags) | S(src1) | A(dst) | B(src2)));
- return (flags & ALT_FORM3) ? push_inst(compiler, MTXER | S(0)) : SLJIT_SUCCESS;
- }
-
- SLJIT_ASSERT_STOP();
- return SLJIT_SUCCESS;
-}
-
-static SLJIT_INLINE sljit_si emit_const(struct sljit_compiler *compiler, sljit_si reg, sljit_sw init_value)
-{
- FAIL_IF(push_inst(compiler, ADDIS | D(reg) | A(0) | IMM(init_value >> 16)));
- return push_inst(compiler, ORI | S(reg) | A(reg) | IMM(init_value));
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr)
-{
- sljit_ins *inst = (sljit_ins*)addr;
-
- inst[0] = (inst[0] & 0xffff0000) | ((new_addr >> 16) & 0xffff);
- inst[1] = (inst[1] & 0xffff0000) | (new_addr & 0xffff);
- SLJIT_CACHE_FLUSH(inst, inst + 2);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant)
-{
- sljit_ins *inst = (sljit_ins*)addr;
-
- inst[0] = (inst[0] & 0xffff0000) | ((new_constant >> 16) & 0xffff);
- inst[1] = (inst[1] & 0xffff0000) | (new_constant & 0xffff);
- SLJIT_CACHE_FLUSH(inst, inst + 2);
-}
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitNativePPC_64.c r-base-3.3.1/src/extra/pcre/sljit/sljitNativePPC_64.c
--- r-base-3.2.3/src/extra/pcre/sljit/sljitNativePPC_64.c 2014-04-20 22:15:03.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitNativePPC_64.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,421 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* ppc 64-bit arch dependent functions. */
-
-#if defined(__GNUC__) || (defined(__IBM_GCC_ASM) && __IBM_GCC_ASM)
-#define ASM_SLJIT_CLZ(src, dst) \
- __asm__ volatile ( "cntlzd %0, %1" : "=r"(dst) : "r"(src) )
-#elif defined(__xlc__)
-#error "Please enable GCC syntax for inline assembly statements"
-#else
-#error "Must implement count leading zeroes"
-#endif
-
-#define RLDI(dst, src, sh, mb, type) \
- (HI(30) | S(src) | A(dst) | ((type) << 2) | (((sh) & 0x1f) << 11) | (((sh) & 0x20) >> 4) | (((mb) & 0x1f) << 6) | ((mb) & 0x20))
-
-#define PUSH_RLDICR(reg, shift) \
- push_inst(compiler, RLDI(reg, reg, 63 - shift, shift, 1))
-
-static sljit_si load_immediate(struct sljit_compiler *compiler, sljit_si reg, sljit_sw imm)
-{
- sljit_uw tmp;
- sljit_uw shift;
- sljit_uw tmp2;
- sljit_uw shift2;
-
- if (imm <= SIMM_MAX && imm >= SIMM_MIN)
- return push_inst(compiler, ADDI | D(reg) | A(0) | IMM(imm));
-
- if (!(imm & ~0xffff))
- return push_inst(compiler, ORI | S(TMP_ZERO) | A(reg) | IMM(imm));
-
- if (imm <= 0x7fffffffl && imm >= -0x80000000l) {
- FAIL_IF(push_inst(compiler, ADDIS | D(reg) | A(0) | IMM(imm >> 16)));
- return (imm & 0xffff) ? push_inst(compiler, ORI | S(reg) | A(reg) | IMM(imm)) : SLJIT_SUCCESS;
- }
-
- /* Count leading zeroes. */
- tmp = (imm >= 0) ? imm : ~imm;
- ASM_SLJIT_CLZ(tmp, shift);
- SLJIT_ASSERT(shift > 0);
- shift--;
- tmp = (imm << shift);
-
- if ((tmp & ~0xffff000000000000ul) == 0) {
- FAIL_IF(push_inst(compiler, ADDI | D(reg) | A(0) | IMM(tmp >> 48)));
- shift += 15;
- return PUSH_RLDICR(reg, shift);
- }
-
- if ((tmp & ~0xffffffff00000000ul) == 0) {
- FAIL_IF(push_inst(compiler, ADDIS | D(reg) | A(0) | IMM(tmp >> 48)));
- FAIL_IF(push_inst(compiler, ORI | S(reg) | A(reg) | IMM(tmp >> 32)));
- shift += 31;
- return PUSH_RLDICR(reg, shift);
- }
-
- /* Cut out the 16 bit from immediate. */
- shift += 15;
- tmp2 = imm & ((1ul << (63 - shift)) - 1);
-
- if (tmp2 <= 0xffff) {
- FAIL_IF(push_inst(compiler, ADDI | D(reg) | A(0) | IMM(tmp >> 48)));
- FAIL_IF(PUSH_RLDICR(reg, shift));
- return push_inst(compiler, ORI | S(reg) | A(reg) | tmp2);
- }
-
- if (tmp2 <= 0xffffffff) {
- FAIL_IF(push_inst(compiler, ADDI | D(reg) | A(0) | IMM(tmp >> 48)));
- FAIL_IF(PUSH_RLDICR(reg, shift));
- FAIL_IF(push_inst(compiler, ORIS | S(reg) | A(reg) | (tmp2 >> 16)));
- return (imm & 0xffff) ? push_inst(compiler, ORI | S(reg) | A(reg) | IMM(tmp2)) : SLJIT_SUCCESS;
- }
-
- ASM_SLJIT_CLZ(tmp2, shift2);
- tmp2 <<= shift2;
-
- if ((tmp2 & ~0xffff000000000000ul) == 0) {
- FAIL_IF(push_inst(compiler, ADDI | D(reg) | A(0) | IMM(tmp >> 48)));
- shift2 += 15;
- shift += (63 - shift2);
- FAIL_IF(PUSH_RLDICR(reg, shift));
- FAIL_IF(push_inst(compiler, ORI | S(reg) | A(reg) | (tmp2 >> 48)));
- return PUSH_RLDICR(reg, shift2);
- }
-
- /* The general version. */
- FAIL_IF(push_inst(compiler, ADDIS | D(reg) | A(0) | IMM(imm >> 48)));
- FAIL_IF(push_inst(compiler, ORI | S(reg) | A(reg) | IMM(imm >> 32)));
- FAIL_IF(PUSH_RLDICR(reg, 31));
- FAIL_IF(push_inst(compiler, ORIS | S(reg) | A(reg) | IMM(imm >> 16)));
- return push_inst(compiler, ORI | S(reg) | A(reg) | IMM(imm));
-}
-
-/* Simplified mnemonics: clrldi. */
-#define INS_CLEAR_LEFT(dst, src, from) \
- (RLDICL | S(src) | A(dst) | ((from) << 6) | (1 << 5))
-
-/* Sign extension for integer operations. */
-#define UN_EXTS() \
- if ((flags & (ALT_SIGN_EXT | REG2_SOURCE)) == (ALT_SIGN_EXT | REG2_SOURCE)) { \
- FAIL_IF(push_inst(compiler, EXTSW | S(src2) | A(TMP_REG2))); \
- src2 = TMP_REG2; \
- }
-
-#define BIN_EXTS() \
- if (flags & ALT_SIGN_EXT) { \
- if (flags & REG1_SOURCE) { \
- FAIL_IF(push_inst(compiler, EXTSW | S(src1) | A(TMP_REG1))); \
- src1 = TMP_REG1; \
- } \
- if (flags & REG2_SOURCE) { \
- FAIL_IF(push_inst(compiler, EXTSW | S(src2) | A(TMP_REG2))); \
- src2 = TMP_REG2; \
- } \
- }
-
-#define BIN_IMM_EXTS() \
- if ((flags & (ALT_SIGN_EXT | REG1_SOURCE)) == (ALT_SIGN_EXT | REG1_SOURCE)) { \
- FAIL_IF(push_inst(compiler, EXTSW | S(src1) | A(TMP_REG1))); \
- src1 = TMP_REG1; \
- }
-
-static SLJIT_INLINE sljit_si emit_single_op(struct sljit_compiler *compiler, sljit_si op, sljit_si flags,
- sljit_si dst, sljit_si src1, sljit_si src2)
-{
- switch (op) {
- case SLJIT_MOV:
- case SLJIT_MOV_P:
- SLJIT_ASSERT(src1 == TMP_REG1);
- if (dst != src2)
- return push_inst(compiler, OR | S(src2) | A(dst) | B(src2));
- return SLJIT_SUCCESS;
-
- case SLJIT_MOV_UI:
- case SLJIT_MOV_SI:
- SLJIT_ASSERT(src1 == TMP_REG1);
- if ((flags & (REG_DEST | REG2_SOURCE)) == (REG_DEST | REG2_SOURCE)) {
- if (op == SLJIT_MOV_SI)
- return push_inst(compiler, EXTSW | S(src2) | A(dst));
- return push_inst(compiler, INS_CLEAR_LEFT(dst, src2, 0));
- }
- else {
- SLJIT_ASSERT(dst == src2);
- }
- return SLJIT_SUCCESS;
-
- case SLJIT_MOV_UB:
- case SLJIT_MOV_SB:
- SLJIT_ASSERT(src1 == TMP_REG1);
- if ((flags & (REG_DEST | REG2_SOURCE)) == (REG_DEST | REG2_SOURCE)) {
- if (op == SLJIT_MOV_SB)
- return push_inst(compiler, EXTSB | S(src2) | A(dst));
- return push_inst(compiler, INS_CLEAR_LEFT(dst, src2, 24));
- }
- else if ((flags & REG_DEST) && op == SLJIT_MOV_SB)
- return push_inst(compiler, EXTSB | S(src2) | A(dst));
- else {
- SLJIT_ASSERT(dst == src2);
- }
- return SLJIT_SUCCESS;
-
- case SLJIT_MOV_UH:
- case SLJIT_MOV_SH:
- SLJIT_ASSERT(src1 == TMP_REG1);
- if ((flags & (REG_DEST | REG2_SOURCE)) == (REG_DEST | REG2_SOURCE)) {
- if (op == SLJIT_MOV_SH)
- return push_inst(compiler, EXTSH | S(src2) | A(dst));
- return push_inst(compiler, INS_CLEAR_LEFT(dst, src2, 16));
- }
- else {
- SLJIT_ASSERT(dst == src2);
- }
- return SLJIT_SUCCESS;
-
- case SLJIT_NOT:
- SLJIT_ASSERT(src1 == TMP_REG1);
- UN_EXTS();
- return push_inst(compiler, NOR | RC(flags) | S(src2) | A(dst) | B(src2));
-
- case SLJIT_NEG:
- SLJIT_ASSERT(src1 == TMP_REG1);
- UN_EXTS();
- return push_inst(compiler, NEG | OERC(flags) | D(dst) | A(src2));
-
- case SLJIT_CLZ:
- SLJIT_ASSERT(src1 == TMP_REG1);
- if (flags & ALT_FORM1)
- return push_inst(compiler, CNTLZW | RC(flags) | S(src2) | A(dst));
- return push_inst(compiler, CNTLZD | RC(flags) | S(src2) | A(dst));
-
- case SLJIT_ADD:
- if (flags & ALT_FORM1) {
- /* Flags does not set: BIN_IMM_EXTS unnecessary. */
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ADDI | D(dst) | A(src1) | compiler->imm);
- }
- if (flags & ALT_FORM2) {
- /* Flags does not set: BIN_IMM_EXTS unnecessary. */
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ADDIS | D(dst) | A(src1) | compiler->imm);
- }
- if (flags & ALT_FORM3) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- BIN_IMM_EXTS();
- return push_inst(compiler, ADDIC | D(dst) | A(src1) | compiler->imm);
- }
- if (flags & ALT_FORM4) {
- /* Flags does not set: BIN_IMM_EXTS unnecessary. */
- FAIL_IF(push_inst(compiler, ADDI | D(dst) | A(src1) | (compiler->imm & 0xffff)));
- return push_inst(compiler, ADDIS | D(dst) | A(dst) | (((compiler->imm >> 16) & 0xffff) + ((compiler->imm >> 15) & 0x1)));
- }
- if (!(flags & ALT_SET_FLAGS))
- return push_inst(compiler, ADD | D(dst) | A(src1) | B(src2));
- BIN_EXTS();
- return push_inst(compiler, ADDC | OERC(ALT_SET_FLAGS) | D(dst) | A(src1) | B(src2));
-
- case SLJIT_ADDC:
- if (flags & ALT_FORM1) {
- FAIL_IF(push_inst(compiler, MFXER | D(0)));
- FAIL_IF(push_inst(compiler, ADDE | D(dst) | A(src1) | B(src2)));
- return push_inst(compiler, MTXER | S(0));
- }
- BIN_EXTS();
- return push_inst(compiler, ADDE | D(dst) | A(src1) | B(src2));
-
- case SLJIT_SUB:
- if (flags & ALT_FORM1) {
- /* Flags does not set: BIN_IMM_EXTS unnecessary. */
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, SUBFIC | D(dst) | A(src1) | compiler->imm);
- }
- if (flags & (ALT_FORM2 | ALT_FORM3)) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- if (flags & ALT_FORM2)
- FAIL_IF(push_inst(compiler, CMPI | CRD(0 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | compiler->imm));
- if (flags & ALT_FORM3)
- return push_inst(compiler, CMPLI | CRD(4 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | compiler->imm);
- return SLJIT_SUCCESS;
- }
- if (flags & (ALT_FORM4 | ALT_FORM5)) {
- if (flags & ALT_FORM4)
- FAIL_IF(push_inst(compiler, CMPL | CRD(4 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | B(src2)));
- if (flags & ALT_FORM5)
- return push_inst(compiler, CMP | CRD(0 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | B(src2));
- return SLJIT_SUCCESS;
- }
- if (!(flags & ALT_SET_FLAGS))
- return push_inst(compiler, SUBF | D(dst) | A(src2) | B(src1));
- BIN_EXTS();
- if (flags & ALT_FORM6)
- FAIL_IF(push_inst(compiler, CMPL | CRD(4 | ((flags & ALT_SIGN_EXT) ? 0 : 1)) | A(src1) | B(src2)));
- return push_inst(compiler, SUBFC | OERC(ALT_SET_FLAGS) | D(dst) | A(src2) | B(src1));
-
- case SLJIT_SUBC:
- if (flags & ALT_FORM1) {
- FAIL_IF(push_inst(compiler, MFXER | D(0)));
- FAIL_IF(push_inst(compiler, SUBFE | D(dst) | A(src2) | B(src1)));
- return push_inst(compiler, MTXER | S(0));
- }
- BIN_EXTS();
- return push_inst(compiler, SUBFE | D(dst) | A(src2) | B(src1));
-
- case SLJIT_MUL:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, MULLI | D(dst) | A(src1) | compiler->imm);
- }
- BIN_EXTS();
- if (flags & ALT_FORM2)
- return push_inst(compiler, MULLW | OERC(flags) | D(dst) | A(src2) | B(src1));
- return push_inst(compiler, MULLD | OERC(flags) | D(dst) | A(src2) | B(src1));
-
- case SLJIT_AND:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ANDI | S(src1) | A(dst) | compiler->imm);
- }
- if (flags & ALT_FORM2) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ANDIS | S(src1) | A(dst) | compiler->imm);
- }
- return push_inst(compiler, AND | RC(flags) | S(src1) | A(dst) | B(src2));
-
- case SLJIT_OR:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ORI | S(src1) | A(dst) | compiler->imm);
- }
- if (flags & ALT_FORM2) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, ORIS | S(src1) | A(dst) | compiler->imm);
- }
- if (flags & ALT_FORM3) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- FAIL_IF(push_inst(compiler, ORI | S(src1) | A(dst) | IMM(compiler->imm)));
- return push_inst(compiler, ORIS | S(dst) | A(dst) | IMM(compiler->imm >> 16));
- }
- return push_inst(compiler, OR | RC(flags) | S(src1) | A(dst) | B(src2));
-
- case SLJIT_XOR:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, XORI | S(src1) | A(dst) | compiler->imm);
- }
- if (flags & ALT_FORM2) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- return push_inst(compiler, XORIS | S(src1) | A(dst) | compiler->imm);
- }
- if (flags & ALT_FORM3) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- FAIL_IF(push_inst(compiler, XORI | S(src1) | A(dst) | IMM(compiler->imm)));
- return push_inst(compiler, XORIS | S(dst) | A(dst) | IMM(compiler->imm >> 16));
- }
- return push_inst(compiler, XOR | RC(flags) | S(src1) | A(dst) | B(src2));
-
- case SLJIT_SHL:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- if (flags & ALT_FORM2) {
- compiler->imm &= 0x1f;
- return push_inst(compiler, RLWINM | RC(flags) | S(src1) | A(dst) | (compiler->imm << 11) | ((31 - compiler->imm) << 1));
- }
- else {
- compiler->imm &= 0x3f;
- return push_inst(compiler, RLDI(dst, src1, compiler->imm, 63 - compiler->imm, 1) | RC(flags));
- }
- }
- return push_inst(compiler, ((flags & ALT_FORM2) ? SLW : SLD) | RC(flags) | S(src1) | A(dst) | B(src2));
-
- case SLJIT_LSHR:
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- if (flags & ALT_FORM2) {
- compiler->imm &= 0x1f;
- return push_inst(compiler, RLWINM | RC(flags) | S(src1) | A(dst) | (((32 - compiler->imm) & 0x1f) << 11) | (compiler->imm << 6) | (31 << 1));
- }
- else {
- compiler->imm &= 0x3f;
- return push_inst(compiler, RLDI(dst, src1, 64 - compiler->imm, compiler->imm, 0) | RC(flags));
- }
- }
- return push_inst(compiler, ((flags & ALT_FORM2) ? SRW : SRD) | RC(flags) | S(src1) | A(dst) | B(src2));
-
- case SLJIT_ASHR:
- if (flags & ALT_FORM3)
- FAIL_IF(push_inst(compiler, MFXER | D(0)));
- if (flags & ALT_FORM1) {
- SLJIT_ASSERT(src2 == TMP_REG2);
- if (flags & ALT_FORM2) {
- compiler->imm &= 0x1f;
- FAIL_IF(push_inst(compiler, SRAWI | RC(flags) | S(src1) | A(dst) | (compiler->imm << 11)));
- }
- else {
- compiler->imm &= 0x3f;
- FAIL_IF(push_inst(compiler, SRADI | RC(flags) | S(src1) | A(dst) | ((compiler->imm & 0x1f) << 11) | ((compiler->imm & 0x20) >> 4)));
- }
- }
- else
- FAIL_IF(push_inst(compiler, ((flags & ALT_FORM2) ? SRAW : SRAD) | RC(flags) | S(src1) | A(dst) | B(src2)));
- return (flags & ALT_FORM3) ? push_inst(compiler, MTXER | S(0)) : SLJIT_SUCCESS;
- }
-
- SLJIT_ASSERT_STOP();
- return SLJIT_SUCCESS;
-}
-
-static SLJIT_INLINE sljit_si emit_const(struct sljit_compiler *compiler, sljit_si reg, sljit_sw init_value)
-{
- FAIL_IF(push_inst(compiler, ADDIS | D(reg) | A(0) | IMM(init_value >> 48)));
- FAIL_IF(push_inst(compiler, ORI | S(reg) | A(reg) | IMM(init_value >> 32)));
- FAIL_IF(PUSH_RLDICR(reg, 31));
- FAIL_IF(push_inst(compiler, ORIS | S(reg) | A(reg) | IMM(init_value >> 16)));
- return push_inst(compiler, ORI | S(reg) | A(reg) | IMM(init_value));
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr)
-{
- sljit_ins *inst = (sljit_ins*)addr;
-
- inst[0] = (inst[0] & 0xffff0000) | ((new_addr >> 48) & 0xffff);
- inst[1] = (inst[1] & 0xffff0000) | ((new_addr >> 32) & 0xffff);
- inst[3] = (inst[3] & 0xffff0000) | ((new_addr >> 16) & 0xffff);
- inst[4] = (inst[4] & 0xffff0000) | (new_addr & 0xffff);
- SLJIT_CACHE_FLUSH(inst, inst + 5);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant)
-{
- sljit_ins *inst = (sljit_ins*)addr;
-
- inst[0] = (inst[0] & 0xffff0000) | ((new_constant >> 48) & 0xffff);
- inst[1] = (inst[1] & 0xffff0000) | ((new_constant >> 32) & 0xffff);
- inst[3] = (inst[3] & 0xffff0000) | ((new_constant >> 16) & 0xffff);
- inst[4] = (inst[4] & 0xffff0000) | (new_constant & 0xffff);
- SLJIT_CACHE_FLUSH(inst, inst + 5);
-}
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitNativePPC_common.c r-base-3.3.1/src/extra/pcre/sljit/sljitNativePPC_common.c
--- r-base-3.2.3/src/extra/pcre/sljit/sljitNativePPC_common.c 2015-11-26 23:15:10.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitNativePPC_common.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,2375 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void)
-{
- return "PowerPC" SLJIT_CPUINFO;
-}
-
-/* Length of an instruction word.
- Both for ppc-32 and ppc-64. */
-typedef sljit_ui sljit_ins;
-
-#if ((defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32) && (defined _AIX)) \
- || (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-#define SLJIT_PPC_STACK_FRAME_V2 1
-#endif
-
-#ifdef _AIX
-#include
-#endif
-
-#if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
-#define SLJIT_PASS_ENTRY_ADDR_TO_CALL 1
-#endif
-
-static void ppc_cache_flush(sljit_ins *from, sljit_ins *to)
-{
-#ifdef _AIX
- _sync_cache_range((caddr_t)from, (int)((size_t)to - (size_t)from));
-#elif defined(__GNUC__) || (defined(__IBM_GCC_ASM) && __IBM_GCC_ASM)
-# if defined(_ARCH_PWR) || defined(_ARCH_PWR2)
- /* Cache flush for POWER architecture. */
- while (from < to) {
- __asm__ volatile (
- "clf 0, %0\n"
- "dcs\n"
- : : "r"(from)
- );
- from++;
- }
- __asm__ volatile ( "ics" );
-# elif defined(_ARCH_COM) && !defined(_ARCH_PPC)
-# error "Cache flush is not implemented for PowerPC/POWER common mode."
-# else
- /* Cache flush for PowerPC architecture. */
- while (from < to) {
- __asm__ volatile (
- "dcbf 0, %0\n"
- "sync\n"
- "icbi 0, %0\n"
- : : "r"(from)
- );
- from++;
- }
- __asm__ volatile ( "isync" );
-# endif
-# ifdef __xlc__
-# warning "This file may fail to compile if -qfuncsect is used"
-# endif
-#elif defined(__xlc__)
-#error "Please enable GCC syntax for inline assembly statements with -qasm=gcc"
-#else
-#error "This platform requires a cache flush implementation."
-#endif /* _AIX */
-}
-
-#define TMP_REG1 (SLJIT_NUMBER_OF_REGISTERS + 2)
-#define TMP_REG2 (SLJIT_NUMBER_OF_REGISTERS + 3)
-#define TMP_REG3 (SLJIT_NUMBER_OF_REGISTERS + 4)
-#define TMP_ZERO (SLJIT_NUMBER_OF_REGISTERS + 5)
-
-#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL)
-#define TMP_CALL_REG (SLJIT_NUMBER_OF_REGISTERS + 6)
-#else
-#define TMP_CALL_REG TMP_REG2
-#endif
-
-#define TMP_FREG1 (0)
-#define TMP_FREG2 (SLJIT_NUMBER_OF_FLOAT_REGISTERS + 1)
-
-static SLJIT_CONST sljit_ub reg_map[SLJIT_NUMBER_OF_REGISTERS + 7] = {
- 0, 3, 4, 5, 6, 7, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 8, 9, 10, 31, 12
-};
-
-/* --------------------------------------------------------------------- */
-/* Instrucion forms */
-/* --------------------------------------------------------------------- */
-#define D(d) (reg_map[d] << 21)
-#define S(s) (reg_map[s] << 21)
-#define A(a) (reg_map[a] << 16)
-#define B(b) (reg_map[b] << 11)
-#define C(c) (reg_map[c] << 6)
-#define FD(fd) ((fd) << 21)
-#define FS(fs) ((fs) << 21)
-#define FA(fa) ((fa) << 16)
-#define FB(fb) ((fb) << 11)
-#define FC(fc) ((fc) << 6)
-#define IMM(imm) ((imm) & 0xffff)
-#define CRD(d) ((d) << 21)
-
-/* Instruction bit sections.
- OE and Rc flag (see ALT_SET_FLAGS). */
-#define OERC(flags) (((flags & ALT_SET_FLAGS) >> 10) | (flags & ALT_SET_FLAGS))
-/* Rc flag (see ALT_SET_FLAGS). */
-#define RC(flags) ((flags & ALT_SET_FLAGS) >> 10)
-#define HI(opcode) ((opcode) << 26)
-#define LO(opcode) ((opcode) << 1)
-
-#define ADD (HI(31) | LO(266))
-#define ADDC (HI(31) | LO(10))
-#define ADDE (HI(31) | LO(138))
-#define ADDI (HI(14))
-#define ADDIC (HI(13))
-#define ADDIS (HI(15))
-#define ADDME (HI(31) | LO(234))
-#define AND (HI(31) | LO(28))
-#define ANDI (HI(28))
-#define ANDIS (HI(29))
-#define Bx (HI(18))
-#define BCx (HI(16))
-#define BCCTR (HI(19) | LO(528) | (3 << 11))
-#define BLR (HI(19) | LO(16) | (0x14 << 21))
-#define CNTLZD (HI(31) | LO(58))
-#define CNTLZW (HI(31) | LO(26))
-#define CMP (HI(31) | LO(0))
-#define CMPI (HI(11))
-#define CMPL (HI(31) | LO(32))
-#define CMPLI (HI(10))
-#define CROR (HI(19) | LO(449))
-#define DIVD (HI(31) | LO(489))
-#define DIVDU (HI(31) | LO(457))
-#define DIVW (HI(31) | LO(491))
-#define DIVWU (HI(31) | LO(459))
-#define EXTSB (HI(31) | LO(954))
-#define EXTSH (HI(31) | LO(922))
-#define EXTSW (HI(31) | LO(986))
-#define FABS (HI(63) | LO(264))
-#define FADD (HI(63) | LO(21))
-#define FADDS (HI(59) | LO(21))
-#define FCFID (HI(63) | LO(846))
-#define FCMPU (HI(63) | LO(0))
-#define FCTIDZ (HI(63) | LO(815))
-#define FCTIWZ (HI(63) | LO(15))
-#define FDIV (HI(63) | LO(18))
-#define FDIVS (HI(59) | LO(18))
-#define FMR (HI(63) | LO(72))
-#define FMUL (HI(63) | LO(25))
-#define FMULS (HI(59) | LO(25))
-#define FNEG (HI(63) | LO(40))
-#define FRSP (HI(63) | LO(12))
-#define FSUB (HI(63) | LO(20))
-#define FSUBS (HI(59) | LO(20))
-#define LD (HI(58) | 0)
-#define LWZ (HI(32))
-#define MFCR (HI(31) | LO(19))
-#define MFLR (HI(31) | LO(339) | 0x80000)
-#define MFXER (HI(31) | LO(339) | 0x10000)
-#define MTCTR (HI(31) | LO(467) | 0x90000)
-#define MTLR (HI(31) | LO(467) | 0x80000)
-#define MTXER (HI(31) | LO(467) | 0x10000)
-#define MULHD (HI(31) | LO(73))
-#define MULHDU (HI(31) | LO(9))
-#define MULHW (HI(31) | LO(75))
-#define MULHWU (HI(31) | LO(11))
-#define MULLD (HI(31) | LO(233))
-#define MULLI (HI(7))
-#define MULLW (HI(31) | LO(235))
-#define NEG (HI(31) | LO(104))
-#define NOP (HI(24))
-#define NOR (HI(31) | LO(124))
-#define OR (HI(31) | LO(444))
-#define ORI (HI(24))
-#define ORIS (HI(25))
-#define RLDICL (HI(30))
-#define RLWINM (HI(21))
-#define SLD (HI(31) | LO(27))
-#define SLW (HI(31) | LO(24))
-#define SRAD (HI(31) | LO(794))
-#define SRADI (HI(31) | LO(413 << 1))
-#define SRAW (HI(31) | LO(792))
-#define SRAWI (HI(31) | LO(824))
-#define SRD (HI(31) | LO(539))
-#define SRW (HI(31) | LO(536))
-#define STD (HI(62) | 0)
-#define STDU (HI(62) | 1)
-#define STDUX (HI(31) | LO(181))
-#define STFIWX (HI(31) | LO(983))
-#define STW (HI(36))
-#define STWU (HI(37))
-#define STWUX (HI(31) | LO(183))
-#define SUBF (HI(31) | LO(40))
-#define SUBFC (HI(31) | LO(8))
-#define SUBFE (HI(31) | LO(136))
-#define SUBFIC (HI(8))
-#define XOR (HI(31) | LO(316))
-#define XORI (HI(26))
-#define XORIS (HI(27))
-
-#define SIMM_MAX (0x7fff)
-#define SIMM_MIN (-0x8000)
-#define UIMM_MAX (0xffff)
-
-#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_sw addr, void* func)
-{
- sljit_sw* ptrs;
- if (func_ptr)
- *func_ptr = (void*)context;
- ptrs = (sljit_sw*)func;
- context->addr = addr ? addr : ptrs[0];
- context->r2 = ptrs[1];
- context->r11 = ptrs[2];
-}
-#endif
-
-static sljit_si push_inst(struct sljit_compiler *compiler, sljit_ins ins)
-{
- sljit_ins *ptr = (sljit_ins*)ensure_buf(compiler, sizeof(sljit_ins));
- FAIL_IF(!ptr);
- *ptr = ins;
- compiler->size++;
- return SLJIT_SUCCESS;
-}
-
-static SLJIT_INLINE sljit_si detect_jump_type(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code)
-{
- sljit_sw diff;
- sljit_uw target_addr;
- sljit_sw extra_jump_flags;
-
-#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL) && (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
- if (jump->flags & (SLJIT_REWRITABLE_JUMP | IS_CALL))
- return 0;
-#else
- if (jump->flags & SLJIT_REWRITABLE_JUMP)
- return 0;
-#endif
-
- if (jump->flags & JUMP_ADDR)
- target_addr = jump->u.target;
- else {
- SLJIT_ASSERT(jump->flags & JUMP_LABEL);
- target_addr = (sljit_uw)(code + jump->u.label->size);
- }
-
-#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL) && (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- if (jump->flags & IS_CALL)
- goto keep_address;
-#endif
-
- diff = ((sljit_sw)target_addr - (sljit_sw)(code_ptr)) & ~0x3l;
-
- extra_jump_flags = 0;
- if (jump->flags & IS_COND) {
- if (diff <= 0x7fff && diff >= -0x8000) {
- jump->flags |= PATCH_B;
- return 1;
- }
- if (target_addr <= 0xffff) {
- jump->flags |= PATCH_B | PATCH_ABS_B;
- return 1;
- }
- extra_jump_flags = REMOVE_COND;
-
- diff -= sizeof(sljit_ins);
- }
-
- if (diff <= 0x01ffffff && diff >= -0x02000000) {
- jump->flags |= PATCH_B | extra_jump_flags;
- return 1;
- }
- if (target_addr <= 0x03ffffff) {
- jump->flags |= PATCH_B | PATCH_ABS_B | extra_jump_flags;
- return 1;
- }
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL)
-keep_address:
-#endif
- if (target_addr <= 0x7fffffff) {
- jump->flags |= PATCH_ABS32;
- return 1;
- }
- if (target_addr <= 0x7fffffffffffl) {
- jump->flags |= PATCH_ABS48;
- return 1;
- }
-#endif
-
- return 0;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler)
-{
- struct sljit_memory_fragment *buf;
- sljit_ins *code;
- sljit_ins *code_ptr;
- sljit_ins *buf_ptr;
- sljit_ins *buf_end;
- sljit_uw word_count;
- sljit_uw addr;
-
- struct sljit_label *label;
- struct sljit_jump *jump;
- struct sljit_const *const_;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_generate_code(compiler));
- reverse_buf(compiler);
-
-#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- compiler->size += (compiler->size & 0x1) + (sizeof(struct sljit_function_context) / sizeof(sljit_ins));
-#else
- compiler->size += (sizeof(struct sljit_function_context) / sizeof(sljit_ins));
-#endif
-#endif
- code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
- PTR_FAIL_WITH_EXEC_IF(code);
- buf = compiler->buf;
-
- code_ptr = code;
- word_count = 0;
- label = compiler->labels;
- jump = compiler->jumps;
- const_ = compiler->consts;
- do {
- buf_ptr = (sljit_ins*)buf->memory;
- buf_end = buf_ptr + (buf->used_size >> 2);
- do {
- *code_ptr = *buf_ptr++;
- SLJIT_ASSERT(!label || label->size >= word_count);
- SLJIT_ASSERT(!jump || jump->addr >= word_count);
- SLJIT_ASSERT(!const_ || const_->addr >= word_count);
- /* These structures are ordered by their address. */
- if (label && label->size == word_count) {
- /* Just recording the address. */
- label->addr = (sljit_uw)code_ptr;
- label->size = code_ptr - code;
- label = label->next;
- }
- if (jump && jump->addr == word_count) {
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
- jump->addr = (sljit_uw)(code_ptr - 3);
-#else
- jump->addr = (sljit_uw)(code_ptr - 6);
-#endif
- if (detect_jump_type(jump, code_ptr, code)) {
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
- code_ptr[-3] = code_ptr[0];
- code_ptr -= 3;
-#else
- if (jump->flags & PATCH_ABS32) {
- code_ptr -= 3;
- code_ptr[-1] = code_ptr[2];
- code_ptr[0] = code_ptr[3];
- }
- else if (jump->flags & PATCH_ABS48) {
- code_ptr--;
- code_ptr[-1] = code_ptr[0];
- code_ptr[0] = code_ptr[1];
- /* rldicr rX,rX,32,31 -> rX,rX,16,47 */
- SLJIT_ASSERT((code_ptr[-3] & 0xfc00ffff) == 0x780007c6);
- code_ptr[-3] ^= 0x8422;
- /* oris -> ori */
- code_ptr[-2] ^= 0x4000000;
- }
- else {
- code_ptr[-6] = code_ptr[0];
- code_ptr -= 6;
- }
-#endif
- if (jump->flags & REMOVE_COND) {
- code_ptr[0] = BCx | (2 << 2) | ((code_ptr[0] ^ (8 << 21)) & 0x03ff0001);
- code_ptr++;
- jump->addr += sizeof(sljit_ins);
- code_ptr[0] = Bx;
- jump->flags -= IS_COND;
- }
- }
- jump = jump->next;
- }
- if (const_ && const_->addr == word_count) {
- const_->addr = (sljit_uw)code_ptr;
- const_ = const_->next;
- }
- code_ptr ++;
- word_count ++;
- } while (buf_ptr < buf_end);
-
- buf = buf->next;
- } while (buf);
-
- if (label && label->size == word_count) {
- label->addr = (sljit_uw)code_ptr;
- label->size = code_ptr - code;
- label = label->next;
- }
-
- SLJIT_ASSERT(!label);
- SLJIT_ASSERT(!jump);
- SLJIT_ASSERT(!const_);
-#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
- SLJIT_ASSERT(code_ptr - code <= (sljit_sw)compiler->size - (sizeof(struct sljit_function_context) / sizeof(sljit_ins)));
-#else
- SLJIT_ASSERT(code_ptr - code <= (sljit_sw)compiler->size);
-#endif
-
- jump = compiler->jumps;
- while (jump) {
- do {
- addr = (jump->flags & JUMP_LABEL) ? jump->u.label->addr : jump->u.target;
- buf_ptr = (sljit_ins*)jump->addr;
- if (jump->flags & PATCH_B) {
- if (jump->flags & IS_COND) {
- if (!(jump->flags & PATCH_ABS_B)) {
- addr = addr - jump->addr;
- SLJIT_ASSERT((sljit_sw)addr <= 0x7fff && (sljit_sw)addr >= -0x8000);
- *buf_ptr = BCx | (addr & 0xfffc) | ((*buf_ptr) & 0x03ff0001);
- }
- else {
- SLJIT_ASSERT(addr <= 0xffff);
- *buf_ptr = BCx | (addr & 0xfffc) | 0x2 | ((*buf_ptr) & 0x03ff0001);
- }
- }
- else {
- if (!(jump->flags & PATCH_ABS_B)) {
- addr = addr - jump->addr;
- SLJIT_ASSERT((sljit_sw)addr <= 0x01ffffff && (sljit_sw)addr >= -0x02000000);
- *buf_ptr = Bx | (addr & 0x03fffffc) | ((*buf_ptr) & 0x1);
- }
- else {
- SLJIT_ASSERT(addr <= 0x03ffffff);
- *buf_ptr = Bx | (addr & 0x03fffffc) | 0x2 | ((*buf_ptr) & 0x1);
- }
- }
- break;
- }
- /* Set the fields of immediate loads. */
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
- buf_ptr[0] = (buf_ptr[0] & 0xffff0000) | ((addr >> 16) & 0xffff);
- buf_ptr[1] = (buf_ptr[1] & 0xffff0000) | (addr & 0xffff);
-#else
- if (jump->flags & PATCH_ABS32) {
- SLJIT_ASSERT(addr <= 0x7fffffff);
- buf_ptr[0] = (buf_ptr[0] & 0xffff0000) | ((addr >> 16) & 0xffff);
- buf_ptr[1] = (buf_ptr[1] & 0xffff0000) | (addr & 0xffff);
- break;
- }
- if (jump->flags & PATCH_ABS48) {
- SLJIT_ASSERT(addr <= 0x7fffffffffff);
- buf_ptr[0] = (buf_ptr[0] & 0xffff0000) | ((addr >> 32) & 0xffff);
- buf_ptr[1] = (buf_ptr[1] & 0xffff0000) | ((addr >> 16) & 0xffff);
- buf_ptr[3] = (buf_ptr[3] & 0xffff0000) | (addr & 0xffff);
- break;
- }
- buf_ptr[0] = (buf_ptr[0] & 0xffff0000) | ((addr >> 48) & 0xffff);
- buf_ptr[1] = (buf_ptr[1] & 0xffff0000) | ((addr >> 32) & 0xffff);
- buf_ptr[3] = (buf_ptr[3] & 0xffff0000) | ((addr >> 16) & 0xffff);
- buf_ptr[4] = (buf_ptr[4] & 0xffff0000) | (addr & 0xffff);
-#endif
- } while (0);
- jump = jump->next;
- }
-
- compiler->error = SLJIT_ERR_COMPILED;
- compiler->executable_size = (code_ptr - code) * sizeof(sljit_ins);
- SLJIT_CACHE_FLUSH(code, code_ptr);
-
-#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- if (((sljit_sw)code_ptr) & 0x4)
- code_ptr++;
- sljit_set_function_context(NULL, (struct sljit_function_context*)code_ptr, (sljit_sw)code, (void*)sljit_generate_code);
- return code_ptr;
-#else
- sljit_set_function_context(NULL, (struct sljit_function_context*)code_ptr, (sljit_sw)code, (void*)sljit_generate_code);
- return code_ptr;
-#endif
-#else
- return code;
-#endif
-}
-
-/* --------------------------------------------------------------------- */
-/* Entry, exit */
-/* --------------------------------------------------------------------- */
-
-/* inp_flags: */
-
-/* Creates an index in data_transfer_insts array. */
-#define LOAD_DATA 0x01
-#define INDEXED 0x02
-#define WRITE_BACK 0x04
-#define WORD_DATA 0x00
-#define BYTE_DATA 0x08
-#define HALF_DATA 0x10
-#define INT_DATA 0x18
-#define SIGNED_DATA 0x20
-/* Separates integer and floating point registers */
-#define GPR_REG 0x3f
-#define DOUBLE_DATA 0x40
-
-#define MEM_MASK 0x7f
-
-/* Other inp_flags. */
-
-#define ARG_TEST 0x000100
-/* Integer opertion and set flags -> requires exts on 64 bit systems. */
-#define ALT_SIGN_EXT 0x000200
-/* This flag affects the RC() and OERC() macros. */
-#define ALT_SET_FLAGS 0x000400
-#define ALT_KEEP_CACHE 0x000800
-#define ALT_FORM1 0x010000
-#define ALT_FORM2 0x020000
-#define ALT_FORM3 0x040000
-#define ALT_FORM4 0x080000
-#define ALT_FORM5 0x100000
-#define ALT_FORM6 0x200000
-
-/* Source and destination is register. */
-#define REG_DEST 0x000001
-#define REG1_SOURCE 0x000002
-#define REG2_SOURCE 0x000004
-/* getput_arg_fast returned true. */
-#define FAST_DEST 0x000008
-/* Multiple instructions are required. */
-#define SLOW_DEST 0x000010
-/*
-ALT_SIGN_EXT 0x000200
-ALT_SET_FLAGS 0x000400
-ALT_FORM1 0x010000
-...
-ALT_FORM6 0x200000 */
-
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
-#include "sljitNativePPC_32.c"
-#else
-#include "sljitNativePPC_64.c"
-#endif
-
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
-#define STACK_STORE STW
-#define STACK_LOAD LWZ
-#else
-#define STACK_STORE STD
-#define STACK_LOAD LD
-#endif
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- sljit_si i, tmp, offs;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
- set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- FAIL_IF(push_inst(compiler, MFLR | D(0)));
- offs = -(sljit_si)(sizeof(sljit_sw));
- FAIL_IF(push_inst(compiler, STACK_STORE | S(TMP_ZERO) | A(SLJIT_SP) | IMM(offs)));
-
- tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
- for (i = SLJIT_S0; i >= tmp; i--) {
- offs -= (sljit_si)(sizeof(sljit_sw));
- FAIL_IF(push_inst(compiler, STACK_STORE | S(i) | A(SLJIT_SP) | IMM(offs)));
- }
-
- for (i = scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
- offs -= (sljit_si)(sizeof(sljit_sw));
- FAIL_IF(push_inst(compiler, STACK_STORE | S(i) | A(SLJIT_SP) | IMM(offs)));
- }
-
- SLJIT_ASSERT(offs == -(sljit_si)GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 1));
-
-#if (defined SLJIT_PPC_STACK_FRAME_V2 && SLJIT_PPC_STACK_FRAME_V2)
- FAIL_IF(push_inst(compiler, STACK_STORE | S(0) | A(SLJIT_SP) | IMM(2 * sizeof(sljit_sw))));
-#else
- FAIL_IF(push_inst(compiler, STACK_STORE | S(0) | A(SLJIT_SP) | IMM(sizeof(sljit_sw))));
-#endif
-
- FAIL_IF(push_inst(compiler, ADDI | D(TMP_ZERO) | A(0) | 0));
- if (args >= 1)
- FAIL_IF(push_inst(compiler, OR | S(SLJIT_R0) | A(SLJIT_S0) | B(SLJIT_R0)));
- if (args >= 2)
- FAIL_IF(push_inst(compiler, OR | S(SLJIT_R1) | A(SLJIT_S1) | B(SLJIT_R1)));
- if (args >= 3)
- FAIL_IF(push_inst(compiler, OR | S(SLJIT_R2) | A(SLJIT_S2) | B(SLJIT_R2)));
-
- local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + SLJIT_LOCALS_OFFSET;
- local_size = (local_size + 15) & ~0xf;
- compiler->local_size = local_size;
-
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
- if (local_size <= SIMM_MAX)
- FAIL_IF(push_inst(compiler, STWU | S(SLJIT_SP) | A(SLJIT_SP) | IMM(-local_size)));
- else {
- FAIL_IF(load_immediate(compiler, 0, -local_size));
- FAIL_IF(push_inst(compiler, STWUX | S(SLJIT_SP) | A(SLJIT_SP) | B(0)));
- }
-#else
- if (local_size <= SIMM_MAX)
- FAIL_IF(push_inst(compiler, STDU | S(SLJIT_SP) | A(SLJIT_SP) | IMM(-local_size)));
- else {
- FAIL_IF(load_immediate(compiler, 0, -local_size));
- FAIL_IF(push_inst(compiler, STDUX | S(SLJIT_SP) | A(SLJIT_SP) | B(0)));
- }
-#endif
-
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- CHECK_ERROR();
- CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
- set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- local_size += GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1) + SLJIT_LOCALS_OFFSET;
- compiler->local_size = (local_size + 15) & ~0xf;
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
-{
- sljit_si i, tmp, offs;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_return(compiler, op, src, srcw));
-
- FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
-
- if (compiler->local_size <= SIMM_MAX)
- FAIL_IF(push_inst(compiler, ADDI | D(SLJIT_SP) | A(SLJIT_SP) | IMM(compiler->local_size)));
- else {
- FAIL_IF(load_immediate(compiler, 0, compiler->local_size));
- FAIL_IF(push_inst(compiler, ADD | D(SLJIT_SP) | A(SLJIT_SP) | B(0)));
- }
-
-#if (defined SLJIT_PPC_STACK_FRAME_V2 && SLJIT_PPC_STACK_FRAME_V2)
- FAIL_IF(push_inst(compiler, STACK_LOAD | D(0) | A(SLJIT_SP) | IMM(2 * sizeof(sljit_sw))));
-#else
- FAIL_IF(push_inst(compiler, STACK_LOAD | D(0) | A(SLJIT_SP) | IMM(sizeof(sljit_sw))));
-#endif
-
- offs = -(sljit_si)GET_SAVED_REGISTERS_SIZE(compiler->scratches, compiler->saveds, 1);
-
- tmp = compiler->scratches;
- for (i = SLJIT_FIRST_SAVED_REG; i <= tmp; i++) {
- FAIL_IF(push_inst(compiler, STACK_LOAD | D(i) | A(SLJIT_SP) | IMM(offs)));
- offs += (sljit_si)(sizeof(sljit_sw));
- }
-
- tmp = compiler->saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - compiler->saveds) : SLJIT_FIRST_SAVED_REG;
- for (i = tmp; i <= SLJIT_S0; i++) {
- FAIL_IF(push_inst(compiler, STACK_LOAD | D(i) | A(SLJIT_SP) | IMM(offs)));
- offs += (sljit_si)(sizeof(sljit_sw));
- }
-
- FAIL_IF(push_inst(compiler, STACK_LOAD | D(TMP_ZERO) | A(SLJIT_SP) | IMM(offs)));
- SLJIT_ASSERT(offs == -(sljit_sw)(sizeof(sljit_sw)));
-
- FAIL_IF(push_inst(compiler, MTLR | S(0)));
- FAIL_IF(push_inst(compiler, BLR));
-
- return SLJIT_SUCCESS;
-}
-
-#undef STACK_STORE
-#undef STACK_LOAD
-
-/* --------------------------------------------------------------------- */
-/* Operators */
-/* --------------------------------------------------------------------- */
-
-/* i/x - immediate/indexed form
- n/w - no write-back / write-back (1 bit)
- s/l - store/load (1 bit)
- u/s - signed/unsigned (1 bit)
- w/b/h/i - word/byte/half/int allowed (2 bit)
- It contans 32 items, but not all are different. */
-
-/* 64 bit only: [reg+imm] must be aligned to 4 bytes. */
-#define INT_ALIGNED 0x10000
-/* 64-bit only: there is no lwau instruction. */
-#define UPDATE_REQ 0x20000
-
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
-#define ARCH_32_64(a, b) a
-#define INST_CODE_AND_DST(inst, flags, reg) \
- ((inst) | (((flags) & MEM_MASK) <= GPR_REG ? D(reg) : FD(reg)))
-#else
-#define ARCH_32_64(a, b) b
-#define INST_CODE_AND_DST(inst, flags, reg) \
- (((inst) & ~(INT_ALIGNED | UPDATE_REQ)) | (((flags) & MEM_MASK) <= GPR_REG ? D(reg) : FD(reg)))
-#endif
-
-static SLJIT_CONST sljit_ins data_transfer_insts[64 + 8] = {
-
-/* -------- Unsigned -------- */
-
-/* Word. */
-
-/* u w n i s */ ARCH_32_64(HI(36) /* stw */, HI(62) | INT_ALIGNED | 0x0 /* std */),
-/* u w n i l */ ARCH_32_64(HI(32) /* lwz */, HI(58) | INT_ALIGNED | 0x0 /* ld */),
-/* u w n x s */ ARCH_32_64(HI(31) | LO(151) /* stwx */, HI(31) | LO(149) /* stdx */),
-/* u w n x l */ ARCH_32_64(HI(31) | LO(23) /* lwzx */, HI(31) | LO(21) /* ldx */),
-
-/* u w w i s */ ARCH_32_64(HI(37) /* stwu */, HI(62) | INT_ALIGNED | 0x1 /* stdu */),
-/* u w w i l */ ARCH_32_64(HI(33) /* lwzu */, HI(58) | INT_ALIGNED | 0x1 /* ldu */),
-/* u w w x s */ ARCH_32_64(HI(31) | LO(183) /* stwux */, HI(31) | LO(181) /* stdux */),
-/* u w w x l */ ARCH_32_64(HI(31) | LO(55) /* lwzux */, HI(31) | LO(53) /* ldux */),
-
-/* Byte. */
-
-/* u b n i s */ HI(38) /* stb */,
-/* u b n i l */ HI(34) /* lbz */,
-/* u b n x s */ HI(31) | LO(215) /* stbx */,
-/* u b n x l */ HI(31) | LO(87) /* lbzx */,
-
-/* u b w i s */ HI(39) /* stbu */,
-/* u b w i l */ HI(35) /* lbzu */,
-/* u b w x s */ HI(31) | LO(247) /* stbux */,
-/* u b w x l */ HI(31) | LO(119) /* lbzux */,
-
-/* Half. */
-
-/* u h n i s */ HI(44) /* sth */,
-/* u h n i l */ HI(40) /* lhz */,
-/* u h n x s */ HI(31) | LO(407) /* sthx */,
-/* u h n x l */ HI(31) | LO(279) /* lhzx */,
-
-/* u h w i s */ HI(45) /* sthu */,
-/* u h w i l */ HI(41) /* lhzu */,
-/* u h w x s */ HI(31) | LO(439) /* sthux */,
-/* u h w x l */ HI(31) | LO(311) /* lhzux */,
-
-/* Int. */
-
-/* u i n i s */ HI(36) /* stw */,
-/* u i n i l */ HI(32) /* lwz */,
-/* u i n x s */ HI(31) | LO(151) /* stwx */,
-/* u i n x l */ HI(31) | LO(23) /* lwzx */,
-
-/* u i w i s */ HI(37) /* stwu */,
-/* u i w i l */ HI(33) /* lwzu */,
-/* u i w x s */ HI(31) | LO(183) /* stwux */,
-/* u i w x l */ HI(31) | LO(55) /* lwzux */,
-
-/* -------- Signed -------- */
-
-/* Word. */
-
-/* s w n i s */ ARCH_32_64(HI(36) /* stw */, HI(62) | INT_ALIGNED | 0x0 /* std */),
-/* s w n i l */ ARCH_32_64(HI(32) /* lwz */, HI(58) | INT_ALIGNED | 0x0 /* ld */),
-/* s w n x s */ ARCH_32_64(HI(31) | LO(151) /* stwx */, HI(31) | LO(149) /* stdx */),
-/* s w n x l */ ARCH_32_64(HI(31) | LO(23) /* lwzx */, HI(31) | LO(21) /* ldx */),
-
-/* s w w i s */ ARCH_32_64(HI(37) /* stwu */, HI(62) | INT_ALIGNED | 0x1 /* stdu */),
-/* s w w i l */ ARCH_32_64(HI(33) /* lwzu */, HI(58) | INT_ALIGNED | 0x1 /* ldu */),
-/* s w w x s */ ARCH_32_64(HI(31) | LO(183) /* stwux */, HI(31) | LO(181) /* stdux */),
-/* s w w x l */ ARCH_32_64(HI(31) | LO(55) /* lwzux */, HI(31) | LO(53) /* ldux */),
-
-/* Byte. */
-
-/* s b n i s */ HI(38) /* stb */,
-/* s b n i l */ HI(34) /* lbz */ /* EXTS_REQ */,
-/* s b n x s */ HI(31) | LO(215) /* stbx */,
-/* s b n x l */ HI(31) | LO(87) /* lbzx */ /* EXTS_REQ */,
-
-/* s b w i s */ HI(39) /* stbu */,
-/* s b w i l */ HI(35) /* lbzu */ /* EXTS_REQ */,
-/* s b w x s */ HI(31) | LO(247) /* stbux */,
-/* s b w x l */ HI(31) | LO(119) /* lbzux */ /* EXTS_REQ */,
-
-/* Half. */
-
-/* s h n i s */ HI(44) /* sth */,
-/* s h n i l */ HI(42) /* lha */,
-/* s h n x s */ HI(31) | LO(407) /* sthx */,
-/* s h n x l */ HI(31) | LO(343) /* lhax */,
-
-/* s h w i s */ HI(45) /* sthu */,
-/* s h w i l */ HI(43) /* lhau */,
-/* s h w x s */ HI(31) | LO(439) /* sthux */,
-/* s h w x l */ HI(31) | LO(375) /* lhaux */,
-
-/* Int. */
-
-/* s i n i s */ HI(36) /* stw */,
-/* s i n i l */ ARCH_32_64(HI(32) /* lwz */, HI(58) | INT_ALIGNED | 0x2 /* lwa */),
-/* s i n x s */ HI(31) | LO(151) /* stwx */,
-/* s i n x l */ ARCH_32_64(HI(31) | LO(23) /* lwzx */, HI(31) | LO(341) /* lwax */),
-
-/* s i w i s */ HI(37) /* stwu */,
-/* s i w i l */ ARCH_32_64(HI(33) /* lwzu */, HI(58) | INT_ALIGNED | UPDATE_REQ | 0x2 /* lwa */),
-/* s i w x s */ HI(31) | LO(183) /* stwux */,
-/* s i w x l */ ARCH_32_64(HI(31) | LO(55) /* lwzux */, HI(31) | LO(373) /* lwaux */),
-
-/* -------- Double -------- */
-
-/* d n i s */ HI(54) /* stfd */,
-/* d n i l */ HI(50) /* lfd */,
-/* d n x s */ HI(31) | LO(727) /* stfdx */,
-/* d n x l */ HI(31) | LO(599) /* lfdx */,
-
-/* s n i s */ HI(52) /* stfs */,
-/* s n i l */ HI(48) /* lfs */,
-/* s n x s */ HI(31) | LO(663) /* stfsx */,
-/* s n x l */ HI(31) | LO(535) /* lfsx */,
-
-};
-
-#undef ARCH_32_64
-
-/* Simple cases, (no caching is required). */
-static sljit_si getput_arg_fast(struct sljit_compiler *compiler, sljit_si inp_flags, sljit_si reg, sljit_si arg, sljit_sw argw)
-{
- sljit_ins inst;
-
- /* Should work when (arg & REG_MASK) == 0. */
- SLJIT_COMPILE_ASSERT(A(0) == 0, a0_must_be_0);
- SLJIT_ASSERT(arg & SLJIT_MEM);
-
- if (arg & OFFS_REG_MASK) {
- if (argw & 0x3)
- return 0;
- if (inp_flags & ARG_TEST)
- return 1;
-
- inst = data_transfer_insts[(inp_flags | INDEXED) & MEM_MASK];
- SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ)));
- FAIL_IF(push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | B(OFFS_REG(arg))));
- return -1;
- }
-
- if (SLJIT_UNLIKELY(!(arg & REG_MASK)))
- inp_flags &= ~WRITE_BACK;
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- inst = data_transfer_insts[inp_flags & MEM_MASK];
- SLJIT_ASSERT((arg & REG_MASK) || !(inst & UPDATE_REQ));
-
- if (argw > SIMM_MAX || argw < SIMM_MIN || ((inst & INT_ALIGNED) && (argw & 0x3)) || (inst & UPDATE_REQ))
- return 0;
- if (inp_flags & ARG_TEST)
- return 1;
-#endif
-
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
- if (argw > SIMM_MAX || argw < SIMM_MIN)
- return 0;
- if (inp_flags & ARG_TEST)
- return 1;
-
- inst = data_transfer_insts[inp_flags & MEM_MASK];
- SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ)));
-#endif
-
- FAIL_IF(push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | IMM(argw)));
- return -1;
-}
-
-/* See getput_arg below.
- Note: can_cache is called only for binary operators. Those operator always
- uses word arguments without write back. */
-static sljit_si can_cache(sljit_si arg, sljit_sw argw, sljit_si next_arg, sljit_sw next_argw)
-{
- sljit_sw high_short, next_high_short;
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- sljit_sw diff;
-#endif
-
- SLJIT_ASSERT((arg & SLJIT_MEM) && (next_arg & SLJIT_MEM));
-
- if (arg & OFFS_REG_MASK)
- return ((arg & OFFS_REG_MASK) == (next_arg & OFFS_REG_MASK) && (argw & 0x3) == (next_argw & 0x3));
-
- if (next_arg & OFFS_REG_MASK)
- return 0;
-
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
- high_short = (argw + ((argw & 0x8000) << 1)) & ~0xffff;
- next_high_short = (next_argw + ((next_argw & 0x8000) << 1)) & ~0xffff;
- return high_short == next_high_short;
-#else
- if (argw <= 0x7fffffffl && argw >= -0x80000000l) {
- high_short = (argw + ((argw & 0x8000) << 1)) & ~0xffff;
- next_high_short = (next_argw + ((next_argw & 0x8000) << 1)) & ~0xffff;
- if (high_short == next_high_short)
- return 1;
- }
-
- diff = argw - next_argw;
- if (!(arg & REG_MASK))
- return diff <= SIMM_MAX && diff >= SIMM_MIN;
-
- if (arg == next_arg && diff <= SIMM_MAX && diff >= SIMM_MIN)
- return 1;
-
- return 0;
-#endif
-}
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-#define ADJUST_CACHED_IMM(imm) \
- if ((inst & INT_ALIGNED) && (imm & 0x3)) { \
- /* Adjust cached value. Fortunately this is really a rare case */ \
- compiler->cache_argw += imm & 0x3; \
- FAIL_IF(push_inst(compiler, ADDI | D(TMP_REG3) | A(TMP_REG3) | (imm & 0x3))); \
- imm &= ~0x3; \
- }
-#endif
-
-/* Emit the necessary instructions. See can_cache above. */
-static sljit_si getput_arg(struct sljit_compiler *compiler, sljit_si inp_flags, sljit_si reg, sljit_si arg, sljit_sw argw, sljit_si next_arg, sljit_sw next_argw)
-{
- sljit_si tmp_r;
- sljit_ins inst;
- sljit_sw high_short, next_high_short;
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- sljit_sw diff;
-#endif
-
- SLJIT_ASSERT(arg & SLJIT_MEM);
-
- tmp_r = ((inp_flags & LOAD_DATA) && ((inp_flags) & MEM_MASK) <= GPR_REG) ? reg : TMP_REG1;
- /* Special case for "mov reg, [reg, ... ]". */
- if ((arg & REG_MASK) == tmp_r)
- tmp_r = TMP_REG1;
-
- if (SLJIT_UNLIKELY(arg & OFFS_REG_MASK)) {
- argw &= 0x3;
- /* Otherwise getput_arg_fast would capture it. */
- SLJIT_ASSERT(argw);
-
- if ((SLJIT_MEM | (arg & OFFS_REG_MASK)) == compiler->cache_arg && argw == compiler->cache_argw)
- tmp_r = TMP_REG3;
- else {
- if ((arg & OFFS_REG_MASK) == (next_arg & OFFS_REG_MASK) && argw == (next_argw & 0x3)) {
- compiler->cache_arg = SLJIT_MEM | (arg & OFFS_REG_MASK);
- compiler->cache_argw = argw;
- tmp_r = TMP_REG3;
- }
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
- FAIL_IF(push_inst(compiler, RLWINM | S(OFFS_REG(arg)) | A(tmp_r) | (argw << 11) | ((31 - argw) << 1)));
-#else
- FAIL_IF(push_inst(compiler, RLDI(tmp_r, OFFS_REG(arg), argw, 63 - argw, 1)));
-#endif
- }
- inst = data_transfer_insts[(inp_flags | INDEXED) & MEM_MASK];
- SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ)));
- return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | B(tmp_r));
- }
-
- if (SLJIT_UNLIKELY(!(arg & REG_MASK)))
- inp_flags &= ~WRITE_BACK;
-
- inst = data_transfer_insts[inp_flags & MEM_MASK];
- SLJIT_ASSERT((arg & REG_MASK) || !(inst & UPDATE_REQ));
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- if (argw <= 0x7fff7fffl && argw >= -0x80000000l
- && (!(inst & INT_ALIGNED) || !(argw & 0x3)) && !(inst & UPDATE_REQ)) {
-#endif
-
- arg &= REG_MASK;
- high_short = (sljit_si)(argw + ((argw & 0x8000) << 1)) & ~0xffff;
- /* The getput_arg_fast should handle this otherwise. */
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- SLJIT_ASSERT(high_short && high_short <= 0x7fffffffl && high_short >= -0x80000000l);
-#else
- SLJIT_ASSERT(high_short && !(inst & (INT_ALIGNED | UPDATE_REQ)));
-#endif
-
- if (inp_flags & WRITE_BACK) {
- if (arg == reg) {
- FAIL_IF(push_inst(compiler, OR | S(reg) | A(tmp_r) | B(reg)));
- reg = tmp_r;
- }
- tmp_r = arg;
- FAIL_IF(push_inst(compiler, ADDIS | D(arg) | A(arg) | IMM(high_short >> 16)));
- }
- else if (compiler->cache_arg != (SLJIT_MEM | arg) || high_short != compiler->cache_argw) {
- if ((next_arg & SLJIT_MEM) && !(next_arg & OFFS_REG_MASK)) {
- next_high_short = (sljit_si)(next_argw + ((next_argw & 0x8000) << 1)) & ~0xffff;
- if (high_short == next_high_short) {
- compiler->cache_arg = SLJIT_MEM | arg;
- compiler->cache_argw = high_short;
- tmp_r = TMP_REG3;
- }
- }
- FAIL_IF(push_inst(compiler, ADDIS | D(tmp_r) | A(arg & REG_MASK) | IMM(high_short >> 16)));
- }
- else
- tmp_r = TMP_REG3;
-
- return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(tmp_r) | IMM(argw));
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- }
-
- /* Everything else is PPC-64 only. */
- if (SLJIT_UNLIKELY(!(arg & REG_MASK))) {
- diff = argw - compiler->cache_argw;
- if ((compiler->cache_arg & SLJIT_IMM) && diff <= SIMM_MAX && diff >= SIMM_MIN) {
- ADJUST_CACHED_IMM(diff);
- return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(TMP_REG3) | IMM(diff));
- }
-
- diff = argw - next_argw;
- if ((next_arg & SLJIT_MEM) && diff <= SIMM_MAX && diff >= SIMM_MIN) {
- SLJIT_ASSERT(inp_flags & LOAD_DATA);
-
- compiler->cache_arg = SLJIT_IMM;
- compiler->cache_argw = argw;
- tmp_r = TMP_REG3;
- }
-
- FAIL_IF(load_immediate(compiler, tmp_r, argw));
- return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(tmp_r));
- }
-
- diff = argw - compiler->cache_argw;
- if (compiler->cache_arg == arg && diff <= SIMM_MAX && diff >= SIMM_MIN) {
- SLJIT_ASSERT(!(inp_flags & WRITE_BACK) && !(inst & UPDATE_REQ));
- ADJUST_CACHED_IMM(diff);
- return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(TMP_REG3) | IMM(diff));
- }
-
- if ((compiler->cache_arg & SLJIT_IMM) && diff <= SIMM_MAX && diff >= SIMM_MIN) {
- inst = data_transfer_insts[(inp_flags | INDEXED) & MEM_MASK];
- SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ)));
- if (compiler->cache_argw != argw) {
- FAIL_IF(push_inst(compiler, ADDI | D(TMP_REG3) | A(TMP_REG3) | IMM(diff)));
- compiler->cache_argw = argw;
- }
- return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | B(TMP_REG3));
- }
-
- if (argw == next_argw && (next_arg & SLJIT_MEM)) {
- SLJIT_ASSERT(inp_flags & LOAD_DATA);
- FAIL_IF(load_immediate(compiler, TMP_REG3, argw));
-
- compiler->cache_arg = SLJIT_IMM;
- compiler->cache_argw = argw;
-
- inst = data_transfer_insts[(inp_flags | INDEXED) & MEM_MASK];
- SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ)));
- return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | B(TMP_REG3));
- }
-
- diff = argw - next_argw;
- if (arg == next_arg && !(inp_flags & WRITE_BACK) && diff <= SIMM_MAX && diff >= SIMM_MIN) {
- SLJIT_ASSERT(inp_flags & LOAD_DATA);
- FAIL_IF(load_immediate(compiler, TMP_REG3, argw));
- FAIL_IF(push_inst(compiler, ADD | D(TMP_REG3) | A(TMP_REG3) | B(arg & REG_MASK)));
-
- compiler->cache_arg = arg;
- compiler->cache_argw = argw;
-
- return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(TMP_REG3));
- }
-
- if ((next_arg & SLJIT_MEM) && !(next_arg & OFFS_REG_MASK) && diff <= SIMM_MAX && diff >= SIMM_MIN) {
- SLJIT_ASSERT(inp_flags & LOAD_DATA);
- FAIL_IF(load_immediate(compiler, TMP_REG3, argw));
-
- compiler->cache_arg = SLJIT_IMM;
- compiler->cache_argw = argw;
- tmp_r = TMP_REG3;
- }
- else
- FAIL_IF(load_immediate(compiler, tmp_r, argw));
-
- /* Get the indexed version instead of the normal one. */
- inst = data_transfer_insts[(inp_flags | INDEXED) & MEM_MASK];
- SLJIT_ASSERT(!(inst & (INT_ALIGNED | UPDATE_REQ)));
- return push_inst(compiler, INST_CODE_AND_DST(inst, inp_flags, reg) | A(arg & REG_MASK) | B(tmp_r));
-#endif
-}
-
-static SLJIT_INLINE sljit_si emit_op_mem2(struct sljit_compiler *compiler, sljit_si flags, sljit_si reg, sljit_si arg1, sljit_sw arg1w, sljit_si arg2, sljit_sw arg2w)
-{
- if (getput_arg_fast(compiler, flags, reg, arg1, arg1w))
- return compiler->error;
- return getput_arg(compiler, flags, reg, arg1, arg1w, arg2, arg2w);
-}
-
-static sljit_si emit_op(struct sljit_compiler *compiler, sljit_si op, sljit_si input_flags,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- /* arg1 goes to TMP_REG1 or src reg
- arg2 goes to TMP_REG2, imm or src reg
- TMP_REG3 can be used for caching
- result goes to TMP_REG2, so put result can use TMP_REG1 and TMP_REG3. */
- sljit_si dst_r;
- sljit_si src1_r;
- sljit_si src2_r;
- sljit_si sugg_src2_r = TMP_REG2;
- sljit_si flags = input_flags & (ALT_FORM1 | ALT_FORM2 | ALT_FORM3 | ALT_FORM4 | ALT_FORM5 | ALT_FORM6 | ALT_SIGN_EXT | ALT_SET_FLAGS);
-
- if (!(input_flags & ALT_KEEP_CACHE)) {
- compiler->cache_arg = 0;
- compiler->cache_argw = 0;
- }
-
- /* Destination check. */
- if (SLJIT_UNLIKELY(dst == SLJIT_UNUSED)) {
- if (op >= SLJIT_MOV && op <= SLJIT_MOVU_SI && !(src2 & SLJIT_MEM))
- return SLJIT_SUCCESS;
- dst_r = TMP_REG2;
- }
- else if (FAST_IS_REG(dst)) {
- dst_r = dst;
- flags |= REG_DEST;
- if (op >= SLJIT_MOV && op <= SLJIT_MOVU_SI)
- sugg_src2_r = dst_r;
- }
- else {
- SLJIT_ASSERT(dst & SLJIT_MEM);
- if (getput_arg_fast(compiler, input_flags | ARG_TEST, TMP_REG2, dst, dstw)) {
- flags |= FAST_DEST;
- dst_r = TMP_REG2;
- }
- else {
- flags |= SLOW_DEST;
- dst_r = 0;
- }
- }
-
- /* Source 1. */
- if (FAST_IS_REG(src1)) {
- src1_r = src1;
- flags |= REG1_SOURCE;
- }
- else if (src1 & SLJIT_IMM) {
- FAIL_IF(load_immediate(compiler, TMP_REG1, src1w));
- src1_r = TMP_REG1;
- }
- else if (getput_arg_fast(compiler, input_flags | LOAD_DATA, TMP_REG1, src1, src1w)) {
- FAIL_IF(compiler->error);
- src1_r = TMP_REG1;
- }
- else
- src1_r = 0;
-
- /* Source 2. */
- if (FAST_IS_REG(src2)) {
- src2_r = src2;
- flags |= REG2_SOURCE;
- if (!(flags & REG_DEST) && op >= SLJIT_MOV && op <= SLJIT_MOVU_SI)
- dst_r = src2_r;
- }
- else if (src2 & SLJIT_IMM) {
- FAIL_IF(load_immediate(compiler, sugg_src2_r, src2w));
- src2_r = sugg_src2_r;
- }
- else if (getput_arg_fast(compiler, input_flags | LOAD_DATA, sugg_src2_r, src2, src2w)) {
- FAIL_IF(compiler->error);
- src2_r = sugg_src2_r;
- }
- else
- src2_r = 0;
-
- /* src1_r, src2_r and dst_r can be zero (=unprocessed).
- All arguments are complex addressing modes, and it is a binary operator. */
- if (src1_r == 0 && src2_r == 0 && dst_r == 0) {
- if (!can_cache(src1, src1w, src2, src2w) && can_cache(src1, src1w, dst, dstw)) {
- FAIL_IF(getput_arg(compiler, input_flags | LOAD_DATA, TMP_REG2, src2, src2w, src1, src1w));
- FAIL_IF(getput_arg(compiler, input_flags | LOAD_DATA, TMP_REG1, src1, src1w, dst, dstw));
- }
- else {
- FAIL_IF(getput_arg(compiler, input_flags | LOAD_DATA, TMP_REG1, src1, src1w, src2, src2w));
- FAIL_IF(getput_arg(compiler, input_flags | LOAD_DATA, TMP_REG2, src2, src2w, dst, dstw));
- }
- src1_r = TMP_REG1;
- src2_r = TMP_REG2;
- }
- else if (src1_r == 0 && src2_r == 0) {
- FAIL_IF(getput_arg(compiler, input_flags | LOAD_DATA, TMP_REG1, src1, src1w, src2, src2w));
- src1_r = TMP_REG1;
- }
- else if (src1_r == 0 && dst_r == 0) {
- FAIL_IF(getput_arg(compiler, input_flags | LOAD_DATA, TMP_REG1, src1, src1w, dst, dstw));
- src1_r = TMP_REG1;
- }
- else if (src2_r == 0 && dst_r == 0) {
- FAIL_IF(getput_arg(compiler, input_flags | LOAD_DATA, sugg_src2_r, src2, src2w, dst, dstw));
- src2_r = sugg_src2_r;
- }
-
- if (dst_r == 0)
- dst_r = TMP_REG2;
-
- if (src1_r == 0) {
- FAIL_IF(getput_arg(compiler, input_flags | LOAD_DATA, TMP_REG1, src1, src1w, 0, 0));
- src1_r = TMP_REG1;
- }
-
- if (src2_r == 0) {
- FAIL_IF(getput_arg(compiler, input_flags | LOAD_DATA, sugg_src2_r, src2, src2w, 0, 0));
- src2_r = sugg_src2_r;
- }
-
- FAIL_IF(emit_single_op(compiler, op, flags, dst_r, src1_r, src2_r));
-
- if (flags & (FAST_DEST | SLOW_DEST)) {
- if (flags & FAST_DEST)
- FAIL_IF(getput_arg_fast(compiler, input_flags, dst_r, dst, dstw));
- else
- FAIL_IF(getput_arg(compiler, input_flags, dst_r, dst, dstw, 0, 0));
- }
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
-{
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- sljit_si int_op = op & SLJIT_INT_OP;
-#endif
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_op0(compiler, op));
-
- op = GET_OPCODE(op);
- switch (op) {
- case SLJIT_BREAKPOINT:
- case SLJIT_NOP:
- return push_inst(compiler, NOP);
- case SLJIT_LUMUL:
- case SLJIT_LSMUL:
- FAIL_IF(push_inst(compiler, OR | S(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R0)));
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- FAIL_IF(push_inst(compiler, MULLD | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
- return push_inst(compiler, (op == SLJIT_LUMUL ? MULHDU : MULHD) | D(SLJIT_R1) | A(TMP_REG1) | B(SLJIT_R1));
-#else
- FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R1)));
- return push_inst(compiler, (op == SLJIT_LUMUL ? MULHWU : MULHW) | D(SLJIT_R1) | A(TMP_REG1) | B(SLJIT_R1));
-#endif
- case SLJIT_UDIVMOD:
- case SLJIT_SDIVMOD:
- FAIL_IF(push_inst(compiler, OR | S(SLJIT_R0) | A(TMP_REG1) | B(SLJIT_R0)));
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- FAIL_IF(push_inst(compiler, (int_op ? (op == SLJIT_UDIVMOD ? DIVWU : DIVW) : (op == SLJIT_UDIVMOD ? DIVDU : DIVD)) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1)));
- FAIL_IF(push_inst(compiler, (int_op ? MULLW : MULLD) | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
-#else
- FAIL_IF(push_inst(compiler, (op == SLJIT_UDIVMOD ? DIVWU : DIVW) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1)));
- FAIL_IF(push_inst(compiler, MULLW | D(SLJIT_R1) | A(SLJIT_R0) | B(SLJIT_R1)));
-#endif
- return push_inst(compiler, SUBF | D(SLJIT_R1) | A(SLJIT_R1) | B(TMP_REG1));
- case SLJIT_UDIVI:
- case SLJIT_SDIVI:
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- return push_inst(compiler, (int_op ? (op == SLJIT_UDIVI ? DIVWU : DIVW) : (op == SLJIT_UDIVI ? DIVDU : DIVD)) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1));
-#else
- return push_inst(compiler, (op == SLJIT_UDIVI ? DIVWU : DIVW) | D(SLJIT_R0) | A(SLJIT_R0) | B(SLJIT_R1));
-#endif
- }
-
- return SLJIT_SUCCESS;
-}
-
-#define EMIT_MOV(type, type_flags, type_cast) \
- emit_op(compiler, (src & SLJIT_IMM) ? SLJIT_MOV : type, flags | (type_flags), dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? type_cast srcw : srcw)
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_si flags = GET_FLAGS(op) ? ALT_SET_FLAGS : 0;
- sljit_si op_flags = GET_ALL_FLAGS(op);
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
- ADJUST_LOCAL_OFFSET(dst, dstw);
- ADJUST_LOCAL_OFFSET(src, srcw);
-
- op = GET_OPCODE(op);
- if ((src & SLJIT_IMM) && srcw == 0)
- src = TMP_ZERO;
-
- if (op_flags & SLJIT_SET_O)
- FAIL_IF(push_inst(compiler, MTXER | S(TMP_ZERO)));
-
- if (op_flags & SLJIT_INT_OP) {
- if (op < SLJIT_NOT) {
- if (FAST_IS_REG(src) && src == dst) {
- if (!TYPE_CAST_NEEDED(op))
- return SLJIT_SUCCESS;
- }
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- if (op == SLJIT_MOV_SI && (src & SLJIT_MEM))
- op = SLJIT_MOV_UI;
- if (op == SLJIT_MOVU_SI && (src & SLJIT_MEM))
- op = SLJIT_MOVU_UI;
- if (op == SLJIT_MOV_UI && (src & SLJIT_IMM))
- op = SLJIT_MOV_SI;
- if (op == SLJIT_MOVU_UI && (src & SLJIT_IMM))
- op = SLJIT_MOVU_SI;
-#endif
- }
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- else {
- /* Most operations expect sign extended arguments. */
- flags |= INT_DATA | SIGNED_DATA;
- if (src & SLJIT_IMM)
- srcw = (sljit_si)srcw;
- }
-#endif
- }
-
- switch (op) {
- case SLJIT_MOV:
- case SLJIT_MOV_P:
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
- case SLJIT_MOV_UI:
- case SLJIT_MOV_SI:
-#endif
- return emit_op(compiler, SLJIT_MOV, flags | WORD_DATA, dst, dstw, TMP_REG1, 0, src, srcw);
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- case SLJIT_MOV_UI:
- return EMIT_MOV(SLJIT_MOV_UI, INT_DATA, (sljit_ui));
-
- case SLJIT_MOV_SI:
- return EMIT_MOV(SLJIT_MOV_SI, INT_DATA | SIGNED_DATA, (sljit_si));
-#endif
-
- case SLJIT_MOV_UB:
- return EMIT_MOV(SLJIT_MOV_UB, BYTE_DATA, (sljit_ub));
-
- case SLJIT_MOV_SB:
- return EMIT_MOV(SLJIT_MOV_SB, BYTE_DATA | SIGNED_DATA, (sljit_sb));
-
- case SLJIT_MOV_UH:
- return EMIT_MOV(SLJIT_MOV_UH, HALF_DATA, (sljit_uh));
-
- case SLJIT_MOV_SH:
- return EMIT_MOV(SLJIT_MOV_SH, HALF_DATA | SIGNED_DATA, (sljit_sh));
-
- case SLJIT_MOVU:
- case SLJIT_MOVU_P:
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
- case SLJIT_MOVU_UI:
- case SLJIT_MOVU_SI:
-#endif
- return emit_op(compiler, SLJIT_MOV, flags | WORD_DATA | WRITE_BACK, dst, dstw, TMP_REG1, 0, src, srcw);
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- case SLJIT_MOVU_UI:
- return EMIT_MOV(SLJIT_MOV_UI, INT_DATA | WRITE_BACK, (sljit_ui));
-
- case SLJIT_MOVU_SI:
- return EMIT_MOV(SLJIT_MOV_SI, INT_DATA | SIGNED_DATA | WRITE_BACK, (sljit_si));
-#endif
-
- case SLJIT_MOVU_UB:
- return EMIT_MOV(SLJIT_MOV_UB, BYTE_DATA | WRITE_BACK, (sljit_ub));
-
- case SLJIT_MOVU_SB:
- return EMIT_MOV(SLJIT_MOV_SB, BYTE_DATA | SIGNED_DATA | WRITE_BACK, (sljit_sb));
-
- case SLJIT_MOVU_UH:
- return EMIT_MOV(SLJIT_MOV_UH, HALF_DATA | WRITE_BACK, (sljit_uh));
-
- case SLJIT_MOVU_SH:
- return EMIT_MOV(SLJIT_MOV_SH, HALF_DATA | SIGNED_DATA | WRITE_BACK, (sljit_sh));
-
- case SLJIT_NOT:
- return emit_op(compiler, SLJIT_NOT, flags, dst, dstw, TMP_REG1, 0, src, srcw);
-
- case SLJIT_NEG:
- return emit_op(compiler, SLJIT_NEG, flags, dst, dstw, TMP_REG1, 0, src, srcw);
-
- case SLJIT_CLZ:
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- return emit_op(compiler, SLJIT_CLZ, flags | (!(op_flags & SLJIT_INT_OP) ? 0 : ALT_FORM1), dst, dstw, TMP_REG1, 0, src, srcw);
-#else
- return emit_op(compiler, SLJIT_CLZ, flags, dst, dstw, TMP_REG1, 0, src, srcw);
-#endif
- }
-
- return SLJIT_SUCCESS;
-}
-
-#undef EMIT_MOV
-
-#define TEST_SL_IMM(src, srcw) \
- (((src) & SLJIT_IMM) && (srcw) <= SIMM_MAX && (srcw) >= SIMM_MIN)
-
-#define TEST_UL_IMM(src, srcw) \
- (((src) & SLJIT_IMM) && !((srcw) & ~0xffff))
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-#define TEST_SH_IMM(src, srcw) \
- (((src) & SLJIT_IMM) && !((srcw) & 0xffff) && (srcw) <= 0x7fffffffl && (srcw) >= -0x80000000l)
-#else
-#define TEST_SH_IMM(src, srcw) \
- (((src) & SLJIT_IMM) && !((srcw) & 0xffff))
-#endif
-
-#define TEST_UH_IMM(src, srcw) \
- (((src) & SLJIT_IMM) && !((srcw) & ~0xffff0000))
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-#define TEST_ADD_IMM(src, srcw) \
- (((src) & SLJIT_IMM) && (srcw) <= 0x7fff7fffl && (srcw) >= -0x80000000l)
-#else
-#define TEST_ADD_IMM(src, srcw) \
- ((src) & SLJIT_IMM)
-#endif
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-#define TEST_UI_IMM(src, srcw) \
- (((src) & SLJIT_IMM) && !((srcw) & ~0xffffffff))
-#else
-#define TEST_UI_IMM(src, srcw) \
- ((src) & SLJIT_IMM)
-#endif
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_si flags = GET_FLAGS(op) ? ALT_SET_FLAGS : 0;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
- ADJUST_LOCAL_OFFSET(dst, dstw);
- ADJUST_LOCAL_OFFSET(src1, src1w);
- ADJUST_LOCAL_OFFSET(src2, src2w);
-
- if ((src1 & SLJIT_IMM) && src1w == 0)
- src1 = TMP_ZERO;
- if ((src2 & SLJIT_IMM) && src2w == 0)
- src2 = TMP_ZERO;
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- if (op & SLJIT_INT_OP) {
- /* Most operations expect sign extended arguments. */
- flags |= INT_DATA | SIGNED_DATA;
- if (src1 & SLJIT_IMM)
- src1w = (sljit_si)(src1w);
- if (src2 & SLJIT_IMM)
- src2w = (sljit_si)(src2w);
- if (GET_FLAGS(op))
- flags |= ALT_SIGN_EXT;
- }
-#endif
- if (op & SLJIT_SET_O)
- FAIL_IF(push_inst(compiler, MTXER | S(TMP_ZERO)));
- if (src2 == TMP_REG2)
- flags |= ALT_KEEP_CACHE;
-
- switch (GET_OPCODE(op)) {
- case SLJIT_ADD:
- if (!GET_FLAGS(op) && ((src1 | src2) & SLJIT_IMM)) {
- if (TEST_SL_IMM(src2, src2w)) {
- compiler->imm = src2w & 0xffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM1, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- if (TEST_SL_IMM(src1, src1w)) {
- compiler->imm = src1w & 0xffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM1, dst, dstw, src2, src2w, TMP_REG2, 0);
- }
- if (TEST_SH_IMM(src2, src2w)) {
- compiler->imm = (src2w >> 16) & 0xffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM2, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- if (TEST_SH_IMM(src1, src1w)) {
- compiler->imm = (src1w >> 16) & 0xffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM2, dst, dstw, src2, src2w, TMP_REG2, 0);
- }
- /* Range between -1 and -32768 is covered above. */
- if (TEST_ADD_IMM(src2, src2w)) {
- compiler->imm = src2w & 0xffffffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM4, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- if (TEST_ADD_IMM(src1, src1w)) {
- compiler->imm = src1w & 0xffffffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM4, dst, dstw, src2, src2w, TMP_REG2, 0);
- }
- }
- if (!(GET_FLAGS(op) & (SLJIT_SET_E | SLJIT_SET_O))) {
- if (TEST_SL_IMM(src2, src2w)) {
- compiler->imm = src2w & 0xffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- if (TEST_SL_IMM(src1, src1w)) {
- compiler->imm = src1w & 0xffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM3, dst, dstw, src2, src2w, TMP_REG2, 0);
- }
- }
- return emit_op(compiler, SLJIT_ADD, flags, dst, dstw, src1, src1w, src2, src2w);
-
- case SLJIT_ADDC:
- return emit_op(compiler, SLJIT_ADDC, flags | (!(op & SLJIT_KEEP_FLAGS) ? 0 : ALT_FORM1), dst, dstw, src1, src1w, src2, src2w);
-
- case SLJIT_SUB:
- if (!GET_FLAGS(op) && ((src1 | src2) & SLJIT_IMM)) {
- if (TEST_SL_IMM(src2, -src2w)) {
- compiler->imm = (-src2w) & 0xffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM1, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- if (TEST_SL_IMM(src1, src1w)) {
- compiler->imm = src1w & 0xffff;
- return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM1, dst, dstw, src2, src2w, TMP_REG2, 0);
- }
- if (TEST_SH_IMM(src2, -src2w)) {
- compiler->imm = ((-src2w) >> 16) & 0xffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM2, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- /* Range between -1 and -32768 is covered above. */
- if (TEST_ADD_IMM(src2, -src2w)) {
- compiler->imm = -src2w & 0xffffffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM4, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- }
- if (dst == SLJIT_UNUSED && (op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S)) && !(op & (SLJIT_SET_O | SLJIT_SET_C))) {
- if (!(op & SLJIT_SET_U)) {
- /* We know ALT_SIGN_EXT is set if it is an SLJIT_INT_OP on 64 bit systems. */
- if (TEST_SL_IMM(src2, src2w)) {
- compiler->imm = src2w & 0xffff;
- return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM2, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- if (GET_FLAGS(op) == SLJIT_SET_E && TEST_SL_IMM(src1, src1w)) {
- compiler->imm = src1w & 0xffff;
- return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM2, dst, dstw, src2, src2w, TMP_REG2, 0);
- }
- }
- if (!(op & (SLJIT_SET_E | SLJIT_SET_S))) {
- /* We know ALT_SIGN_EXT is set if it is an SLJIT_INT_OP on 64 bit systems. */
- if (TEST_UL_IMM(src2, src2w)) {
- compiler->imm = src2w & 0xffff;
- return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM4, dst, dstw, src1, src1w, src2, src2w);
- }
- if ((src2 & SLJIT_IMM) && src2w >= 0 && src2w <= 0x7fff) {
- compiler->imm = src2w;
- return emit_op(compiler, SLJIT_SUB, flags | ALT_FORM2 | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- return emit_op(compiler, SLJIT_SUB, flags | ((op & SLJIT_SET_U) ? ALT_FORM4 : 0) | ((op & (SLJIT_SET_E | SLJIT_SET_S)) ? ALT_FORM5 : 0), dst, dstw, src1, src1w, src2, src2w);
- }
- if (!(op & (SLJIT_SET_E | SLJIT_SET_U | SLJIT_SET_S | SLJIT_SET_O))) {
- if (TEST_SL_IMM(src2, -src2w)) {
- compiler->imm = (-src2w) & 0xffff;
- return emit_op(compiler, SLJIT_ADD, flags | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- }
- /* We know ALT_SIGN_EXT is set if it is an SLJIT_INT_OP on 64 bit systems. */
- return emit_op(compiler, SLJIT_SUB, flags | (!(op & SLJIT_SET_U) ? 0 : ALT_FORM6), dst, dstw, src1, src1w, src2, src2w);
-
- case SLJIT_SUBC:
- return emit_op(compiler, SLJIT_SUBC, flags | (!(op & SLJIT_KEEP_FLAGS) ? 0 : ALT_FORM1), dst, dstw, src1, src1w, src2, src2w);
-
- case SLJIT_MUL:
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- if (op & SLJIT_INT_OP)
- flags |= ALT_FORM2;
-#endif
- if (!GET_FLAGS(op)) {
- if (TEST_SL_IMM(src2, src2w)) {
- compiler->imm = src2w & 0xffff;
- return emit_op(compiler, SLJIT_MUL, flags | ALT_FORM1, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- if (TEST_SL_IMM(src1, src1w)) {
- compiler->imm = src1w & 0xffff;
- return emit_op(compiler, SLJIT_MUL, flags | ALT_FORM1, dst, dstw, src2, src2w, TMP_REG2, 0);
- }
- }
- return emit_op(compiler, SLJIT_MUL, flags, dst, dstw, src1, src1w, src2, src2w);
-
- case SLJIT_AND:
- case SLJIT_OR:
- case SLJIT_XOR:
- /* Commutative unsigned operations. */
- if (!GET_FLAGS(op) || GET_OPCODE(op) == SLJIT_AND) {
- if (TEST_UL_IMM(src2, src2w)) {
- compiler->imm = src2w;
- return emit_op(compiler, GET_OPCODE(op), flags | ALT_FORM1, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- if (TEST_UL_IMM(src1, src1w)) {
- compiler->imm = src1w;
- return emit_op(compiler, GET_OPCODE(op), flags | ALT_FORM1, dst, dstw, src2, src2w, TMP_REG2, 0);
- }
- if (TEST_UH_IMM(src2, src2w)) {
- compiler->imm = (src2w >> 16) & 0xffff;
- return emit_op(compiler, GET_OPCODE(op), flags | ALT_FORM2, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- if (TEST_UH_IMM(src1, src1w)) {
- compiler->imm = (src1w >> 16) & 0xffff;
- return emit_op(compiler, GET_OPCODE(op), flags | ALT_FORM2, dst, dstw, src2, src2w, TMP_REG2, 0);
- }
- }
- if (!GET_FLAGS(op) && GET_OPCODE(op) != SLJIT_AND) {
- if (TEST_UI_IMM(src2, src2w)) {
- compiler->imm = src2w;
- return emit_op(compiler, GET_OPCODE(op), flags | ALT_FORM3, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- if (TEST_UI_IMM(src1, src1w)) {
- compiler->imm = src1w;
- return emit_op(compiler, GET_OPCODE(op), flags | ALT_FORM3, dst, dstw, src2, src2w, TMP_REG2, 0);
- }
- }
- return emit_op(compiler, GET_OPCODE(op), flags, dst, dstw, src1, src1w, src2, src2w);
-
- case SLJIT_ASHR:
- if (op & SLJIT_KEEP_FLAGS)
- flags |= ALT_FORM3;
- /* Fall through. */
- case SLJIT_SHL:
- case SLJIT_LSHR:
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- if (op & SLJIT_INT_OP)
- flags |= ALT_FORM2;
-#endif
- if (src2 & SLJIT_IMM) {
- compiler->imm = src2w;
- return emit_op(compiler, GET_OPCODE(op), flags | ALT_FORM1, dst, dstw, src1, src1w, TMP_REG2, 0);
- }
- return emit_op(compiler, GET_OPCODE(op), flags, dst, dstw, src1, src1w, src2, src2w);
- }
-
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
-{
- CHECK_REG_INDEX(check_sljit_get_register_index(reg));
- return reg_map[reg];
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg)
-{
- CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
- return reg;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
- void *instruction, sljit_si size)
-{
- CHECK_ERROR();
- CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
-
- return push_inst(compiler, *(sljit_ins*)instruction);
-}
-
-/* --------------------------------------------------------------------- */
-/* Floating point operators */
-/* --------------------------------------------------------------------- */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void)
-{
-#ifdef SLJIT_IS_FPU_AVAILABLE
- return SLJIT_IS_FPU_AVAILABLE;
-#else
- /* Available by default. */
- return 1;
-#endif
-}
-
-#define FLOAT_DATA(op) (DOUBLE_DATA | ((op & SLJIT_SINGLE_OP) >> 6))
-#define SELECT_FOP(op, single, double) ((op & SLJIT_SINGLE_OP) ? single : double)
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-#define FLOAT_TMP_MEM_OFFSET (6 * sizeof(sljit_sw))
-#else
-#define FLOAT_TMP_MEM_OFFSET (2 * sizeof(sljit_sw))
-
-#if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
-#define FLOAT_TMP_MEM_OFFSET_LOW (2 * sizeof(sljit_sw))
-#define FLOAT_TMP_MEM_OFFSET_HI (3 * sizeof(sljit_sw))
-#else
-#define FLOAT_TMP_MEM_OFFSET_LOW (3 * sizeof(sljit_sw))
-#define FLOAT_TMP_MEM_OFFSET_HI (2 * sizeof(sljit_sw))
-#endif
-
-#endif /* SLJIT_CONFIG_PPC_64 */
-
-static SLJIT_INLINE sljit_si sljit_emit_fop1_convw_fromd(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- if (src & SLJIT_MEM) {
- /* We can ignore the temporary data store on the stack from caching point of view. */
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src, srcw, dst, dstw));
- src = TMP_FREG1;
- }
-
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- op = GET_OPCODE(op);
- FAIL_IF(push_inst(compiler, (op == SLJIT_CONVI_FROMD ? FCTIWZ : FCTIDZ) | FD(TMP_FREG1) | FB(src)));
-
- if (dst == SLJIT_UNUSED)
- return SLJIT_SUCCESS;
-
- if (op == SLJIT_CONVW_FROMD) {
- if (FAST_IS_REG(dst)) {
- FAIL_IF(emit_op_mem2(compiler, DOUBLE_DATA, TMP_FREG1, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, 0, 0));
- return emit_op_mem2(compiler, WORD_DATA | LOAD_DATA, dst, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, 0, 0);
- }
- return emit_op_mem2(compiler, DOUBLE_DATA, TMP_FREG1, dst, dstw, 0, 0);
- }
-
-#else
- FAIL_IF(push_inst(compiler, FCTIWZ | FD(TMP_FREG1) | FB(src)));
-
- if (dst == SLJIT_UNUSED)
- return SLJIT_SUCCESS;
-#endif
-
- if (FAST_IS_REG(dst)) {
- FAIL_IF(load_immediate(compiler, TMP_REG1, FLOAT_TMP_MEM_OFFSET));
- FAIL_IF(push_inst(compiler, STFIWX | FS(TMP_FREG1) | A(SLJIT_SP) | B(TMP_REG1)));
- return emit_op_mem2(compiler, INT_DATA | LOAD_DATA, dst, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, 0, 0);
- }
-
- SLJIT_ASSERT(dst & SLJIT_MEM);
-
- if (dst & OFFS_REG_MASK) {
- dstw &= 0x3;
- if (dstw) {
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
- FAIL_IF(push_inst(compiler, RLWINM | S(OFFS_REG(dst)) | A(TMP_REG1) | (dstw << 11) | ((31 - dstw) << 1)));
-#else
- FAIL_IF(push_inst(compiler, RLDI(TMP_REG1, OFFS_REG(dst), dstw, 63 - dstw, 1)));
-#endif
- dstw = TMP_REG1;
- }
- else
- dstw = OFFS_REG(dst);
- }
- else {
- if ((dst & REG_MASK) && !dstw) {
- dstw = dst & REG_MASK;
- dst = 0;
- }
- else {
- /* This works regardless we have SLJIT_MEM1 or SLJIT_MEM0. */
- FAIL_IF(load_immediate(compiler, TMP_REG1, dstw));
- dstw = TMP_REG1;
- }
- }
-
- return push_inst(compiler, STFIWX | FS(TMP_FREG1) | A(dst & REG_MASK) | B(dstw));
-}
-
-static SLJIT_INLINE sljit_si sljit_emit_fop1_convd_fromw(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-
- sljit_si dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1;
-
- if (src & SLJIT_IMM) {
- if (GET_OPCODE(op) == SLJIT_CONVD_FROMI)
- srcw = (sljit_si)srcw;
- FAIL_IF(load_immediate(compiler, TMP_REG1, srcw));
- src = TMP_REG1;
- }
- else if (GET_OPCODE(op) == SLJIT_CONVD_FROMI) {
- if (FAST_IS_REG(src))
- FAIL_IF(push_inst(compiler, EXTSW | S(src) | A(TMP_REG1)));
- else
- FAIL_IF(emit_op_mem2(compiler, INT_DATA | SIGNED_DATA | LOAD_DATA, TMP_REG1, src, srcw, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET));
- src = TMP_REG1;
- }
-
- if (FAST_IS_REG(src)) {
- FAIL_IF(emit_op_mem2(compiler, WORD_DATA, src, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET));
- FAIL_IF(emit_op_mem2(compiler, DOUBLE_DATA | LOAD_DATA, TMP_FREG1, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, dst, dstw));
- }
- else
- FAIL_IF(emit_op_mem2(compiler, DOUBLE_DATA | LOAD_DATA, TMP_FREG1, src, srcw, dst, dstw));
-
- FAIL_IF(push_inst(compiler, FCFID | FD(dst_r) | FB(TMP_FREG1)));
-
- if (dst & SLJIT_MEM)
- return emit_op_mem2(compiler, FLOAT_DATA(op), TMP_FREG1, dst, dstw, 0, 0);
- if (op & SLJIT_SINGLE_OP)
- return push_inst(compiler, FRSP | FD(dst_r) | FB(dst_r));
- return SLJIT_SUCCESS;
-
-#else
-
- sljit_si dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1;
- sljit_si invert_sign = 1;
-
- if (src & SLJIT_IMM) {
- FAIL_IF(load_immediate(compiler, TMP_REG1, srcw ^ 0x80000000));
- src = TMP_REG1;
- invert_sign = 0;
- }
- else if (!FAST_IS_REG(src)) {
- FAIL_IF(emit_op_mem2(compiler, WORD_DATA | SIGNED_DATA | LOAD_DATA, TMP_REG1, src, srcw, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_LOW));
- src = TMP_REG1;
- }
-
- /* First, a special double floating point value is constructed: (2^53 + (input xor (2^31)))
- The double precision format has exactly 53 bit precision, so the lower 32 bit represents
- the lower 32 bit of such value. The result of xor 2^31 is the same as adding 0x80000000
- to the input, which shifts it into the 0 - 0xffffffff range. To get the converted floating
- point value, we need to substract 2^53 + 2^31 from the constructed value. */
- FAIL_IF(push_inst(compiler, ADDIS | D(TMP_REG2) | A(0) | 0x4330));
- if (invert_sign)
- FAIL_IF(push_inst(compiler, XORIS | S(src) | A(TMP_REG1) | 0x8000));
- FAIL_IF(emit_op_mem2(compiler, WORD_DATA, TMP_REG2, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_HI, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET));
- FAIL_IF(emit_op_mem2(compiler, WORD_DATA, TMP_REG1, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_LOW, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_HI));
- FAIL_IF(push_inst(compiler, ADDIS | D(TMP_REG1) | A(0) | 0x8000));
- FAIL_IF(emit_op_mem2(compiler, DOUBLE_DATA | LOAD_DATA, TMP_FREG1, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_LOW));
- FAIL_IF(emit_op_mem2(compiler, WORD_DATA, TMP_REG1, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_LOW, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET));
- FAIL_IF(emit_op_mem2(compiler, DOUBLE_DATA | LOAD_DATA, TMP_FREG2, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET_LOW));
-
- FAIL_IF(push_inst(compiler, FSUB | FD(dst_r) | FA(TMP_FREG1) | FB(TMP_FREG2)));
-
- if (dst & SLJIT_MEM)
- return emit_op_mem2(compiler, FLOAT_DATA(op), TMP_FREG1, dst, dstw, 0, 0);
- if (op & SLJIT_SINGLE_OP)
- return push_inst(compiler, FRSP | FD(dst_r) | FB(dst_r));
- return SLJIT_SUCCESS;
-
-#endif
-}
-
-static SLJIT_INLINE sljit_si sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_si op,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- if (src1 & SLJIT_MEM) {
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w, src2, src2w));
- src1 = TMP_FREG1;
- }
-
- if (src2 & SLJIT_MEM) {
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w, 0, 0));
- src2 = TMP_FREG2;
- }
-
- return push_inst(compiler, FCMPU | CRD(4) | FA(src1) | FB(src2));
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_si dst_r;
-
- CHECK_ERROR();
- compiler->cache_arg = 0;
- compiler->cache_argw = 0;
-
- SLJIT_COMPILE_ASSERT((SLJIT_SINGLE_OP == 0x100) && !(DOUBLE_DATA & 0x4), float_transfer_bit_error);
- SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
-
- if (GET_OPCODE(op) == SLJIT_CONVD_FROMS)
- op ^= SLJIT_SINGLE_OP;
-
- dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG1;
-
- if (src & SLJIT_MEM) {
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, dst_r, src, srcw, dst, dstw));
- src = dst_r;
- }
-
- switch (GET_OPCODE(op)) {
- case SLJIT_CONVD_FROMS:
- op ^= SLJIT_SINGLE_OP;
- if (op & SLJIT_SINGLE_OP) {
- FAIL_IF(push_inst(compiler, FRSP | FD(dst_r) | FB(src)));
- break;
- }
- /* Fall through. */
- case SLJIT_DMOV:
- if (src != dst_r) {
- if (dst_r != TMP_FREG1)
- FAIL_IF(push_inst(compiler, FMR | FD(dst_r) | FB(src)));
- else
- dst_r = src;
- }
- break;
- case SLJIT_DNEG:
- FAIL_IF(push_inst(compiler, FNEG | FD(dst_r) | FB(src)));
- break;
- case SLJIT_DABS:
- FAIL_IF(push_inst(compiler, FABS | FD(dst_r) | FB(src)));
- break;
- }
-
- if (dst & SLJIT_MEM)
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op), dst_r, dst, dstw, 0, 0));
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_si dst_r, flags = 0;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
- ADJUST_LOCAL_OFFSET(dst, dstw);
- ADJUST_LOCAL_OFFSET(src1, src1w);
- ADJUST_LOCAL_OFFSET(src2, src2w);
-
- compiler->cache_arg = 0;
- compiler->cache_argw = 0;
-
- dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG2;
-
- if (src1 & SLJIT_MEM) {
- if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w)) {
- FAIL_IF(compiler->error);
- src1 = TMP_FREG1;
- } else
- flags |= ALT_FORM1;
- }
-
- if (src2 & SLJIT_MEM) {
- if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w)) {
- FAIL_IF(compiler->error);
- src2 = TMP_FREG2;
- } else
- flags |= ALT_FORM2;
- }
-
- if ((flags & (ALT_FORM1 | ALT_FORM2)) == (ALT_FORM1 | ALT_FORM2)) {
- if (!can_cache(src1, src1w, src2, src2w) && can_cache(src1, src1w, dst, dstw)) {
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w, src1, src1w));
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w, dst, dstw));
- }
- else {
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w, src2, src2w));
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w, dst, dstw));
- }
- }
- else if (flags & ALT_FORM1)
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w, dst, dstw));
- else if (flags & ALT_FORM2)
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w, dst, dstw));
-
- if (flags & ALT_FORM1)
- src1 = TMP_FREG1;
- if (flags & ALT_FORM2)
- src2 = TMP_FREG2;
-
- switch (GET_OPCODE(op)) {
- case SLJIT_DADD:
- FAIL_IF(push_inst(compiler, SELECT_FOP(op, FADDS, FADD) | FD(dst_r) | FA(src1) | FB(src2)));
- break;
-
- case SLJIT_DSUB:
- FAIL_IF(push_inst(compiler, SELECT_FOP(op, FSUBS, FSUB) | FD(dst_r) | FA(src1) | FB(src2)));
- break;
-
- case SLJIT_DMUL:
- FAIL_IF(push_inst(compiler, SELECT_FOP(op, FMULS, FMUL) | FD(dst_r) | FA(src1) | FC(src2) /* FMUL use FC as src2 */));
- break;
-
- case SLJIT_DDIV:
- FAIL_IF(push_inst(compiler, SELECT_FOP(op, FDIVS, FDIV) | FD(dst_r) | FA(src1) | FB(src2)));
- break;
- }
-
- if (dst_r == TMP_FREG2)
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op), TMP_FREG2, dst, dstw, 0, 0));
-
- return SLJIT_SUCCESS;
-}
-
-#undef FLOAT_DATA
-#undef SELECT_FOP
-
-/* --------------------------------------------------------------------- */
-/* Other instructions */
-/* --------------------------------------------------------------------- */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
-{
- CHECK_ERROR();
- CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
- ADJUST_LOCAL_OFFSET(dst, dstw);
-
- /* For UNUSED dst. Uncommon, but possible. */
- if (dst == SLJIT_UNUSED)
- return SLJIT_SUCCESS;
-
- if (FAST_IS_REG(dst))
- return push_inst(compiler, MFLR | D(dst));
-
- /* Memory. */
- FAIL_IF(push_inst(compiler, MFLR | D(TMP_REG2)));
- return emit_op(compiler, SLJIT_MOV, WORD_DATA, dst, dstw, TMP_REG1, 0, TMP_REG2, 0);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
-{
- CHECK_ERROR();
- CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
- ADJUST_LOCAL_OFFSET(src, srcw);
-
- if (FAST_IS_REG(src))
- FAIL_IF(push_inst(compiler, MTLR | S(src)));
- else {
- if (src & SLJIT_MEM)
- FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, TMP_REG2, 0, TMP_REG1, 0, src, srcw));
- else if (src & SLJIT_IMM)
- FAIL_IF(load_immediate(compiler, TMP_REG2, srcw));
- FAIL_IF(push_inst(compiler, MTLR | S(TMP_REG2)));
- }
- return push_inst(compiler, BLR);
-}
-
-/* --------------------------------------------------------------------- */
-/* Conditional instructions */
-/* --------------------------------------------------------------------- */
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler)
-{
- struct sljit_label *label;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_emit_label(compiler));
-
- if (compiler->last_label && compiler->last_label->size == compiler->size)
- return compiler->last_label;
-
- label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label));
- PTR_FAIL_IF(!label);
- set_label(label, compiler);
- return label;
-}
-
-static sljit_ins get_bo_bi_flags(sljit_si type)
-{
- switch (type) {
- case SLJIT_EQUAL:
- return (12 << 21) | (2 << 16);
-
- case SLJIT_NOT_EQUAL:
- return (4 << 21) | (2 << 16);
-
- case SLJIT_LESS:
- case SLJIT_D_LESS:
- return (12 << 21) | ((4 + 0) << 16);
-
- case SLJIT_GREATER_EQUAL:
- case SLJIT_D_GREATER_EQUAL:
- return (4 << 21) | ((4 + 0) << 16);
-
- case SLJIT_GREATER:
- case SLJIT_D_GREATER:
- return (12 << 21) | ((4 + 1) << 16);
-
- case SLJIT_LESS_EQUAL:
- case SLJIT_D_LESS_EQUAL:
- return (4 << 21) | ((4 + 1) << 16);
-
- case SLJIT_SIG_LESS:
- return (12 << 21) | (0 << 16);
-
- case SLJIT_SIG_GREATER_EQUAL:
- return (4 << 21) | (0 << 16);
-
- case SLJIT_SIG_GREATER:
- return (12 << 21) | (1 << 16);
-
- case SLJIT_SIG_LESS_EQUAL:
- return (4 << 21) | (1 << 16);
-
- case SLJIT_OVERFLOW:
- case SLJIT_MUL_OVERFLOW:
- return (12 << 21) | (3 << 16);
-
- case SLJIT_NOT_OVERFLOW:
- case SLJIT_MUL_NOT_OVERFLOW:
- return (4 << 21) | (3 << 16);
-
- case SLJIT_D_EQUAL:
- return (12 << 21) | ((4 + 2) << 16);
-
- case SLJIT_D_NOT_EQUAL:
- return (4 << 21) | ((4 + 2) << 16);
-
- case SLJIT_D_UNORDERED:
- return (12 << 21) | ((4 + 3) << 16);
-
- case SLJIT_D_ORDERED:
- return (4 << 21) | ((4 + 3) << 16);
-
- default:
- SLJIT_ASSERT(type >= SLJIT_JUMP && type <= SLJIT_CALL3);
- return (20 << 21);
- }
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_si type)
-{
- struct sljit_jump *jump;
- sljit_ins bo_bi_flags;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_emit_jump(compiler, type));
-
- bo_bi_flags = get_bo_bi_flags(type & 0xff);
- if (!bo_bi_flags)
- return NULL;
-
- jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
- PTR_FAIL_IF(!jump);
- set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
- type &= 0xff;
-
- /* In PPC, we don't need to touch the arguments. */
- if (type < SLJIT_JUMP)
- jump->flags |= IS_COND;
-#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL)
- if (type >= SLJIT_CALL0)
- jump->flags |= IS_CALL;
-#endif
-
- PTR_FAIL_IF(emit_const(compiler, TMP_CALL_REG, 0));
- PTR_FAIL_IF(push_inst(compiler, MTCTR | S(TMP_CALL_REG)));
- jump->addr = compiler->size;
- PTR_FAIL_IF(push_inst(compiler, BCCTR | bo_bi_flags | (type >= SLJIT_FAST_CALL ? 1 : 0)));
- return jump;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, sljit_si src, sljit_sw srcw)
-{
- struct sljit_jump *jump = NULL;
- sljit_si src_r;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
- ADJUST_LOCAL_OFFSET(src, srcw);
-
- if (FAST_IS_REG(src)) {
-#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL)
- if (type >= SLJIT_CALL0) {
- FAIL_IF(push_inst(compiler, OR | S(src) | A(TMP_CALL_REG) | B(src)));
- src_r = TMP_CALL_REG;
- }
- else
- src_r = src;
-#else
- src_r = src;
-#endif
- } else if (src & SLJIT_IMM) {
- jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
- FAIL_IF(!jump);
- set_jump(jump, compiler, JUMP_ADDR);
- jump->u.target = srcw;
-#if (defined SLJIT_PASS_ENTRY_ADDR_TO_CALL && SLJIT_PASS_ENTRY_ADDR_TO_CALL)
- if (type >= SLJIT_CALL0)
- jump->flags |= IS_CALL;
-#endif
- FAIL_IF(emit_const(compiler, TMP_CALL_REG, 0));
- src_r = TMP_CALL_REG;
- }
- else {
- FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, TMP_CALL_REG, 0, TMP_REG1, 0, src, srcw));
- src_r = TMP_CALL_REG;
- }
-
- FAIL_IF(push_inst(compiler, MTCTR | S(src_r)));
- if (jump)
- jump->addr = compiler->size;
- return push_inst(compiler, BCCTR | (20 << 21) | (type >= SLJIT_FAST_CALL ? 1 : 0));
-}
-
-/* Get a bit from CR, all other bits are zeroed. */
-#define GET_CR_BIT(bit, dst) \
- FAIL_IF(push_inst(compiler, MFCR | D(dst))); \
- FAIL_IF(push_inst(compiler, RLWINM | S(dst) | A(dst) | ((1 + (bit)) << 11) | (31 << 6) | (31 << 1)));
-
-#define INVERT_BIT(dst) \
- FAIL_IF(push_inst(compiler, XORI | S(dst) | A(dst) | 0x1));
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw,
- sljit_si type)
-{
- sljit_si reg, input_flags;
- sljit_si flags = GET_ALL_FLAGS(op);
- sljit_sw original_dstw = dstw;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
- ADJUST_LOCAL_OFFSET(dst, dstw);
-
- if (dst == SLJIT_UNUSED)
- return SLJIT_SUCCESS;
-
- op = GET_OPCODE(op);
- reg = (op < SLJIT_ADD && FAST_IS_REG(dst)) ? dst : TMP_REG2;
-
- compiler->cache_arg = 0;
- compiler->cache_argw = 0;
- if (op >= SLJIT_ADD && (src & SLJIT_MEM)) {
- ADJUST_LOCAL_OFFSET(src, srcw);
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- input_flags = (flags & SLJIT_INT_OP) ? INT_DATA : WORD_DATA;
-#else
- input_flags = WORD_DATA;
-#endif
- FAIL_IF(emit_op_mem2(compiler, input_flags | LOAD_DATA, TMP_REG1, src, srcw, dst, dstw));
- src = TMP_REG1;
- srcw = 0;
- }
-
- switch (type & 0xff) {
- case SLJIT_EQUAL:
- GET_CR_BIT(2, reg);
- break;
-
- case SLJIT_NOT_EQUAL:
- GET_CR_BIT(2, reg);
- INVERT_BIT(reg);
- break;
-
- case SLJIT_LESS:
- case SLJIT_D_LESS:
- GET_CR_BIT(4 + 0, reg);
- break;
-
- case SLJIT_GREATER_EQUAL:
- case SLJIT_D_GREATER_EQUAL:
- GET_CR_BIT(4 + 0, reg);
- INVERT_BIT(reg);
- break;
-
- case SLJIT_GREATER:
- case SLJIT_D_GREATER:
- GET_CR_BIT(4 + 1, reg);
- break;
-
- case SLJIT_LESS_EQUAL:
- case SLJIT_D_LESS_EQUAL:
- GET_CR_BIT(4 + 1, reg);
- INVERT_BIT(reg);
- break;
-
- case SLJIT_SIG_LESS:
- GET_CR_BIT(0, reg);
- break;
-
- case SLJIT_SIG_GREATER_EQUAL:
- GET_CR_BIT(0, reg);
- INVERT_BIT(reg);
- break;
-
- case SLJIT_SIG_GREATER:
- GET_CR_BIT(1, reg);
- break;
-
- case SLJIT_SIG_LESS_EQUAL:
- GET_CR_BIT(1, reg);
- INVERT_BIT(reg);
- break;
-
- case SLJIT_OVERFLOW:
- case SLJIT_MUL_OVERFLOW:
- GET_CR_BIT(3, reg);
- break;
-
- case SLJIT_NOT_OVERFLOW:
- case SLJIT_MUL_NOT_OVERFLOW:
- GET_CR_BIT(3, reg);
- INVERT_BIT(reg);
- break;
-
- case SLJIT_D_EQUAL:
- GET_CR_BIT(4 + 2, reg);
- break;
-
- case SLJIT_D_NOT_EQUAL:
- GET_CR_BIT(4 + 2, reg);
- INVERT_BIT(reg);
- break;
-
- case SLJIT_D_UNORDERED:
- GET_CR_BIT(4 + 3, reg);
- break;
-
- case SLJIT_D_ORDERED:
- GET_CR_BIT(4 + 3, reg);
- INVERT_BIT(reg);
- break;
-
- default:
- SLJIT_ASSERT_STOP();
- break;
- }
-
- if (op < SLJIT_ADD) {
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
- if (op == SLJIT_MOV)
- input_flags = WORD_DATA;
- else {
- op = SLJIT_MOV_UI;
- input_flags = INT_DATA;
- }
-#else
- op = SLJIT_MOV;
- input_flags = WORD_DATA;
-#endif
- if (reg != TMP_REG2)
- return SLJIT_SUCCESS;
- return emit_op(compiler, op, input_flags, dst, dstw, TMP_REG1, 0, TMP_REG2, 0);
- }
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
- || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- compiler->skip_checks = 1;
-#endif
- return sljit_emit_op2(compiler, op | flags, dst, original_dstw, src, srcw, TMP_REG2, 0);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw init_value)
-{
- struct sljit_const *const_;
- sljit_si reg;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
- ADJUST_LOCAL_OFFSET(dst, dstw);
-
- const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
- PTR_FAIL_IF(!const_);
- set_const(const_, compiler);
-
- reg = SLOW_IS_REG(dst) ? dst : TMP_REG2;
-
- PTR_FAIL_IF(emit_const(compiler, reg, init_value));
-
- if (dst & SLJIT_MEM)
- PTR_FAIL_IF(emit_op(compiler, SLJIT_MOV, WORD_DATA, dst, dstw, TMP_REG1, 0, TMP_REG2, 0));
- return const_;
-}
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitNativeSPARC_32.c r-base-3.3.1/src/extra/pcre/sljit/sljitNativeSPARC_32.c
--- r-base-3.2.3/src/extra/pcre/sljit/sljitNativeSPARC_32.c 2014-11-12 23:15:05.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitNativeSPARC_32.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,164 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-static sljit_si load_immediate(struct sljit_compiler *compiler, sljit_si dst, sljit_sw imm)
-{
- if (imm <= SIMM_MAX && imm >= SIMM_MIN)
- return push_inst(compiler, OR | D(dst) | S1(0) | IMM(imm), DR(dst));
-
- FAIL_IF(push_inst(compiler, SETHI | D(dst) | ((imm >> 10) & 0x3fffff), DR(dst)));
- return (imm & 0x3ff) ? push_inst(compiler, OR | D(dst) | S1(dst) | IMM_ARG | (imm & 0x3ff), DR(dst)) : SLJIT_SUCCESS;
-}
-
-#define ARG2(flags, src2) ((flags & SRC2_IMM) ? IMM(src2) : S2(src2))
-
-static SLJIT_INLINE sljit_si emit_single_op(struct sljit_compiler *compiler, sljit_si op, sljit_si flags,
- sljit_si dst, sljit_si src1, sljit_sw src2)
-{
- SLJIT_COMPILE_ASSERT(ICC_IS_SET == SET_FLAGS, icc_is_set_and_set_flags_must_be_the_same);
-
- switch (op) {
- case SLJIT_MOV:
- case SLJIT_MOV_UI:
- case SLJIT_MOV_SI:
- case SLJIT_MOV_P:
- SLJIT_ASSERT(src1 == TMP_REG1 && !(flags & SRC2_IMM));
- if (dst != src2)
- return push_inst(compiler, OR | D(dst) | S1(0) | S2(src2), DR(dst));
- return SLJIT_SUCCESS;
-
- case SLJIT_MOV_UB:
- case SLJIT_MOV_SB:
- SLJIT_ASSERT(src1 == TMP_REG1 && !(flags & SRC2_IMM));
- if ((flags & (REG_DEST | REG2_SOURCE)) == (REG_DEST | REG2_SOURCE)) {
- if (op == SLJIT_MOV_UB)
- return push_inst(compiler, AND | D(dst) | S1(src2) | IMM(0xff), DR(dst));
- FAIL_IF(push_inst(compiler, SLL | D(dst) | S1(src2) | IMM(24), DR(dst)));
- return push_inst(compiler, SRA | D(dst) | S1(dst) | IMM(24), DR(dst));
- }
- else if (dst != src2)
- SLJIT_ASSERT_STOP();
- return SLJIT_SUCCESS;
-
- case SLJIT_MOV_UH:
- case SLJIT_MOV_SH:
- SLJIT_ASSERT(src1 == TMP_REG1 && !(flags & SRC2_IMM));
- if ((flags & (REG_DEST | REG2_SOURCE)) == (REG_DEST | REG2_SOURCE)) {
- FAIL_IF(push_inst(compiler, SLL | D(dst) | S1(src2) | IMM(16), DR(dst)));
- return push_inst(compiler, (op == SLJIT_MOV_SH ? SRA : SRL) | D(dst) | S1(dst) | IMM(16), DR(dst));
- }
- else if (dst != src2)
- SLJIT_ASSERT_STOP();
- return SLJIT_SUCCESS;
-
- case SLJIT_NOT:
- SLJIT_ASSERT(src1 == TMP_REG1 && !(flags & SRC2_IMM));
- return push_inst(compiler, XNOR | (flags & SET_FLAGS) | D(dst) | S1(0) | S2(src2), DR(dst) | (flags & SET_FLAGS));
-
- case SLJIT_CLZ:
- SLJIT_ASSERT(src1 == TMP_REG1 && !(flags & SRC2_IMM));
- /* sparc 32 does not support SLJIT_KEEP_FLAGS. Not sure I can fix this. */
- FAIL_IF(push_inst(compiler, SUB | SET_FLAGS | D(0) | S1(src2) | S2(0), SET_FLAGS));
- FAIL_IF(push_inst(compiler, OR | D(TMP_REG1) | S1(0) | S2(src2), DR(TMP_REG1)));
- FAIL_IF(push_inst(compiler, BICC | DA(0x1) | (7 & DISP_MASK), UNMOVABLE_INS));
- FAIL_IF(push_inst(compiler, OR | (flags & SET_FLAGS) | D(dst) | S1(0) | IMM(32), UNMOVABLE_INS | (flags & SET_FLAGS)));
- FAIL_IF(push_inst(compiler, OR | D(dst) | S1(0) | IMM(-1), DR(dst)));
-
- /* Loop. */
- FAIL_IF(push_inst(compiler, SUB | SET_FLAGS | D(0) | S1(TMP_REG1) | S2(0), SET_FLAGS));
- FAIL_IF(push_inst(compiler, SLL | D(TMP_REG1) | S1(TMP_REG1) | IMM(1), DR(TMP_REG1)));
- FAIL_IF(push_inst(compiler, BICC | DA(0xe) | (-2 & DISP_MASK), UNMOVABLE_INS));
- return push_inst(compiler, ADD | (flags & SET_FLAGS) | D(dst) | S1(dst) | IMM(1), UNMOVABLE_INS | (flags & SET_FLAGS));
-
- case SLJIT_ADD:
- return push_inst(compiler, ADD | (flags & SET_FLAGS) | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst) | (flags & SET_FLAGS));
-
- case SLJIT_ADDC:
- return push_inst(compiler, ADDC | (flags & SET_FLAGS) | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst) | (flags & SET_FLAGS));
-
- case SLJIT_SUB:
- return push_inst(compiler, SUB | (flags & SET_FLAGS) | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst) | (flags & SET_FLAGS));
-
- case SLJIT_SUBC:
- return push_inst(compiler, SUBC | (flags & SET_FLAGS) | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst) | (flags & SET_FLAGS));
-
- case SLJIT_MUL:
- FAIL_IF(push_inst(compiler, SMUL | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst)));
- if (!(flags & SET_FLAGS))
- return SLJIT_SUCCESS;
- FAIL_IF(push_inst(compiler, SRA | D(TMP_REG1) | S1(dst) | IMM(31), DR(TMP_REG1)));
- FAIL_IF(push_inst(compiler, RDY | D(TMP_LINK), DR(TMP_LINK)));
- return push_inst(compiler, SUB | SET_FLAGS | D(0) | S1(TMP_REG1) | S2(TMP_LINK), MOVABLE_INS | SET_FLAGS);
-
- case SLJIT_AND:
- return push_inst(compiler, AND | (flags & SET_FLAGS) | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst) | (flags & SET_FLAGS));
-
- case SLJIT_OR:
- return push_inst(compiler, OR | (flags & SET_FLAGS) | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst) | (flags & SET_FLAGS));
-
- case SLJIT_XOR:
- return push_inst(compiler, XOR | (flags & SET_FLAGS) | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst) | (flags & SET_FLAGS));
-
- case SLJIT_SHL:
- FAIL_IF(push_inst(compiler, SLL | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst)));
- return !(flags & SET_FLAGS) ? SLJIT_SUCCESS : push_inst(compiler, SUB | SET_FLAGS | D(0) | S1(dst) | S2(0), SET_FLAGS);
-
- case SLJIT_LSHR:
- FAIL_IF(push_inst(compiler, SRL | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst)));
- return !(flags & SET_FLAGS) ? SLJIT_SUCCESS : push_inst(compiler, SUB | SET_FLAGS | D(0) | S1(dst) | S2(0), SET_FLAGS);
-
- case SLJIT_ASHR:
- FAIL_IF(push_inst(compiler, SRA | D(dst) | S1(src1) | ARG2(flags, src2), DR(dst)));
- return !(flags & SET_FLAGS) ? SLJIT_SUCCESS : push_inst(compiler, SUB | SET_FLAGS | D(0) | S1(dst) | S2(0), SET_FLAGS);
- }
-
- SLJIT_ASSERT_STOP();
- return SLJIT_SUCCESS;
-}
-
-static SLJIT_INLINE sljit_si emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw init_value)
-{
- FAIL_IF(push_inst(compiler, SETHI | D(dst) | ((init_value >> 10) & 0x3fffff), DR(dst)));
- return push_inst(compiler, OR | D(dst) | S1(dst) | IMM_ARG | (init_value & 0x3ff), DR(dst));
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr)
-{
- sljit_ins *inst = (sljit_ins*)addr;
-
- inst[0] = (inst[0] & 0xffc00000) | ((new_addr >> 10) & 0x3fffff);
- inst[1] = (inst[1] & 0xfffffc00) | (new_addr & 0x3ff);
- SLJIT_CACHE_FLUSH(inst, inst + 2);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant)
-{
- sljit_ins *inst = (sljit_ins*)addr;
-
- inst[0] = (inst[0] & 0xffc00000) | ((new_constant >> 10) & 0x3fffff);
- inst[1] = (inst[1] & 0xfffffc00) | (new_constant & 0x3ff);
- SLJIT_CACHE_FLUSH(inst, inst + 2);
-}
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitNativeSPARC_common.c r-base-3.3.1/src/extra/pcre/sljit/sljitNativeSPARC_common.c
--- r-base-3.2.3/src/extra/pcre/sljit/sljitNativeSPARC_common.c 2015-11-26 23:15:10.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitNativeSPARC_common.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,1435 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void)
-{
- return "SPARC" SLJIT_CPUINFO;
-}
-
-/* Length of an instruction word
- Both for sparc-32 and sparc-64 */
-typedef sljit_ui sljit_ins;
-
-static void sparc_cache_flush(sljit_ins *from, sljit_ins *to)
-{
-#if defined(__SUNPRO_C) && __SUNPRO_C < 0x590
- __asm (
- /* if (from == to) return */
- "cmp %i0, %i1\n"
- "be .leave\n"
- "nop\n"
-
- /* loop until from >= to */
- ".mainloop:\n"
- "flush %i0\n"
- "add %i0, 8, %i0\n"
- "cmp %i0, %i1\n"
- "bcs .mainloop\n"
- "nop\n"
-
- /* The comparison was done above. */
- "bne .leave\n"
- /* nop is not necessary here, since the
- sub operation has no side effect. */
- "sub %i0, 4, %i0\n"
- "flush %i0\n"
- ".leave:"
- );
-#else
- if (SLJIT_UNLIKELY(from == to))
- return;
-
- do {
- __asm__ volatile (
- "flush %0\n"
- : : "r"(from)
- );
- /* Operates at least on doubleword. */
- from += 2;
- } while (from < to);
-
- if (from == to) {
- /* Flush the last word. */
- from --;
- __asm__ volatile (
- "flush %0\n"
- : : "r"(from)
- );
- }
-#endif
-}
-
-/* TMP_REG2 is not used by getput_arg */
-#define TMP_REG1 (SLJIT_NUMBER_OF_REGISTERS + 2)
-#define TMP_REG2 (SLJIT_NUMBER_OF_REGISTERS + 3)
-#define TMP_REG3 (SLJIT_NUMBER_OF_REGISTERS + 4)
-#define TMP_LINK (SLJIT_NUMBER_OF_REGISTERS + 5)
-
-#define TMP_FREG1 (0)
-#define TMP_FREG2 ((SLJIT_NUMBER_OF_FLOAT_REGISTERS + 1) << 1)
-
-static SLJIT_CONST sljit_ub reg_map[SLJIT_NUMBER_OF_REGISTERS + 6] = {
- 0, 8, 9, 10, 13, 29, 28, 27, 23, 22, 21, 20, 19, 18, 17, 16, 26, 25, 24, 14, 1, 11, 12, 15
-};
-
-/* --------------------------------------------------------------------- */
-/* Instrucion forms */
-/* --------------------------------------------------------------------- */
-
-#define D(d) (reg_map[d] << 25)
-#define DA(d) ((d) << 25)
-#define S1(s1) (reg_map[s1] << 14)
-#define S2(s2) (reg_map[s2])
-#define S1A(s1) ((s1) << 14)
-#define S2A(s2) (s2)
-#define IMM_ARG 0x2000
-#define DOP(op) ((op) << 5)
-#define IMM(imm) (((imm) & 0x1fff) | IMM_ARG)
-
-#define DR(dr) (reg_map[dr])
-#define OPC1(opcode) ((opcode) << 30)
-#define OPC2(opcode) ((opcode) << 22)
-#define OPC3(opcode) ((opcode) << 19)
-#define SET_FLAGS OPC3(0x10)
-
-#define ADD (OPC1(0x2) | OPC3(0x00))
-#define ADDC (OPC1(0x2) | OPC3(0x08))
-#define AND (OPC1(0x2) | OPC3(0x01))
-#define ANDN (OPC1(0x2) | OPC3(0x05))
-#define CALL (OPC1(0x1))
-#define FABSS (OPC1(0x2) | OPC3(0x34) | DOP(0x09))
-#define FADDD (OPC1(0x2) | OPC3(0x34) | DOP(0x42))
-#define FADDS (OPC1(0x2) | OPC3(0x34) | DOP(0x41))
-#define FCMPD (OPC1(0x2) | OPC3(0x35) | DOP(0x52))
-#define FCMPS (OPC1(0x2) | OPC3(0x35) | DOP(0x51))
-#define FDIVD (OPC1(0x2) | OPC3(0x34) | DOP(0x4e))
-#define FDIVS (OPC1(0x2) | OPC3(0x34) | DOP(0x4d))
-#define FDTOI (OPC1(0x2) | OPC3(0x34) | DOP(0xd2))
-#define FDTOS (OPC1(0x2) | OPC3(0x34) | DOP(0xc6))
-#define FITOD (OPC1(0x2) | OPC3(0x34) | DOP(0xc8))
-#define FITOS (OPC1(0x2) | OPC3(0x34) | DOP(0xc4))
-#define FMOVS (OPC1(0x2) | OPC3(0x34) | DOP(0x01))
-#define FMULD (OPC1(0x2) | OPC3(0x34) | DOP(0x4a))
-#define FMULS (OPC1(0x2) | OPC3(0x34) | DOP(0x49))
-#define FNEGS (OPC1(0x2) | OPC3(0x34) | DOP(0x05))
-#define FSTOD (OPC1(0x2) | OPC3(0x34) | DOP(0xc9))
-#define FSTOI (OPC1(0x2) | OPC3(0x34) | DOP(0xd1))
-#define FSUBD (OPC1(0x2) | OPC3(0x34) | DOP(0x46))
-#define FSUBS (OPC1(0x2) | OPC3(0x34) | DOP(0x45))
-#define JMPL (OPC1(0x2) | OPC3(0x38))
-#define NOP (OPC1(0x0) | OPC2(0x04))
-#define OR (OPC1(0x2) | OPC3(0x02))
-#define ORN (OPC1(0x2) | OPC3(0x06))
-#define RDY (OPC1(0x2) | OPC3(0x28) | S1A(0))
-#define RESTORE (OPC1(0x2) | OPC3(0x3d))
-#define SAVE (OPC1(0x2) | OPC3(0x3c))
-#define SETHI (OPC1(0x0) | OPC2(0x04))
-#define SLL (OPC1(0x2) | OPC3(0x25))
-#define SLLX (OPC1(0x2) | OPC3(0x25) | (1 << 12))
-#define SRA (OPC1(0x2) | OPC3(0x27))
-#define SRAX (OPC1(0x2) | OPC3(0x27) | (1 << 12))
-#define SRL (OPC1(0x2) | OPC3(0x26))
-#define SRLX (OPC1(0x2) | OPC3(0x26) | (1 << 12))
-#define SUB (OPC1(0x2) | OPC3(0x04))
-#define SUBC (OPC1(0x2) | OPC3(0x0c))
-#define TA (OPC1(0x2) | OPC3(0x3a) | (8 << 25))
-#define WRY (OPC1(0x2) | OPC3(0x30) | DA(0))
-#define XOR (OPC1(0x2) | OPC3(0x03))
-#define XNOR (OPC1(0x2) | OPC3(0x07))
-
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
-#define MAX_DISP (0x1fffff)
-#define MIN_DISP (-0x200000)
-#define DISP_MASK (0x3fffff)
-
-#define BICC (OPC1(0x0) | OPC2(0x2))
-#define FBFCC (OPC1(0x0) | OPC2(0x6))
-#define SLL_W SLL
-#define SDIV (OPC1(0x2) | OPC3(0x0f))
-#define SMUL (OPC1(0x2) | OPC3(0x0b))
-#define UDIV (OPC1(0x2) | OPC3(0x0e))
-#define UMUL (OPC1(0x2) | OPC3(0x0a))
-#else
-#define SLL_W SLLX
-#endif
-
-#define SIMM_MAX (0x0fff)
-#define SIMM_MIN (-0x1000)
-
-/* dest_reg is the absolute name of the register
- Useful for reordering instructions in the delay slot. */
-static sljit_si push_inst(struct sljit_compiler *compiler, sljit_ins ins, sljit_si delay_slot)
-{
- sljit_ins *ptr;
- SLJIT_ASSERT((delay_slot & DST_INS_MASK) == UNMOVABLE_INS
- || (delay_slot & DST_INS_MASK) == MOVABLE_INS
- || (delay_slot & DST_INS_MASK) == ((ins >> 25) & 0x1f));
- ptr = (sljit_ins*)ensure_buf(compiler, sizeof(sljit_ins));
- FAIL_IF(!ptr);
- *ptr = ins;
- compiler->size++;
- compiler->delay_slot = delay_slot;
- return SLJIT_SUCCESS;
-}
-
-static SLJIT_INLINE sljit_ins* detect_jump_type(struct sljit_jump *jump, sljit_ins *code_ptr, sljit_ins *code)
-{
- sljit_sw diff;
- sljit_uw target_addr;
- sljit_ins *inst;
- sljit_ins saved_inst;
-
- if (jump->flags & SLJIT_REWRITABLE_JUMP)
- return code_ptr;
-
- if (jump->flags & JUMP_ADDR)
- target_addr = jump->u.target;
- else {
- SLJIT_ASSERT(jump->flags & JUMP_LABEL);
- target_addr = (sljit_uw)(code + jump->u.label->size);
- }
- inst = (sljit_ins*)jump->addr;
-
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- if (jump->flags & IS_CALL) {
- /* Call is always patchable on sparc 32. */
- jump->flags |= PATCH_CALL;
- if (jump->flags & IS_MOVABLE) {
- inst[0] = inst[-1];
- inst[-1] = CALL;
- jump->addr -= sizeof(sljit_ins);
- return inst;
- }
- inst[0] = CALL;
- inst[1] = NOP;
- return inst + 1;
- }
-#else
- /* Both calls and BPr instructions shall not pass this point. */
-#error "Implementation required"
-#endif
-
- if (jump->flags & IS_COND)
- inst--;
-
- if (jump->flags & IS_MOVABLE) {
- diff = ((sljit_sw)target_addr - (sljit_sw)(inst - 1)) >> 2;
- if (diff <= MAX_DISP && diff >= MIN_DISP) {
- jump->flags |= PATCH_B;
- inst--;
- if (jump->flags & IS_COND) {
- saved_inst = inst[0];
- inst[0] = inst[1] ^ (1 << 28);
- inst[1] = saved_inst;
- } else {
- inst[1] = inst[0];
- inst[0] = BICC | DA(0x8);
- }
- jump->addr = (sljit_uw)inst;
- return inst + 1;
- }
- }
-
- diff = ((sljit_sw)target_addr - (sljit_sw)(inst)) >> 2;
- if (diff <= MAX_DISP && diff >= MIN_DISP) {
- jump->flags |= PATCH_B;
- if (jump->flags & IS_COND)
- inst[0] ^= (1 << 28);
- else
- inst[0] = BICC | DA(0x8);
- inst[1] = NOP;
- jump->addr = (sljit_uw)inst;
- return inst + 1;
- }
-
- return code_ptr;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler)
-{
- struct sljit_memory_fragment *buf;
- sljit_ins *code;
- sljit_ins *code_ptr;
- sljit_ins *buf_ptr;
- sljit_ins *buf_end;
- sljit_uw word_count;
- sljit_uw addr;
-
- struct sljit_label *label;
- struct sljit_jump *jump;
- struct sljit_const *const_;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_generate_code(compiler));
- reverse_buf(compiler);
-
- code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
- PTR_FAIL_WITH_EXEC_IF(code);
- buf = compiler->buf;
-
- code_ptr = code;
- word_count = 0;
- label = compiler->labels;
- jump = compiler->jumps;
- const_ = compiler->consts;
- do {
- buf_ptr = (sljit_ins*)buf->memory;
- buf_end = buf_ptr + (buf->used_size >> 2);
- do {
- *code_ptr = *buf_ptr++;
- SLJIT_ASSERT(!label || label->size >= word_count);
- SLJIT_ASSERT(!jump || jump->addr >= word_count);
- SLJIT_ASSERT(!const_ || const_->addr >= word_count);
- /* These structures are ordered by their address. */
- if (label && label->size == word_count) {
- /* Just recording the address. */
- label->addr = (sljit_uw)code_ptr;
- label->size = code_ptr - code;
- label = label->next;
- }
- if (jump && jump->addr == word_count) {
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- jump->addr = (sljit_uw)(code_ptr - 3);
-#else
- jump->addr = (sljit_uw)(code_ptr - 6);
-#endif
- code_ptr = detect_jump_type(jump, code_ptr, code);
- jump = jump->next;
- }
- if (const_ && const_->addr == word_count) {
- /* Just recording the address. */
- const_->addr = (sljit_uw)code_ptr;
- const_ = const_->next;
- }
- code_ptr ++;
- word_count ++;
- } while (buf_ptr < buf_end);
-
- buf = buf->next;
- } while (buf);
-
- if (label && label->size == word_count) {
- label->addr = (sljit_uw)code_ptr;
- label->size = code_ptr - code;
- label = label->next;
- }
-
- SLJIT_ASSERT(!label);
- SLJIT_ASSERT(!jump);
- SLJIT_ASSERT(!const_);
- SLJIT_ASSERT(code_ptr - code <= (sljit_si)compiler->size);
-
- jump = compiler->jumps;
- while (jump) {
- do {
- addr = (jump->flags & JUMP_LABEL) ? jump->u.label->addr : jump->u.target;
- buf_ptr = (sljit_ins*)jump->addr;
-
- if (jump->flags & PATCH_CALL) {
- addr = (sljit_sw)(addr - jump->addr) >> 2;
- SLJIT_ASSERT((sljit_sw)addr <= 0x1fffffff && (sljit_sw)addr >= -0x20000000);
- buf_ptr[0] = CALL | (addr & 0x3fffffff);
- break;
- }
- if (jump->flags & PATCH_B) {
- addr = (sljit_sw)(addr - jump->addr) >> 2;
- SLJIT_ASSERT((sljit_sw)addr <= MAX_DISP && (sljit_sw)addr >= MIN_DISP);
- buf_ptr[0] = (buf_ptr[0] & ~DISP_MASK) | (addr & DISP_MASK);
- break;
- }
-
- /* Set the fields of immediate loads. */
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- buf_ptr[0] = (buf_ptr[0] & 0xffc00000) | ((addr >> 10) & 0x3fffff);
- buf_ptr[1] = (buf_ptr[1] & 0xfffffc00) | (addr & 0x3ff);
-#else
-#error "Implementation required"
-#endif
- } while (0);
- jump = jump->next;
- }
-
-
- compiler->error = SLJIT_ERR_COMPILED;
- compiler->executable_size = (code_ptr - code) * sizeof(sljit_ins);
- SLJIT_CACHE_FLUSH(code, code_ptr);
- return code;
-}
-
-/* --------------------------------------------------------------------- */
-/* Entry, exit */
-/* --------------------------------------------------------------------- */
-
-/* Creates an index in data_transfer_insts array. */
-#define LOAD_DATA 0x01
-#define WORD_DATA 0x00
-#define BYTE_DATA 0x02
-#define HALF_DATA 0x04
-#define INT_DATA 0x06
-#define SIGNED_DATA 0x08
-/* Separates integer and floating point registers */
-#define GPR_REG 0x0f
-#define DOUBLE_DATA 0x10
-#define SINGLE_DATA 0x12
-
-#define MEM_MASK 0x1f
-
-#define WRITE_BACK 0x00020
-#define ARG_TEST 0x00040
-#define ALT_KEEP_CACHE 0x00080
-#define CUMULATIVE_OP 0x00100
-#define IMM_OP 0x00200
-#define SRC2_IMM 0x00400
-
-#define REG_DEST 0x00800
-#define REG2_SOURCE 0x01000
-#define SLOW_SRC1 0x02000
-#define SLOW_SRC2 0x04000
-#define SLOW_DEST 0x08000
-
-/* SET_FLAGS (0x10 << 19) also belong here! */
-
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
-#include "sljitNativeSPARC_32.c"
-#else
-#include "sljitNativeSPARC_64.c"
-#endif
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- CHECK_ERROR();
- CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
- set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- local_size = (local_size + SLJIT_LOCALS_OFFSET + 7) & ~0x7;
- compiler->local_size = local_size;
-
- if (local_size <= SIMM_MAX) {
- FAIL_IF(push_inst(compiler, SAVE | D(SLJIT_SP) | S1(SLJIT_SP) | IMM(-local_size), UNMOVABLE_INS));
- }
- else {
- FAIL_IF(load_immediate(compiler, TMP_REG1, -local_size));
- FAIL_IF(push_inst(compiler, SAVE | D(SLJIT_SP) | S1(SLJIT_SP) | S2(TMP_REG1), UNMOVABLE_INS));
- }
-
- /* Arguments are in their appropriate registers. */
-
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- CHECK_ERROR();
- CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
- set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->local_size = (local_size + SLJIT_LOCALS_OFFSET + 7) & ~0x7;
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
-{
- CHECK_ERROR();
- CHECK(check_sljit_emit_return(compiler, op, src, srcw));
-
- if (op != SLJIT_MOV || !FAST_IS_REG(src)) {
- FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
- src = SLJIT_R0;
- }
-
- FAIL_IF(push_inst(compiler, JMPL | D(0) | S1A(31) | IMM(8), UNMOVABLE_INS));
- return push_inst(compiler, RESTORE | D(SLJIT_R0) | S1(src) | S2(0), UNMOVABLE_INS);
-}
-
-/* --------------------------------------------------------------------- */
-/* Operators */
-/* --------------------------------------------------------------------- */
-
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
-#define ARCH_32_64(a, b) a
-#else
-#define ARCH_32_64(a, b) b
-#endif
-
-static SLJIT_CONST sljit_ins data_transfer_insts[16 + 4] = {
-/* u w s */ ARCH_32_64(OPC1(3) | OPC3(0x04) /* stw */, OPC1(3) | OPC3(0x0e) /* stx */),
-/* u w l */ ARCH_32_64(OPC1(3) | OPC3(0x00) /* lduw */, OPC1(3) | OPC3(0x0b) /* ldx */),
-/* u b s */ OPC1(3) | OPC3(0x05) /* stb */,
-/* u b l */ OPC1(3) | OPC3(0x01) /* ldub */,
-/* u h s */ OPC1(3) | OPC3(0x06) /* sth */,
-/* u h l */ OPC1(3) | OPC3(0x02) /* lduh */,
-/* u i s */ OPC1(3) | OPC3(0x04) /* stw */,
-/* u i l */ OPC1(3) | OPC3(0x00) /* lduw */,
-
-/* s w s */ ARCH_32_64(OPC1(3) | OPC3(0x04) /* stw */, OPC1(3) | OPC3(0x0e) /* stx */),
-/* s w l */ ARCH_32_64(OPC1(3) | OPC3(0x00) /* lduw */, OPC1(3) | OPC3(0x0b) /* ldx */),
-/* s b s */ OPC1(3) | OPC3(0x05) /* stb */,
-/* s b l */ OPC1(3) | OPC3(0x09) /* ldsb */,
-/* s h s */ OPC1(3) | OPC3(0x06) /* sth */,
-/* s h l */ OPC1(3) | OPC3(0x0a) /* ldsh */,
-/* s i s */ OPC1(3) | OPC3(0x04) /* stw */,
-/* s i l */ ARCH_32_64(OPC1(3) | OPC3(0x00) /* lduw */, OPC1(3) | OPC3(0x08) /* ldsw */),
-
-/* d s */ OPC1(3) | OPC3(0x27),
-/* d l */ OPC1(3) | OPC3(0x23),
-/* s s */ OPC1(3) | OPC3(0x24),
-/* s l */ OPC1(3) | OPC3(0x20),
-};
-
-#undef ARCH_32_64
-
-/* Can perform an operation using at most 1 instruction. */
-static sljit_si getput_arg_fast(struct sljit_compiler *compiler, sljit_si flags, sljit_si reg, sljit_si arg, sljit_sw argw)
-{
- SLJIT_ASSERT(arg & SLJIT_MEM);
-
- if (!(flags & WRITE_BACK) || !(arg & REG_MASK)) {
- if ((!(arg & OFFS_REG_MASK) && argw <= SIMM_MAX && argw >= SIMM_MIN)
- || ((arg & OFFS_REG_MASK) && (argw & 0x3) == 0)) {
- /* Works for both absoulte and relative addresses (immediate case). */
- if (SLJIT_UNLIKELY(flags & ARG_TEST))
- return 1;
- FAIL_IF(push_inst(compiler, data_transfer_insts[flags & MEM_MASK]
- | ((flags & MEM_MASK) <= GPR_REG ? D(reg) : DA(reg))
- | S1(arg & REG_MASK) | ((arg & OFFS_REG_MASK) ? S2(OFFS_REG(arg)) : IMM(argw)),
- ((flags & MEM_MASK) <= GPR_REG && (flags & LOAD_DATA)) ? DR(reg) : MOVABLE_INS));
- return -1;
- }
- }
- return 0;
-}
-
-/* See getput_arg below.
- Note: can_cache is called only for binary operators. Those
- operators always uses word arguments without write back. */
-static sljit_si can_cache(sljit_si arg, sljit_sw argw, sljit_si next_arg, sljit_sw next_argw)
-{
- SLJIT_ASSERT((arg & SLJIT_MEM) && (next_arg & SLJIT_MEM));
-
- /* Simple operation except for updates. */
- if (arg & OFFS_REG_MASK) {
- argw &= 0x3;
- SLJIT_ASSERT(argw);
- next_argw &= 0x3;
- if ((arg & OFFS_REG_MASK) == (next_arg & OFFS_REG_MASK) && argw == next_argw)
- return 1;
- return 0;
- }
-
- if (((next_argw - argw) <= SIMM_MAX && (next_argw - argw) >= SIMM_MIN))
- return 1;
- return 0;
-}
-
-/* Emit the necessary instructions. See can_cache above. */
-static sljit_si getput_arg(struct sljit_compiler *compiler, sljit_si flags, sljit_si reg, sljit_si arg, sljit_sw argw, sljit_si next_arg, sljit_sw next_argw)
-{
- sljit_si base, arg2, delay_slot;
- sljit_ins dest;
-
- SLJIT_ASSERT(arg & SLJIT_MEM);
- if (!(next_arg & SLJIT_MEM)) {
- next_arg = 0;
- next_argw = 0;
- }
-
- base = arg & REG_MASK;
- if (SLJIT_UNLIKELY(arg & OFFS_REG_MASK)) {
- argw &= 0x3;
- SLJIT_ASSERT(argw != 0);
-
- /* Using the cache. */
- if (((SLJIT_MEM | (arg & OFFS_REG_MASK)) == compiler->cache_arg) && (argw == compiler->cache_argw))
- arg2 = TMP_REG3;
- else {
- if ((arg & OFFS_REG_MASK) == (next_arg & OFFS_REG_MASK) && argw == (next_argw & 0x3)) {
- compiler->cache_arg = SLJIT_MEM | (arg & OFFS_REG_MASK);
- compiler->cache_argw = argw;
- arg2 = TMP_REG3;
- }
- else if ((flags & LOAD_DATA) && ((flags & MEM_MASK) <= GPR_REG) && reg != base && reg != OFFS_REG(arg))
- arg2 = reg;
- else /* It must be a mov operation, so tmp1 must be free to use. */
- arg2 = TMP_REG1;
- FAIL_IF(push_inst(compiler, SLL_W | D(arg2) | S1(OFFS_REG(arg)) | IMM_ARG | argw, DR(arg2)));
- }
- }
- else {
- /* Using the cache. */
- if ((compiler->cache_arg == SLJIT_MEM) && (argw - compiler->cache_argw) <= SIMM_MAX && (argw - compiler->cache_argw) >= SIMM_MIN) {
- if (argw != compiler->cache_argw) {
- FAIL_IF(push_inst(compiler, ADD | D(TMP_REG3) | S1(TMP_REG3) | IMM(argw - compiler->cache_argw), DR(TMP_REG3)));
- compiler->cache_argw = argw;
- }
- arg2 = TMP_REG3;
- } else {
- if ((next_argw - argw) <= SIMM_MAX && (next_argw - argw) >= SIMM_MIN) {
- compiler->cache_arg = SLJIT_MEM;
- compiler->cache_argw = argw;
- arg2 = TMP_REG3;
- }
- else if ((flags & LOAD_DATA) && ((flags & MEM_MASK) <= GPR_REG) && reg != base)
- arg2 = reg;
- else /* It must be a mov operation, so tmp1 must be free to use. */
- arg2 = TMP_REG1;
- FAIL_IF(load_immediate(compiler, arg2, argw));
- }
- }
-
- dest = ((flags & MEM_MASK) <= GPR_REG ? D(reg) : DA(reg));
- delay_slot = ((flags & MEM_MASK) <= GPR_REG && (flags & LOAD_DATA)) ? DR(reg) : MOVABLE_INS;
- if (!base)
- return push_inst(compiler, data_transfer_insts[flags & MEM_MASK] | dest | S1(arg2) | IMM(0), delay_slot);
- if (!(flags & WRITE_BACK))
- return push_inst(compiler, data_transfer_insts[flags & MEM_MASK] | dest | S1(base) | S2(arg2), delay_slot);
- FAIL_IF(push_inst(compiler, data_transfer_insts[flags & MEM_MASK] | dest | S1(base) | S2(arg2), delay_slot));
- return push_inst(compiler, ADD | D(base) | S1(base) | S2(arg2), DR(base));
-}
-
-static SLJIT_INLINE sljit_si emit_op_mem(struct sljit_compiler *compiler, sljit_si flags, sljit_si reg, sljit_si arg, sljit_sw argw)
-{
- if (getput_arg_fast(compiler, flags, reg, arg, argw))
- return compiler->error;
- compiler->cache_arg = 0;
- compiler->cache_argw = 0;
- return getput_arg(compiler, flags, reg, arg, argw, 0, 0);
-}
-
-static SLJIT_INLINE sljit_si emit_op_mem2(struct sljit_compiler *compiler, sljit_si flags, sljit_si reg, sljit_si arg1, sljit_sw arg1w, sljit_si arg2, sljit_sw arg2w)
-{
- if (getput_arg_fast(compiler, flags, reg, arg1, arg1w))
- return compiler->error;
- return getput_arg(compiler, flags, reg, arg1, arg1w, arg2, arg2w);
-}
-
-static sljit_si emit_op(struct sljit_compiler *compiler, sljit_si op, sljit_si flags,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- /* arg1 goes to TMP_REG1 or src reg
- arg2 goes to TMP_REG2, imm or src reg
- TMP_REG3 can be used for caching
- result goes to TMP_REG2, so put result can use TMP_REG1 and TMP_REG3. */
- sljit_si dst_r = TMP_REG2;
- sljit_si src1_r;
- sljit_sw src2_r = 0;
- sljit_si sugg_src2_r = TMP_REG2;
-
- if (!(flags & ALT_KEEP_CACHE)) {
- compiler->cache_arg = 0;
- compiler->cache_argw = 0;
- }
-
- if (SLJIT_UNLIKELY(dst == SLJIT_UNUSED)) {
- if (op >= SLJIT_MOV && op <= SLJIT_MOVU_SI && !(src2 & SLJIT_MEM))
- return SLJIT_SUCCESS;
- }
- else if (FAST_IS_REG(dst)) {
- dst_r = dst;
- flags |= REG_DEST;
- if (op >= SLJIT_MOV && op <= SLJIT_MOVU_SI)
- sugg_src2_r = dst_r;
- }
- else if ((dst & SLJIT_MEM) && !getput_arg_fast(compiler, flags | ARG_TEST, TMP_REG1, dst, dstw))
- flags |= SLOW_DEST;
-
- if (flags & IMM_OP) {
- if ((src2 & SLJIT_IMM) && src2w) {
- if (src2w <= SIMM_MAX && src2w >= SIMM_MIN) {
- flags |= SRC2_IMM;
- src2_r = src2w;
- }
- }
- if (!(flags & SRC2_IMM) && (flags & CUMULATIVE_OP) && (src1 & SLJIT_IMM) && src1w) {
- if (src1w <= SIMM_MAX && src1w >= SIMM_MIN) {
- flags |= SRC2_IMM;
- src2_r = src1w;
-
- /* And swap arguments. */
- src1 = src2;
- src1w = src2w;
- src2 = SLJIT_IMM;
- /* src2w = src2_r unneeded. */
- }
- }
- }
-
- /* Source 1. */
- if (FAST_IS_REG(src1))
- src1_r = src1;
- else if (src1 & SLJIT_IMM) {
- if (src1w) {
- FAIL_IF(load_immediate(compiler, TMP_REG1, src1w));
- src1_r = TMP_REG1;
- }
- else
- src1_r = 0;
- }
- else {
- if (getput_arg_fast(compiler, flags | LOAD_DATA, TMP_REG1, src1, src1w))
- FAIL_IF(compiler->error);
- else
- flags |= SLOW_SRC1;
- src1_r = TMP_REG1;
- }
-
- /* Source 2. */
- if (FAST_IS_REG(src2)) {
- src2_r = src2;
- flags |= REG2_SOURCE;
- if (!(flags & REG_DEST) && op >= SLJIT_MOV && op <= SLJIT_MOVU_SI)
- dst_r = src2_r;
- }
- else if (src2 & SLJIT_IMM) {
- if (!(flags & SRC2_IMM)) {
- if (src2w) {
- FAIL_IF(load_immediate(compiler, sugg_src2_r, src2w));
- src2_r = sugg_src2_r;
- }
- else {
- src2_r = 0;
- if ((op >= SLJIT_MOV && op <= SLJIT_MOVU_SI) && (dst & SLJIT_MEM))
- dst_r = 0;
- }
- }
- }
- else {
- if (getput_arg_fast(compiler, flags | LOAD_DATA, sugg_src2_r, src2, src2w))
- FAIL_IF(compiler->error);
- else
- flags |= SLOW_SRC2;
- src2_r = sugg_src2_r;
- }
-
- if ((flags & (SLOW_SRC1 | SLOW_SRC2)) == (SLOW_SRC1 | SLOW_SRC2)) {
- SLJIT_ASSERT(src2_r == TMP_REG2);
- if (!can_cache(src1, src1w, src2, src2w) && can_cache(src1, src1w, dst, dstw)) {
- FAIL_IF(getput_arg(compiler, flags | LOAD_DATA, TMP_REG2, src2, src2w, src1, src1w));
- FAIL_IF(getput_arg(compiler, flags | LOAD_DATA, TMP_REG1, src1, src1w, dst, dstw));
- }
- else {
- FAIL_IF(getput_arg(compiler, flags | LOAD_DATA, TMP_REG1, src1, src1w, src2, src2w));
- FAIL_IF(getput_arg(compiler, flags | LOAD_DATA, TMP_REG2, src2, src2w, dst, dstw));
- }
- }
- else if (flags & SLOW_SRC1)
- FAIL_IF(getput_arg(compiler, flags | LOAD_DATA, TMP_REG1, src1, src1w, dst, dstw));
- else if (flags & SLOW_SRC2)
- FAIL_IF(getput_arg(compiler, flags | LOAD_DATA, sugg_src2_r, src2, src2w, dst, dstw));
-
- FAIL_IF(emit_single_op(compiler, op, flags, dst_r, src1_r, src2_r));
-
- if (dst & SLJIT_MEM) {
- if (!(flags & SLOW_DEST)) {
- getput_arg_fast(compiler, flags, dst_r, dst, dstw);
- return compiler->error;
- }
- return getput_arg(compiler, flags, dst_r, dst, dstw, 0, 0);
- }
-
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
-{
- CHECK_ERROR();
- CHECK(check_sljit_emit_op0(compiler, op));
-
- op = GET_OPCODE(op);
- switch (op) {
- case SLJIT_BREAKPOINT:
- return push_inst(compiler, TA, UNMOVABLE_INS);
- case SLJIT_NOP:
- return push_inst(compiler, NOP, UNMOVABLE_INS);
- case SLJIT_LUMUL:
- case SLJIT_LSMUL:
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- FAIL_IF(push_inst(compiler, (op == SLJIT_LUMUL ? UMUL : SMUL) | D(SLJIT_R0) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R0)));
- return push_inst(compiler, RDY | D(SLJIT_R1), DR(SLJIT_R1));
-#else
-#error "Implementation required"
-#endif
- case SLJIT_UDIVMOD:
- case SLJIT_SDIVMOD:
- case SLJIT_UDIVI:
- case SLJIT_SDIVI:
- SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- if ((op | 0x2) == SLJIT_UDIVI)
- FAIL_IF(push_inst(compiler, WRY | S1(0), MOVABLE_INS));
- else {
- FAIL_IF(push_inst(compiler, SRA | D(TMP_REG1) | S1(SLJIT_R0) | IMM(31), DR(TMP_REG1)));
- FAIL_IF(push_inst(compiler, WRY | S1(TMP_REG1), MOVABLE_INS));
- }
- if (op <= SLJIT_SDIVMOD)
- FAIL_IF(push_inst(compiler, OR | D(TMP_REG2) | S1(0) | S2(SLJIT_R0), DR(TMP_REG2)));
- FAIL_IF(push_inst(compiler, ((op | 0x2) == SLJIT_UDIVI ? UDIV : SDIV) | D(SLJIT_R0) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R0)));
- if (op >= SLJIT_UDIVI)
- return SLJIT_SUCCESS;
- FAIL_IF(push_inst(compiler, SMUL | D(SLJIT_R1) | S1(SLJIT_R0) | S2(SLJIT_R1), DR(SLJIT_R1)));
- return push_inst(compiler, SUB | D(SLJIT_R1) | S1(TMP_REG2) | S2(SLJIT_R1), DR(SLJIT_R1));
-#else
-#error "Implementation required"
-#endif
- }
-
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_si flags = GET_FLAGS(op) ? SET_FLAGS : 0;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
- ADJUST_LOCAL_OFFSET(dst, dstw);
- ADJUST_LOCAL_OFFSET(src, srcw);
-
- op = GET_OPCODE(op);
- switch (op) {
- case SLJIT_MOV:
- case SLJIT_MOV_P:
- return emit_op(compiler, SLJIT_MOV, flags | WORD_DATA, dst, dstw, TMP_REG1, 0, src, srcw);
-
- case SLJIT_MOV_UI:
- return emit_op(compiler, SLJIT_MOV_UI, flags | INT_DATA, dst, dstw, TMP_REG1, 0, src, srcw);
-
- case SLJIT_MOV_SI:
- return emit_op(compiler, SLJIT_MOV_SI, flags | INT_DATA | SIGNED_DATA, dst, dstw, TMP_REG1, 0, src, srcw);
-
- case SLJIT_MOV_UB:
- return emit_op(compiler, SLJIT_MOV_UB, flags | BYTE_DATA, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_ub)srcw : srcw);
-
- case SLJIT_MOV_SB:
- return emit_op(compiler, SLJIT_MOV_SB, flags | BYTE_DATA | SIGNED_DATA, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_sb)srcw : srcw);
-
- case SLJIT_MOV_UH:
- return emit_op(compiler, SLJIT_MOV_UH, flags | HALF_DATA, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_uh)srcw : srcw);
-
- case SLJIT_MOV_SH:
- return emit_op(compiler, SLJIT_MOV_SH, flags | HALF_DATA | SIGNED_DATA, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_sh)srcw : srcw);
-
- case SLJIT_MOVU:
- case SLJIT_MOVU_P:
- return emit_op(compiler, SLJIT_MOV, flags | WORD_DATA | WRITE_BACK, dst, dstw, TMP_REG1, 0, src, srcw);
-
- case SLJIT_MOVU_UI:
- return emit_op(compiler, SLJIT_MOV_UI, flags | INT_DATA | WRITE_BACK, dst, dstw, TMP_REG1, 0, src, srcw);
-
- case SLJIT_MOVU_SI:
- return emit_op(compiler, SLJIT_MOV_SI, flags | INT_DATA | SIGNED_DATA | WRITE_BACK, dst, dstw, TMP_REG1, 0, src, srcw);
-
- case SLJIT_MOVU_UB:
- return emit_op(compiler, SLJIT_MOV_UB, flags | BYTE_DATA | WRITE_BACK, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_ub)srcw : srcw);
-
- case SLJIT_MOVU_SB:
- return emit_op(compiler, SLJIT_MOV_SB, flags | BYTE_DATA | SIGNED_DATA | WRITE_BACK, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_sb)srcw : srcw);
-
- case SLJIT_MOVU_UH:
- return emit_op(compiler, SLJIT_MOV_UH, flags | HALF_DATA | WRITE_BACK, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_uh)srcw : srcw);
-
- case SLJIT_MOVU_SH:
- return emit_op(compiler, SLJIT_MOV_SH, flags | HALF_DATA | SIGNED_DATA | WRITE_BACK, dst, dstw, TMP_REG1, 0, src, (src & SLJIT_IMM) ? (sljit_sh)srcw : srcw);
-
- case SLJIT_NOT:
- case SLJIT_CLZ:
- return emit_op(compiler, op, flags, dst, dstw, TMP_REG1, 0, src, srcw);
-
- case SLJIT_NEG:
- return emit_op(compiler, SLJIT_SUB, flags | IMM_OP, dst, dstw, SLJIT_IMM, 0, src, srcw);
- }
-
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_si flags = GET_FLAGS(op) ? SET_FLAGS : 0;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
- ADJUST_LOCAL_OFFSET(dst, dstw);
- ADJUST_LOCAL_OFFSET(src1, src1w);
- ADJUST_LOCAL_OFFSET(src2, src2w);
-
- op = GET_OPCODE(op);
- switch (op) {
- case SLJIT_ADD:
- case SLJIT_ADDC:
- case SLJIT_MUL:
- case SLJIT_AND:
- case SLJIT_OR:
- case SLJIT_XOR:
- return emit_op(compiler, op, flags | CUMULATIVE_OP | IMM_OP, dst, dstw, src1, src1w, src2, src2w);
-
- case SLJIT_SUB:
- case SLJIT_SUBC:
- return emit_op(compiler, op, flags | IMM_OP, dst, dstw, src1, src1w, src2, src2w);
-
- case SLJIT_SHL:
- case SLJIT_LSHR:
- case SLJIT_ASHR:
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- if (src2 & SLJIT_IMM)
- src2w &= 0x1f;
-#else
- SLJIT_ASSERT_STOP();
-#endif
- return emit_op(compiler, op, flags | IMM_OP, dst, dstw, src1, src1w, src2, src2w);
- }
-
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
-{
- CHECK_REG_INDEX(check_sljit_get_register_index(reg));
- return reg_map[reg];
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg)
-{
- CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
- return reg << 1;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
- void *instruction, sljit_si size)
-{
- CHECK_ERROR();
- CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
-
- return push_inst(compiler, *(sljit_ins*)instruction, UNMOVABLE_INS);
-}
-
-/* --------------------------------------------------------------------- */
-/* Floating point operators */
-/* --------------------------------------------------------------------- */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void)
-{
-#ifdef SLJIT_IS_FPU_AVAILABLE
- return SLJIT_IS_FPU_AVAILABLE;
-#else
- /* Available by default. */
- return 1;
-#endif
-}
-
-#define FLOAT_DATA(op) (DOUBLE_DATA | ((op & SLJIT_SINGLE_OP) >> 7))
-#define SELECT_FOP(op, single, double) ((op & SLJIT_SINGLE_OP) ? single : double)
-#define FLOAT_TMP_MEM_OFFSET (22 * sizeof(sljit_sw))
-
-static SLJIT_INLINE sljit_si sljit_emit_fop1_convw_fromd(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- if (src & SLJIT_MEM) {
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src, srcw, dst, dstw));
- src = TMP_FREG1;
- }
- else
- src <<= 1;
-
- FAIL_IF(push_inst(compiler, SELECT_FOP(op, FSTOI, FDTOI) | DA(TMP_FREG1) | S2A(src), MOVABLE_INS));
-
- if (dst == SLJIT_UNUSED)
- return SLJIT_SUCCESS;
-
- if (FAST_IS_REG(dst)) {
- FAIL_IF(emit_op_mem2(compiler, SINGLE_DATA, TMP_FREG1, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET));
- return emit_op_mem2(compiler, WORD_DATA | LOAD_DATA, dst, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET);
- }
-
- /* Store the integer value from a VFP register. */
- return emit_op_mem2(compiler, SINGLE_DATA, TMP_FREG1, dst, dstw, 0, 0);
-}
-
-static SLJIT_INLINE sljit_si sljit_emit_fop1_convd_fromw(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_si dst_r = FAST_IS_REG(dst) ? (dst << 1) : TMP_FREG1;
-
- if (src & SLJIT_IMM) {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (GET_OPCODE(op) == SLJIT_CONVD_FROMI)
- srcw = (sljit_si)srcw;
-#endif
- FAIL_IF(load_immediate(compiler, TMP_REG1, srcw));
- src = TMP_REG1;
- srcw = 0;
- }
-
- if (FAST_IS_REG(src)) {
- FAIL_IF(emit_op_mem2(compiler, WORD_DATA, src, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET, SLJIT_MEM1(SLJIT_SP), FLOAT_TMP_MEM_OFFSET));
- src = SLJIT_MEM1(SLJIT_SP);
- srcw = FLOAT_TMP_MEM_OFFSET;
- }
-
- FAIL_IF(emit_op_mem2(compiler, SINGLE_DATA | LOAD_DATA, TMP_FREG1, src, srcw, dst, dstw));
- FAIL_IF(push_inst(compiler, SELECT_FOP(op, FITOS, FITOD) | DA(dst_r) | S2A(TMP_FREG1), MOVABLE_INS));
-
- if (dst & SLJIT_MEM)
- return emit_op_mem2(compiler, FLOAT_DATA(op), TMP_FREG1, dst, dstw, 0, 0);
- return SLJIT_SUCCESS;
-}
-
-static SLJIT_INLINE sljit_si sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_si op,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- if (src1 & SLJIT_MEM) {
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w, src2, src2w));
- src1 = TMP_FREG1;
- }
- else
- src1 <<= 1;
-
- if (src2 & SLJIT_MEM) {
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w, 0, 0));
- src2 = TMP_FREG2;
- }
- else
- src2 <<= 1;
-
- return push_inst(compiler, SELECT_FOP(op, FCMPS, FCMPD) | S1A(src1) | S2A(src2), FCC_IS_SET | MOVABLE_INS);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_si dst_r;
-
- CHECK_ERROR();
- compiler->cache_arg = 0;
- compiler->cache_argw = 0;
-
- SLJIT_COMPILE_ASSERT((SLJIT_SINGLE_OP == 0x100) && !(DOUBLE_DATA & 0x2), float_transfer_bit_error);
- SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
-
- if (GET_OPCODE(op) == SLJIT_CONVD_FROMS)
- op ^= SLJIT_SINGLE_OP;
-
- dst_r = FAST_IS_REG(dst) ? (dst << 1) : TMP_FREG1;
-
- if (src & SLJIT_MEM) {
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op) | LOAD_DATA, dst_r, src, srcw, dst, dstw));
- src = dst_r;
- }
- else
- src <<= 1;
-
- switch (GET_OPCODE(op)) {
- case SLJIT_DMOV:
- if (src != dst_r) {
- if (dst_r != TMP_FREG1) {
- FAIL_IF(push_inst(compiler, FMOVS | DA(dst_r) | S2A(src), MOVABLE_INS));
- if (!(op & SLJIT_SINGLE_OP))
- FAIL_IF(push_inst(compiler, FMOVS | DA(dst_r | 1) | S2A(src | 1), MOVABLE_INS));
- }
- else
- dst_r = src;
- }
- break;
- case SLJIT_DNEG:
- FAIL_IF(push_inst(compiler, FNEGS | DA(dst_r) | S2A(src), MOVABLE_INS));
- if (dst_r != src && !(op & SLJIT_SINGLE_OP))
- FAIL_IF(push_inst(compiler, FMOVS | DA(dst_r | 1) | S2A(src | 1), MOVABLE_INS));
- break;
- case SLJIT_DABS:
- FAIL_IF(push_inst(compiler, FABSS | DA(dst_r) | S2A(src), MOVABLE_INS));
- if (dst_r != src && !(op & SLJIT_SINGLE_OP))
- FAIL_IF(push_inst(compiler, FMOVS | DA(dst_r | 1) | S2A(src | 1), MOVABLE_INS));
- break;
- case SLJIT_CONVD_FROMS:
- FAIL_IF(push_inst(compiler, SELECT_FOP(op, FSTOD, FDTOS) | DA(dst_r) | S2A(src), MOVABLE_INS));
- op ^= SLJIT_SINGLE_OP;
- break;
- }
-
- if (dst & SLJIT_MEM)
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op), dst_r, dst, dstw, 0, 0));
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_si dst_r, flags = 0;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
- ADJUST_LOCAL_OFFSET(dst, dstw);
- ADJUST_LOCAL_OFFSET(src1, src1w);
- ADJUST_LOCAL_OFFSET(src2, src2w);
-
- compiler->cache_arg = 0;
- compiler->cache_argw = 0;
-
- dst_r = FAST_IS_REG(dst) ? (dst << 1) : TMP_FREG2;
-
- if (src1 & SLJIT_MEM) {
- if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w)) {
- FAIL_IF(compiler->error);
- src1 = TMP_FREG1;
- } else
- flags |= SLOW_SRC1;
- }
- else
- src1 <<= 1;
-
- if (src2 & SLJIT_MEM) {
- if (getput_arg_fast(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w)) {
- FAIL_IF(compiler->error);
- src2 = TMP_FREG2;
- } else
- flags |= SLOW_SRC2;
- }
- else
- src2 <<= 1;
-
- if ((flags & (SLOW_SRC1 | SLOW_SRC2)) == (SLOW_SRC1 | SLOW_SRC2)) {
- if (!can_cache(src1, src1w, src2, src2w) && can_cache(src1, src1w, dst, dstw)) {
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w, src1, src1w));
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w, dst, dstw));
- }
- else {
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w, src2, src2w));
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w, dst, dstw));
- }
- }
- else if (flags & SLOW_SRC1)
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG1, src1, src1w, dst, dstw));
- else if (flags & SLOW_SRC2)
- FAIL_IF(getput_arg(compiler, FLOAT_DATA(op) | LOAD_DATA, TMP_FREG2, src2, src2w, dst, dstw));
-
- if (flags & SLOW_SRC1)
- src1 = TMP_FREG1;
- if (flags & SLOW_SRC2)
- src2 = TMP_FREG2;
-
- switch (GET_OPCODE(op)) {
- case SLJIT_DADD:
- FAIL_IF(push_inst(compiler, SELECT_FOP(op, FADDS, FADDD) | DA(dst_r) | S1A(src1) | S2A(src2), MOVABLE_INS));
- break;
-
- case SLJIT_DSUB:
- FAIL_IF(push_inst(compiler, SELECT_FOP(op, FSUBS, FSUBD) | DA(dst_r) | S1A(src1) | S2A(src2), MOVABLE_INS));
- break;
-
- case SLJIT_DMUL:
- FAIL_IF(push_inst(compiler, SELECT_FOP(op, FMULS, FMULD) | DA(dst_r) | S1A(src1) | S2A(src2), MOVABLE_INS));
- break;
-
- case SLJIT_DDIV:
- FAIL_IF(push_inst(compiler, SELECT_FOP(op, FDIVS, FDIVD) | DA(dst_r) | S1A(src1) | S2A(src2), MOVABLE_INS));
- break;
- }
-
- if (dst_r == TMP_FREG2)
- FAIL_IF(emit_op_mem2(compiler, FLOAT_DATA(op), TMP_FREG2, dst, dstw, 0, 0));
-
- return SLJIT_SUCCESS;
-}
-
-#undef FLOAT_DATA
-#undef SELECT_FOP
-
-/* --------------------------------------------------------------------- */
-/* Other instructions */
-/* --------------------------------------------------------------------- */
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
-{
- CHECK_ERROR();
- CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
- ADJUST_LOCAL_OFFSET(dst, dstw);
-
- /* For UNUSED dst. Uncommon, but possible. */
- if (dst == SLJIT_UNUSED)
- return SLJIT_SUCCESS;
-
- if (FAST_IS_REG(dst))
- return push_inst(compiler, OR | D(dst) | S1(0) | S2(TMP_LINK), DR(dst));
-
- /* Memory. */
- return emit_op_mem(compiler, WORD_DATA, TMP_LINK, dst, dstw);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
-{
- CHECK_ERROR();
- CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
- ADJUST_LOCAL_OFFSET(src, srcw);
-
- if (FAST_IS_REG(src))
- FAIL_IF(push_inst(compiler, OR | D(TMP_LINK) | S1(0) | S2(src), DR(TMP_LINK)));
- else if (src & SLJIT_MEM)
- FAIL_IF(emit_op_mem(compiler, WORD_DATA | LOAD_DATA, TMP_LINK, src, srcw));
- else if (src & SLJIT_IMM)
- FAIL_IF(load_immediate(compiler, TMP_LINK, srcw));
-
- FAIL_IF(push_inst(compiler, JMPL | D(0) | S1(TMP_LINK) | IMM(8), UNMOVABLE_INS));
- return push_inst(compiler, NOP, UNMOVABLE_INS);
-}
-
-/* --------------------------------------------------------------------- */
-/* Conditional instructions */
-/* --------------------------------------------------------------------- */
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler)
-{
- struct sljit_label *label;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_emit_label(compiler));
-
- if (compiler->last_label && compiler->last_label->size == compiler->size)
- return compiler->last_label;
-
- label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label));
- PTR_FAIL_IF(!label);
- set_label(label, compiler);
- compiler->delay_slot = UNMOVABLE_INS;
- return label;
-}
-
-static sljit_ins get_cc(sljit_si type)
-{
- switch (type) {
- case SLJIT_EQUAL:
- case SLJIT_MUL_NOT_OVERFLOW:
- case SLJIT_D_NOT_EQUAL: /* Unordered. */
- return DA(0x1);
-
- case SLJIT_NOT_EQUAL:
- case SLJIT_MUL_OVERFLOW:
- case SLJIT_D_EQUAL:
- return DA(0x9);
-
- case SLJIT_LESS:
- case SLJIT_D_GREATER: /* Unordered. */
- return DA(0x5);
-
- case SLJIT_GREATER_EQUAL:
- case SLJIT_D_LESS_EQUAL:
- return DA(0xd);
-
- case SLJIT_GREATER:
- case SLJIT_D_GREATER_EQUAL: /* Unordered. */
- return DA(0xc);
-
- case SLJIT_LESS_EQUAL:
- case SLJIT_D_LESS:
- return DA(0x4);
-
- case SLJIT_SIG_LESS:
- return DA(0x3);
-
- case SLJIT_SIG_GREATER_EQUAL:
- return DA(0xb);
-
- case SLJIT_SIG_GREATER:
- return DA(0xa);
-
- case SLJIT_SIG_LESS_EQUAL:
- return DA(0x2);
-
- case SLJIT_OVERFLOW:
- case SLJIT_D_UNORDERED:
- return DA(0x7);
-
- case SLJIT_NOT_OVERFLOW:
- case SLJIT_D_ORDERED:
- return DA(0xf);
-
- default:
- SLJIT_ASSERT_STOP();
- return DA(0x8);
- }
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_si type)
-{
- struct sljit_jump *jump;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_emit_jump(compiler, type));
-
- jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
- PTR_FAIL_IF(!jump);
- set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
- type &= 0xff;
-
- if (type < SLJIT_D_EQUAL) {
- jump->flags |= IS_COND;
- if (((compiler->delay_slot & DST_INS_MASK) != UNMOVABLE_INS) && !(compiler->delay_slot & ICC_IS_SET))
- jump->flags |= IS_MOVABLE;
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- PTR_FAIL_IF(push_inst(compiler, BICC | get_cc(type ^ 1) | 5, UNMOVABLE_INS));
-#else
-#error "Implementation required"
-#endif
- }
- else if (type < SLJIT_JUMP) {
- jump->flags |= IS_COND;
- if (((compiler->delay_slot & DST_INS_MASK) != UNMOVABLE_INS) && !(compiler->delay_slot & FCC_IS_SET))
- jump->flags |= IS_MOVABLE;
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- PTR_FAIL_IF(push_inst(compiler, FBFCC | get_cc(type ^ 1) | 5, UNMOVABLE_INS));
-#else
-#error "Implementation required"
-#endif
- } else {
- if ((compiler->delay_slot & DST_INS_MASK) != UNMOVABLE_INS)
- jump->flags |= IS_MOVABLE;
- if (type >= SLJIT_FAST_CALL)
- jump->flags |= IS_CALL;
- }
-
- PTR_FAIL_IF(emit_const(compiler, TMP_REG2, 0));
- PTR_FAIL_IF(push_inst(compiler, JMPL | D(type >= SLJIT_FAST_CALL ? TMP_LINK : 0) | S1(TMP_REG2) | IMM(0), UNMOVABLE_INS));
- jump->addr = compiler->size;
- PTR_FAIL_IF(push_inst(compiler, NOP, UNMOVABLE_INS));
-
- return jump;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, sljit_si src, sljit_sw srcw)
-{
- struct sljit_jump *jump = NULL;
- sljit_si src_r;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
- ADJUST_LOCAL_OFFSET(src, srcw);
-
- if (FAST_IS_REG(src))
- src_r = src;
- else if (src & SLJIT_IMM) {
- jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
- FAIL_IF(!jump);
- set_jump(jump, compiler, JUMP_ADDR);
- jump->u.target = srcw;
- if ((compiler->delay_slot & DST_INS_MASK) != UNMOVABLE_INS)
- jump->flags |= IS_MOVABLE;
- if (type >= SLJIT_FAST_CALL)
- jump->flags |= IS_CALL;
-
- FAIL_IF(emit_const(compiler, TMP_REG2, 0));
- src_r = TMP_REG2;
- }
- else {
- FAIL_IF(emit_op_mem(compiler, WORD_DATA | LOAD_DATA, TMP_REG2, src, srcw));
- src_r = TMP_REG2;
- }
-
- FAIL_IF(push_inst(compiler, JMPL | D(type >= SLJIT_FAST_CALL ? TMP_LINK : 0) | S1(src_r) | IMM(0), UNMOVABLE_INS));
- if (jump)
- jump->addr = compiler->size;
- return push_inst(compiler, NOP, UNMOVABLE_INS);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw,
- sljit_si type)
-{
- sljit_si reg, flags = (GET_FLAGS(op) ? SET_FLAGS : 0);
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
- ADJUST_LOCAL_OFFSET(dst, dstw);
-
- if (dst == SLJIT_UNUSED)
- return SLJIT_SUCCESS;
-
-#if (defined SLJIT_CONFIG_SPARC_32 && SLJIT_CONFIG_SPARC_32)
- op = GET_OPCODE(op);
- reg = (op < SLJIT_ADD && FAST_IS_REG(dst)) ? dst : TMP_REG2;
-
- compiler->cache_arg = 0;
- compiler->cache_argw = 0;
- if (op >= SLJIT_ADD && (src & SLJIT_MEM)) {
- ADJUST_LOCAL_OFFSET(src, srcw);
- FAIL_IF(emit_op_mem2(compiler, WORD_DATA | LOAD_DATA, TMP_REG1, src, srcw, dst, dstw));
- src = TMP_REG1;
- srcw = 0;
- }
-
- type &= 0xff;
- if (type < SLJIT_D_EQUAL)
- FAIL_IF(push_inst(compiler, BICC | get_cc(type) | 3, UNMOVABLE_INS));
- else
- FAIL_IF(push_inst(compiler, FBFCC | get_cc(type) | 3, UNMOVABLE_INS));
-
- FAIL_IF(push_inst(compiler, OR | D(reg) | S1(0) | IMM(1), UNMOVABLE_INS));
- FAIL_IF(push_inst(compiler, OR | D(reg) | S1(0) | IMM(0), UNMOVABLE_INS));
-
- if (op >= SLJIT_ADD)
- return emit_op(compiler, op, flags | CUMULATIVE_OP | IMM_OP | ALT_KEEP_CACHE, dst, dstw, src, srcw, TMP_REG2, 0);
-
- return (reg == TMP_REG2) ? emit_op_mem(compiler, WORD_DATA, TMP_REG2, dst, dstw) : SLJIT_SUCCESS;
-#else
-#error "Implementation required"
-#endif
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw init_value)
-{
- sljit_si reg;
- struct sljit_const *const_;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
- ADJUST_LOCAL_OFFSET(dst, dstw);
-
- const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
- PTR_FAIL_IF(!const_);
- set_const(const_, compiler);
-
- reg = SLOW_IS_REG(dst) ? dst : TMP_REG2;
-
- PTR_FAIL_IF(emit_const(compiler, reg, init_value));
-
- if (dst & SLJIT_MEM)
- PTR_FAIL_IF(emit_op_mem(compiler, WORD_DATA, TMP_REG2, dst, dstw));
- return const_;
-}
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitNativeX86_32.c r-base-3.3.1/src/extra/pcre/sljit/sljitNativeX86_32.c
--- r-base-3.2.3/src/extra/pcre/sljit/sljitNativeX86_32.c 2015-05-13 22:15:07.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitNativeX86_32.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,550 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* x86 32-bit arch dependent functions. */
-
-static sljit_si emit_do_imm(struct sljit_compiler *compiler, sljit_ub opcode, sljit_sw imm)
-{
- sljit_ub *inst;
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + sizeof(sljit_sw));
- FAIL_IF(!inst);
- INC_SIZE(1 + sizeof(sljit_sw));
- *inst++ = opcode;
- *(sljit_sw*)inst = imm;
- return SLJIT_SUCCESS;
-}
-
-static sljit_ub* generate_far_jump_code(struct sljit_jump *jump, sljit_ub *code_ptr, sljit_si type)
-{
- if (type == SLJIT_JUMP) {
- *code_ptr++ = JMP_i32;
- jump->addr++;
- }
- else if (type >= SLJIT_FAST_CALL) {
- *code_ptr++ = CALL_i32;
- jump->addr++;
- }
- else {
- *code_ptr++ = GROUP_0F;
- *code_ptr++ = get_jump_code(type);
- jump->addr += 2;
- }
-
- if (jump->flags & JUMP_LABEL)
- jump->flags |= PATCH_MW;
- else
- *(sljit_sw*)code_ptr = jump->u.target - (jump->addr + 4);
- code_ptr += 4;
-
- return code_ptr;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- sljit_si size;
- sljit_ub *inst;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
- set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->args = args;
- compiler->flags_saved = 0;
-
- size = 1 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3);
-#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
- size += (args > 0 ? (args * 2) : 0) + (args > 2 ? 2 : 0);
-#else
- size += (args > 0 ? (2 + args * 3) : 0);
-#endif
- inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
- FAIL_IF(!inst);
-
- INC_SIZE(size);
- PUSH_REG(reg_map[TMP_REG1]);
-#if !(defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
- if (args > 0) {
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_map[TMP_REG1] << 3) | 0x4 /* esp */;
- }
-#endif
- if (saveds > 2 || scratches > 7)
- PUSH_REG(reg_map[SLJIT_S2]);
- if (saveds > 1 || scratches > 8)
- PUSH_REG(reg_map[SLJIT_S1]);
- if (saveds > 0 || scratches > 9)
- PUSH_REG(reg_map[SLJIT_S0]);
-
-#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
- if (args > 0) {
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_map[SLJIT_S0] << 3) | reg_map[SLJIT_R2];
- }
- if (args > 1) {
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_map[SLJIT_S1] << 3) | reg_map[SLJIT_R1];
- }
- if (args > 2) {
- *inst++ = MOV_r_rm;
- *inst++ = MOD_DISP8 | (reg_map[SLJIT_S2] << 3) | 0x4 /* esp */;
- *inst++ = 0x24;
- *inst++ = sizeof(sljit_sw) * (3 + 2); /* saveds >= 3 as well. */
- }
-#else
- if (args > 0) {
- *inst++ = MOV_r_rm;
- *inst++ = MOD_DISP8 | (reg_map[SLJIT_S0] << 3) | reg_map[TMP_REG1];
- *inst++ = sizeof(sljit_sw) * 2;
- }
- if (args > 1) {
- *inst++ = MOV_r_rm;
- *inst++ = MOD_DISP8 | (reg_map[SLJIT_S1] << 3) | reg_map[TMP_REG1];
- *inst++ = sizeof(sljit_sw) * 3;
- }
- if (args > 2) {
- *inst++ = MOV_r_rm;
- *inst++ = MOD_DISP8 | (reg_map[SLJIT_S2] << 3) | reg_map[TMP_REG1];
- *inst++ = sizeof(sljit_sw) * 4;
- }
-#endif
-
- SLJIT_COMPILE_ASSERT(SLJIT_LOCALS_OFFSET >= (2 + 4) * sizeof(sljit_uw), require_at_least_two_words);
-#if defined(__APPLE__)
- /* Ignore pushed registers and SLJIT_LOCALS_OFFSET when computing the aligned local size. */
- saveds = (2 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3)) * sizeof(sljit_uw);
- local_size = ((SLJIT_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds;
-#else
- if (options & SLJIT_DOUBLE_ALIGNMENT) {
- local_size = SLJIT_LOCALS_OFFSET + ((local_size + 7) & ~7);
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 17);
- FAIL_IF(!inst);
-
- INC_SIZE(17);
- inst[0] = MOV_r_rm;
- inst[1] = MOD_REG | (reg_map[TMP_REG1] << 3) | reg_map[SLJIT_SP];
- inst[2] = GROUP_F7;
- inst[3] = MOD_REG | (0 << 3) | reg_map[SLJIT_SP];
- *(sljit_sw*)(inst + 4) = 0x4;
- inst[8] = JNE_i8;
- inst[9] = 6;
- inst[10] = GROUP_BINARY_81;
- inst[11] = MOD_REG | (5 << 3) | reg_map[SLJIT_SP];
- *(sljit_sw*)(inst + 12) = 0x4;
- inst[16] = PUSH_r + reg_map[TMP_REG1];
- }
- else
- local_size = SLJIT_LOCALS_OFFSET + ((local_size + 3) & ~3);
-#endif
-
- compiler->local_size = local_size;
-#ifdef _WIN32
- if (local_size > 1024) {
-#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
- FAIL_IF(emit_do_imm(compiler, MOV_r_i32 + reg_map[SLJIT_R0], local_size));
-#else
- local_size -= SLJIT_LOCALS_OFFSET;
- FAIL_IF(emit_do_imm(compiler, MOV_r_i32 + reg_map[SLJIT_R0], local_size));
- FAIL_IF(emit_non_cum_binary(compiler, SUB_r_rm, SUB_rm_r, SUB, SUB_EAX_i32,
- SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, SLJIT_LOCALS_OFFSET));
-#endif
- FAIL_IF(sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_grow_stack)));
- }
-#endif
-
- SLJIT_ASSERT(local_size > 0);
- return emit_non_cum_binary(compiler, SUB_r_rm, SUB_rm_r, SUB, SUB_EAX_i32,
- SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, local_size);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- CHECK_ERROR();
- CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
- set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->args = args;
-
-#if defined(__APPLE__)
- saveds = (2 + (scratches > 7 ? (scratches - 7) : 0) + (saveds <= 3 ? saveds : 3)) * sizeof(sljit_uw);
- compiler->local_size = ((SLJIT_LOCALS_OFFSET + saveds + local_size + 15) & ~15) - saveds;
-#else
- if (options & SLJIT_DOUBLE_ALIGNMENT)
- compiler->local_size = SLJIT_LOCALS_OFFSET + ((local_size + 7) & ~7);
- else
- compiler->local_size = SLJIT_LOCALS_OFFSET + ((local_size + 3) & ~3);
-#endif
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
-{
- sljit_si size;
- sljit_ub *inst;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_return(compiler, op, src, srcw));
- SLJIT_ASSERT(compiler->args >= 0);
-
- compiler->flags_saved = 0;
- FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
-
- SLJIT_ASSERT(compiler->local_size > 0);
- FAIL_IF(emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32,
- SLJIT_SP, 0, SLJIT_SP, 0, SLJIT_IMM, compiler->local_size));
-
-#if !defined(__APPLE__)
- if (compiler->options & SLJIT_DOUBLE_ALIGNMENT) {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 3);
- FAIL_IF(!inst);
-
- INC_SIZE(3);
- inst[0] = MOV_r_rm;
- inst[1] = (reg_map[SLJIT_SP] << 3) | 0x4 /* SIB */;
- inst[2] = (4 << 3) | reg_map[SLJIT_SP];
- }
-#endif
-
- size = 2 + (compiler->scratches > 7 ? (compiler->scratches - 7) : 0) +
- (compiler->saveds <= 3 ? compiler->saveds : 3);
-#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
- if (compiler->args > 2)
- size += 2;
-#else
- if (compiler->args > 0)
- size += 2;
-#endif
- inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
- FAIL_IF(!inst);
-
- INC_SIZE(size);
-
- if (compiler->saveds > 0 || compiler->scratches > 9)
- POP_REG(reg_map[SLJIT_S0]);
- if (compiler->saveds > 1 || compiler->scratches > 8)
- POP_REG(reg_map[SLJIT_S1]);
- if (compiler->saveds > 2 || compiler->scratches > 7)
- POP_REG(reg_map[SLJIT_S2]);
- POP_REG(reg_map[TMP_REG1]);
-#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
- if (compiler->args > 2)
- RET_I16(sizeof(sljit_sw));
- else
- RET();
-#else
- RET();
-#endif
-
- return SLJIT_SUCCESS;
-}
-
-/* --------------------------------------------------------------------- */
-/* Operators */
-/* --------------------------------------------------------------------- */
-
-/* Size contains the flags as well. */
-static sljit_ub* emit_x86_instruction(struct sljit_compiler *compiler, sljit_si size,
- /* The register or immediate operand. */
- sljit_si a, sljit_sw imma,
- /* The general operand (not immediate). */
- sljit_si b, sljit_sw immb)
-{
- sljit_ub *inst;
- sljit_ub *buf_ptr;
- sljit_si flags = size & ~0xf;
- sljit_si inst_size;
-
- /* Both cannot be switched on. */
- SLJIT_ASSERT((flags & (EX86_BIN_INS | EX86_SHIFT_INS)) != (EX86_BIN_INS | EX86_SHIFT_INS));
- /* Size flags not allowed for typed instructions. */
- SLJIT_ASSERT(!(flags & (EX86_BIN_INS | EX86_SHIFT_INS)) || (flags & (EX86_BYTE_ARG | EX86_HALF_ARG)) == 0);
- /* Both size flags cannot be switched on. */
- SLJIT_ASSERT((flags & (EX86_BYTE_ARG | EX86_HALF_ARG)) != (EX86_BYTE_ARG | EX86_HALF_ARG));
- /* SSE2 and immediate is not possible. */
- SLJIT_ASSERT(!(a & SLJIT_IMM) || !(flags & EX86_SSE2));
- SLJIT_ASSERT((flags & (EX86_PREF_F2 | EX86_PREF_F3)) != (EX86_PREF_F2 | EX86_PREF_F3)
- && (flags & (EX86_PREF_F2 | EX86_PREF_66)) != (EX86_PREF_F2 | EX86_PREF_66)
- && (flags & (EX86_PREF_F3 | EX86_PREF_66)) != (EX86_PREF_F3 | EX86_PREF_66));
-
- size &= 0xf;
- inst_size = size;
-
- if (flags & (EX86_PREF_F2 | EX86_PREF_F3))
- inst_size++;
- if (flags & EX86_PREF_66)
- inst_size++;
-
- /* Calculate size of b. */
- inst_size += 1; /* mod r/m byte. */
- if (b & SLJIT_MEM) {
- if ((b & REG_MASK) == SLJIT_UNUSED)
- inst_size += sizeof(sljit_sw);
- else if (immb != 0 && !(b & OFFS_REG_MASK)) {
- /* Immediate operand. */
- if (immb <= 127 && immb >= -128)
- inst_size += sizeof(sljit_sb);
- else
- inst_size += sizeof(sljit_sw);
- }
-
- if ((b & REG_MASK) == SLJIT_SP && !(b & OFFS_REG_MASK))
- b |= TO_OFFS_REG(SLJIT_SP);
-
- if ((b & OFFS_REG_MASK) != SLJIT_UNUSED)
- inst_size += 1; /* SIB byte. */
- }
-
- /* Calculate size of a. */
- if (a & SLJIT_IMM) {
- if (flags & EX86_BIN_INS) {
- if (imma <= 127 && imma >= -128) {
- inst_size += 1;
- flags |= EX86_BYTE_ARG;
- } else
- inst_size += 4;
- }
- else if (flags & EX86_SHIFT_INS) {
- imma &= 0x1f;
- if (imma != 1) {
- inst_size ++;
- flags |= EX86_BYTE_ARG;
- }
- } else if (flags & EX86_BYTE_ARG)
- inst_size++;
- else if (flags & EX86_HALF_ARG)
- inst_size += sizeof(short);
- else
- inst_size += sizeof(sljit_sw);
- }
- else
- SLJIT_ASSERT(!(flags & EX86_SHIFT_INS) || a == SLJIT_PREF_SHIFT_REG);
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + inst_size);
- PTR_FAIL_IF(!inst);
-
- /* Encoding the byte. */
- INC_SIZE(inst_size);
- if (flags & EX86_PREF_F2)
- *inst++ = 0xf2;
- if (flags & EX86_PREF_F3)
- *inst++ = 0xf3;
- if (flags & EX86_PREF_66)
- *inst++ = 0x66;
-
- buf_ptr = inst + size;
-
- /* Encode mod/rm byte. */
- if (!(flags & EX86_SHIFT_INS)) {
- if ((flags & EX86_BIN_INS) && (a & SLJIT_IMM))
- *inst = (flags & EX86_BYTE_ARG) ? GROUP_BINARY_83 : GROUP_BINARY_81;
-
- if ((a & SLJIT_IMM) || (a == 0))
- *buf_ptr = 0;
- else if (!(flags & EX86_SSE2_OP1))
- *buf_ptr = reg_map[a] << 3;
- else
- *buf_ptr = a << 3;
- }
- else {
- if (a & SLJIT_IMM) {
- if (imma == 1)
- *inst = GROUP_SHIFT_1;
- else
- *inst = GROUP_SHIFT_N;
- } else
- *inst = GROUP_SHIFT_CL;
- *buf_ptr = 0;
- }
-
- if (!(b & SLJIT_MEM))
- *buf_ptr++ |= MOD_REG + ((!(flags & EX86_SSE2_OP2)) ? reg_map[b] : b);
- else if ((b & REG_MASK) != SLJIT_UNUSED) {
- if ((b & OFFS_REG_MASK) == SLJIT_UNUSED || (b & OFFS_REG_MASK) == TO_OFFS_REG(SLJIT_SP)) {
- if (immb != 0) {
- if (immb <= 127 && immb >= -128)
- *buf_ptr |= 0x40;
- else
- *buf_ptr |= 0x80;
- }
-
- if ((b & OFFS_REG_MASK) == SLJIT_UNUSED)
- *buf_ptr++ |= reg_map[b & REG_MASK];
- else {
- *buf_ptr++ |= 0x04;
- *buf_ptr++ = reg_map[b & REG_MASK] | (reg_map[OFFS_REG(b)] << 3);
- }
-
- if (immb != 0) {
- if (immb <= 127 && immb >= -128)
- *buf_ptr++ = immb; /* 8 bit displacement. */
- else {
- *(sljit_sw*)buf_ptr = immb; /* 32 bit displacement. */
- buf_ptr += sizeof(sljit_sw);
- }
- }
- }
- else {
- *buf_ptr++ |= 0x04;
- *buf_ptr++ = reg_map[b & REG_MASK] | (reg_map[OFFS_REG(b)] << 3) | (immb << 6);
- }
- }
- else {
- *buf_ptr++ |= 0x05;
- *(sljit_sw*)buf_ptr = immb; /* 32 bit displacement. */
- buf_ptr += sizeof(sljit_sw);
- }
-
- if (a & SLJIT_IMM) {
- if (flags & EX86_BYTE_ARG)
- *buf_ptr = imma;
- else if (flags & EX86_HALF_ARG)
- *(short*)buf_ptr = imma;
- else if (!(flags & EX86_SHIFT_INS))
- *(sljit_sw*)buf_ptr = imma;
- }
-
- return !(flags & EX86_SHIFT_INS) ? inst : (inst + 1);
-}
-
-/* --------------------------------------------------------------------- */
-/* Call / return instructions */
-/* --------------------------------------------------------------------- */
-
-static SLJIT_INLINE sljit_si call_with_args(struct sljit_compiler *compiler, sljit_si type)
-{
- sljit_ub *inst;
-
-#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
- inst = (sljit_ub*)ensure_buf(compiler, type >= SLJIT_CALL3 ? 1 + 2 + 1 : 1 + 2);
- FAIL_IF(!inst);
- INC_SIZE(type >= SLJIT_CALL3 ? 2 + 1 : 2);
-
- if (type >= SLJIT_CALL3)
- PUSH_REG(reg_map[SLJIT_R2]);
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_map[SLJIT_R2] << 3) | reg_map[SLJIT_R0];
-#else
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 4 * (type - SLJIT_CALL0));
- FAIL_IF(!inst);
- INC_SIZE(4 * (type - SLJIT_CALL0));
-
- *inst++ = MOV_rm_r;
- *inst++ = MOD_DISP8 | (reg_map[SLJIT_R0] << 3) | 0x4 /* SIB */;
- *inst++ = (0x4 /* none*/ << 3) | reg_map[SLJIT_SP];
- *inst++ = 0;
- if (type >= SLJIT_CALL2) {
- *inst++ = MOV_rm_r;
- *inst++ = MOD_DISP8 | (reg_map[SLJIT_R1] << 3) | 0x4 /* SIB */;
- *inst++ = (0x4 /* none*/ << 3) | reg_map[SLJIT_SP];
- *inst++ = sizeof(sljit_sw);
- }
- if (type >= SLJIT_CALL3) {
- *inst++ = MOV_rm_r;
- *inst++ = MOD_DISP8 | (reg_map[SLJIT_R2] << 3) | 0x4 /* SIB */;
- *inst++ = (0x4 /* none*/ << 3) | reg_map[SLJIT_SP];
- *inst++ = 2 * sizeof(sljit_sw);
- }
-#endif
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
-{
- sljit_ub *inst;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
- ADJUST_LOCAL_OFFSET(dst, dstw);
-
- CHECK_EXTRA_REGS(dst, dstw, (void)0);
-
- /* For UNUSED dst. Uncommon, but possible. */
- if (dst == SLJIT_UNUSED)
- dst = TMP_REG1;
-
- if (FAST_IS_REG(dst)) {
- /* Unused dest is possible here. */
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
- FAIL_IF(!inst);
-
- INC_SIZE(1);
- POP_REG(reg_map[dst]);
- return SLJIT_SUCCESS;
- }
-
- /* Memory. */
- inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst++ = POP_rm;
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
-{
- sljit_ub *inst;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
- ADJUST_LOCAL_OFFSET(src, srcw);
-
- CHECK_EXTRA_REGS(src, srcw, (void)0);
-
- if (FAST_IS_REG(src)) {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 1);
- FAIL_IF(!inst);
-
- INC_SIZE(1 + 1);
- PUSH_REG(reg_map[src]);
- }
- else if (src & SLJIT_MEM) {
- inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
- FAIL_IF(!inst);
- *inst++ = GROUP_FF;
- *inst |= PUSH_rm;
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1);
- }
- else {
- /* SLJIT_IMM. */
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 5 + 1);
- FAIL_IF(!inst);
-
- INC_SIZE(5 + 1);
- *inst++ = PUSH_i32;
- *(sljit_sw*)inst = srcw;
- inst += sizeof(sljit_sw);
- }
-
- RET();
- return SLJIT_SUCCESS;
-}
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitNativeX86_64.c r-base-3.3.1/src/extra/pcre/sljit/sljitNativeX86_64.c
--- r-base-3.2.3/src/extra/pcre/sljit/sljitNativeX86_64.c 2015-05-13 22:15:08.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitNativeX86_64.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,747 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* x86 64-bit arch dependent functions. */
-
-static sljit_si emit_load_imm64(struct sljit_compiler *compiler, sljit_si reg, sljit_sw imm)
-{
- sljit_ub *inst;
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 2 + sizeof(sljit_sw));
- FAIL_IF(!inst);
- INC_SIZE(2 + sizeof(sljit_sw));
- *inst++ = REX_W | ((reg_map[reg] <= 7) ? 0 : REX_B);
- *inst++ = MOV_r_i32 + (reg_map[reg] & 0x7);
- *(sljit_sw*)inst = imm;
- return SLJIT_SUCCESS;
-}
-
-static sljit_ub* generate_far_jump_code(struct sljit_jump *jump, sljit_ub *code_ptr, sljit_si type)
-{
- if (type < SLJIT_JUMP) {
- /* Invert type. */
- *code_ptr++ = get_jump_code(type ^ 0x1) - 0x10;
- *code_ptr++ = 10 + 3;
- }
-
- SLJIT_COMPILE_ASSERT(reg_map[TMP_REG3] == 9, tmp3_is_9_first);
- *code_ptr++ = REX_W | REX_B;
- *code_ptr++ = MOV_r_i32 + 1;
- jump->addr = (sljit_uw)code_ptr;
-
- if (jump->flags & JUMP_LABEL)
- jump->flags |= PATCH_MD;
- else
- *(sljit_sw*)code_ptr = jump->u.target;
-
- code_ptr += sizeof(sljit_sw);
- *code_ptr++ = REX_B;
- *code_ptr++ = GROUP_FF;
- *code_ptr++ = (type >= SLJIT_FAST_CALL) ? (MOD_REG | CALL_rm | 1) : (MOD_REG | JMP_rm | 1);
-
- return code_ptr;
-}
-
-static sljit_ub* generate_fixed_jump(sljit_ub *code_ptr, sljit_sw addr, sljit_si type)
-{
- sljit_sw delta = addr - ((sljit_sw)code_ptr + 1 + sizeof(sljit_si));
-
- if (delta <= HALFWORD_MAX && delta >= HALFWORD_MIN) {
- *code_ptr++ = (type == 2) ? CALL_i32 : JMP_i32;
- *(sljit_sw*)code_ptr = delta;
- }
- else {
- SLJIT_COMPILE_ASSERT(reg_map[TMP_REG3] == 9, tmp3_is_9_second);
- *code_ptr++ = REX_W | REX_B;
- *code_ptr++ = MOV_r_i32 + 1;
- *(sljit_sw*)code_ptr = addr;
- code_ptr += sizeof(sljit_sw);
- *code_ptr++ = REX_B;
- *code_ptr++ = GROUP_FF;
- *code_ptr++ = (type == 2) ? (MOD_REG | CALL_rm | 1) : (MOD_REG | JMP_rm | 1);
- }
-
- return code_ptr;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_enter(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- sljit_si i, tmp, size, saved_register_size;
- sljit_ub *inst;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
- set_emit_enter(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- compiler->flags_saved = 0;
-
- /* Including the return address saved by the call instruction. */
- saved_register_size = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1);
-
- tmp = saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - saveds) : SLJIT_FIRST_SAVED_REG;
- for (i = SLJIT_S0; i >= tmp; i--) {
- size = reg_map[i] >= 8 ? 2 : 1;
- inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
- FAIL_IF(!inst);
- INC_SIZE(size);
- if (reg_map[i] >= 8)
- *inst++ = REX_B;
- PUSH_REG(reg_lmap[i]);
- }
-
- for (i = scratches; i >= SLJIT_FIRST_SAVED_REG; i--) {
- size = reg_map[i] >= 8 ? 2 : 1;
- inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
- FAIL_IF(!inst);
- INC_SIZE(size);
- if (reg_map[i] >= 8)
- *inst++ = REX_B;
- PUSH_REG(reg_lmap[i]);
- }
-
- if (args > 0) {
- size = args * 3;
- inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
- FAIL_IF(!inst);
-
- INC_SIZE(size);
-
-#ifndef _WIN64
- if (args > 0) {
- *inst++ = REX_W;
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_map[SLJIT_S0] << 3) | 0x7 /* rdi */;
- }
- if (args > 1) {
- *inst++ = REX_W | REX_R;
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_lmap[SLJIT_S1] << 3) | 0x6 /* rsi */;
- }
- if (args > 2) {
- *inst++ = REX_W | REX_R;
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_lmap[SLJIT_S2] << 3) | 0x2 /* rdx */;
- }
-#else
- if (args > 0) {
- *inst++ = REX_W;
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_map[SLJIT_S0] << 3) | 0x1 /* rcx */;
- }
- if (args > 1) {
- *inst++ = REX_W;
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_map[SLJIT_S1] << 3) | 0x2 /* rdx */;
- }
- if (args > 2) {
- *inst++ = REX_W | REX_B;
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_map[SLJIT_S2] << 3) | 0x0 /* r8 */;
- }
-#endif
- }
-
- local_size = ((local_size + SLJIT_LOCALS_OFFSET + saved_register_size + 15) & ~15) - saved_register_size;
- compiler->local_size = local_size;
-
-#ifdef _WIN64
- if (local_size > 1024) {
- /* Allocate stack for the callback, which grows the stack. */
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 4 + (3 + sizeof(sljit_si)));
- FAIL_IF(!inst);
- INC_SIZE(4 + (3 + sizeof(sljit_si)));
- *inst++ = REX_W;
- *inst++ = GROUP_BINARY_83;
- *inst++ = MOD_REG | SUB | 4;
- /* Allocated size for registers must be divisible by 8. */
- SLJIT_ASSERT(!(saved_register_size & 0x7));
- /* Aligned to 16 byte. */
- if (saved_register_size & 0x8) {
- *inst++ = 5 * sizeof(sljit_sw);
- local_size -= 5 * sizeof(sljit_sw);
- } else {
- *inst++ = 4 * sizeof(sljit_sw);
- local_size -= 4 * sizeof(sljit_sw);
- }
- /* Second instruction */
- SLJIT_COMPILE_ASSERT(reg_map[SLJIT_R0] < 8, temporary_reg1_is_loreg);
- *inst++ = REX_W;
- *inst++ = MOV_rm_i32;
- *inst++ = MOD_REG | reg_lmap[SLJIT_R0];
- *(sljit_si*)inst = local_size;
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
- || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- compiler->skip_checks = 1;
-#endif
- FAIL_IF(sljit_emit_ijump(compiler, SLJIT_CALL1, SLJIT_IMM, SLJIT_FUNC_OFFSET(sljit_grow_stack)));
- }
-#endif
-
- SLJIT_ASSERT(local_size > 0);
- if (local_size <= 127) {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
- FAIL_IF(!inst);
- INC_SIZE(4);
- *inst++ = REX_W;
- *inst++ = GROUP_BINARY_83;
- *inst++ = MOD_REG | SUB | 4;
- *inst++ = local_size;
- }
- else {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 7);
- FAIL_IF(!inst);
- INC_SIZE(7);
- *inst++ = REX_W;
- *inst++ = GROUP_BINARY_81;
- *inst++ = MOD_REG | SUB | 4;
- *(sljit_si*)inst = local_size;
- inst += sizeof(sljit_si);
- }
-
-#ifdef _WIN64
- /* Save xmm6 register: movaps [rsp + 0x20], xmm6 */
- if (fscratches >= 6 || fsaveds >= 1) {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 5);
- FAIL_IF(!inst);
- INC_SIZE(5);
- *inst++ = GROUP_0F;
- *(sljit_si*)inst = 0x20247429;
- }
-#endif
-
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_set_context(struct sljit_compiler *compiler,
- sljit_si options, sljit_si args, sljit_si scratches, sljit_si saveds,
- sljit_si fscratches, sljit_si fsaveds, sljit_si local_size)
-{
- sljit_si saved_register_size;
-
- CHECK_ERROR();
- CHECK(check_sljit_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size));
- set_set_context(compiler, options, args, scratches, saveds, fscratches, fsaveds, local_size);
-
- /* Including the return address saved by the call instruction. */
- saved_register_size = GET_SAVED_REGISTERS_SIZE(scratches, saveds, 1);
- compiler->local_size = ((local_size + SLJIT_LOCALS_OFFSET + saved_register_size + 15) & ~15) - saved_register_size;
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_return(struct sljit_compiler *compiler, sljit_si op, sljit_si src, sljit_sw srcw)
-{
- sljit_si i, tmp, size;
- sljit_ub *inst;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_return(compiler, op, src, srcw));
-
- compiler->flags_saved = 0;
- FAIL_IF(emit_mov_before_return(compiler, op, src, srcw));
-
-#ifdef _WIN64
- /* Restore xmm6 register: movaps xmm6, [rsp + 0x20] */
- if (compiler->fscratches >= 6 || compiler->fsaveds >= 1) {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 5);
- FAIL_IF(!inst);
- INC_SIZE(5);
- *inst++ = GROUP_0F;
- *(sljit_si*)inst = 0x20247428;
- }
-#endif
-
- SLJIT_ASSERT(compiler->local_size > 0);
- if (compiler->local_size <= 127) {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
- FAIL_IF(!inst);
- INC_SIZE(4);
- *inst++ = REX_W;
- *inst++ = GROUP_BINARY_83;
- *inst++ = MOD_REG | ADD | 4;
- *inst = compiler->local_size;
- }
- else {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 7);
- FAIL_IF(!inst);
- INC_SIZE(7);
- *inst++ = REX_W;
- *inst++ = GROUP_BINARY_81;
- *inst++ = MOD_REG | ADD | 4;
- *(sljit_si*)inst = compiler->local_size;
- }
-
- tmp = compiler->scratches;
- for (i = SLJIT_FIRST_SAVED_REG; i <= tmp; i++) {
- size = reg_map[i] >= 8 ? 2 : 1;
- inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
- FAIL_IF(!inst);
- INC_SIZE(size);
- if (reg_map[i] >= 8)
- *inst++ = REX_B;
- POP_REG(reg_lmap[i]);
- }
-
- tmp = compiler->saveds < SLJIT_NUMBER_OF_SAVED_REGISTERS ? (SLJIT_S0 + 1 - compiler->saveds) : SLJIT_FIRST_SAVED_REG;
- for (i = tmp; i <= SLJIT_S0; i++) {
- size = reg_map[i] >= 8 ? 2 : 1;
- inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
- FAIL_IF(!inst);
- INC_SIZE(size);
- if (reg_map[i] >= 8)
- *inst++ = REX_B;
- POP_REG(reg_lmap[i]);
- }
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1);
- RET();
- return SLJIT_SUCCESS;
-}
-
-/* --------------------------------------------------------------------- */
-/* Operators */
-/* --------------------------------------------------------------------- */
-
-static sljit_si emit_do_imm32(struct sljit_compiler *compiler, sljit_ub rex, sljit_ub opcode, sljit_sw imm)
-{
- sljit_ub *inst;
- sljit_si length = 1 + (rex ? 1 : 0) + sizeof(sljit_si);
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + length);
- FAIL_IF(!inst);
- INC_SIZE(length);
- if (rex)
- *inst++ = rex;
- *inst++ = opcode;
- *(sljit_si*)inst = imm;
- return SLJIT_SUCCESS;
-}
-
-static sljit_ub* emit_x86_instruction(struct sljit_compiler *compiler, sljit_si size,
- /* The register or immediate operand. */
- sljit_si a, sljit_sw imma,
- /* The general operand (not immediate). */
- sljit_si b, sljit_sw immb)
-{
- sljit_ub *inst;
- sljit_ub *buf_ptr;
- sljit_ub rex = 0;
- sljit_si flags = size & ~0xf;
- sljit_si inst_size;
-
- /* The immediate operand must be 32 bit. */
- SLJIT_ASSERT(!(a & SLJIT_IMM) || compiler->mode32 || IS_HALFWORD(imma));
- /* Both cannot be switched on. */
- SLJIT_ASSERT((flags & (EX86_BIN_INS | EX86_SHIFT_INS)) != (EX86_BIN_INS | EX86_SHIFT_INS));
- /* Size flags not allowed for typed instructions. */
- SLJIT_ASSERT(!(flags & (EX86_BIN_INS | EX86_SHIFT_INS)) || (flags & (EX86_BYTE_ARG | EX86_HALF_ARG)) == 0);
- /* Both size flags cannot be switched on. */
- SLJIT_ASSERT((flags & (EX86_BYTE_ARG | EX86_HALF_ARG)) != (EX86_BYTE_ARG | EX86_HALF_ARG));
- /* SSE2 and immediate is not possible. */
- SLJIT_ASSERT(!(a & SLJIT_IMM) || !(flags & EX86_SSE2));
- SLJIT_ASSERT((flags & (EX86_PREF_F2 | EX86_PREF_F3)) != (EX86_PREF_F2 | EX86_PREF_F3)
- && (flags & (EX86_PREF_F2 | EX86_PREF_66)) != (EX86_PREF_F2 | EX86_PREF_66)
- && (flags & (EX86_PREF_F3 | EX86_PREF_66)) != (EX86_PREF_F3 | EX86_PREF_66));
-
- size &= 0xf;
- inst_size = size;
-
- if (!compiler->mode32 && !(flags & EX86_NO_REXW))
- rex |= REX_W;
- else if (flags & EX86_REX)
- rex |= REX;
-
- if (flags & (EX86_PREF_F2 | EX86_PREF_F3))
- inst_size++;
- if (flags & EX86_PREF_66)
- inst_size++;
-
- /* Calculate size of b. */
- inst_size += 1; /* mod r/m byte. */
- if (b & SLJIT_MEM) {
- if (!(b & OFFS_REG_MASK)) {
- if (NOT_HALFWORD(immb)) {
- if (emit_load_imm64(compiler, TMP_REG3, immb))
- return NULL;
- immb = 0;
- if (b & REG_MASK)
- b |= TO_OFFS_REG(TMP_REG3);
- else
- b |= TMP_REG3;
- }
- else if (reg_lmap[b & REG_MASK] == 4)
- b |= TO_OFFS_REG(SLJIT_SP);
- }
-
- if ((b & REG_MASK) == SLJIT_UNUSED)
- inst_size += 1 + sizeof(sljit_si); /* SIB byte required to avoid RIP based addressing. */
- else {
- if (reg_map[b & REG_MASK] >= 8)
- rex |= REX_B;
-
- if (immb != 0 && (!(b & OFFS_REG_MASK) || (b & OFFS_REG_MASK) == TO_OFFS_REG(SLJIT_SP))) {
- /* Immediate operand. */
- if (immb <= 127 && immb >= -128)
- inst_size += sizeof(sljit_sb);
- else
- inst_size += sizeof(sljit_si);
- }
- else if (reg_lmap[b & REG_MASK] == 5)
- inst_size += sizeof(sljit_sb);
-
- if ((b & OFFS_REG_MASK) != SLJIT_UNUSED) {
- inst_size += 1; /* SIB byte. */
- if (reg_map[OFFS_REG(b)] >= 8)
- rex |= REX_X;
- }
- }
- }
- else if (!(flags & EX86_SSE2_OP2) && reg_map[b] >= 8)
- rex |= REX_B;
-
- if (a & SLJIT_IMM) {
- if (flags & EX86_BIN_INS) {
- if (imma <= 127 && imma >= -128) {
- inst_size += 1;
- flags |= EX86_BYTE_ARG;
- } else
- inst_size += 4;
- }
- else if (flags & EX86_SHIFT_INS) {
- imma &= compiler->mode32 ? 0x1f : 0x3f;
- if (imma != 1) {
- inst_size ++;
- flags |= EX86_BYTE_ARG;
- }
- } else if (flags & EX86_BYTE_ARG)
- inst_size++;
- else if (flags & EX86_HALF_ARG)
- inst_size += sizeof(short);
- else
- inst_size += sizeof(sljit_si);
- }
- else {
- SLJIT_ASSERT(!(flags & EX86_SHIFT_INS) || a == SLJIT_PREF_SHIFT_REG);
- /* reg_map[SLJIT_PREF_SHIFT_REG] is less than 8. */
- if (!(flags & EX86_SSE2_OP1) && reg_map[a] >= 8)
- rex |= REX_R;
- }
-
- if (rex)
- inst_size++;
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + inst_size);
- PTR_FAIL_IF(!inst);
-
- /* Encoding the byte. */
- INC_SIZE(inst_size);
- if (flags & EX86_PREF_F2)
- *inst++ = 0xf2;
- if (flags & EX86_PREF_F3)
- *inst++ = 0xf3;
- if (flags & EX86_PREF_66)
- *inst++ = 0x66;
- if (rex)
- *inst++ = rex;
- buf_ptr = inst + size;
-
- /* Encode mod/rm byte. */
- if (!(flags & EX86_SHIFT_INS)) {
- if ((flags & EX86_BIN_INS) && (a & SLJIT_IMM))
- *inst = (flags & EX86_BYTE_ARG) ? GROUP_BINARY_83 : GROUP_BINARY_81;
-
- if ((a & SLJIT_IMM) || (a == 0))
- *buf_ptr = 0;
- else if (!(flags & EX86_SSE2_OP1))
- *buf_ptr = reg_lmap[a] << 3;
- else
- *buf_ptr = a << 3;
- }
- else {
- if (a & SLJIT_IMM) {
- if (imma == 1)
- *inst = GROUP_SHIFT_1;
- else
- *inst = GROUP_SHIFT_N;
- } else
- *inst = GROUP_SHIFT_CL;
- *buf_ptr = 0;
- }
-
- if (!(b & SLJIT_MEM))
- *buf_ptr++ |= MOD_REG + ((!(flags & EX86_SSE2_OP2)) ? reg_lmap[b] : b);
- else if ((b & REG_MASK) != SLJIT_UNUSED) {
- if ((b & OFFS_REG_MASK) == SLJIT_UNUSED || (b & OFFS_REG_MASK) == TO_OFFS_REG(SLJIT_SP)) {
- if (immb != 0 || reg_lmap[b & REG_MASK] == 5) {
- if (immb <= 127 && immb >= -128)
- *buf_ptr |= 0x40;
- else
- *buf_ptr |= 0x80;
- }
-
- if ((b & OFFS_REG_MASK) == SLJIT_UNUSED)
- *buf_ptr++ |= reg_lmap[b & REG_MASK];
- else {
- *buf_ptr++ |= 0x04;
- *buf_ptr++ = reg_lmap[b & REG_MASK] | (reg_lmap[OFFS_REG(b)] << 3);
- }
-
- if (immb != 0 || reg_lmap[b & REG_MASK] == 5) {
- if (immb <= 127 && immb >= -128)
- *buf_ptr++ = immb; /* 8 bit displacement. */
- else {
- *(sljit_si*)buf_ptr = immb; /* 32 bit displacement. */
- buf_ptr += sizeof(sljit_si);
- }
- }
- }
- else {
- if (reg_lmap[b & REG_MASK] == 5)
- *buf_ptr |= 0x40;
- *buf_ptr++ |= 0x04;
- *buf_ptr++ = reg_lmap[b & REG_MASK] | (reg_lmap[OFFS_REG(b)] << 3) | (immb << 6);
- if (reg_lmap[b & REG_MASK] == 5)
- *buf_ptr++ = 0;
- }
- }
- else {
- *buf_ptr++ |= 0x04;
- *buf_ptr++ = 0x25;
- *(sljit_si*)buf_ptr = immb; /* 32 bit displacement. */
- buf_ptr += sizeof(sljit_si);
- }
-
- if (a & SLJIT_IMM) {
- if (flags & EX86_BYTE_ARG)
- *buf_ptr = imma;
- else if (flags & EX86_HALF_ARG)
- *(short*)buf_ptr = imma;
- else if (!(flags & EX86_SHIFT_INS))
- *(sljit_si*)buf_ptr = imma;
- }
-
- return !(flags & EX86_SHIFT_INS) ? inst : (inst + 1);
-}
-
-/* --------------------------------------------------------------------- */
-/* Call / return instructions */
-/* --------------------------------------------------------------------- */
-
-static SLJIT_INLINE sljit_si call_with_args(struct sljit_compiler *compiler, sljit_si type)
-{
- sljit_ub *inst;
-
-#ifndef _WIN64
- SLJIT_COMPILE_ASSERT(reg_map[SLJIT_R1] == 6 && reg_map[SLJIT_R0] < 8 && reg_map[SLJIT_R2] < 8, args_registers);
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + ((type < SLJIT_CALL3) ? 3 : 6));
- FAIL_IF(!inst);
- INC_SIZE((type < SLJIT_CALL3) ? 3 : 6);
- if (type >= SLJIT_CALL3) {
- *inst++ = REX_W;
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (0x2 /* rdx */ << 3) | reg_lmap[SLJIT_R2];
- }
- *inst++ = REX_W;
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (0x7 /* rdi */ << 3) | reg_lmap[SLJIT_R0];
-#else
- SLJIT_COMPILE_ASSERT(reg_map[SLJIT_R1] == 2 && reg_map[SLJIT_R0] < 8 && reg_map[SLJIT_R2] < 8, args_registers);
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + ((type < SLJIT_CALL3) ? 3 : 6));
- FAIL_IF(!inst);
- INC_SIZE((type < SLJIT_CALL3) ? 3 : 6);
- if (type >= SLJIT_CALL3) {
- *inst++ = REX_W | REX_R;
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (0x0 /* r8 */ << 3) | reg_lmap[SLJIT_R2];
- }
- *inst++ = REX_W;
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (0x1 /* rcx */ << 3) | reg_lmap[SLJIT_R0];
-#endif
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_enter(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw)
-{
- sljit_ub *inst;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_fast_enter(compiler, dst, dstw));
- ADJUST_LOCAL_OFFSET(dst, dstw);
-
- /* For UNUSED dst. Uncommon, but possible. */
- if (dst == SLJIT_UNUSED)
- dst = TMP_REG1;
-
- if (FAST_IS_REG(dst)) {
- if (reg_map[dst] < 8) {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1);
- POP_REG(reg_lmap[dst]);
- return SLJIT_SUCCESS;
- }
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 2);
- FAIL_IF(!inst);
- INC_SIZE(2);
- *inst++ = REX_B;
- POP_REG(reg_lmap[dst]);
- return SLJIT_SUCCESS;
- }
-
- /* REX_W is not necessary (src is not immediate). */
- compiler->mode32 = 1;
- inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst++ = POP_rm;
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fast_return(struct sljit_compiler *compiler, sljit_si src, sljit_sw srcw)
-{
- sljit_ub *inst;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_fast_return(compiler, src, srcw));
- ADJUST_LOCAL_OFFSET(src, srcw);
-
- if ((src & SLJIT_IMM) && NOT_HALFWORD(srcw)) {
- FAIL_IF(emit_load_imm64(compiler, TMP_REG1, srcw));
- src = TMP_REG1;
- }
-
- if (FAST_IS_REG(src)) {
- if (reg_map[src] < 8) {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 1);
- FAIL_IF(!inst);
-
- INC_SIZE(1 + 1);
- PUSH_REG(reg_lmap[src]);
- }
- else {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 2 + 1);
- FAIL_IF(!inst);
-
- INC_SIZE(2 + 1);
- *inst++ = REX_B;
- PUSH_REG(reg_lmap[src]);
- }
- }
- else if (src & SLJIT_MEM) {
- /* REX_W is not necessary (src is not immediate). */
- compiler->mode32 = 1;
- inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
- FAIL_IF(!inst);
- *inst++ = GROUP_FF;
- *inst |= PUSH_rm;
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1);
- }
- else {
- SLJIT_ASSERT(IS_HALFWORD(srcw));
- /* SLJIT_IMM. */
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 5 + 1);
- FAIL_IF(!inst);
-
- INC_SIZE(5 + 1);
- *inst++ = PUSH_i32;
- *(sljit_si*)inst = srcw;
- inst += sizeof(sljit_si);
- }
-
- RET();
- return SLJIT_SUCCESS;
-}
-
-
-/* --------------------------------------------------------------------- */
-/* Extend input */
-/* --------------------------------------------------------------------- */
-
-static sljit_si emit_mov_int(struct sljit_compiler *compiler, sljit_si sign,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_ub* inst;
- sljit_si dst_r;
-
- compiler->mode32 = 0;
-
- if (dst == SLJIT_UNUSED && !(src & SLJIT_MEM))
- return SLJIT_SUCCESS; /* Empty instruction. */
-
- if (src & SLJIT_IMM) {
- if (FAST_IS_REG(dst)) {
- if (sign || ((sljit_uw)srcw <= 0x7fffffff)) {
- inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, (sljit_sw)(sljit_si)srcw, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm_i32;
- return SLJIT_SUCCESS;
- }
- return emit_load_imm64(compiler, dst, srcw);
- }
- compiler->mode32 = 1;
- inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, (sljit_sw)(sljit_si)srcw, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm_i32;
- compiler->mode32 = 0;
- return SLJIT_SUCCESS;
- }
-
- dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1;
-
- if ((dst & SLJIT_MEM) && FAST_IS_REG(src))
- dst_r = src;
- else {
- if (sign) {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, src, srcw);
- FAIL_IF(!inst);
- *inst++ = MOVSXD_r_rm;
- } else {
- compiler->mode32 = 1;
- FAIL_IF(emit_mov(compiler, dst_r, 0, src, srcw));
- compiler->mode32 = 0;
- }
- }
-
- if (dst & SLJIT_MEM) {
- compiler->mode32 = 1;
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm_r;
- compiler->mode32 = 0;
- }
-
- return SLJIT_SUCCESS;
-}
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitNativeX86_common.c r-base-3.3.1/src/extra/pcre/sljit/sljitNativeX86_common.c
--- r-base-3.2.3/src/extra/pcre/sljit/sljitNativeX86_common.c 2015-11-26 23:15:10.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitNativeX86_common.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,3004 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name(void)
-{
- return "x86" SLJIT_CPUINFO;
-}
-
-/*
- 32b register indexes:
- 0 - EAX
- 1 - ECX
- 2 - EDX
- 3 - EBX
- 4 - none
- 5 - EBP
- 6 - ESI
- 7 - EDI
-*/
-
-/*
- 64b register indexes:
- 0 - RAX
- 1 - RCX
- 2 - RDX
- 3 - RBX
- 4 - none
- 5 - RBP
- 6 - RSI
- 7 - RDI
- 8 - R8 - From now on REX prefix is required
- 9 - R9
- 10 - R10
- 11 - R11
- 12 - R12
- 13 - R13
- 14 - R14
- 15 - R15
-*/
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-
-/* Last register + 1. */
-#define TMP_REG1 (SLJIT_NUMBER_OF_REGISTERS + 2)
-
-static SLJIT_CONST sljit_ub reg_map[SLJIT_NUMBER_OF_REGISTERS + 3] = {
- 0, 0, 2, 1, 0, 0, 0, 0, 7, 6, 3, 4, 5
-};
-
-#define CHECK_EXTRA_REGS(p, w, do) \
- if (p >= SLJIT_R3 && p <= SLJIT_R6) { \
- w = SLJIT_LOCALS_OFFSET + ((p) - (SLJIT_R3 + 4)) * sizeof(sljit_sw); \
- p = SLJIT_MEM1(SLJIT_SP); \
- do; \
- }
-
-#else /* SLJIT_CONFIG_X86_32 */
-
-/* Last register + 1. */
-#define TMP_REG1 (SLJIT_NUMBER_OF_REGISTERS + 2)
-#define TMP_REG2 (SLJIT_NUMBER_OF_REGISTERS + 3)
-#define TMP_REG3 (SLJIT_NUMBER_OF_REGISTERS + 4)
-
-/* Note: r12 & 0x7 == 0b100, which decoded as SIB byte present
- Note: avoid to use r12 and r13 for memory addessing
- therefore r12 is better for SAVED_EREG than SAVED_REG. */
-#ifndef _WIN64
-/* 1st passed in rdi, 2nd argument passed in rsi, 3rd in rdx. */
-static SLJIT_CONST sljit_ub reg_map[SLJIT_NUMBER_OF_REGISTERS + 5] = {
- 0, 0, 6, 1, 8, 11, 10, 12, 5, 13, 14, 15, 3, 4, 2, 7, 9
-};
-/* low-map. reg_map & 0x7. */
-static SLJIT_CONST sljit_ub reg_lmap[SLJIT_NUMBER_OF_REGISTERS + 5] = {
- 0, 0, 6, 1, 0, 3, 2, 4, 5, 5, 6, 7, 3, 4, 2, 7, 1
-};
-#else
-/* 1st passed in rcx, 2nd argument passed in rdx, 3rd in r8. */
-static SLJIT_CONST sljit_ub reg_map[SLJIT_NUMBER_OF_REGISTERS + 5] = {
- 0, 0, 2, 1, 11, 12, 5, 13, 14, 15, 7, 6, 3, 4, 10, 8, 9
-};
-/* low-map. reg_map & 0x7. */
-static SLJIT_CONST sljit_ub reg_lmap[SLJIT_NUMBER_OF_REGISTERS + 5] = {
- 0, 0, 2, 1, 3, 4, 5, 5, 6, 7, 7, 6, 3, 4, 2, 0, 1
-};
-#endif
-
-#define REX_W 0x48
-#define REX_R 0x44
-#define REX_X 0x42
-#define REX_B 0x41
-#define REX 0x40
-
-#ifndef _WIN64
-#define HALFWORD_MAX 0x7fffffffl
-#define HALFWORD_MIN -0x80000000l
-#else
-#define HALFWORD_MAX 0x7fffffffll
-#define HALFWORD_MIN -0x80000000ll
-#endif
-
-#define IS_HALFWORD(x) ((x) <= HALFWORD_MAX && (x) >= HALFWORD_MIN)
-#define NOT_HALFWORD(x) ((x) > HALFWORD_MAX || (x) < HALFWORD_MIN)
-
-#define CHECK_EXTRA_REGS(p, w, do)
-
-#endif /* SLJIT_CONFIG_X86_32 */
-
-#define TMP_FREG (0)
-
-/* Size flags for emit_x86_instruction: */
-#define EX86_BIN_INS 0x0010
-#define EX86_SHIFT_INS 0x0020
-#define EX86_REX 0x0040
-#define EX86_NO_REXW 0x0080
-#define EX86_BYTE_ARG 0x0100
-#define EX86_HALF_ARG 0x0200
-#define EX86_PREF_66 0x0400
-#define EX86_PREF_F2 0x0800
-#define EX86_PREF_F3 0x1000
-#define EX86_SSE2_OP1 0x2000
-#define EX86_SSE2_OP2 0x4000
-#define EX86_SSE2 (EX86_SSE2_OP1 | EX86_SSE2_OP2)
-
-/* --------------------------------------------------------------------- */
-/* Instrucion forms */
-/* --------------------------------------------------------------------- */
-
-#define ADD (/* BINARY */ 0 << 3)
-#define ADD_EAX_i32 0x05
-#define ADD_r_rm 0x03
-#define ADD_rm_r 0x01
-#define ADDSD_x_xm 0x58
-#define ADC (/* BINARY */ 2 << 3)
-#define ADC_EAX_i32 0x15
-#define ADC_r_rm 0x13
-#define ADC_rm_r 0x11
-#define AND (/* BINARY */ 4 << 3)
-#define AND_EAX_i32 0x25
-#define AND_r_rm 0x23
-#define AND_rm_r 0x21
-#define ANDPD_x_xm 0x54
-#define BSR_r_rm (/* GROUP_0F */ 0xbd)
-#define CALL_i32 0xe8
-#define CALL_rm (/* GROUP_FF */ 2 << 3)
-#define CDQ 0x99
-#define CMOVNE_r_rm (/* GROUP_0F */ 0x45)
-#define CMP (/* BINARY */ 7 << 3)
-#define CMP_EAX_i32 0x3d
-#define CMP_r_rm 0x3b
-#define CMP_rm_r 0x39
-#define CVTPD2PS_x_xm 0x5a
-#define CVTSI2SD_x_rm 0x2a
-#define CVTTSD2SI_r_xm 0x2c
-#define DIV (/* GROUP_F7 */ 6 << 3)
-#define DIVSD_x_xm 0x5e
-#define INT3 0xcc
-#define IDIV (/* GROUP_F7 */ 7 << 3)
-#define IMUL (/* GROUP_F7 */ 5 << 3)
-#define IMUL_r_rm (/* GROUP_0F */ 0xaf)
-#define IMUL_r_rm_i8 0x6b
-#define IMUL_r_rm_i32 0x69
-#define JE_i8 0x74
-#define JNE_i8 0x75
-#define JMP_i8 0xeb
-#define JMP_i32 0xe9
-#define JMP_rm (/* GROUP_FF */ 4 << 3)
-#define LEA_r_m 0x8d
-#define MOV_r_rm 0x8b
-#define MOV_r_i32 0xb8
-#define MOV_rm_r 0x89
-#define MOV_rm_i32 0xc7
-#define MOV_rm8_i8 0xc6
-#define MOV_rm8_r8 0x88
-#define MOVSD_x_xm 0x10
-#define MOVSD_xm_x 0x11
-#define MOVSXD_r_rm 0x63
-#define MOVSX_r_rm8 (/* GROUP_0F */ 0xbe)
-#define MOVSX_r_rm16 (/* GROUP_0F */ 0xbf)
-#define MOVZX_r_rm8 (/* GROUP_0F */ 0xb6)
-#define MOVZX_r_rm16 (/* GROUP_0F */ 0xb7)
-#define MUL (/* GROUP_F7 */ 4 << 3)
-#define MULSD_x_xm 0x59
-#define NEG_rm (/* GROUP_F7 */ 3 << 3)
-#define NOP 0x90
-#define NOT_rm (/* GROUP_F7 */ 2 << 3)
-#define OR (/* BINARY */ 1 << 3)
-#define OR_r_rm 0x0b
-#define OR_EAX_i32 0x0d
-#define OR_rm_r 0x09
-#define OR_rm8_r8 0x08
-#define POP_r 0x58
-#define POP_rm 0x8f
-#define POPF 0x9d
-#define PUSH_i32 0x68
-#define PUSH_r 0x50
-#define PUSH_rm (/* GROUP_FF */ 6 << 3)
-#define PUSHF 0x9c
-#define RET_near 0xc3
-#define RET_i16 0xc2
-#define SBB (/* BINARY */ 3 << 3)
-#define SBB_EAX_i32 0x1d
-#define SBB_r_rm 0x1b
-#define SBB_rm_r 0x19
-#define SAR (/* SHIFT */ 7 << 3)
-#define SHL (/* SHIFT */ 4 << 3)
-#define SHR (/* SHIFT */ 5 << 3)
-#define SUB (/* BINARY */ 5 << 3)
-#define SUB_EAX_i32 0x2d
-#define SUB_r_rm 0x2b
-#define SUB_rm_r 0x29
-#define SUBSD_x_xm 0x5c
-#define TEST_EAX_i32 0xa9
-#define TEST_rm_r 0x85
-#define UCOMISD_x_xm 0x2e
-#define UNPCKLPD_x_xm 0x14
-#define XCHG_EAX_r 0x90
-#define XCHG_r_rm 0x87
-#define XOR (/* BINARY */ 6 << 3)
-#define XOR_EAX_i32 0x35
-#define XOR_r_rm 0x33
-#define XOR_rm_r 0x31
-#define XORPD_x_xm 0x57
-
-#define GROUP_0F 0x0f
-#define GROUP_F7 0xf7
-#define GROUP_FF 0xff
-#define GROUP_BINARY_81 0x81
-#define GROUP_BINARY_83 0x83
-#define GROUP_SHIFT_1 0xd1
-#define GROUP_SHIFT_N 0xc1
-#define GROUP_SHIFT_CL 0xd3
-
-#define MOD_REG 0xc0
-#define MOD_DISP8 0x40
-
-#define INC_SIZE(s) (*inst++ = (s), compiler->size += (s))
-
-#define PUSH_REG(r) (*inst++ = (PUSH_r + (r)))
-#define POP_REG(r) (*inst++ = (POP_r + (r)))
-#define RET() (*inst++ = (RET_near))
-#define RET_I16(n) (*inst++ = (RET_i16), *inst++ = n, *inst++ = 0)
-/* r32, r/m32 */
-#define MOV_RM(mod, reg, rm) (*inst++ = (MOV_r_rm), *inst++ = (mod) << 6 | (reg) << 3 | (rm))
-
-/* Multithreading does not affect these static variables, since they store
- built-in CPU features. Therefore they can be overwritten by different threads
- if they detect the CPU features in the same time. */
-#if (defined SLJIT_DETECT_SSE2 && SLJIT_DETECT_SSE2)
-static sljit_si cpu_has_sse2 = -1;
-#endif
-static sljit_si cpu_has_cmov = -1;
-
-#ifdef _WIN32_WCE
-#include
-#elif defined(_MSC_VER) && _MSC_VER >= 1400
-#include
-#endif
-
-static void get_cpu_features(void)
-{
- sljit_ui features;
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-
- int CPUInfo[4];
- __cpuid(CPUInfo, 1);
- features = (sljit_ui)CPUInfo[3];
-
-#elif defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__SUNPRO_C)
-
- /* AT&T syntax. */
- __asm__ (
- "movl $0x1, %%eax\n"
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- /* On x86-32, there is no red zone, so this
- should work (no need for a local variable). */
- "push %%ebx\n"
-#endif
- "cpuid\n"
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- "pop %%ebx\n"
-#endif
- "movl %%edx, %0\n"
- : "=g" (features)
- :
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- : "%eax", "%ecx", "%edx"
-#else
- : "%rax", "%rbx", "%rcx", "%rdx"
-#endif
- );
-
-#else /* _MSC_VER && _MSC_VER >= 1400 */
-
- /* Intel syntax. */
- __asm {
- mov eax, 1
- cpuid
- mov features, edx
- }
-
-#endif /* _MSC_VER && _MSC_VER >= 1400 */
-
-#if (defined SLJIT_DETECT_SSE2 && SLJIT_DETECT_SSE2)
- cpu_has_sse2 = (features >> 26) & 0x1;
-#endif
- cpu_has_cmov = (features >> 15) & 0x1;
-}
-
-static sljit_ub get_jump_code(sljit_si type)
-{
- switch (type) {
- case SLJIT_EQUAL:
- case SLJIT_D_EQUAL:
- return 0x84 /* je */;
-
- case SLJIT_NOT_EQUAL:
- case SLJIT_D_NOT_EQUAL:
- return 0x85 /* jne */;
-
- case SLJIT_LESS:
- case SLJIT_D_LESS:
- return 0x82 /* jc */;
-
- case SLJIT_GREATER_EQUAL:
- case SLJIT_D_GREATER_EQUAL:
- return 0x83 /* jae */;
-
- case SLJIT_GREATER:
- case SLJIT_D_GREATER:
- return 0x87 /* jnbe */;
-
- case SLJIT_LESS_EQUAL:
- case SLJIT_D_LESS_EQUAL:
- return 0x86 /* jbe */;
-
- case SLJIT_SIG_LESS:
- return 0x8c /* jl */;
-
- case SLJIT_SIG_GREATER_EQUAL:
- return 0x8d /* jnl */;
-
- case SLJIT_SIG_GREATER:
- return 0x8f /* jnle */;
-
- case SLJIT_SIG_LESS_EQUAL:
- return 0x8e /* jle */;
-
- case SLJIT_OVERFLOW:
- case SLJIT_MUL_OVERFLOW:
- return 0x80 /* jo */;
-
- case SLJIT_NOT_OVERFLOW:
- case SLJIT_MUL_NOT_OVERFLOW:
- return 0x81 /* jno */;
-
- case SLJIT_D_UNORDERED:
- return 0x8a /* jp */;
-
- case SLJIT_D_ORDERED:
- return 0x8b /* jpo */;
- }
- return 0;
-}
-
-static sljit_ub* generate_far_jump_code(struct sljit_jump *jump, sljit_ub *code_ptr, sljit_si type);
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
-static sljit_ub* generate_fixed_jump(sljit_ub *code_ptr, sljit_sw addr, sljit_si type);
-#endif
-
-static sljit_ub* generate_near_jump_code(struct sljit_jump *jump, sljit_ub *code_ptr, sljit_ub *code, sljit_si type)
-{
- sljit_si short_jump;
- sljit_uw label_addr;
-
- if (jump->flags & JUMP_LABEL)
- label_addr = (sljit_uw)(code + jump->u.label->size);
- else
- label_addr = jump->u.target;
- short_jump = (sljit_sw)(label_addr - (jump->addr + 2)) >= -128 && (sljit_sw)(label_addr - (jump->addr + 2)) <= 127;
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if ((sljit_sw)(label_addr - (jump->addr + 1)) > HALFWORD_MAX || (sljit_sw)(label_addr - (jump->addr + 1)) < HALFWORD_MIN)
- return generate_far_jump_code(jump, code_ptr, type);
-#endif
-
- if (type == SLJIT_JUMP) {
- if (short_jump)
- *code_ptr++ = JMP_i8;
- else
- *code_ptr++ = JMP_i32;
- jump->addr++;
- }
- else if (type >= SLJIT_FAST_CALL) {
- short_jump = 0;
- *code_ptr++ = CALL_i32;
- jump->addr++;
- }
- else if (short_jump) {
- *code_ptr++ = get_jump_code(type) - 0x10;
- jump->addr++;
- }
- else {
- *code_ptr++ = GROUP_0F;
- *code_ptr++ = get_jump_code(type);
- jump->addr += 2;
- }
-
- if (short_jump) {
- jump->flags |= PATCH_MB;
- code_ptr += sizeof(sljit_sb);
- } else {
- jump->flags |= PATCH_MW;
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- code_ptr += sizeof(sljit_sw);
-#else
- code_ptr += sizeof(sljit_si);
-#endif
- }
-
- return code_ptr;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void* sljit_generate_code(struct sljit_compiler *compiler)
-{
- struct sljit_memory_fragment *buf;
- sljit_ub *code;
- sljit_ub *code_ptr;
- sljit_ub *buf_ptr;
- sljit_ub *buf_end;
- sljit_ub len;
-
- struct sljit_label *label;
- struct sljit_jump *jump;
- struct sljit_const *const_;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_generate_code(compiler));
- reverse_buf(compiler);
-
- /* Second code generation pass. */
- code = (sljit_ub*)SLJIT_MALLOC_EXEC(compiler->size);
- PTR_FAIL_WITH_EXEC_IF(code);
- buf = compiler->buf;
-
- code_ptr = code;
- label = compiler->labels;
- jump = compiler->jumps;
- const_ = compiler->consts;
- do {
- buf_ptr = buf->memory;
- buf_end = buf_ptr + buf->used_size;
- do {
- len = *buf_ptr++;
- if (len > 0) {
- /* The code is already generated. */
- SLJIT_MEMMOVE(code_ptr, buf_ptr, len);
- code_ptr += len;
- buf_ptr += len;
- }
- else {
- if (*buf_ptr >= 4) {
- jump->addr = (sljit_uw)code_ptr;
- if (!(jump->flags & SLJIT_REWRITABLE_JUMP))
- code_ptr = generate_near_jump_code(jump, code_ptr, code, *buf_ptr - 4);
- else
- code_ptr = generate_far_jump_code(jump, code_ptr, *buf_ptr - 4);
- jump = jump->next;
- }
- else if (*buf_ptr == 0) {
- label->addr = (sljit_uw)code_ptr;
- label->size = code_ptr - code;
- label = label->next;
- }
- else if (*buf_ptr == 1) {
- const_->addr = ((sljit_uw)code_ptr) - sizeof(sljit_sw);
- const_ = const_->next;
- }
- else {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- *code_ptr++ = (*buf_ptr == 2) ? CALL_i32 : JMP_i32;
- buf_ptr++;
- *(sljit_sw*)code_ptr = *(sljit_sw*)buf_ptr - ((sljit_sw)code_ptr + sizeof(sljit_sw));
- code_ptr += sizeof(sljit_sw);
- buf_ptr += sizeof(sljit_sw) - 1;
-#else
- code_ptr = generate_fixed_jump(code_ptr, *(sljit_sw*)(buf_ptr + 1), *buf_ptr);
- buf_ptr += sizeof(sljit_sw);
-#endif
- }
- buf_ptr++;
- }
- } while (buf_ptr < buf_end);
- SLJIT_ASSERT(buf_ptr == buf_end);
- buf = buf->next;
- } while (buf);
-
- SLJIT_ASSERT(!label);
- SLJIT_ASSERT(!jump);
- SLJIT_ASSERT(!const_);
-
- jump = compiler->jumps;
- while (jump) {
- if (jump->flags & PATCH_MB) {
- SLJIT_ASSERT((sljit_sw)(jump->u.label->addr - (jump->addr + sizeof(sljit_sb))) >= -128 && (sljit_sw)(jump->u.label->addr - (jump->addr + sizeof(sljit_sb))) <= 127);
- *(sljit_ub*)jump->addr = (sljit_ub)(jump->u.label->addr - (jump->addr + sizeof(sljit_sb)));
- } else if (jump->flags & PATCH_MW) {
- if (jump->flags & JUMP_LABEL) {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- *(sljit_sw*)jump->addr = (sljit_sw)(jump->u.label->addr - (jump->addr + sizeof(sljit_sw)));
-#else
- SLJIT_ASSERT((sljit_sw)(jump->u.label->addr - (jump->addr + sizeof(sljit_si))) >= HALFWORD_MIN && (sljit_sw)(jump->u.label->addr - (jump->addr + sizeof(sljit_si))) <= HALFWORD_MAX);
- *(sljit_si*)jump->addr = (sljit_si)(jump->u.label->addr - (jump->addr + sizeof(sljit_si)));
-#endif
- }
- else {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- *(sljit_sw*)jump->addr = (sljit_sw)(jump->u.target - (jump->addr + sizeof(sljit_sw)));
-#else
- SLJIT_ASSERT((sljit_sw)(jump->u.target - (jump->addr + sizeof(sljit_si))) >= HALFWORD_MIN && (sljit_sw)(jump->u.target - (jump->addr + sizeof(sljit_si))) <= HALFWORD_MAX);
- *(sljit_si*)jump->addr = (sljit_si)(jump->u.target - (jump->addr + sizeof(sljit_si)));
-#endif
- }
- }
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- else if (jump->flags & PATCH_MD)
- *(sljit_sw*)jump->addr = jump->u.label->addr;
-#endif
-
- jump = jump->next;
- }
-
- /* Maybe we waste some space because of short jumps. */
- SLJIT_ASSERT(code_ptr <= code + compiler->size);
- compiler->error = SLJIT_ERR_COMPILED;
- compiler->executable_size = code_ptr - code;
- return (void*)code;
-}
-
-/* --------------------------------------------------------------------- */
-/* Operators */
-/* --------------------------------------------------------------------- */
-
-static sljit_si emit_cum_binary(struct sljit_compiler *compiler,
- sljit_ub op_rm, sljit_ub op_mr, sljit_ub op_imm, sljit_ub op_eax_imm,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w);
-
-static sljit_si emit_non_cum_binary(struct sljit_compiler *compiler,
- sljit_ub op_rm, sljit_ub op_mr, sljit_ub op_imm, sljit_ub op_eax_imm,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w);
-
-static sljit_si emit_mov(struct sljit_compiler *compiler,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw);
-
-static SLJIT_INLINE sljit_si emit_save_flags(struct sljit_compiler *compiler)
-{
- sljit_ub *inst;
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 5);
- FAIL_IF(!inst);
- INC_SIZE(5);
-#else
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 6);
- FAIL_IF(!inst);
- INC_SIZE(6);
- *inst++ = REX_W;
-#endif
- *inst++ = LEA_r_m; /* lea esp/rsp, [esp/rsp + sizeof(sljit_sw)] */
- *inst++ = 0x64;
- *inst++ = 0x24;
- *inst++ = (sljit_ub)sizeof(sljit_sw);
- *inst++ = PUSHF;
- compiler->flags_saved = 1;
- return SLJIT_SUCCESS;
-}
-
-static SLJIT_INLINE sljit_si emit_restore_flags(struct sljit_compiler *compiler, sljit_si keep_flags)
-{
- sljit_ub *inst;
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 5);
- FAIL_IF(!inst);
- INC_SIZE(5);
- *inst++ = POPF;
-#else
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 6);
- FAIL_IF(!inst);
- INC_SIZE(6);
- *inst++ = POPF;
- *inst++ = REX_W;
-#endif
- *inst++ = LEA_r_m; /* lea esp/rsp, [esp/rsp - sizeof(sljit_sw)] */
- *inst++ = 0x64;
- *inst++ = 0x24;
- *inst++ = (sljit_ub)-(sljit_sb)sizeof(sljit_sw);
- compiler->flags_saved = keep_flags;
- return SLJIT_SUCCESS;
-}
-
-#ifdef _WIN32
-#include
-
-static void SLJIT_CALL sljit_grow_stack(sljit_sw local_size)
-{
- /* Workaround for calling the internal _chkstk() function on Windows.
- This function touches all 4k pages belongs to the requested stack space,
- which size is passed in local_size. This is necessary on Windows where
- the stack can only grow in 4k steps. However, this function just burn
- CPU cycles if the stack is large enough. However, you don't know it in
- advance, so it must always be called. I think this is a bad design in
- general even if it has some reasons. */
- *(volatile sljit_si*)alloca(local_size) = 0;
-}
-
-#endif
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-#include "sljitNativeX86_32.c"
-#else
-#include "sljitNativeX86_64.c"
-#endif
-
-static sljit_si emit_mov(struct sljit_compiler *compiler,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_ub* inst;
-
- if (dst == SLJIT_UNUSED) {
- /* No destination, doesn't need to setup flags. */
- if (src & SLJIT_MEM) {
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw);
- FAIL_IF(!inst);
- *inst = MOV_r_rm;
- }
- return SLJIT_SUCCESS;
- }
- if (FAST_IS_REG(src)) {
- inst = emit_x86_instruction(compiler, 1, src, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm_r;
- return SLJIT_SUCCESS;
- }
- if (src & SLJIT_IMM) {
- if (FAST_IS_REG(dst)) {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw);
-#else
- if (!compiler->mode32) {
- if (NOT_HALFWORD(srcw))
- return emit_load_imm64(compiler, dst, srcw);
- }
- else
- return emit_do_imm32(compiler, (reg_map[dst] >= 8) ? REX_B : 0, MOV_r_i32 + reg_lmap[dst], srcw);
-#endif
- }
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (!compiler->mode32 && NOT_HALFWORD(srcw)) {
- FAIL_IF(emit_load_imm64(compiler, TMP_REG2, srcw));
- inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm_r;
- return SLJIT_SUCCESS;
- }
-#endif
- inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm_i32;
- return SLJIT_SUCCESS;
- }
- if (FAST_IS_REG(dst)) {
- inst = emit_x86_instruction(compiler, 1, dst, 0, src, srcw);
- FAIL_IF(!inst);
- *inst = MOV_r_rm;
- return SLJIT_SUCCESS;
- }
-
- /* Memory to memory move. Requires two instruction. */
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src, srcw);
- FAIL_IF(!inst);
- *inst = MOV_r_rm;
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm_r;
- return SLJIT_SUCCESS;
-}
-
-#define EMIT_MOV(compiler, dst, dstw, src, srcw) \
- FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw));
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op0(struct sljit_compiler *compiler, sljit_si op)
-{
- sljit_ub *inst;
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- sljit_si size;
-#endif
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_op0(compiler, op));
-
- switch (GET_OPCODE(op)) {
- case SLJIT_BREAKPOINT:
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1);
- *inst = INT3;
- break;
- case SLJIT_NOP:
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1);
- *inst = NOP;
- break;
- case SLJIT_LUMUL:
- case SLJIT_LSMUL:
- case SLJIT_UDIVMOD:
- case SLJIT_SDIVMOD:
- case SLJIT_UDIVI:
- case SLJIT_SDIVI:
- compiler->flags_saved = 0;
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
-#ifdef _WIN64
- SLJIT_COMPILE_ASSERT(
- reg_map[SLJIT_R0] == 0
- && reg_map[SLJIT_R1] == 2
- && reg_map[TMP_REG1] > 7,
- invalid_register_assignment_for_div_mul);
-#else
- SLJIT_COMPILE_ASSERT(
- reg_map[SLJIT_R0] == 0
- && reg_map[SLJIT_R1] < 7
- && reg_map[TMP_REG1] == 2,
- invalid_register_assignment_for_div_mul);
-#endif
- compiler->mode32 = op & SLJIT_INT_OP;
-#endif
- SLJIT_COMPILE_ASSERT((SLJIT_UDIVMOD & 0x2) == 0 && SLJIT_UDIVI - 0x2 == SLJIT_UDIVMOD, bad_div_opcode_assignments);
-
- op = GET_OPCODE(op);
- if ((op | 0x2) == SLJIT_UDIVI) {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || defined(_WIN64)
- EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0);
- inst = emit_x86_instruction(compiler, 1, SLJIT_R1, 0, SLJIT_R1, 0);
-#else
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0);
-#endif
- FAIL_IF(!inst);
- *inst = XOR_r_rm;
- }
-
- if ((op | 0x2) == SLJIT_SDIVI) {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) || defined(_WIN64)
- EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_R1, 0);
-#endif
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1);
- *inst = CDQ;
-#else
- if (compiler->mode32) {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1);
- *inst = CDQ;
- } else {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 2);
- FAIL_IF(!inst);
- INC_SIZE(2);
- *inst++ = REX_W;
- *inst = CDQ;
- }
-#endif
- }
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 2);
- FAIL_IF(!inst);
- INC_SIZE(2);
- *inst++ = GROUP_F7;
- *inst = MOD_REG | ((op >= SLJIT_UDIVMOD) ? reg_map[TMP_REG1] : reg_map[SLJIT_R1]);
-#else
-#ifdef _WIN64
- size = (!compiler->mode32 || op >= SLJIT_UDIVMOD) ? 3 : 2;
-#else
- size = (!compiler->mode32) ? 3 : 2;
-#endif
- inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
- FAIL_IF(!inst);
- INC_SIZE(size);
-#ifdef _WIN64
- if (!compiler->mode32)
- *inst++ = REX_W | ((op >= SLJIT_UDIVMOD) ? REX_B : 0);
- else if (op >= SLJIT_UDIVMOD)
- *inst++ = REX_B;
- *inst++ = GROUP_F7;
- *inst = MOD_REG | ((op >= SLJIT_UDIVMOD) ? reg_lmap[TMP_REG1] : reg_lmap[SLJIT_R1]);
-#else
- if (!compiler->mode32)
- *inst++ = REX_W;
- *inst++ = GROUP_F7;
- *inst = MOD_REG | reg_map[SLJIT_R1];
-#endif
-#endif
- switch (op) {
- case SLJIT_LUMUL:
- *inst |= MUL;
- break;
- case SLJIT_LSMUL:
- *inst |= IMUL;
- break;
- case SLJIT_UDIVMOD:
- case SLJIT_UDIVI:
- *inst |= DIV;
- break;
- case SLJIT_SDIVMOD:
- case SLJIT_SDIVI:
- *inst |= IDIV;
- break;
- }
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && !defined(_WIN64)
- if (op <= SLJIT_SDIVMOD)
- EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0);
-#else
- if (op >= SLJIT_UDIVI)
- EMIT_MOV(compiler, SLJIT_R1, 0, TMP_REG1, 0);
-#endif
- break;
- }
-
- return SLJIT_SUCCESS;
-}
-
-#define ENCODE_PREFIX(prefix) \
- do { \
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1); \
- FAIL_IF(!inst); \
- INC_SIZE(1); \
- *inst = (prefix); \
- } while (0)
-
-static sljit_si emit_mov_byte(struct sljit_compiler *compiler, sljit_si sign,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_ub* inst;
- sljit_si dst_r;
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- sljit_si work_r;
-#endif
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- compiler->mode32 = 0;
-#endif
-
- if (dst == SLJIT_UNUSED && !(src & SLJIT_MEM))
- return SLJIT_SUCCESS; /* Empty instruction. */
-
- if (src & SLJIT_IMM) {
- if (FAST_IS_REG(dst)) {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw);
-#else
- inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0);
- FAIL_IF(!inst);
- *inst = MOV_rm_i32;
- return SLJIT_SUCCESS;
-#endif
- }
- inst = emit_x86_instruction(compiler, 1 | EX86_BYTE_ARG | EX86_NO_REXW, SLJIT_IMM, srcw, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm8_i8;
- return SLJIT_SUCCESS;
- }
-
- dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1;
-
- if ((dst & SLJIT_MEM) && FAST_IS_REG(src)) {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- if (reg_map[src] >= 4) {
- SLJIT_ASSERT(dst_r == TMP_REG1);
- EMIT_MOV(compiler, TMP_REG1, 0, src, 0);
- } else
- dst_r = src;
-#else
- dst_r = src;
-#endif
- }
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- else if (FAST_IS_REG(src) && reg_map[src] >= 4) {
- /* src, dst are registers. */
- SLJIT_ASSERT(SLOW_IS_REG(dst));
- if (reg_map[dst] < 4) {
- if (dst != src)
- EMIT_MOV(compiler, dst, 0, src, 0);
- inst = emit_x86_instruction(compiler, 2, dst, 0, dst, 0);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = sign ? MOVSX_r_rm8 : MOVZX_r_rm8;
- }
- else {
- if (dst != src)
- EMIT_MOV(compiler, dst, 0, src, 0);
- if (sign) {
- /* shl reg, 24 */
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0);
- FAIL_IF(!inst);
- *inst |= SHL;
- /* sar reg, 24 */
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 24, dst, 0);
- FAIL_IF(!inst);
- *inst |= SAR;
- }
- else {
- inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 0xff, dst, 0);
- FAIL_IF(!inst);
- *(inst + 1) |= AND;
- }
- }
- return SLJIT_SUCCESS;
- }
-#endif
- else {
- /* src can be memory addr or reg_map[src] < 4 on x86_32 architectures. */
- inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = sign ? MOVSX_r_rm8 : MOVZX_r_rm8;
- }
-
- if (dst & SLJIT_MEM) {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- if (dst_r == TMP_REG1) {
- /* Find a non-used register, whose reg_map[src] < 4. */
- if ((dst & REG_MASK) == SLJIT_R0) {
- if ((dst & OFFS_REG_MASK) == TO_OFFS_REG(SLJIT_R1))
- work_r = SLJIT_R2;
- else
- work_r = SLJIT_R1;
- }
- else {
- if ((dst & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_R0))
- work_r = SLJIT_R0;
- else if ((dst & REG_MASK) == SLJIT_R1)
- work_r = SLJIT_R2;
- else
- work_r = SLJIT_R1;
- }
-
- if (work_r == SLJIT_R0) {
- ENCODE_PREFIX(XCHG_EAX_r + reg_map[TMP_REG1]);
- }
- else {
- inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0);
- FAIL_IF(!inst);
- *inst = XCHG_r_rm;
- }
-
- inst = emit_x86_instruction(compiler, 1, work_r, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm8_r8;
-
- if (work_r == SLJIT_R0) {
- ENCODE_PREFIX(XCHG_EAX_r + reg_map[TMP_REG1]);
- }
- else {
- inst = emit_x86_instruction(compiler, 1, work_r, 0, dst_r, 0);
- FAIL_IF(!inst);
- *inst = XCHG_r_rm;
- }
- }
- else {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm8_r8;
- }
-#else
- inst = emit_x86_instruction(compiler, 1 | EX86_REX | EX86_NO_REXW, dst_r, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm8_r8;
-#endif
- }
-
- return SLJIT_SUCCESS;
-}
-
-static sljit_si emit_mov_half(struct sljit_compiler *compiler, sljit_si sign,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_ub* inst;
- sljit_si dst_r;
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- compiler->mode32 = 0;
-#endif
-
- if (dst == SLJIT_UNUSED && !(src & SLJIT_MEM))
- return SLJIT_SUCCESS; /* Empty instruction. */
-
- if (src & SLJIT_IMM) {
- if (FAST_IS_REG(dst)) {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- return emit_do_imm(compiler, MOV_r_i32 + reg_map[dst], srcw);
-#else
- inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, srcw, dst, 0);
- FAIL_IF(!inst);
- *inst = MOV_rm_i32;
- return SLJIT_SUCCESS;
-#endif
- }
- inst = emit_x86_instruction(compiler, 1 | EX86_HALF_ARG | EX86_NO_REXW | EX86_PREF_66, SLJIT_IMM, srcw, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm_i32;
- return SLJIT_SUCCESS;
- }
-
- dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1;
-
- if ((dst & SLJIT_MEM) && FAST_IS_REG(src))
- dst_r = src;
- else {
- inst = emit_x86_instruction(compiler, 2, dst_r, 0, src, srcw);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = sign ? MOVSX_r_rm16 : MOVZX_r_rm16;
- }
-
- if (dst & SLJIT_MEM) {
- inst = emit_x86_instruction(compiler, 1 | EX86_NO_REXW | EX86_PREF_66, dst_r, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = MOV_rm_r;
- }
-
- return SLJIT_SUCCESS;
-}
-
-static sljit_si emit_unary(struct sljit_compiler *compiler, sljit_ub opcode,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_ub* inst;
-
- if (dst == SLJIT_UNUSED) {
- EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
- inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst++ = GROUP_F7;
- *inst |= opcode;
- return SLJIT_SUCCESS;
- }
- if (dst == src && dstw == srcw) {
- /* Same input and output */
- inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst++ = GROUP_F7;
- *inst |= opcode;
- return SLJIT_SUCCESS;
- }
- if (FAST_IS_REG(dst)) {
- EMIT_MOV(compiler, dst, 0, src, srcw);
- inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst++ = GROUP_F7;
- *inst |= opcode;
- return SLJIT_SUCCESS;
- }
- EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
- inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst++ = GROUP_F7;
- *inst |= opcode;
- EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
- return SLJIT_SUCCESS;
-}
-
-static sljit_si emit_not_with_flags(struct sljit_compiler *compiler,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_ub* inst;
-
- if (dst == SLJIT_UNUSED) {
- EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
- inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst++ = GROUP_F7;
- *inst |= NOT_rm;
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst = OR_r_rm;
- return SLJIT_SUCCESS;
- }
- if (FAST_IS_REG(dst)) {
- EMIT_MOV(compiler, dst, 0, src, srcw);
- inst = emit_x86_instruction(compiler, 1, 0, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst++ = GROUP_F7;
- *inst |= NOT_rm;
- inst = emit_x86_instruction(compiler, 1, dst, 0, dst, 0);
- FAIL_IF(!inst);
- *inst = OR_r_rm;
- return SLJIT_SUCCESS;
- }
- EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
- inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst++ = GROUP_F7;
- *inst |= NOT_rm;
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst = OR_r_rm;
- EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
- return SLJIT_SUCCESS;
-}
-
-static sljit_si emit_clz(struct sljit_compiler *compiler, sljit_si op_flags,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_ub* inst;
- sljit_si dst_r;
-
- SLJIT_UNUSED_ARG(op_flags);
- if (SLJIT_UNLIKELY(dst == SLJIT_UNUSED)) {
- /* Just set the zero flag. */
- EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
- inst = emit_x86_instruction(compiler, 1, 0, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst++ = GROUP_F7;
- *inst |= NOT_rm;
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, 31, TMP_REG1, 0);
-#else
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 63 : 31, TMP_REG1, 0);
-#endif
- FAIL_IF(!inst);
- *inst |= SHR;
- return SLJIT_SUCCESS;
- }
-
- if (SLJIT_UNLIKELY(src & SLJIT_IMM)) {
- EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw);
- src = TMP_REG1;
- srcw = 0;
- }
-
- inst = emit_x86_instruction(compiler, 2, TMP_REG1, 0, src, srcw);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = BSR_r_rm;
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- if (FAST_IS_REG(dst))
- dst_r = dst;
- else {
- /* Find an unused temporary register. */
- if ((dst & REG_MASK) != SLJIT_R0 && (dst & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_R0))
- dst_r = SLJIT_R0;
- else if ((dst & REG_MASK) != SLJIT_R1 && (dst & OFFS_REG_MASK) != TO_OFFS_REG(SLJIT_R1))
- dst_r = SLJIT_R1;
- else
- dst_r = SLJIT_R2;
- EMIT_MOV(compiler, dst, dstw, dst_r, 0);
- }
- EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, 32 + 31);
-#else
- dst_r = FAST_IS_REG(dst) ? dst : TMP_REG2;
- compiler->mode32 = 0;
- EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 64 + 63 : 32 + 31);
- compiler->mode32 = op_flags & SLJIT_INT_OP;
-#endif
-
- if (cpu_has_cmov == -1)
- get_cpu_features();
-
- if (cpu_has_cmov) {
- inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = CMOVNE_r_rm;
- } else {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
- FAIL_IF(!inst);
- INC_SIZE(4);
-
- *inst++ = JE_i8;
- *inst++ = 2;
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_map[dst_r] << 3) | reg_map[TMP_REG1];
-#else
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 5);
- FAIL_IF(!inst);
- INC_SIZE(5);
-
- *inst++ = JE_i8;
- *inst++ = 3;
- *inst++ = REX_W | (reg_map[dst_r] >= 8 ? REX_R : 0) | (reg_map[TMP_REG1] >= 8 ? REX_B : 0);
- *inst++ = MOV_r_rm;
- *inst++ = MOD_REG | (reg_lmap[dst_r] << 3) | reg_lmap[TMP_REG1];
-#endif
- }
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, 31, dst_r, 0);
-#else
- inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, !(op_flags & SLJIT_INT_OP) ? 63 : 31, dst_r, 0);
-#endif
- FAIL_IF(!inst);
- *(inst + 1) |= XOR;
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- if (dst & SLJIT_MEM) {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = XCHG_r_rm;
- }
-#else
- if (dst & SLJIT_MEM)
- EMIT_MOV(compiler, dst, dstw, TMP_REG2, 0);
-#endif
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op1(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_ub* inst;
- sljit_si update = 0;
- sljit_si op_flags = GET_ALL_FLAGS(op);
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- sljit_si dst_is_ereg = 0;
- sljit_si src_is_ereg = 0;
-#else
-# define src_is_ereg 0
-#endif
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_op1(compiler, op, dst, dstw, src, srcw));
- ADJUST_LOCAL_OFFSET(dst, dstw);
- ADJUST_LOCAL_OFFSET(src, srcw);
-
- CHECK_EXTRA_REGS(dst, dstw, dst_is_ereg = 1);
- CHECK_EXTRA_REGS(src, srcw, src_is_ereg = 1);
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- compiler->mode32 = op_flags & SLJIT_INT_OP;
-#endif
-
- op = GET_OPCODE(op);
- if (op >= SLJIT_MOV && op <= SLJIT_MOVU_P) {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- compiler->mode32 = 0;
-#endif
-
- if (op_flags & SLJIT_INT_OP) {
- if (FAST_IS_REG(src) && src == dst) {
- if (!TYPE_CAST_NEEDED(op))
- return SLJIT_SUCCESS;
- }
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (op == SLJIT_MOV_SI && (src & SLJIT_MEM))
- op = SLJIT_MOV_UI;
- if (op == SLJIT_MOVU_SI && (src & SLJIT_MEM))
- op = SLJIT_MOVU_UI;
- if (op == SLJIT_MOV_UI && (src & SLJIT_IMM))
- op = SLJIT_MOV_SI;
- if (op == SLJIT_MOVU_UI && (src & SLJIT_IMM))
- op = SLJIT_MOVU_SI;
-#endif
- }
-
- SLJIT_COMPILE_ASSERT(SLJIT_MOV + 8 == SLJIT_MOVU, movu_offset);
- if (op >= SLJIT_MOVU) {
- update = 1;
- op -= 8;
- }
-
- if (src & SLJIT_IMM) {
- switch (op) {
- case SLJIT_MOV_UB:
- srcw = (sljit_ub)srcw;
- break;
- case SLJIT_MOV_SB:
- srcw = (sljit_sb)srcw;
- break;
- case SLJIT_MOV_UH:
- srcw = (sljit_uh)srcw;
- break;
- case SLJIT_MOV_SH:
- srcw = (sljit_sh)srcw;
- break;
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- case SLJIT_MOV_UI:
- srcw = (sljit_ui)srcw;
- break;
- case SLJIT_MOV_SI:
- srcw = (sljit_si)srcw;
- break;
-#endif
- }
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- if (SLJIT_UNLIKELY(dst_is_ereg))
- return emit_mov(compiler, dst, dstw, src, srcw);
-#endif
- }
-
- if (SLJIT_UNLIKELY(update) && (src & SLJIT_MEM) && !src_is_ereg && (src & REG_MASK) && (srcw != 0 || (src & OFFS_REG_MASK) != 0)) {
- inst = emit_x86_instruction(compiler, 1, src & REG_MASK, 0, src, srcw);
- FAIL_IF(!inst);
- *inst = LEA_r_m;
- src &= SLJIT_MEM | 0xf;
- srcw = 0;
- }
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- if (SLJIT_UNLIKELY(dst_is_ereg) && (!(op == SLJIT_MOV || op == SLJIT_MOV_UI || op == SLJIT_MOV_SI || op == SLJIT_MOV_P) || (src & SLJIT_MEM))) {
- SLJIT_ASSERT(dst == SLJIT_MEM1(SLJIT_SP));
- dst = TMP_REG1;
- }
-#endif
-
- switch (op) {
- case SLJIT_MOV:
- case SLJIT_MOV_P:
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- case SLJIT_MOV_UI:
- case SLJIT_MOV_SI:
-#endif
- FAIL_IF(emit_mov(compiler, dst, dstw, src, srcw));
- break;
- case SLJIT_MOV_UB:
- FAIL_IF(emit_mov_byte(compiler, 0, dst, dstw, src, srcw));
- break;
- case SLJIT_MOV_SB:
- FAIL_IF(emit_mov_byte(compiler, 1, dst, dstw, src, srcw));
- break;
- case SLJIT_MOV_UH:
- FAIL_IF(emit_mov_half(compiler, 0, dst, dstw, src, srcw));
- break;
- case SLJIT_MOV_SH:
- FAIL_IF(emit_mov_half(compiler, 1, dst, dstw, src, srcw));
- break;
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- case SLJIT_MOV_UI:
- FAIL_IF(emit_mov_int(compiler, 0, dst, dstw, src, srcw));
- break;
- case SLJIT_MOV_SI:
- FAIL_IF(emit_mov_int(compiler, 1, dst, dstw, src, srcw));
- break;
-#endif
- }
-
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- if (SLJIT_UNLIKELY(dst_is_ereg) && dst == TMP_REG1)
- return emit_mov(compiler, SLJIT_MEM1(SLJIT_SP), dstw, TMP_REG1, 0);
-#endif
-
- if (SLJIT_UNLIKELY(update) && (dst & SLJIT_MEM) && (dst & REG_MASK) && (dstw != 0 || (dst & OFFS_REG_MASK) != 0)) {
- inst = emit_x86_instruction(compiler, 1, dst & REG_MASK, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = LEA_r_m;
- }
- return SLJIT_SUCCESS;
- }
-
- if (SLJIT_UNLIKELY(GET_FLAGS(op_flags)))
- compiler->flags_saved = 0;
-
- switch (op) {
- case SLJIT_NOT:
- if (SLJIT_UNLIKELY(op_flags & SLJIT_SET_E))
- return emit_not_with_flags(compiler, dst, dstw, src, srcw);
- return emit_unary(compiler, NOT_rm, dst, dstw, src, srcw);
-
- case SLJIT_NEG:
- if (SLJIT_UNLIKELY(op_flags & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
- FAIL_IF(emit_save_flags(compiler));
- return emit_unary(compiler, NEG_rm, dst, dstw, src, srcw);
-
- case SLJIT_CLZ:
- if (SLJIT_UNLIKELY(op_flags & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
- FAIL_IF(emit_save_flags(compiler));
- return emit_clz(compiler, op_flags, dst, dstw, src, srcw);
- }
-
- return SLJIT_SUCCESS;
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
-# undef src_is_ereg
-#endif
-}
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
-
-#define BINARY_IMM(op_imm, op_mr, immw, arg, argw) \
- if (IS_HALFWORD(immw) || compiler->mode32) { \
- inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
- FAIL_IF(!inst); \
- *(inst + 1) |= (op_imm); \
- } \
- else { \
- FAIL_IF(emit_load_imm64(compiler, TMP_REG2, immw)); \
- inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, arg, argw); \
- FAIL_IF(!inst); \
- *inst = (op_mr); \
- }
-
-#define BINARY_EAX_IMM(op_eax_imm, immw) \
- FAIL_IF(emit_do_imm32(compiler, (!compiler->mode32) ? REX_W : 0, (op_eax_imm), immw))
-
-#else
-
-#define BINARY_IMM(op_imm, op_mr, immw, arg, argw) \
- inst = emit_x86_instruction(compiler, 1 | EX86_BIN_INS, SLJIT_IMM, immw, arg, argw); \
- FAIL_IF(!inst); \
- *(inst + 1) |= (op_imm);
-
-#define BINARY_EAX_IMM(op_eax_imm, immw) \
- FAIL_IF(emit_do_imm(compiler, (op_eax_imm), immw))
-
-#endif
-
-static sljit_si emit_cum_binary(struct sljit_compiler *compiler,
- sljit_ub op_rm, sljit_ub op_mr, sljit_ub op_imm, sljit_ub op_eax_imm,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_ub* inst;
-
- if (dst == SLJIT_UNUSED) {
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- if (src2 & SLJIT_IMM) {
- BINARY_IMM(op_imm, op_mr, src2w, TMP_REG1, 0);
- }
- else {
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = op_rm;
- }
- return SLJIT_SUCCESS;
- }
-
- if (dst == src1 && dstw == src1w) {
- if (src2 & SLJIT_IMM) {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))) {
-#else
- if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128)) {
-#endif
- BINARY_EAX_IMM(op_eax_imm, src2w);
- }
- else {
- BINARY_IMM(op_imm, op_mr, src2w, dst, dstw);
- }
- }
- else if (FAST_IS_REG(dst)) {
- inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
- FAIL_IF(!inst);
- *inst = op_rm;
- }
- else if (FAST_IS_REG(src2)) {
- /* Special exception for sljit_emit_op_flags. */
- inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
- FAIL_IF(!inst);
- *inst = op_mr;
- }
- else {
- EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = op_mr;
- }
- return SLJIT_SUCCESS;
- }
-
- /* Only for cumulative operations. */
- if (dst == src2 && dstw == src2w) {
- if (src1 & SLJIT_IMM) {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if ((dst == SLJIT_R0) && (src1w > 127 || src1w < -128) && (compiler->mode32 || IS_HALFWORD(src1w))) {
-#else
- if ((dst == SLJIT_R0) && (src1w > 127 || src1w < -128)) {
-#endif
- BINARY_EAX_IMM(op_eax_imm, src1w);
- }
- else {
- BINARY_IMM(op_imm, op_mr, src1w, dst, dstw);
- }
- }
- else if (FAST_IS_REG(dst)) {
- inst = emit_x86_instruction(compiler, 1, dst, dstw, src1, src1w);
- FAIL_IF(!inst);
- *inst = op_rm;
- }
- else if (FAST_IS_REG(src1)) {
- inst = emit_x86_instruction(compiler, 1, src1, src1w, dst, dstw);
- FAIL_IF(!inst);
- *inst = op_mr;
- }
- else {
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = op_mr;
- }
- return SLJIT_SUCCESS;
- }
-
- /* General version. */
- if (FAST_IS_REG(dst)) {
- EMIT_MOV(compiler, dst, 0, src1, src1w);
- if (src2 & SLJIT_IMM) {
- BINARY_IMM(op_imm, op_mr, src2w, dst, 0);
- }
- else {
- inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = op_rm;
- }
- }
- else {
- /* This version requires less memory writing. */
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- if (src2 & SLJIT_IMM) {
- BINARY_IMM(op_imm, op_mr, src2w, TMP_REG1, 0);
- }
- else {
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = op_rm;
- }
- EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
- }
-
- return SLJIT_SUCCESS;
-}
-
-static sljit_si emit_non_cum_binary(struct sljit_compiler *compiler,
- sljit_ub op_rm, sljit_ub op_mr, sljit_ub op_imm, sljit_ub op_eax_imm,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_ub* inst;
-
- if (dst == SLJIT_UNUSED) {
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- if (src2 & SLJIT_IMM) {
- BINARY_IMM(op_imm, op_mr, src2w, TMP_REG1, 0);
- }
- else {
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = op_rm;
- }
- return SLJIT_SUCCESS;
- }
-
- if (dst == src1 && dstw == src1w) {
- if (src2 & SLJIT_IMM) {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))) {
-#else
- if ((dst == SLJIT_R0) && (src2w > 127 || src2w < -128)) {
-#endif
- BINARY_EAX_IMM(op_eax_imm, src2w);
- }
- else {
- BINARY_IMM(op_imm, op_mr, src2w, dst, dstw);
- }
- }
- else if (FAST_IS_REG(dst)) {
- inst = emit_x86_instruction(compiler, 1, dst, dstw, src2, src2w);
- FAIL_IF(!inst);
- *inst = op_rm;
- }
- else if (FAST_IS_REG(src2)) {
- inst = emit_x86_instruction(compiler, 1, src2, src2w, dst, dstw);
- FAIL_IF(!inst);
- *inst = op_mr;
- }
- else {
- EMIT_MOV(compiler, TMP_REG1, 0, src2, src2w);
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, dst, dstw);
- FAIL_IF(!inst);
- *inst = op_mr;
- }
- return SLJIT_SUCCESS;
- }
-
- /* General version. */
- if (FAST_IS_REG(dst) && dst != src2) {
- EMIT_MOV(compiler, dst, 0, src1, src1w);
- if (src2 & SLJIT_IMM) {
- BINARY_IMM(op_imm, op_mr, src2w, dst, 0);
- }
- else {
- inst = emit_x86_instruction(compiler, 1, dst, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = op_rm;
- }
- }
- else {
- /* This version requires less memory writing. */
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- if (src2 & SLJIT_IMM) {
- BINARY_IMM(op_imm, op_mr, src2w, TMP_REG1, 0);
- }
- else {
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = op_rm;
- }
- EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
- }
-
- return SLJIT_SUCCESS;
-}
-
-static sljit_si emit_mul(struct sljit_compiler *compiler,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_ub* inst;
- sljit_si dst_r;
-
- dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1;
-
- /* Register destination. */
- if (dst_r == src1 && !(src2 & SLJIT_IMM)) {
- inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = IMUL_r_rm;
- }
- else if (dst_r == src2 && !(src1 & SLJIT_IMM)) {
- inst = emit_x86_instruction(compiler, 2, dst_r, 0, src1, src1w);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = IMUL_r_rm;
- }
- else if (src1 & SLJIT_IMM) {
- if (src2 & SLJIT_IMM) {
- EMIT_MOV(compiler, dst_r, 0, SLJIT_IMM, src2w);
- src2 = dst_r;
- src2w = 0;
- }
-
- if (src1w <= 127 && src1w >= -128) {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = IMUL_r_rm_i8;
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1);
- *inst = (sljit_sb)src1w;
- }
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- else {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = IMUL_r_rm_i32;
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
- FAIL_IF(!inst);
- INC_SIZE(4);
- *(sljit_sw*)inst = src1w;
- }
-#else
- else if (IS_HALFWORD(src1w)) {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = IMUL_r_rm_i32;
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
- FAIL_IF(!inst);
- INC_SIZE(4);
- *(sljit_si*)inst = (sljit_si)src1w;
- }
- else {
- EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src1w);
- if (dst_r != src2)
- EMIT_MOV(compiler, dst_r, 0, src2, src2w);
- inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = IMUL_r_rm;
- }
-#endif
- }
- else if (src2 & SLJIT_IMM) {
- /* Note: src1 is NOT immediate. */
-
- if (src2w <= 127 && src2w >= -128) {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
- FAIL_IF(!inst);
- *inst = IMUL_r_rm_i8;
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1);
- *inst = (sljit_sb)src2w;
- }
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- else {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
- FAIL_IF(!inst);
- *inst = IMUL_r_rm_i32;
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
- FAIL_IF(!inst);
- INC_SIZE(4);
- *(sljit_sw*)inst = src2w;
- }
-#else
- else if (IS_HALFWORD(src2w)) {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, src1, src1w);
- FAIL_IF(!inst);
- *inst = IMUL_r_rm_i32;
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 4);
- FAIL_IF(!inst);
- INC_SIZE(4);
- *(sljit_si*)inst = (sljit_si)src2w;
- }
- else {
- EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_IMM, src2w);
- if (dst_r != src1)
- EMIT_MOV(compiler, dst_r, 0, src1, src1w);
- inst = emit_x86_instruction(compiler, 2, dst_r, 0, TMP_REG2, 0);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = IMUL_r_rm;
- }
-#endif
- }
- else {
- /* Neither argument is immediate. */
- if (ADDRESSING_DEPENDS_ON(src2, dst_r))
- dst_r = TMP_REG1;
- EMIT_MOV(compiler, dst_r, 0, src1, src1w);
- inst = emit_x86_instruction(compiler, 2, dst_r, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = IMUL_r_rm;
- }
-
- if (dst_r == TMP_REG1)
- EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
-
- return SLJIT_SUCCESS;
-}
-
-static sljit_si emit_lea_binary(struct sljit_compiler *compiler, sljit_si keep_flags,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_ub* inst;
- sljit_si dst_r, done = 0;
-
- /* These cases better be left to handled by normal way. */
- if (!keep_flags) {
- if (dst == src1 && dstw == src1w)
- return SLJIT_ERR_UNSUPPORTED;
- if (dst == src2 && dstw == src2w)
- return SLJIT_ERR_UNSUPPORTED;
- }
-
- dst_r = FAST_IS_REG(dst) ? dst : TMP_REG1;
-
- if (FAST_IS_REG(src1)) {
- if (FAST_IS_REG(src2)) {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM2(src1, src2), 0);
- FAIL_IF(!inst);
- *inst = LEA_r_m;
- done = 1;
- }
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if ((src2 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src2w))) {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), (sljit_si)src2w);
-#else
- if (src2 & SLJIT_IMM) {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src1), src2w);
-#endif
- FAIL_IF(!inst);
- *inst = LEA_r_m;
- done = 1;
- }
- }
- else if (FAST_IS_REG(src2)) {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if ((src1 & SLJIT_IMM) && (compiler->mode32 || IS_HALFWORD(src1w))) {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), (sljit_si)src1w);
-#else
- if (src1 & SLJIT_IMM) {
- inst = emit_x86_instruction(compiler, 1, dst_r, 0, SLJIT_MEM1(src2), src1w);
-#endif
- FAIL_IF(!inst);
- *inst = LEA_r_m;
- done = 1;
- }
- }
-
- if (done) {
- if (dst_r == TMP_REG1)
- return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
- return SLJIT_SUCCESS;
- }
- return SLJIT_ERR_UNSUPPORTED;
-}
-
-static sljit_si emit_cmp_binary(struct sljit_compiler *compiler,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_ub* inst;
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))) {
-#else
- if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128)) {
-#endif
- BINARY_EAX_IMM(CMP_EAX_i32, src2w);
- return SLJIT_SUCCESS;
- }
-
- if (FAST_IS_REG(src1)) {
- if (src2 & SLJIT_IMM) {
- BINARY_IMM(CMP, CMP_rm_r, src2w, src1, 0);
- }
- else {
- inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = CMP_r_rm;
- }
- return SLJIT_SUCCESS;
- }
-
- if (FAST_IS_REG(src2) && !(src1 & SLJIT_IMM)) {
- inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
- FAIL_IF(!inst);
- *inst = CMP_rm_r;
- return SLJIT_SUCCESS;
- }
-
- if (src2 & SLJIT_IMM) {
- if (src1 & SLJIT_IMM) {
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- src1 = TMP_REG1;
- src1w = 0;
- }
- BINARY_IMM(CMP, CMP_rm_r, src2w, src1, src1w);
- }
- else {
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = CMP_r_rm;
- }
- return SLJIT_SUCCESS;
-}
-
-static sljit_si emit_test_binary(struct sljit_compiler *compiler,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_ub* inst;
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128) && (compiler->mode32 || IS_HALFWORD(src2w))) {
-#else
- if (src1 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src2w > 127 || src2w < -128)) {
-#endif
- BINARY_EAX_IMM(TEST_EAX_i32, src2w);
- return SLJIT_SUCCESS;
- }
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (src2 == SLJIT_R0 && (src2 & SLJIT_IMM) && (src1w > 127 || src1w < -128) && (compiler->mode32 || IS_HALFWORD(src1w))) {
-#else
- if (src2 == SLJIT_R0 && (src1 & SLJIT_IMM) && (src1w > 127 || src1w < -128)) {
-#endif
- BINARY_EAX_IMM(TEST_EAX_i32, src1w);
- return SLJIT_SUCCESS;
- }
-
- if (!(src1 & SLJIT_IMM)) {
- if (src2 & SLJIT_IMM) {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (IS_HALFWORD(src2w) || compiler->mode32) {
- inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
- FAIL_IF(!inst);
- *inst = GROUP_F7;
- }
- else {
- FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
- inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src1, src1w);
- FAIL_IF(!inst);
- *inst = TEST_rm_r;
- }
-#else
- inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, src1, src1w);
- FAIL_IF(!inst);
- *inst = GROUP_F7;
-#endif
- return SLJIT_SUCCESS;
- }
- else if (FAST_IS_REG(src1)) {
- inst = emit_x86_instruction(compiler, 1, src1, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = TEST_rm_r;
- return SLJIT_SUCCESS;
- }
- }
-
- if (!(src2 & SLJIT_IMM)) {
- if (src1 & SLJIT_IMM) {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (IS_HALFWORD(src1w) || compiler->mode32) {
- inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src1w, src2, src2w);
- FAIL_IF(!inst);
- *inst = GROUP_F7;
- }
- else {
- FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src1w));
- inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = TEST_rm_r;
- }
-#else
- inst = emit_x86_instruction(compiler, 1, src1, src1w, src2, src2w);
- FAIL_IF(!inst);
- *inst = GROUP_F7;
-#endif
- return SLJIT_SUCCESS;
- }
- else if (FAST_IS_REG(src2)) {
- inst = emit_x86_instruction(compiler, 1, src2, 0, src1, src1w);
- FAIL_IF(!inst);
- *inst = TEST_rm_r;
- return SLJIT_SUCCESS;
- }
- }
-
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- if (src2 & SLJIT_IMM) {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (IS_HALFWORD(src2w) || compiler->mode32) {
- inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst = GROUP_F7;
- }
- else {
- FAIL_IF(emit_load_imm64(compiler, TMP_REG2, src2w));
- inst = emit_x86_instruction(compiler, 1, TMP_REG2, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst = TEST_rm_r;
- }
-#else
- inst = emit_x86_instruction(compiler, 1, SLJIT_IMM, src2w, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst = GROUP_F7;
-#endif
- }
- else {
- inst = emit_x86_instruction(compiler, 1, TMP_REG1, 0, src2, src2w);
- FAIL_IF(!inst);
- *inst = TEST_rm_r;
- }
- return SLJIT_SUCCESS;
-}
-
-static sljit_si emit_shift(struct sljit_compiler *compiler,
- sljit_ub mode,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_ub* inst;
-
- if ((src2 & SLJIT_IMM) || (src2 == SLJIT_PREF_SHIFT_REG)) {
- if (dst == src1 && dstw == src1w) {
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, dstw);
- FAIL_IF(!inst);
- *inst |= mode;
- return SLJIT_SUCCESS;
- }
- if (dst == SLJIT_UNUSED) {
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst |= mode;
- return SLJIT_SUCCESS;
- }
- if (dst == SLJIT_PREF_SHIFT_REG && src2 == SLJIT_PREF_SHIFT_REG) {
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst |= mode;
- EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
- return SLJIT_SUCCESS;
- }
- if (FAST_IS_REG(dst)) {
- EMIT_MOV(compiler, dst, 0, src1, src1w);
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, dst, 0);
- FAIL_IF(!inst);
- *inst |= mode;
- return SLJIT_SUCCESS;
- }
-
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, src2, src2w, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst |= mode;
- EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
- return SLJIT_SUCCESS;
- }
-
- if (dst == SLJIT_PREF_SHIFT_REG) {
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
- EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst |= mode;
- EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
- }
- else if (FAST_IS_REG(dst) && dst != src2 && !ADDRESSING_DEPENDS_ON(src2, dst)) {
- if (src1 != dst)
- EMIT_MOV(compiler, dst, 0, src1, src1w);
- EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_PREF_SHIFT_REG, 0);
- EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, dst, 0);
- FAIL_IF(!inst);
- *inst |= mode;
- EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
- }
- else {
- /* This case is really difficult, since ecx itself may used for
- addressing, and we must ensure to work even in that case. */
- EMIT_MOV(compiler, TMP_REG1, 0, src1, src1w);
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- EMIT_MOV(compiler, TMP_REG2, 0, SLJIT_PREF_SHIFT_REG, 0);
-#else
- /* [esp+0] contains the flags. */
- EMIT_MOV(compiler, SLJIT_MEM1(SLJIT_SP), sizeof(sljit_sw), SLJIT_PREF_SHIFT_REG, 0);
-#endif
- EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, src2, src2w);
- inst = emit_x86_instruction(compiler, 1 | EX86_SHIFT_INS, SLJIT_PREF_SHIFT_REG, 0, TMP_REG1, 0);
- FAIL_IF(!inst);
- *inst |= mode;
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, TMP_REG2, 0);
-#else
- EMIT_MOV(compiler, SLJIT_PREF_SHIFT_REG, 0, SLJIT_MEM1(SLJIT_SP), sizeof(sljit_sw));
-#endif
- EMIT_MOV(compiler, dst, dstw, TMP_REG1, 0);
- }
-
- return SLJIT_SUCCESS;
-}
-
-static sljit_si emit_shift_with_flags(struct sljit_compiler *compiler,
- sljit_ub mode, sljit_si set_flags,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- /* The CPU does not set flags if the shift count is 0. */
- if (src2 & SLJIT_IMM) {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if ((src2w & 0x3f) != 0 || (compiler->mode32 && (src2w & 0x1f) != 0))
- return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
-#else
- if ((src2w & 0x1f) != 0)
- return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
-#endif
- if (!set_flags)
- return emit_mov(compiler, dst, dstw, src1, src1w);
- /* OR dst, src, 0 */
- return emit_cum_binary(compiler, OR_r_rm, OR_rm_r, OR, OR_EAX_i32,
- dst, dstw, src1, src1w, SLJIT_IMM, 0);
- }
-
- if (!set_flags)
- return emit_shift(compiler, mode, dst, dstw, src1, src1w, src2, src2w);
-
- if (!FAST_IS_REG(dst))
- FAIL_IF(emit_cmp_binary(compiler, src1, src1w, SLJIT_IMM, 0));
-
- FAIL_IF(emit_shift(compiler,mode, dst, dstw, src1, src1w, src2, src2w));
-
- if (FAST_IS_REG(dst))
- return emit_cmp_binary(compiler, dst, dstw, SLJIT_IMM, 0);
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op2(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- CHECK_ERROR();
- CHECK(check_sljit_emit_op2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
- ADJUST_LOCAL_OFFSET(dst, dstw);
- ADJUST_LOCAL_OFFSET(src1, src1w);
- ADJUST_LOCAL_OFFSET(src2, src2w);
-
- CHECK_EXTRA_REGS(dst, dstw, (void)0);
- CHECK_EXTRA_REGS(src1, src1w, (void)0);
- CHECK_EXTRA_REGS(src2, src2w, (void)0);
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- compiler->mode32 = op & SLJIT_INT_OP;
-#endif
-
- if (GET_OPCODE(op) >= SLJIT_MUL) {
- if (SLJIT_UNLIKELY(GET_FLAGS(op)))
- compiler->flags_saved = 0;
- else if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
- FAIL_IF(emit_save_flags(compiler));
- }
-
- switch (GET_OPCODE(op)) {
- case SLJIT_ADD:
- if (!GET_FLAGS(op)) {
- if (emit_lea_binary(compiler, op & SLJIT_KEEP_FLAGS, dst, dstw, src1, src1w, src2, src2w) != SLJIT_ERR_UNSUPPORTED)
- return compiler->error;
- }
- else
- compiler->flags_saved = 0;
- if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
- FAIL_IF(emit_save_flags(compiler));
- return emit_cum_binary(compiler, ADD_r_rm, ADD_rm_r, ADD, ADD_EAX_i32,
- dst, dstw, src1, src1w, src2, src2w);
- case SLJIT_ADDC:
- if (SLJIT_UNLIKELY(compiler->flags_saved)) /* C flag must be restored. */
- FAIL_IF(emit_restore_flags(compiler, 1));
- else if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS))
- FAIL_IF(emit_save_flags(compiler));
- if (SLJIT_UNLIKELY(GET_FLAGS(op)))
- compiler->flags_saved = 0;
- return emit_cum_binary(compiler, ADC_r_rm, ADC_rm_r, ADC, ADC_EAX_i32,
- dst, dstw, src1, src1w, src2, src2w);
- case SLJIT_SUB:
- if (!GET_FLAGS(op)) {
- if ((src2 & SLJIT_IMM) && emit_lea_binary(compiler, op & SLJIT_KEEP_FLAGS, dst, dstw, src1, src1w, SLJIT_IMM, -src2w) != SLJIT_ERR_UNSUPPORTED)
- return compiler->error;
- }
- else
- compiler->flags_saved = 0;
- if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS) && !compiler->flags_saved)
- FAIL_IF(emit_save_flags(compiler));
- if (dst == SLJIT_UNUSED)
- return emit_cmp_binary(compiler, src1, src1w, src2, src2w);
- return emit_non_cum_binary(compiler, SUB_r_rm, SUB_rm_r, SUB, SUB_EAX_i32,
- dst, dstw, src1, src1w, src2, src2w);
- case SLJIT_SUBC:
- if (SLJIT_UNLIKELY(compiler->flags_saved)) /* C flag must be restored. */
- FAIL_IF(emit_restore_flags(compiler, 1));
- else if (SLJIT_UNLIKELY(op & SLJIT_KEEP_FLAGS))
- FAIL_IF(emit_save_flags(compiler));
- if (SLJIT_UNLIKELY(GET_FLAGS(op)))
- compiler->flags_saved = 0;
- return emit_non_cum_binary(compiler, SBB_r_rm, SBB_rm_r, SBB, SBB_EAX_i32,
- dst, dstw, src1, src1w, src2, src2w);
- case SLJIT_MUL:
- return emit_mul(compiler, dst, dstw, src1, src1w, src2, src2w);
- case SLJIT_AND:
- if (dst == SLJIT_UNUSED)
- return emit_test_binary(compiler, src1, src1w, src2, src2w);
- return emit_cum_binary(compiler, AND_r_rm, AND_rm_r, AND, AND_EAX_i32,
- dst, dstw, src1, src1w, src2, src2w);
- case SLJIT_OR:
- return emit_cum_binary(compiler, OR_r_rm, OR_rm_r, OR, OR_EAX_i32,
- dst, dstw, src1, src1w, src2, src2w);
- case SLJIT_XOR:
- return emit_cum_binary(compiler, XOR_r_rm, XOR_rm_r, XOR, XOR_EAX_i32,
- dst, dstw, src1, src1w, src2, src2w);
- case SLJIT_SHL:
- return emit_shift_with_flags(compiler, SHL, GET_FLAGS(op),
- dst, dstw, src1, src1w, src2, src2w);
- case SLJIT_LSHR:
- return emit_shift_with_flags(compiler, SHR, GET_FLAGS(op),
- dst, dstw, src1, src1w, src2, src2w);
- case SLJIT_ASHR:
- return emit_shift_with_flags(compiler, SAR, GET_FLAGS(op),
- dst, dstw, src1, src1w, src2, src2w);
- }
-
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_register_index(sljit_si reg)
-{
- CHECK_REG_INDEX(check_sljit_get_register_index(reg));
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- if (reg >= SLJIT_R3 && reg <= SLJIT_R6)
- return -1;
-#endif
- return reg_map[reg];
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_float_register_index(sljit_si reg)
-{
- CHECK_REG_INDEX(check_sljit_get_float_register_index(reg));
- return reg;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_custom(struct sljit_compiler *compiler,
- void *instruction, sljit_si size)
-{
- sljit_ub *inst;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_op_custom(compiler, instruction, size));
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + size);
- FAIL_IF(!inst);
- INC_SIZE(size);
- SLJIT_MEMMOVE(inst, instruction, size);
- return SLJIT_SUCCESS;
-}
-
-/* --------------------------------------------------------------------- */
-/* Floating point operators */
-/* --------------------------------------------------------------------- */
-
-/* Alignment + 2 * 16 bytes. */
-static sljit_si sse2_data[3 + (4 + 4) * 2];
-static sljit_si *sse2_buffer;
-
-static void init_compiler(void)
-{
- sse2_buffer = (sljit_si*)(((sljit_uw)sse2_data + 15) & ~0xf);
- /* Single precision constants. */
- sse2_buffer[0] = 0x80000000;
- sse2_buffer[4] = 0x7fffffff;
- /* Double precision constants. */
- sse2_buffer[8] = 0;
- sse2_buffer[9] = 0x80000000;
- sse2_buffer[12] = 0xffffffff;
- sse2_buffer[13] = 0x7fffffff;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_is_fpu_available(void)
-{
-#ifdef SLJIT_IS_FPU_AVAILABLE
- return SLJIT_IS_FPU_AVAILABLE;
-#elif (defined SLJIT_DETECT_SSE2 && SLJIT_DETECT_SSE2)
- if (cpu_has_sse2 == -1)
- get_cpu_features();
- return cpu_has_sse2;
-#else /* SLJIT_DETECT_SSE2 */
- return 1;
-#endif /* SLJIT_DETECT_SSE2 */
-}
-
-static sljit_si emit_sse2(struct sljit_compiler *compiler, sljit_ub opcode,
- sljit_si single, sljit_si xmm1, sljit_si xmm2, sljit_sw xmm2w)
-{
- sljit_ub *inst;
-
- inst = emit_x86_instruction(compiler, 2 | (single ? EX86_PREF_F3 : EX86_PREF_F2) | EX86_SSE2, xmm1, 0, xmm2, xmm2w);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = opcode;
- return SLJIT_SUCCESS;
-}
-
-static sljit_si emit_sse2_logic(struct sljit_compiler *compiler, sljit_ub opcode,
- sljit_si pref66, sljit_si xmm1, sljit_si xmm2, sljit_sw xmm2w)
-{
- sljit_ub *inst;
-
- inst = emit_x86_instruction(compiler, 2 | (pref66 ? EX86_PREF_66 : 0) | EX86_SSE2, xmm1, 0, xmm2, xmm2w);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = opcode;
- return SLJIT_SUCCESS;
-}
-
-static SLJIT_INLINE sljit_si emit_sse2_load(struct sljit_compiler *compiler,
- sljit_si single, sljit_si dst, sljit_si src, sljit_sw srcw)
-{
- return emit_sse2(compiler, MOVSD_x_xm, single, dst, src, srcw);
-}
-
-static SLJIT_INLINE sljit_si emit_sse2_store(struct sljit_compiler *compiler,
- sljit_si single, sljit_si dst, sljit_sw dstw, sljit_si src)
-{
- return emit_sse2(compiler, MOVSD_xm_x, single, src, dst, dstw);
-}
-
-static SLJIT_INLINE sljit_si sljit_emit_fop1_convw_fromd(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_si dst_r = SLOW_IS_REG(dst) ? dst : TMP_REG1;
- sljit_ub *inst;
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (GET_OPCODE(op) == SLJIT_CONVW_FROMD)
- compiler->mode32 = 0;
-#endif
-
- inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_SINGLE_OP) ? EX86_PREF_F3 : EX86_PREF_F2) | EX86_SSE2_OP2, dst_r, 0, src, srcw);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = CVTTSD2SI_r_xm;
-
- if (dst_r == TMP_REG1 && dst != SLJIT_UNUSED)
- return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
- return SLJIT_SUCCESS;
-}
-
-static SLJIT_INLINE sljit_si sljit_emit_fop1_convd_fromw(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_si dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG;
- sljit_ub *inst;
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (GET_OPCODE(op) == SLJIT_CONVD_FROMW)
- compiler->mode32 = 0;
-#endif
-
- if (src & SLJIT_IMM) {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (GET_OPCODE(op) == SLJIT_CONVD_FROMI)
- srcw = (sljit_si)srcw;
-#endif
- EMIT_MOV(compiler, TMP_REG1, 0, src, srcw);
- src = TMP_REG1;
- srcw = 0;
- }
-
- inst = emit_x86_instruction(compiler, 2 | ((op & SLJIT_SINGLE_OP) ? EX86_PREF_F3 : EX86_PREF_F2) | EX86_SSE2_OP1, dst_r, 0, src, srcw);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = CVTSI2SD_x_rm;
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- compiler->mode32 = 1;
-#endif
- if (dst_r == TMP_FREG)
- return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
- return SLJIT_SUCCESS;
-}
-
-static SLJIT_INLINE sljit_si sljit_emit_fop1_cmp(struct sljit_compiler *compiler, sljit_si op,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- compiler->flags_saved = 0;
- if (!FAST_IS_REG(src1)) {
- FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src1, src1w));
- src1 = TMP_FREG;
- }
- return emit_sse2_logic(compiler, UCOMISD_x_xm, !(op & SLJIT_SINGLE_OP), src1, src2, src2w);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop1(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw)
-{
- sljit_si dst_r;
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- compiler->mode32 = 1;
-#endif
-
- CHECK_ERROR();
- SELECT_FOP1_OPERATION_WITH_CHECKS(compiler, op, dst, dstw, src, srcw);
-
- if (GET_OPCODE(op) == SLJIT_DMOV) {
- if (FAST_IS_REG(dst))
- return emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst, src, srcw);
- if (FAST_IS_REG(src))
- return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, src);
- FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src, srcw));
- return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
- }
-
- if (GET_OPCODE(op) == SLJIT_CONVD_FROMS) {
- dst_r = FAST_IS_REG(dst) ? dst : TMP_FREG;
- if (FAST_IS_REG(src)) {
- /* We overwrite the high bits of source. From SLJIT point of view,
- this is not an issue.
- Note: In SSE3, we could also use MOVDDUP and MOVSLDUP. */
- FAIL_IF(emit_sse2_logic(compiler, UNPCKLPD_x_xm, op & SLJIT_SINGLE_OP, src, src, 0));
- }
- else {
- FAIL_IF(emit_sse2_load(compiler, !(op & SLJIT_SINGLE_OP), TMP_FREG, src, srcw));
- src = TMP_FREG;
- }
-
- FAIL_IF(emit_sse2_logic(compiler, CVTPD2PS_x_xm, op & SLJIT_SINGLE_OP, dst_r, src, 0));
- if (dst_r == TMP_FREG)
- return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
- return SLJIT_SUCCESS;
- }
-
- if (SLOW_IS_REG(dst)) {
- dst_r = dst;
- if (dst != src)
- FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst_r, src, srcw));
- }
- else {
- dst_r = TMP_FREG;
- FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst_r, src, srcw));
- }
-
- switch (GET_OPCODE(op)) {
- case SLJIT_DNEG:
- FAIL_IF(emit_sse2_logic(compiler, XORPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_SINGLE_OP ? sse2_buffer : sse2_buffer + 8)));
- break;
-
- case SLJIT_DABS:
- FAIL_IF(emit_sse2_logic(compiler, ANDPD_x_xm, 1, dst_r, SLJIT_MEM0(), (sljit_sw)(op & SLJIT_SINGLE_OP ? sse2_buffer + 4 : sse2_buffer + 12)));
- break;
- }
-
- if (dst_r == TMP_FREG)
- return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_fop2(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src1, sljit_sw src1w,
- sljit_si src2, sljit_sw src2w)
-{
- sljit_si dst_r;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_fop2(compiler, op, dst, dstw, src1, src1w, src2, src2w));
- ADJUST_LOCAL_OFFSET(dst, dstw);
- ADJUST_LOCAL_OFFSET(src1, src1w);
- ADJUST_LOCAL_OFFSET(src2, src2w);
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- compiler->mode32 = 1;
-#endif
-
- if (FAST_IS_REG(dst)) {
- dst_r = dst;
- if (dst == src1)
- ; /* Do nothing here. */
- else if (dst == src2 && (op == SLJIT_DADD || op == SLJIT_DMUL)) {
- /* Swap arguments. */
- src2 = src1;
- src2w = src1w;
- }
- else if (dst != src2)
- FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, dst_r, src1, src1w));
- else {
- dst_r = TMP_FREG;
- FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src1, src1w));
- }
- }
- else {
- dst_r = TMP_FREG;
- FAIL_IF(emit_sse2_load(compiler, op & SLJIT_SINGLE_OP, TMP_FREG, src1, src1w));
- }
-
- switch (GET_OPCODE(op)) {
- case SLJIT_DADD:
- FAIL_IF(emit_sse2(compiler, ADDSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
- break;
-
- case SLJIT_DSUB:
- FAIL_IF(emit_sse2(compiler, SUBSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
- break;
-
- case SLJIT_DMUL:
- FAIL_IF(emit_sse2(compiler, MULSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
- break;
-
- case SLJIT_DDIV:
- FAIL_IF(emit_sse2(compiler, DIVSD_x_xm, op & SLJIT_SINGLE_OP, dst_r, src2, src2w));
- break;
- }
-
- if (dst_r == TMP_FREG)
- return emit_sse2_store(compiler, op & SLJIT_SINGLE_OP, dst, dstw, TMP_FREG);
- return SLJIT_SUCCESS;
-}
-
-/* --------------------------------------------------------------------- */
-/* Conditional instructions */
-/* --------------------------------------------------------------------- */
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_label* sljit_emit_label(struct sljit_compiler *compiler)
-{
- sljit_ub *inst;
- struct sljit_label *label;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_emit_label(compiler));
-
- /* We should restore the flags before the label,
- since other taken jumps has their own flags as well. */
- if (SLJIT_UNLIKELY(compiler->flags_saved))
- PTR_FAIL_IF(emit_restore_flags(compiler, 0));
-
- if (compiler->last_label && compiler->last_label->size == compiler->size)
- return compiler->last_label;
-
- label = (struct sljit_label*)ensure_abuf(compiler, sizeof(struct sljit_label));
- PTR_FAIL_IF(!label);
- set_label(label, compiler);
-
- inst = (sljit_ub*)ensure_buf(compiler, 2);
- PTR_FAIL_IF(!inst);
-
- *inst++ = 0;
- *inst++ = 0;
-
- return label;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_jump* sljit_emit_jump(struct sljit_compiler *compiler, sljit_si type)
-{
- sljit_ub *inst;
- struct sljit_jump *jump;
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_emit_jump(compiler, type));
-
- if (SLJIT_UNLIKELY(compiler->flags_saved)) {
- if ((type & 0xff) <= SLJIT_JUMP)
- PTR_FAIL_IF(emit_restore_flags(compiler, 0));
- compiler->flags_saved = 0;
- }
-
- jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
- PTR_FAIL_IF_NULL(jump);
- set_jump(jump, compiler, type & SLJIT_REWRITABLE_JUMP);
- type &= 0xff;
-
- if (type >= SLJIT_CALL1)
- PTR_FAIL_IF(call_with_args(compiler, type));
-
- /* Worst case size. */
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- compiler->size += (type >= SLJIT_JUMP) ? 5 : 6;
-#else
- compiler->size += (type >= SLJIT_JUMP) ? (10 + 3) : (2 + 10 + 3);
-#endif
-
- inst = (sljit_ub*)ensure_buf(compiler, 2);
- PTR_FAIL_IF_NULL(inst);
-
- *inst++ = 0;
- *inst++ = type + 4;
- return jump;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_ijump(struct sljit_compiler *compiler, sljit_si type, sljit_si src, sljit_sw srcw)
-{
- sljit_ub *inst;
- struct sljit_jump *jump;
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_ijump(compiler, type, src, srcw));
- ADJUST_LOCAL_OFFSET(src, srcw);
-
- CHECK_EXTRA_REGS(src, srcw, (void)0);
-
- if (SLJIT_UNLIKELY(compiler->flags_saved)) {
- if (type <= SLJIT_JUMP)
- FAIL_IF(emit_restore_flags(compiler, 0));
- compiler->flags_saved = 0;
- }
-
- if (type >= SLJIT_CALL1) {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-#if (defined SLJIT_X86_32_FASTCALL && SLJIT_X86_32_FASTCALL)
- if (src == SLJIT_R2) {
- EMIT_MOV(compiler, TMP_REG1, 0, src, 0);
- src = TMP_REG1;
- }
- if (src == SLJIT_MEM1(SLJIT_SP) && type >= SLJIT_CALL3)
- srcw += sizeof(sljit_sw);
-#endif
-#endif
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) && defined(_WIN64)
- if (src == SLJIT_R2) {
- EMIT_MOV(compiler, TMP_REG1, 0, src, 0);
- src = TMP_REG1;
- }
-#endif
- FAIL_IF(call_with_args(compiler, type));
- }
-
- if (src == SLJIT_IMM) {
- jump = (struct sljit_jump*)ensure_abuf(compiler, sizeof(struct sljit_jump));
- FAIL_IF_NULL(jump);
- set_jump(jump, compiler, JUMP_ADDR);
- jump->u.target = srcw;
-
- /* Worst case size. */
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- compiler->size += 5;
-#else
- compiler->size += 10 + 3;
-#endif
-
- inst = (sljit_ub*)ensure_buf(compiler, 2);
- FAIL_IF_NULL(inst);
-
- *inst++ = 0;
- *inst++ = type + 4;
- }
- else {
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- /* REX_W is not necessary (src is not immediate). */
- compiler->mode32 = 1;
-#endif
- inst = emit_x86_instruction(compiler, 1, 0, 0, src, srcw);
- FAIL_IF(!inst);
- *inst++ = GROUP_FF;
- *inst |= (type >= SLJIT_FAST_CALL) ? CALL_rm : JMP_rm;
- }
- return SLJIT_SUCCESS;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_emit_op_flags(struct sljit_compiler *compiler, sljit_si op,
- sljit_si dst, sljit_sw dstw,
- sljit_si src, sljit_sw srcw,
- sljit_si type)
-{
- sljit_ub *inst;
- sljit_ub cond_set = 0;
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- sljit_si reg;
-#else
- /* CHECK_EXTRA_REGS migh overwrite these values. */
- sljit_si dst_save = dst;
- sljit_sw dstw_save = dstw;
-#endif
-
- CHECK_ERROR();
- CHECK(check_sljit_emit_op_flags(compiler, op, dst, dstw, src, srcw, type));
- SLJIT_UNUSED_ARG(srcw);
-
- if (dst == SLJIT_UNUSED)
- return SLJIT_SUCCESS;
-
- ADJUST_LOCAL_OFFSET(dst, dstw);
- CHECK_EXTRA_REGS(dst, dstw, (void)0);
- if (SLJIT_UNLIKELY(compiler->flags_saved))
- FAIL_IF(emit_restore_flags(compiler, op & SLJIT_KEEP_FLAGS));
-
- type &= 0xff;
- /* setcc = jcc + 0x10. */
- cond_set = get_jump_code(type) + 0x10;
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (GET_OPCODE(op) == SLJIT_OR && !GET_ALL_FLAGS(op) && FAST_IS_REG(dst) && dst == src) {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 4 + 3);
- FAIL_IF(!inst);
- INC_SIZE(4 + 3);
- /* Set low register to conditional flag. */
- *inst++ = (reg_map[TMP_REG1] <= 7) ? REX : REX_B;
- *inst++ = GROUP_0F;
- *inst++ = cond_set;
- *inst++ = MOD_REG | reg_lmap[TMP_REG1];
- *inst++ = REX | (reg_map[TMP_REG1] <= 7 ? 0 : REX_R) | (reg_map[dst] <= 7 ? 0 : REX_B);
- *inst++ = OR_rm8_r8;
- *inst++ = MOD_REG | (reg_lmap[TMP_REG1] << 3) | reg_lmap[dst];
- return SLJIT_SUCCESS;
- }
-
- reg = (op == SLJIT_MOV && FAST_IS_REG(dst)) ? dst : TMP_REG1;
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 4 + 4);
- FAIL_IF(!inst);
- INC_SIZE(4 + 4);
- /* Set low register to conditional flag. */
- *inst++ = (reg_map[reg] <= 7) ? REX : REX_B;
- *inst++ = GROUP_0F;
- *inst++ = cond_set;
- *inst++ = MOD_REG | reg_lmap[reg];
- *inst++ = REX_W | (reg_map[reg] <= 7 ? 0 : (REX_B | REX_R));
- *inst++ = GROUP_0F;
- *inst++ = MOVZX_r_rm8;
- *inst = MOD_REG | (reg_lmap[reg] << 3) | reg_lmap[reg];
-
- if (reg != TMP_REG1)
- return SLJIT_SUCCESS;
-
- if (GET_OPCODE(op) < SLJIT_ADD) {
- compiler->mode32 = GET_OPCODE(op) != SLJIT_MOV;
- return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
- }
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
- || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- compiler->skip_checks = 1;
-#endif
- return sljit_emit_op2(compiler, op, dst, dstw, dst, dstw, TMP_REG1, 0);
-#else /* SLJIT_CONFIG_X86_64 */
- if (GET_OPCODE(op) < SLJIT_ADD && FAST_IS_REG(dst)) {
- if (reg_map[dst] <= 4) {
- /* Low byte is accessible. */
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 3 + 3);
- FAIL_IF(!inst);
- INC_SIZE(3 + 3);
- /* Set low byte to conditional flag. */
- *inst++ = GROUP_0F;
- *inst++ = cond_set;
- *inst++ = MOD_REG | reg_map[dst];
-
- *inst++ = GROUP_0F;
- *inst++ = MOVZX_r_rm8;
- *inst = MOD_REG | (reg_map[dst] << 3) | reg_map[dst];
- return SLJIT_SUCCESS;
- }
-
- /* Low byte is not accessible. */
- if (cpu_has_cmov == -1)
- get_cpu_features();
-
- if (cpu_has_cmov) {
- EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 1);
- /* a xor reg, reg operation would overwrite the flags. */
- EMIT_MOV(compiler, dst, 0, SLJIT_IMM, 0);
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 3);
- FAIL_IF(!inst);
- INC_SIZE(3);
-
- *inst++ = GROUP_0F;
- /* cmovcc = setcc - 0x50. */
- *inst++ = cond_set - 0x50;
- *inst++ = MOD_REG | (reg_map[dst] << 3) | reg_map[TMP_REG1];
- return SLJIT_SUCCESS;
- }
-
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1 + 3 + 3 + 1);
- *inst++ = XCHG_EAX_r + reg_map[TMP_REG1];
- /* Set al to conditional flag. */
- *inst++ = GROUP_0F;
- *inst++ = cond_set;
- *inst++ = MOD_REG | 0 /* eax */;
-
- *inst++ = GROUP_0F;
- *inst++ = MOVZX_r_rm8;
- *inst++ = MOD_REG | (reg_map[dst] << 3) | 0 /* eax */;
- *inst++ = XCHG_EAX_r + reg_map[TMP_REG1];
- return SLJIT_SUCCESS;
- }
-
- if (GET_OPCODE(op) == SLJIT_OR && !GET_ALL_FLAGS(op) && FAST_IS_REG(dst) && dst == src && reg_map[dst] <= 4) {
- SLJIT_COMPILE_ASSERT(reg_map[SLJIT_R0] == 0, scratch_reg1_must_be_eax);
- if (dst != SLJIT_R0) {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 2 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1 + 3 + 2 + 1);
- /* Set low register to conditional flag. */
- *inst++ = XCHG_EAX_r + reg_map[TMP_REG1];
- *inst++ = GROUP_0F;
- *inst++ = cond_set;
- *inst++ = MOD_REG | 0 /* eax */;
- *inst++ = OR_rm8_r8;
- *inst++ = MOD_REG | (0 /* eax */ << 3) | reg_map[dst];
- *inst++ = XCHG_EAX_r + reg_map[TMP_REG1];
- }
- else {
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 2 + 3 + 2 + 2);
- FAIL_IF(!inst);
- INC_SIZE(2 + 3 + 2 + 2);
- /* Set low register to conditional flag. */
- *inst++ = XCHG_r_rm;
- *inst++ = MOD_REG | (1 /* ecx */ << 3) | reg_map[TMP_REG1];
- *inst++ = GROUP_0F;
- *inst++ = cond_set;
- *inst++ = MOD_REG | 1 /* ecx */;
- *inst++ = OR_rm8_r8;
- *inst++ = MOD_REG | (1 /* ecx */ << 3) | 0 /* eax */;
- *inst++ = XCHG_r_rm;
- *inst++ = MOD_REG | (1 /* ecx */ << 3) | reg_map[TMP_REG1];
- }
- return SLJIT_SUCCESS;
- }
-
- /* Set TMP_REG1 to the bit. */
- inst = (sljit_ub*)ensure_buf(compiler, 1 + 1 + 3 + 3 + 1);
- FAIL_IF(!inst);
- INC_SIZE(1 + 3 + 3 + 1);
- *inst++ = XCHG_EAX_r + reg_map[TMP_REG1];
- /* Set al to conditional flag. */
- *inst++ = GROUP_0F;
- *inst++ = cond_set;
- *inst++ = MOD_REG | 0 /* eax */;
-
- *inst++ = GROUP_0F;
- *inst++ = MOVZX_r_rm8;
- *inst++ = MOD_REG | (0 << 3) /* eax */ | 0 /* eax */;
-
- *inst++ = XCHG_EAX_r + reg_map[TMP_REG1];
-
- if (GET_OPCODE(op) < SLJIT_ADD)
- return emit_mov(compiler, dst, dstw, TMP_REG1, 0);
-
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE) \
- || (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- compiler->skip_checks = 1;
-#endif
- return sljit_emit_op2(compiler, op, dst_save, dstw_save, dst_save, dstw_save, TMP_REG1, 0);
-#endif /* SLJIT_CONFIG_X86_64 */
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_get_local_base(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw offset)
-{
- CHECK_ERROR();
- CHECK(check_sljit_get_local_base(compiler, dst, dstw, offset));
- ADJUST_LOCAL_OFFSET(dst, dstw);
-
- CHECK_EXTRA_REGS(dst, dstw, (void)0);
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- compiler->mode32 = 0;
-#endif
-
- ADJUST_LOCAL_OFFSET(SLJIT_MEM1(SLJIT_SP), offset);
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (NOT_HALFWORD(offset)) {
- FAIL_IF(emit_load_imm64(compiler, TMP_REG1, offset));
-#if (defined SLJIT_DEBUG && SLJIT_DEBUG)
- SLJIT_ASSERT(emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0) != SLJIT_ERR_UNSUPPORTED);
- return compiler->error;
-#else
- return emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, TMP_REG1, 0);
-#endif
- }
-#endif
-
- if (offset != 0)
- return emit_lea_binary(compiler, SLJIT_KEEP_FLAGS, dst, dstw, SLJIT_SP, 0, SLJIT_IMM, offset);
- return emit_mov(compiler, dst, dstw, SLJIT_SP, 0);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_const* sljit_emit_const(struct sljit_compiler *compiler, sljit_si dst, sljit_sw dstw, sljit_sw init_value)
-{
- sljit_ub *inst;
- struct sljit_const *const_;
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- sljit_si reg;
-#endif
-
- CHECK_ERROR_PTR();
- CHECK_PTR(check_sljit_emit_const(compiler, dst, dstw, init_value));
- ADJUST_LOCAL_OFFSET(dst, dstw);
-
- CHECK_EXTRA_REGS(dst, dstw, (void)0);
-
- const_ = (struct sljit_const*)ensure_abuf(compiler, sizeof(struct sljit_const));
- PTR_FAIL_IF(!const_);
- set_const(const_, compiler);
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- compiler->mode32 = 0;
- reg = SLOW_IS_REG(dst) ? dst : TMP_REG1;
-
- if (emit_load_imm64(compiler, reg, init_value))
- return NULL;
-#else
- if (dst == SLJIT_UNUSED)
- dst = TMP_REG1;
-
- if (emit_mov(compiler, dst, dstw, SLJIT_IMM, init_value))
- return NULL;
-#endif
-
- inst = (sljit_ub*)ensure_buf(compiler, 2);
- PTR_FAIL_IF(!inst);
-
- *inst++ = 0;
- *inst++ = 1;
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- if (dst & SLJIT_MEM)
- if (emit_mov(compiler, dst, dstw, TMP_REG1, 0))
- return NULL;
-#endif
-
- return const_;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_addr)
-{
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
- *(sljit_sw*)addr = new_addr - (addr + 4);
-#else
- *(sljit_uw*)addr = new_addr;
-#endif
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_constant)
-{
- *(sljit_sw*)addr = new_constant;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_sse2_available(void)
-{
-#if (defined SLJIT_DETECT_SSE2 && SLJIT_DETECT_SSE2)
- if (cpu_has_sse2 == -1)
- get_cpu_features();
- return cpu_has_sse2;
-#else
- return 1;
-#endif
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_is_cmov_available(void)
-{
- if (cpu_has_cmov == -1)
- get_cpu_features();
- return cpu_has_cmov;
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_si sljit_x86_emit_cmov(struct sljit_compiler *compiler,
- sljit_si type,
- sljit_si dst_reg,
- sljit_si src, sljit_sw srcw)
-{
- sljit_ub* inst;
-
- CHECK_ERROR();
-#if (defined SLJIT_ARGUMENT_CHECKS && SLJIT_ARGUMENT_CHECKS)
- CHECK_ARGUMENT(sljit_x86_is_cmov_available());
- CHECK_ARGUMENT(!(type & ~(0xff | SLJIT_INT_OP)));
- CHECK_ARGUMENT((type & 0xff) >= SLJIT_EQUAL && (type & 0xff) <= SLJIT_D_ORDERED);
- CHECK_ARGUMENT(FUNCTION_CHECK_IS_REG(dst_reg & ~SLJIT_INT_OP));
- FUNCTION_CHECK_SRC(src, srcw);
-#endif
-#if (defined SLJIT_VERBOSE && SLJIT_VERBOSE)
- if (SLJIT_UNLIKELY(!!compiler->verbose)) {
- fprintf(compiler->verbose, " x86_cmov%s %s%s, ",
- !(dst_reg & SLJIT_INT_OP) ? "" : ".i",
- JUMP_PREFIX(type), jump_names[type & 0xff]);
- sljit_verbose_reg(compiler, dst_reg & ~SLJIT_INT_OP);
- fprintf(compiler->verbose, ", ");
- sljit_verbose_param(compiler, src, srcw);
- fprintf(compiler->verbose, "\n");
- }
-#endif
-
- ADJUST_LOCAL_OFFSET(src, srcw);
- CHECK_EXTRA_REGS(src, srcw, (void)0);
-
-#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
- compiler->mode32 = dst_reg & SLJIT_INT_OP;
-#endif
- dst_reg &= ~SLJIT_INT_OP;
-
- if (SLJIT_UNLIKELY(src & SLJIT_IMM)) {
- EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, srcw);
- src = TMP_REG1;
- srcw = 0;
- }
-
- inst = emit_x86_instruction(compiler, 2, dst_reg, 0, src, srcw);
- FAIL_IF(!inst);
- *inst++ = GROUP_0F;
- *inst = get_jump_code(type & 0xff) - 0x40;
- return SLJIT_SUCCESS;
-}
diff -Nru r-base-3.2.3/src/extra/pcre/sljit/sljitUtils.c r-base-3.3.1/src/extra/pcre/sljit/sljitUtils.c
--- r-base-3.2.3/src/extra/pcre/sljit/sljitUtils.c 2015-05-13 22:15:07.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/sljit/sljitUtils.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,334 +0,0 @@
-/*
- * Stack-less Just-In-Time compiler
- *
- * Copyright 2009-2012 Zoltan Herczeg (hzmester@freemail.hu). All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE COPYRIGHT HOLDER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* ------------------------------------------------------------------------ */
-/* Locks */
-/* ------------------------------------------------------------------------ */
-
-#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR) || (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
-
-#if (defined SLJIT_SINGLE_THREADED && SLJIT_SINGLE_THREADED)
-
-#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
-
-static SLJIT_INLINE void allocator_grab_lock(void)
-{
- /* Always successful. */
-}
-
-static SLJIT_INLINE void allocator_release_lock(void)
-{
- /* Always successful. */
-}
-
-#endif /* SLJIT_EXECUTABLE_ALLOCATOR */
-
-#if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
-
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void)
-{
- /* Always successful. */
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release_lock(void)
-{
- /* Always successful. */
-}
-
-#endif /* SLJIT_UTIL_GLOBAL_LOCK */
-
-#elif defined(_WIN32) /* SLJIT_SINGLE_THREADED */
-
-#include "windows.h"
-
-#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
-
-static HANDLE allocator_mutex = 0;
-
-static SLJIT_INLINE void allocator_grab_lock(void)
-{
- /* No idea what to do if an error occures. Static mutexes should never fail... */
- if (!allocator_mutex)
- allocator_mutex = CreateMutex(NULL, TRUE, NULL);
- else
- WaitForSingleObject(allocator_mutex, INFINITE);
-}
-
-static SLJIT_INLINE void allocator_release_lock(void)
-{
- ReleaseMutex(allocator_mutex);
-}
-
-#endif /* SLJIT_EXECUTABLE_ALLOCATOR */
-
-#if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
-
-static HANDLE global_mutex = 0;
-
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void)
-{
- /* No idea what to do if an error occures. Static mutexes should never fail... */
- if (!global_mutex)
- global_mutex = CreateMutex(NULL, TRUE, NULL);
- else
- WaitForSingleObject(global_mutex, INFINITE);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release_lock(void)
-{
- ReleaseMutex(global_mutex);
-}
-
-#endif /* SLJIT_UTIL_GLOBAL_LOCK */
-
-#else /* _WIN32 */
-
-#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
-
-#include
-
-static pthread_mutex_t allocator_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static SLJIT_INLINE void allocator_grab_lock(void)
-{
- pthread_mutex_lock(&allocator_mutex);
-}
-
-static SLJIT_INLINE void allocator_release_lock(void)
-{
- pthread_mutex_unlock(&allocator_mutex);
-}
-
-#endif /* SLJIT_EXECUTABLE_ALLOCATOR */
-
-#if (defined SLJIT_UTIL_GLOBAL_LOCK && SLJIT_UTIL_GLOBAL_LOCK)
-
-#include
-
-static pthread_mutex_t global_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_grab_lock(void)
-{
- pthread_mutex_lock(&global_mutex);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_release_lock(void)
-{
- pthread_mutex_unlock(&global_mutex);
-}
-
-#endif /* SLJIT_UTIL_GLOBAL_LOCK */
-
-#endif /* _WIN32 */
-
-/* ------------------------------------------------------------------------ */
-/* Stack */
-/* ------------------------------------------------------------------------ */
-
-#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) || (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
-
-#ifdef _WIN32
-#include "windows.h"
-#else
-/* Provides mmap function. */
-#include
-/* For detecting the page size. */
-#include
-
-#ifndef MAP_ANON
-
-#include
-
-/* Some old systems does not have MAP_ANON. */
-static sljit_si dev_zero = -1;
-
-#if (defined SLJIT_SINGLE_THREADED && SLJIT_SINGLE_THREADED)
-
-static SLJIT_INLINE sljit_si open_dev_zero(void)
-{
- dev_zero = open("/dev/zero", O_RDWR);
- return dev_zero < 0;
-}
-
-#else /* SLJIT_SINGLE_THREADED */
-
-#include
-
-static pthread_mutex_t dev_zero_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-static SLJIT_INLINE sljit_si open_dev_zero(void)
-{
- pthread_mutex_lock(&dev_zero_mutex);
- dev_zero = open("/dev/zero", O_RDWR);
- pthread_mutex_unlock(&dev_zero_mutex);
- return dev_zero < 0;
-}
-
-#endif /* SLJIT_SINGLE_THREADED */
-
-#endif
-
-#endif
-
-#endif /* SLJIT_UTIL_STACK || SLJIT_EXECUTABLE_ALLOCATOR */
-
-#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
-
-/* Planning to make it even more clever in the future. */
-static sljit_sw sljit_page_align = 0;
-
-SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_CALL sljit_allocate_stack(sljit_uw limit, sljit_uw max_limit, void *allocator_data)
-{
- struct sljit_stack *stack;
- union {
- void *ptr;
- sljit_uw uw;
- } base;
-#ifdef _WIN32
- SYSTEM_INFO si;
-#endif
-
- SLJIT_UNUSED_ARG(allocator_data);
- if (limit > max_limit || limit < 1)
- return NULL;
-
-#ifdef _WIN32
- if (!sljit_page_align) {
- GetSystemInfo(&si);
- sljit_page_align = si.dwPageSize - 1;
- }
-#else
- if (!sljit_page_align) {
- sljit_page_align = sysconf(_SC_PAGESIZE);
- /* Should never happen. */
- if (sljit_page_align < 0)
- sljit_page_align = 4096;
- sljit_page_align--;
- }
-#endif
-
- /* Align limit and max_limit. */
- max_limit = (max_limit + sljit_page_align) & ~sljit_page_align;
-
- stack = (struct sljit_stack*)SLJIT_MALLOC(sizeof(struct sljit_stack), allocator_data);
- if (!stack)
- return NULL;
-
-#ifdef _WIN32
- base.ptr = VirtualAlloc(NULL, max_limit, MEM_RESERVE, PAGE_READWRITE);
- if (!base.ptr) {
- SLJIT_FREE(stack, allocator_data);
- return NULL;
- }
- stack->base = base.uw;
- stack->limit = stack->base;
- stack->max_limit = stack->base + max_limit;
- if (sljit_stack_resize(stack, stack->base + limit)) {
- sljit_free_stack(stack, allocator_data);
- return NULL;
- }
-#else
-#ifdef MAP_ANON
- base.ptr = mmap(NULL, max_limit, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
-#else
- if (dev_zero < 0) {
- if (open_dev_zero()) {
- SLJIT_FREE(stack, allocator_data);
- return NULL;
- }
- }
- base.ptr = mmap(NULL, max_limit, PROT_READ | PROT_WRITE, MAP_PRIVATE, dev_zero, 0);
-#endif
- if (base.ptr == MAP_FAILED) {
- SLJIT_FREE(stack, allocator_data);
- return NULL;
- }
- stack->base = base.uw;
- stack->limit = stack->base + limit;
- stack->max_limit = stack->base + max_limit;
-#endif
- stack->top = stack->base;
- return stack;
-}
-
-#undef PAGE_ALIGN
-
-SLJIT_API_FUNC_ATTRIBUTE void SLJIT_CALL sljit_free_stack(struct sljit_stack* stack, void *allocator_data)
-{
- SLJIT_UNUSED_ARG(allocator_data);
-#ifdef _WIN32
- VirtualFree((void*)stack->base, 0, MEM_RELEASE);
-#else
- munmap((void*)stack->base, stack->max_limit - stack->base);
-#endif
- SLJIT_FREE(stack, allocator_data);
-}
-
-SLJIT_API_FUNC_ATTRIBUTE sljit_sw SLJIT_CALL sljit_stack_resize(struct sljit_stack* stack, sljit_uw new_limit)
-{
- sljit_uw aligned_old_limit;
- sljit_uw aligned_new_limit;
-
- if ((new_limit > stack->max_limit) || (new_limit < stack->base))
- return -1;
-#ifdef _WIN32
- aligned_new_limit = (new_limit + sljit_page_align) & ~sljit_page_align;
- aligned_old_limit = (stack->limit + sljit_page_align) & ~sljit_page_align;
- if (aligned_new_limit != aligned_old_limit) {
- if (aligned_new_limit > aligned_old_limit) {
- if (!VirtualAlloc((void*)aligned_old_limit, aligned_new_limit - aligned_old_limit, MEM_COMMIT, PAGE_READWRITE))
- return -1;
- }
- else {
- if (!VirtualFree((void*)aligned_new_limit, aligned_old_limit - aligned_new_limit, MEM_DECOMMIT))
- return -1;
- }
- }
- stack->limit = new_limit;
- return 0;
-#else
- if (new_limit >= stack->limit) {
- stack->limit = new_limit;
- return 0;
- }
- aligned_new_limit = (new_limit + sljit_page_align) & ~sljit_page_align;
- aligned_old_limit = (stack->limit + sljit_page_align) & ~sljit_page_align;
- /* If madvise is available, we release the unnecessary space. */
-#if defined(MADV_DONTNEED)
- if (aligned_new_limit < aligned_old_limit)
- madvise((void*)aligned_new_limit, aligned_old_limit - aligned_new_limit, MADV_DONTNEED);
-#elif defined(POSIX_MADV_DONTNEED)
- if (aligned_new_limit < aligned_old_limit)
- posix_madvise((void*)aligned_new_limit, aligned_old_limit - aligned_new_limit, POSIX_MADV_DONTNEED);
-#endif
- stack->limit = new_limit;
- return 0;
-#endif
-}
-
-#endif /* SLJIT_UTIL_STACK */
-
-#endif
diff -Nru r-base-3.2.3/src/extra/pcre/ucp.h r-base-3.3.1/src/extra/pcre/ucp.h
--- r-base-3.2.3/src/extra/pcre/ucp.h 2014-11-12 23:15:06.000000000 +0000
+++ r-base-3.3.1/src/extra/pcre/ucp.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,224 +0,0 @@
-/*************************************************
-* Unicode Property Table handler *
-*************************************************/
-
-#ifndef _UCP_H
-#define _UCP_H
-
-/* This file contains definitions of the property values that are returned by
-the UCD access macros. New values that are added for new releases of Unicode
-should always be at the end of each enum, for backwards compatibility.
-
-IMPORTANT: Note also that the specific numeric values of the enums have to be
-the same as the values that are generated by the maint/MultiStage2.py script,
-where the equivalent property descriptive names are listed in vectors.
-
-ALSO: The specific values of the first two enums are assumed for the table
-called catposstab in pcre_compile.c. */
-
-/* These are the general character categories. */
-
-enum {
- ucp_C, /* Other */
- ucp_L, /* Letter */
- ucp_M, /* Mark */
- ucp_N, /* Number */
- ucp_P, /* Punctuation */
- ucp_S, /* Symbol */
- ucp_Z /* Separator */
-};
-
-/* These are the particular character categories. */
-
-enum {
- ucp_Cc, /* Control */
- ucp_Cf, /* Format */
- ucp_Cn, /* Unassigned */
- ucp_Co, /* Private use */
- ucp_Cs, /* Surrogate */
- ucp_Ll, /* Lower case letter */
- ucp_Lm, /* Modifier letter */
- ucp_Lo, /* Other letter */
- ucp_Lt, /* Title case letter */
- ucp_Lu, /* Upper case letter */
- ucp_Mc, /* Spacing mark */
- ucp_Me, /* Enclosing mark */
- ucp_Mn, /* Non-spacing mark */
- ucp_Nd, /* Decimal number */
- ucp_Nl, /* Letter number */
- ucp_No, /* Other number */
- ucp_Pc, /* Connector punctuation */
- ucp_Pd, /* Dash punctuation */
- ucp_Pe, /* Close punctuation */
- ucp_Pf, /* Final punctuation */
- ucp_Pi, /* Initial punctuation */
- ucp_Po, /* Other punctuation */
- ucp_Ps, /* Open punctuation */
- ucp_Sc, /* Currency symbol */
- ucp_Sk, /* Modifier symbol */
- ucp_Sm, /* Mathematical symbol */
- ucp_So, /* Other symbol */
- ucp_Zl, /* Line separator */
- ucp_Zp, /* Paragraph separator */
- ucp_Zs /* Space separator */
-};
-
-/* These are grapheme break properties. Note that the code for processing them
-assumes that the values are less than 16. If more values are added that take
-the number to 16 or more, the code will have to be rewritten. */
-
-enum {
- ucp_gbCR, /* 0 */
- ucp_gbLF, /* 1 */
- ucp_gbControl, /* 2 */
- ucp_gbExtend, /* 3 */
- ucp_gbPrepend, /* 4 */
- ucp_gbSpacingMark, /* 5 */
- ucp_gbL, /* 6 Hangul syllable type L */
- ucp_gbV, /* 7 Hangul syllable type V */
- ucp_gbT, /* 8 Hangul syllable type T */
- ucp_gbLV, /* 9 Hangul syllable type LV */
- ucp_gbLVT, /* 10 Hangul syllable type LVT */
- ucp_gbRegionalIndicator, /* 11 */
- ucp_gbOther /* 12 */
-};
-
-/* These are the script identifications. */
-
-enum {
- ucp_Arabic,
- ucp_Armenian,
- ucp_Bengali,
- ucp_Bopomofo,
- ucp_Braille,
- ucp_Buginese,
- ucp_Buhid,
- ucp_Canadian_Aboriginal,
- ucp_Cherokee,
- ucp_Common,
- ucp_Coptic,
- ucp_Cypriot,
- ucp_Cyrillic,
- ucp_Deseret,
- ucp_Devanagari,
- ucp_Ethiopic,
- ucp_Georgian,
- ucp_Glagolitic,
- ucp_Gothic,
- ucp_Greek,
- ucp_Gujarati,
- ucp_Gurmukhi,
- ucp_Han,
- ucp_Hangul,
- ucp_Hanunoo,
- ucp_Hebrew,
- ucp_Hiragana,
- ucp_Inherited,
- ucp_Kannada,
- ucp_Katakana,
- ucp_Kharoshthi,
- ucp_Khmer,
- ucp_Lao,
- ucp_Latin,
- ucp_Limbu,
- ucp_Linear_B,
- ucp_Malayalam,
- ucp_Mongolian,
- ucp_Myanmar,
- ucp_New_Tai_Lue,
- ucp_Ogham,
- ucp_Old_Italic,
- ucp_Old_Persian,
- ucp_Oriya,
- ucp_Osmanya,
- ucp_Runic,
- ucp_Shavian,
- ucp_Sinhala,
- ucp_Syloti_Nagri,
- ucp_Syriac,
- ucp_Tagalog,
- ucp_Tagbanwa,
- ucp_Tai_Le,
- ucp_Tamil,
- ucp_Telugu,
- ucp_Thaana,
- ucp_Thai,
- ucp_Tibetan,
- ucp_Tifinagh,
- ucp_Ugaritic,
- ucp_Yi,
- /* New for Unicode 5.0: */
- ucp_Balinese,
- ucp_Cuneiform,
- ucp_Nko,
- ucp_Phags_Pa,
- ucp_Phoenician,
- /* New for Unicode 5.1: */
- ucp_Carian,
- ucp_Cham,
- ucp_Kayah_Li,
- ucp_Lepcha,
- ucp_Lycian,
- ucp_Lydian,
- ucp_Ol_Chiki,
- ucp_Rejang,
- ucp_Saurashtra,
- ucp_Sundanese,
- ucp_Vai,
- /* New for Unicode 5.2: */
- ucp_Avestan,
- ucp_Bamum,
- ucp_Egyptian_Hieroglyphs,
- ucp_Imperial_Aramaic,
- ucp_Inscriptional_Pahlavi,
- ucp_Inscriptional_Parthian,
- ucp_Javanese,
- ucp_Kaithi,
- ucp_Lisu,
- ucp_Meetei_Mayek,
- ucp_Old_South_Arabian,
- ucp_Old_Turkic,
- ucp_Samaritan,
- ucp_Tai_Tham,
- ucp_Tai_Viet,
- /* New for Unicode 6.0.0: */
- ucp_Batak,
- ucp_Brahmi,
- ucp_Mandaic,
- /* New for Unicode 6.1.0: */
- ucp_Chakma,
- ucp_Meroitic_Cursive,
- ucp_Meroitic_Hieroglyphs,
- ucp_Miao,
- ucp_Sharada,
- ucp_Sora_Sompeng,
- ucp_Takri,
- /* New for Unicode 7.0.0: */
- ucp_Bassa_Vah,
- ucp_Caucasian_Albanian,
- ucp_Duployan,
- ucp_Elbasan,
- ucp_Grantha,
- ucp_Khojki,
- ucp_Khudawadi,
- ucp_Linear_A,
- ucp_Mahajani,
- ucp_Manichaean,
- ucp_Mende_Kikakui,
- ucp_Modi,
- ucp_Mro,
- ucp_Nabataean,
- ucp_Old_North_Arabian,
- ucp_Old_Permic,
- ucp_Pahawh_Hmong,
- ucp_Palmyrene,
- ucp_Psalter_Pahlavi,
- ucp_Pau_Cin_Hau,
- ucp_Siddham,
- ucp_Tirhuta,
- ucp_Warang_Citi
-};
-
-#endif
-
-/* End of ucp.h */
diff -Nru r-base-3.2.3/src/extra/tre/Makefile.in r-base-3.3.1/src/extra/tre/Makefile.in
--- r-base-3.2.3/src/extra/tre/Makefile.in 2014-03-12 23:02:09.000000000 +0000
+++ r-base-3.3.1/src/extra/tre/Makefile.in 2015-12-10 23:15:13.000000000 +0000
@@ -49,8 +49,8 @@
@BUILD_TRE_TRUE@ @$(MAKE) $(noinst_LIBRARIES)
libtre.a: $(libtre_a_OBJECTS)
- rm -f $@
- $(AR) cr $@ $(libtre_a_OBJECTS)
+ @rm -f $@
+ $(AR) -cr $@ $(libtre_a_OBJECTS)
$(RANLIB) $@
mostlyclean: clean
diff -Nru r-base-3.2.3/src/extra/tre/tre-internal.h r-base-3.3.1/src/extra/tre/tre-internal.h
--- r-base-3.2.3/src/extra/tre/tre-internal.h 2014-06-13 22:15:07.000000000 +0000
+++ r-base-3.3.1/src/extra/tre/tre-internal.h 2016-03-16 23:02:11.000000000 +0000
@@ -48,7 +48,17 @@
/* Wide characters. */
typedef wint_t tre_cint_t;
-#define TRE_CHAR_MAX WCHAR_MAX
+/* Workaround problem seen on AIX, (2010 & 2015), e.g.,
+ https://stat.ethz.ch/pipermail/r-devel/2015-October/071902.html
+ WCHAR_MAX = UINT32_MAX on AIX and that is "not possible to work"
+ Solaris-sparcv9 WCHAR_MAX = INT32_MAX
+ Linux amd64 WCHAR_MAX = INT32_MAX
+*/
+#if WCHAR_MAX == UINT32_MAX
+# define TRE_CHAR_MAX INT32_MAX
+#else
+# define TRE_CHAR_MAX WCHAR_MAX
+#endif
#ifdef TRE_MULTIBYTE
#define TRE_MB_CUR_MAX MB_CUR_MAX
diff -Nru r-base-3.2.3/src/extra/tre/tre-match-approx.c r-base-3.3.1/src/extra/tre/tre-match-approx.c
--- r-base-3.2.3/src/extra/tre/tre-match-approx.c 2014-03-12 23:02:09.000000000 +0000
+++ r-base-3.3.1/src/extra/tre/tre-match-approx.c 2016-01-04 23:15:05.000000000 +0000
@@ -793,10 +793,10 @@
default_params);
/* Set the costs after this transition. */
- memcpy(&reach_next[dest_id].costs,
- reach[id].costs,
- sizeof(reach[id].costs[0][0])
- * TRE_M_LAST * (depth + 1));
+ memcpy(&reach_next[dest_id].costs,
+ reach[id].costs,
+ sizeof(reach[id].costs[0][0])
+ * TRE_M_LAST * (depth + 1));
reach_next[dest_id].costs[depth][TRE_M_COST] = cost;
reach_next[dest_id].costs[depth][TRE_M_NUM_SUBST] += err;
reach_next[dest_id].costs[depth][TRE_M_NUM_ERR] += err;
diff -Nru r-base-3.2.3/src/extra/tzone/localtime.c r-base-3.3.1/src/extra/tzone/localtime.c
--- r-base-3.2.3/src/extra/tzone/localtime.c 2015-08-25 22:15:07.000000000 +0000
+++ r-base-3.3.1/src/extra/tzone/localtime.c 2016-02-01 23:15:12.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Modifications copyright (C) 2007-2015 The R Core Team
+ * Modifications copyright (C) 2007-2016 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,8 +38,9 @@
#include
#include /* for CHAR_BIT et al. */
-// to get tm_zone, tm_gmtoff defined in glibc.
-// some other header, e.g. math.h, might define the macro.
+// To get tm_zone, tm_gmtoff defined in glibc
+// (although this file is not usually used there).
+// Some other header, e.g. math.h, might define the macro.
#if defined HAVE_FEATURES_H
# include
# ifdef __GNUC_PREREQ
@@ -279,6 +280,8 @@
#define lclptr (&lclmem)
#define gmtptr (&gmtmem)
+/* These are abbreviated names, so 255 should be ample.
+ But this was not checked in strcpy below. */
#ifndef TZ_STRLEN_MAX
#define TZ_STRLEN_MAX 255
#endif /* !defined TZ_STRLEN_MAX */
@@ -1221,8 +1224,11 @@
if (lcl_is_set > 0 && strcmp(lcl_TZname, name) == 0)
return;
lcl_is_set = strlen(name) < sizeof lcl_TZname;
- if (lcl_is_set)
- (void) strcpy(lcl_TZname, name);
+ /* R change: was strcpy before. */
+ if (lcl_is_set) {
+ (void) strncpy(lcl_TZname, name, TZ_STRLEN_MAX);
+ lcl_TZname[TZ_STRLEN_MAX] = '\0';
+ }
if (*name == '\0') {
/*
diff -Nru r-base-3.2.3/src/extra/tzone/Makefile.in r-base-3.3.1/src/extra/tzone/Makefile.in
--- r-base-3.2.3/src/extra/tzone/Makefile.in 2014-03-12 23:02:06.000000000 +0000
+++ r-base-3.3.1/src/extra/tzone/Makefile.in 2015-12-10 23:15:12.000000000 +0000
@@ -24,7 +24,7 @@
libtz.a: $(OBJECTS)
@rm -f $@
- $(AR) cr $@ $(OBJECTS)
+ $(AR) -cr $@ $(OBJECTS)
@$(RANLIB) $@
diff -Nru r-base-3.2.3/src/extra/tzone/Make.zi r-base-3.3.1/src/extra/tzone/Make.zi
--- r-base-3.2.3/src/extra/tzone/Make.zi 2015-06-14 22:15:05.000000000 +0000
+++ r-base-3.3.1/src/extra/tzone/Make.zi 2016-04-19 22:15:05.000000000 +0000
@@ -1,6 +1,6 @@
## Makefile to be run on a Unix box with zic
-VERSION = 2015e
+VERSION = 2016d
TZDIR = zoneinfo
TZTMP = tz
TARFILE = tzdata$(VERSION).tar.gz
diff -Nru r-base-3.2.3/src/extra/tzone/Notes r-base-3.3.1/src/extra/tzone/Notes
--- r-base-3.2.3/src/extra/tzone/Notes 2015-06-18 22:15:03.000000000 +0000
+++ r-base-3.3.1/src/extra/tzone/Notes 2016-04-19 22:15:05.000000000 +0000
@@ -22,11 +22,11 @@
To remake it, download the current version of tzdataXXXXx.tar.gz from
http://www.iana.org/time-zones to this directory and run
-make -f Make.zi VERSION=2015e
+make -f Make.zi VERSION=2016d
for the appropriate version. If zic is not on the path, use something like
-make -f Make.zi VERSION=2015e ZIC=/usr/sbin/zic
+make -f Make.zi VERSION=2016d ZIC=/usr/sbin/zic
NB: it seems that this needs to be done on a system with 64-bit time_t
or the catalogs will be confined to 1902-2038. And even that did not
diff -Nru r-base-3.2.3/src/extra/tzone/tzfile.h r-base-3.3.1/src/extra/tzone/tzfile.h
--- r-base-3.2.3/src/extra/tzone/tzfile.h 2015-08-14 22:15:04.000000000 +0000
+++ r-base-3.3.1/src/extra/tzone/tzfile.h 2016-03-16 23:02:10.000000000 +0000
@@ -115,8 +115,9 @@
#endif /* !defined NOSOLAR */
#endif /* !defined TZ_MAX_TYPES */
+// increased from 50, http://mm.icann.org/pipermail/tz/2015-August/022623.html
#ifndef TZ_MAX_CHARS
-#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */
+#define TZ_MAX_CHARS 100 /* Maximum number of abbreviation characters */
/* (limited by what unsigned chars can hold) */
#endif /* !defined TZ_MAX_CHARS */
Binary files /tmp/tmpr1xlqo/rKiOMPh78h/r-base-3.2.3/src/extra/tzone/zoneinfo.zip and /tmp/tmpr1xlqo/EboCyhHyzT/r-base-3.3.1/src/extra/tzone/zoneinfo.zip differ
diff -Nru r-base-3.2.3/src/extra/xdr/Makefile.in r-base-3.3.1/src/extra/xdr/Makefile.in
--- r-base-3.2.3/src/extra/xdr/Makefile.in 2013-09-26 22:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xdr/Makefile.in 2015-12-10 23:15:13.000000000 +0000
@@ -44,8 +44,8 @@
@$(MAKE) $(noinst_LIBRARIES)
libxdr.a: $(libxdr_a_OBJECTS)
- rm -f $@
- $(AR) cr $@ $(libxdr_a_OBJECTS)
+ @rm -f $@
+ $(AR) -cr $@ $(libxdr_a_OBJECTS)
$(RANLIB) $@
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/base.h r-base-3.3.1/src/extra/xz/api/lzma/base.h
--- r-base-3.2.3/src/extra/xz/api/lzma/base.h 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/base.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,601 +0,0 @@
-/**
- * \file lzma/base.h
- * \brief Data types and functions used in many places in liblzma API
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/**
- * \brief Boolean
- *
- * This is here because C89 doesn't have stdbool.h. To set a value for
- * variables having type lzma_bool, you can use
- * - C99's `true' and `false' from stdbool.h;
- * - C++'s internal `true' and `false'; or
- * - integers one (true) and zero (false).
- */
-typedef unsigned char lzma_bool;
-
-
-/**
- * \brief Type of reserved enumeration variable in structures
- *
- * To avoid breaking library ABI when new features are added, several
- * structures contain extra variables that may be used in future. Since
- * sizeof(enum) can be different than sizeof(int), and sizeof(enum) may
- * even vary depending on the range of enumeration constants, we specify
- * a separate type to be used for reserved enumeration variables. All
- * enumeration constants in liblzma API will be non-negative and less
- * than 128, which should guarantee that the ABI won't break even when
- * new constants are added to existing enumerations.
- */
-typedef enum {
- LZMA_RESERVED_ENUM = 0
-} lzma_reserved_enum;
-
-
-/**
- * \brief Return values used by several functions in liblzma
- *
- * Check the descriptions of specific functions to find out which return
- * values they can return. With some functions the return values may have
- * more specific meanings than described here; those differences are
- * described per-function basis.
- */
-typedef enum {
- LZMA_OK = 0,
- /**<
- * \brief Operation completed successfully
- */
-
- LZMA_STREAM_END = 1,
- /**<
- * \brief End of stream was reached
- *
- * In encoder, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or
- * LZMA_FINISH was finished. In decoder, this indicates
- * that all the data was successfully decoded.
- *
- * In all cases, when LZMA_STREAM_END is returned, the last
- * output bytes should be picked from strm->next_out.
- */
-
- LZMA_NO_CHECK = 2,
- /**<
- * \brief Input stream has no integrity check
- *
- * This return value can be returned only if the
- * LZMA_TELL_NO_CHECK flag was used when initializing
- * the decoder. LZMA_NO_CHECK is just a warning, and
- * the decoding can be continued normally.
- *
- * It is possible to call lzma_get_check() immediately after
- * lzma_code has returned LZMA_NO_CHECK. The result will
- * naturally be LZMA_CHECK_NONE, but the possibility to call
- * lzma_get_check() may be convenient in some applications.
- */
-
- LZMA_UNSUPPORTED_CHECK = 3,
- /**<
- * \brief Cannot calculate the integrity check
- *
- * The usage of this return value is different in encoders
- * and decoders.
- *
- * Encoders can return this value only from the initialization
- * function. If initialization fails with this value, the
- * encoding cannot be done, because there's no way to produce
- * output with the correct integrity check.
- *
- * Decoders can return this value only from lzma_code() and
- * only if the LZMA_TELL_UNSUPPORTED_CHECK flag was used when
- * initializing the decoder. The decoding can still be
- * continued normally even if the check type is unsupported,
- * but naturally the check will not be validated, and possible
- * errors may go undetected.
- *
- * With decoder, it is possible to call lzma_get_check()
- * immediately after lzma_code() has returned
- * LZMA_UNSUPPORTED_CHECK. This way it is possible to find
- * out what the unsupported Check ID was.
- */
-
- LZMA_GET_CHECK = 4,
- /**<
- * \brief Integrity check type is now available
- *
- * This value can be returned only by the lzma_code() function
- * and only if the decoder was initialized with the
- * LZMA_TELL_ANY_CHECK flag. LZMA_GET_CHECK tells the
- * application that it may now call lzma_get_check() to find
- * out the Check ID. This can be used, for example, to
- * implement a decoder that accepts only files that have
- * strong enough integrity check.
- */
-
- LZMA_MEM_ERROR = 5,
- /**<
- * \brief Cannot allocate memory
- *
- * Memory allocation failed, or the size of the allocation
- * would be greater than SIZE_MAX.
- *
- * Due to internal implementation reasons, the coding cannot
- * be continued even if more memory were made available after
- * LZMA_MEM_ERROR.
- */
-
- LZMA_MEMLIMIT_ERROR = 6,
- /**
- * \brief Memory usage limit was reached
- *
- * Decoder would need more memory than allowed by the
- * specified memory usage limit. To continue decoding,
- * the memory usage limit has to be increased with
- * lzma_memlimit_set().
- */
-
- LZMA_FORMAT_ERROR = 7,
- /**<
- * \brief File format not recognized
- *
- * The decoder did not recognize the input as supported file
- * format. This error can occur, for example, when trying to
- * decode .lzma format file with lzma_stream_decoder,
- * because lzma_stream_decoder accepts only the .xz format.
- */
-
- LZMA_OPTIONS_ERROR = 8,
- /**<
- * \brief Invalid or unsupported options
- *
- * Invalid or unsupported options, for example
- * - unsupported filter(s) or filter options; or
- * - reserved bits set in headers (decoder only).
- *
- * Rebuilding liblzma with more features enabled, or
- * upgrading to a newer version of liblzma may help.
- */
-
- LZMA_DATA_ERROR = 9,
- /**<
- * \brief Data is corrupt
- *
- * The usage of this return value is different in encoders
- * and decoders. In both encoder and decoder, the coding
- * cannot continue after this error.
- *
- * Encoders return this if size limits of the target file
- * format would be exceeded. These limits are huge, thus
- * getting this error from an encoder is mostly theoretical.
- * For example, the maximum compressed and uncompressed
- * size of a .xz Stream is roughly 8 EiB (2^63 bytes).
- *
- * Decoders return this error if the input data is corrupt.
- * This can mean, for example, invalid CRC32 in headers
- * or invalid check of uncompressed data.
- */
-
- LZMA_BUF_ERROR = 10,
- /**<
- * \brief No progress is possible
- *
- * This error code is returned when the coder cannot consume
- * any new input and produce any new output. The most common
- * reason for this error is that the input stream being
- * decoded is truncated or corrupt.
- *
- * This error is not fatal. Coding can be continued normally
- * by providing more input and/or more output space, if
- * possible.
- *
- * Typically the first call to lzma_code() that can do no
- * progress returns LZMA_OK instead of LZMA_BUF_ERROR. Only
- * the second consecutive call doing no progress will return
- * LZMA_BUF_ERROR. This is intentional.
- *
- * With zlib, Z_BUF_ERROR may be returned even if the
- * application is doing nothing wrong, so apps will need
- * to handle Z_BUF_ERROR specially. The above hack
- * guarantees that liblzma never returns LZMA_BUF_ERROR
- * to properly written applications unless the input file
- * is truncated or corrupt. This should simplify the
- * applications a little.
- */
-
- LZMA_PROG_ERROR = 11,
- /**<
- * \brief Programming error
- *
- * This indicates that the arguments given to the function are
- * invalid or the internal state of the decoder is corrupt.
- * - Function arguments are invalid or the structures
- * pointed by the argument pointers are invalid
- * e.g. if strm->next_out has been set to NULL and
- * strm->avail_out > 0 when calling lzma_code().
- * - lzma_* functions have been called in wrong order
- * e.g. lzma_code() was called right after lzma_end().
- * - If errors occur randomly, the reason might be flaky
- * hardware.
- *
- * If you think that your code is correct, this error code
- * can be a sign of a bug in liblzma. See the documentation
- * how to report bugs.
- */
-} lzma_ret;
-
-
-/**
- * \brief The `action' argument for lzma_code()
- *
- * After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or LZMA_FINISH,
- * the same `action' must is used until lzma_code() returns LZMA_STREAM_END.
- * Also, the amount of input (that is, strm->avail_in) must not be modified
- * by the application until lzma_code() returns LZMA_STREAM_END. Changing the
- * `action' or modifying the amount of input will make lzma_code() return
- * LZMA_PROG_ERROR.
- */
-typedef enum {
- LZMA_RUN = 0,
- /**<
- * \brief Continue coding
- *
- * Encoder: Encode as much input as possible. Some internal
- * buffering will probably be done (depends on the filter
- * chain in use), which causes latency: the input used won't
- * usually be decodeable from the output of the same
- * lzma_code() call.
- *
- * Decoder: Decode as much input as possible and produce as
- * much output as possible.
- */
-
- LZMA_SYNC_FLUSH = 1,
- /**<
- * \brief Make all the input available at output
- *
- * Normally the encoder introduces some latency.
- * LZMA_SYNC_FLUSH forces all the buffered data to be
- * available at output without resetting the internal
- * state of the encoder. This way it is possible to use
- * compressed stream for example for communication over
- * network.
- *
- * Only some filters support LZMA_SYNC_FLUSH. Trying to use
- * LZMA_SYNC_FLUSH with filters that don't support it will
- * make lzma_code() return LZMA_OPTIONS_ERROR. For example,
- * LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does.
- *
- * Using LZMA_SYNC_FLUSH very often can dramatically reduce
- * the compression ratio. With some filters (for example,
- * LZMA2), fine-tuning the compression options may help
- * mitigate this problem significantly (for example,
- * match finder with LZMA2).
- *
- * Decoders don't support LZMA_SYNC_FLUSH.
- */
-
- LZMA_FULL_FLUSH = 2,
- /**<
- * \brief Finish encoding of the current Block
- *
- * All the input data going to the current Block must have
- * been given to the encoder (the last bytes can still be
- * pending in* next_in). Call lzma_code() with LZMA_FULL_FLUSH
- * until it returns LZMA_STREAM_END. Then continue normally
- * with LZMA_RUN or finish the Stream with LZMA_FINISH.
- *
- * This action is currently supported only by Stream encoder
- * and easy encoder (which uses Stream encoder). If there is
- * no unfinished Block, no empty Block is created.
- */
-
- LZMA_FINISH = 3
- /**<
- * \brief Finish the coding operation
- *
- * All the input data must have been given to the encoder
- * (the last bytes can still be pending in next_in).
- * Call lzma_code() with LZMA_FINISH until it returns
- * LZMA_STREAM_END. Once LZMA_FINISH has been used,
- * the amount of input must no longer be changed by
- * the application.
- *
- * When decoding, using LZMA_FINISH is optional unless the
- * LZMA_CONCATENATED flag was used when the decoder was
- * initialized. When LZMA_CONCATENATED was not used, the only
- * effect of LZMA_FINISH is that the amount of input must not
- * be changed just like in the encoder.
- */
-} lzma_action;
-
-
-/**
- * \brief Custom functions for memory handling
- *
- * A pointer to lzma_allocator may be passed via lzma_stream structure
- * to liblzma, and some advanced functions take a pointer to lzma_allocator
- * as a separate function argument. The library will use the functions
- * specified in lzma_allocator for memory handling instead of the default
- * malloc() and free(). C++ users should note that the custom memory
- * handling functions must not throw exceptions.
- *
- * liblzma doesn't make an internal copy of lzma_allocator. Thus, it is
- * OK to change these function pointers in the middle of the coding
- * process, but obviously it must be done carefully to make sure that the
- * replacement `free' can deallocate memory allocated by the earlier
- * `alloc' function(s).
- */
-typedef struct {
- /**
- * \brief Pointer to a custom memory allocation function
- *
- * If you don't want a custom allocator, but still want
- * custom free(), set this to NULL and liblzma will use
- * the standard malloc().
- *
- * \param opaque lzma_allocator.opaque (see below)
- * \param nmemb Number of elements like in calloc(). liblzma
- * will always set nmemb to 1, so it is safe to
- * ignore nmemb in a custom allocator if you like.
- * The nmemb argument exists only for
- * compatibility with zlib and libbzip2.
- * \param size Size of an element in bytes.
- * liblzma never sets this to zero.
- *
- * \return Pointer to the beginning of a memory block of
- * `size' bytes, or NULL if allocation fails
- * for some reason. When allocation fails, functions
- * of liblzma return LZMA_MEM_ERROR.
- *
- * The allocator should not waste time zeroing the allocated buffers.
- * This is not only about speed, but also memory usage, since the
- * operating system kernel doesn't necessarily allocate the requested
- * memory in physical memory until it is actually used. With small
- * input files, liblzma may actually need only a fraction of the
- * memory that it requested for allocation.
- *
- * \note LZMA_MEM_ERROR is also used when the size of the
- * allocation would be greater than SIZE_MAX. Thus,
- * don't assume that the custom allocator must have
- * returned NULL if some function from liblzma
- * returns LZMA_MEM_ERROR.
- */
- void *(LZMA_API_CALL *alloc)(void *opaque, size_t nmemb, size_t size);
-
- /**
- * \brief Pointer to a custom memory freeing function
- *
- * If you don't want a custom freeing function, but still
- * want a custom allocator, set this to NULL and liblzma
- * will use the standard free().
- *
- * \param opaque lzma_allocator.opaque (see below)
- * \param ptr Pointer returned by lzma_allocator.alloc(),
- * or when it is set to NULL, a pointer returned
- * by the standard malloc().
- */
- void (LZMA_API_CALL *free)(void *opaque, void *ptr);
-
- /**
- * \brief Pointer passed to .alloc() and .free()
- *
- * opaque is passed as the first argument to lzma_allocator.alloc()
- * and lzma_allocator.free(). This intended to ease implementing
- * custom memory allocation functions for use with liblzma.
- *
- * If you don't need this, you should set this to NULL.
- */
- void *opaque;
-
-} lzma_allocator;
-
-
-/**
- * \brief Internal data structure
- *
- * The contents of this structure is not visible outside the library.
- */
-typedef struct lzma_internal_s lzma_internal;
-
-
-/**
- * \brief Passing data to and from liblzma
- *
- * The lzma_stream structure is used for
- * - passing pointers to input and output buffers to liblzma;
- * - defining custom memory hander functions; and
- * - holding a pointer to coder-specific internal data structures.
- *
- * Typical usage:
- *
- * - After allocating lzma_stream (on stack or with malloc()), it must be
- * initialized to LZMA_STREAM_INIT (see LZMA_STREAM_INIT for details).
- *
- * - Initialize a coder to the lzma_stream, for example by using
- * lzma_easy_encoder() or lzma_auto_decoder(). Some notes:
- * - In contrast to zlib, strm->next_in and strm->next_out are
- * ignored by all initialization functions, thus it is safe
- * to not initialize them yet.
- * - The initialization functions always set strm->total_in and
- * strm->total_out to zero.
- * - If the initialization function fails, no memory is left allocated
- * that would require freeing with lzma_end() even if some memory was
- * associated with the lzma_stream structure when the initialization
- * function was called.
- *
- * - Use lzma_code() to do the actual work.
- *
- * - Once the coding has been finished, the existing lzma_stream can be
- * reused. It is OK to reuse lzma_stream with different initialization
- * function without calling lzma_end() first. Old allocations are
- * automatically freed.
- *
- * - Finally, use lzma_end() to free the allocated memory. lzma_end() never
- * frees the lzma_stream structure itself.
- *
- * Application may modify the values of total_in and total_out as it wants.
- * They are updated by liblzma to match the amount of data read and
- * written, but aren't used for anything else.
- */
-typedef struct {
- const uint8_t *next_in; /**< Pointer to the next input byte. */
- size_t avail_in; /**< Number of available input bytes in next_in. */
- uint64_t total_in; /**< Total number of bytes read by liblzma. */
-
- uint8_t *next_out; /**< Pointer to the next output position. */
- size_t avail_out; /**< Amount of free space in next_out. */
- uint64_t total_out; /**< Total number of bytes written by liblzma. */
-
- /**
- * \brief Custom memory allocation functions
- *
- * In most cases this is NULL which makes liblzma use
- * the standard malloc() and free().
- */
- lzma_allocator *allocator;
-
- /** Internal state is not visible to applications. */
- lzma_internal *internal;
-
- /*
- * Reserved space to allow possible future extensions without
- * breaking the ABI. Excluding the initialization of this structure,
- * you should not touch these, because the names of these variables
- * may change.
- */
- void *reserved_ptr1;
- void *reserved_ptr2;
- void *reserved_ptr3;
- void *reserved_ptr4;
- uint64_t reserved_int1;
- uint64_t reserved_int2;
- size_t reserved_int3;
- size_t reserved_int4;
- lzma_reserved_enum reserved_enum1;
- lzma_reserved_enum reserved_enum2;
-
-} lzma_stream;
-
-
-/**
- * \brief Initialization for lzma_stream
- *
- * When you declare an instance of lzma_stream, you can immediately
- * initialize it so that initialization functions know that no memory
- * has been allocated yet:
- *
- * lzma_stream strm = LZMA_STREAM_INIT;
- *
- * If you need to initialize a dynamically allocated lzma_stream, you can use
- * memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this
- * violates the C standard since NULL may have different internal
- * representation than zero, but it should be portable enough in practice.
- * Anyway, for maximum portability, you can use something like this:
- *
- * lzma_stream tmp = LZMA_STREAM_INIT;
- * *strm = tmp;
- */
-#define LZMA_STREAM_INIT \
- { NULL, 0, 0, NULL, 0, 0, NULL, NULL, \
- NULL, NULL, NULL, NULL, 0, 0, 0, 0, \
- LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM }
-
-
-/**
- * \brief Encode or decode data
- *
- * Once the lzma_stream has been successfully initialized (e.g. with
- * lzma_stream_encoder()), the actual encoding or decoding is done
- * using this function. The application has to update strm->next_in,
- * strm->avail_in, strm->next_out, and strm->avail_out to pass input
- * to and get output from liblzma.
- *
- * See the description of the coder-specific initialization function to find
- * out what `action' values are supported by the coder.
- */
-extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Free memory allocated for the coder data structures
- *
- * \param strm Pointer to lzma_stream that is at least initialized
- * with LZMA_STREAM_INIT.
- *
- * After lzma_end(strm), strm->internal is guaranteed to be NULL. No other
- * members of the lzma_stream structure are touched.
- *
- * \note zlib indicates an error if application end()s unfinished
- * stream structure. liblzma doesn't do this, and assumes that
- * application knows what it is doing.
- */
-extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow;
-
-
-/**
- * \brief Get the memory usage of decoder filter chain
- *
- * This function is currently supported only when *strm has been initialized
- * with a function that takes a memlimit argument. With other functions, you
- * should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage()
- * to estimate the memory requirements.
- *
- * This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big
- * the memory usage limit should have been to decode the input. Note that
- * this may give misleading information if decoding .xz Streams that have
- * multiple Blocks, because each Block can have different memory requirements.
- *
- * \return How much memory is currently allocated for the filter
- * decoders. If no filter chain is currently allocated,
- * some non-zero value is still returned, which is less than
- * or equal to what any filter chain would indicate as its
- * memory requirement.
- *
- * If this function isn't supported by *strm or some other error
- * occurs, zero is returned.
- */
-extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Get the current memory usage limit
- *
- * This function is supported only when *strm has been initialized with
- * a function that takes a memlimit argument.
- *
- * \return On success, the current memory usage limit is returned
- * (always non-zero). On error, zero is returned.
- */
-extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Set the memory usage limit
- *
- * This function is supported only when *strm has been initialized with
- * a function that takes a memlimit argument.
- *
- * \return - LZMA_OK: New memory usage limit successfully set.
- * - LZMA_MEMLIMIT_ERROR: The new limit is too small.
- * The limit was not changed.
- * - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't
- * support memory usage limit or memlimit was zero.
- */
-extern LZMA_API(lzma_ret) lzma_memlimit_set(
- lzma_stream *strm, uint64_t memlimit) lzma_nothrow;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/bcj.h r-base-3.3.1/src/extra/xz/api/lzma/bcj.h
--- r-base-3.2.3/src/extra/xz/api/lzma/bcj.h 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/bcj.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,90 +0,0 @@
-/**
- * \file lzma/bcj.h
- * \brief Branch/Call/Jump conversion filters
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/* Filter IDs for lzma_filter.id */
-
-#define LZMA_FILTER_X86 LZMA_VLI_C(0x04)
- /**<
- * Filter for x86 binaries
- */
-
-#define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05)
- /**<
- * Filter for Big endian PowerPC binaries
- */
-
-#define LZMA_FILTER_IA64 LZMA_VLI_C(0x06)
- /**<
- * Filter for IA-64 (Itanium) binaries.
- */
-
-#define LZMA_FILTER_ARM LZMA_VLI_C(0x07)
- /**<
- * Filter for ARM binaries.
- */
-
-#define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08)
- /**<
- * Filter for ARM-Thumb binaries.
- */
-
-#define LZMA_FILTER_SPARC LZMA_VLI_C(0x09)
- /**<
- * Filter for SPARC binaries.
- */
-
-
-/**
- * \brief Options for BCJ filters
- *
- * The BCJ filters never change the size of the data. Specifying options
- * for them is optional: if pointer to options is NULL, default value is
- * used. You probably never need to specify options to BCJ filters, so just
- * set the options pointer to NULL and be happy.
- *
- * If options with non-default values have been specified when encoding,
- * the same options must also be specified when decoding.
- *
- * \note At the moment, none of the BCJ filters support
- * LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified,
- * LZMA_OPTIONS_ERROR will be returned. If there is need,
- * partial support for LZMA_SYNC_FLUSH can be added in future.
- * Partial means that flushing would be possible only at
- * offsets that are multiple of 2, 4, or 16 depending on
- * the filter, except x86 which cannot be made to support
- * LZMA_SYNC_FLUSH predictably.
- */
-typedef struct {
- /**
- * \brief Start offset for conversions
- *
- * This setting is useful only when the same filter is used
- * _separately_ for multiple sections of the same executable file,
- * and the sections contain cross-section branch/call/jump
- * instructions. In that case it is beneficial to set the start
- * offset of the non-first sections so that the relative addresses
- * of the cross-section branch/call/jump instructions will use the
- * same absolute addresses as in the first section.
- *
- * When the pointer to options is NULL, the default value (zero)
- * is used.
- */
- uint32_t start_offset;
-
-} lzma_options_bcj;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/block.h r-base-3.3.1/src/extra/xz/api/lzma/block.h
--- r-base-3.2.3/src/extra/xz/api/lzma/block.h 2015-03-18 23:02:07.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/block.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,533 +0,0 @@
-/**
- * \file lzma/block.h
- * \brief .xz Block handling
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/**
- * \brief Options for the Block and Block Header encoders and decoders
- *
- * Different Block handling functions use different parts of this structure.
- * Some read some members, other functions write, and some do both. Only the
- * members listed for reading need to be initialized when the specified
- * functions are called. The members marked for writing will be assigned
- * new values at some point either by calling the given function or by
- * later calls to lzma_code().
- */
-typedef struct {
- /**
- * \brief Block format version
- *
- * To prevent API and ABI breakages if new features are needed in
- * the Block field, a version number is used to indicate which
- * fields in this structure are in use. For now, version must always
- * be zero. With non-zero version, most Block related functions will
- * return LZMA_OPTIONS_ERROR.
- *
- * Read by:
- * - All functions that take pointer to lzma_block as argument,
- * including lzma_block_header_decode().
- *
- * Written by:
- * - lzma_block_header_decode()
- */
- uint32_t version;
-
- /**
- * \brief Size of the Block Header field
- *
- * This is always a multiple of four.
- *
- * Read by:
- * - lzma_block_header_encode()
- * - lzma_block_header_decode()
- * - lzma_block_compressed_size()
- * - lzma_block_unpadded_size()
- * - lzma_block_total_size()
- * - lzma_block_decoder()
- * - lzma_block_buffer_decode()
- *
- * Written by:
- * - lzma_block_header_size()
- * - lzma_block_buffer_encode()
- */
- uint32_t header_size;
-# define LZMA_BLOCK_HEADER_SIZE_MIN 8
-# define LZMA_BLOCK_HEADER_SIZE_MAX 1024
-
- /**
- * \brief Type of integrity Check
- *
- * The Check ID is not stored into the Block Header, thus its value
- * must be provided also when decoding.
- *
- * Read by:
- * - lzma_block_header_encode()
- * - lzma_block_header_decode()
- * - lzma_block_compressed_size()
- * - lzma_block_unpadded_size()
- * - lzma_block_total_size()
- * - lzma_block_encoder()
- * - lzma_block_decoder()
- * - lzma_block_buffer_encode()
- * - lzma_block_buffer_decode()
- */
- lzma_check check;
-
- /**
- * \brief Size of the Compressed Data in bytes
- *
- * Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder
- * will store this value to the Block Header. Block encoder doesn't
- * care about this value, but will set it once the encoding has been
- * finished.
- *
- * Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will
- * verify that the size of the Compressed Data field matches
- * compressed_size.
- *
- * Usually you don't know this value when encoding in streamed mode,
- * and thus cannot write this field into the Block Header.
- *
- * In non-streamed mode you can reserve space for this field before
- * encoding the actual Block. After encoding the data, finish the
- * Block by encoding the Block Header. Steps in detail:
- *
- * - Set compressed_size to some big enough value. If you don't know
- * better, use LZMA_VLI_MAX, but remember that bigger values take
- * more space in Block Header.
- *
- * - Call lzma_block_header_size() to see how much space you need to
- * reserve for the Block Header.
- *
- * - Encode the Block using lzma_block_encoder() and lzma_code().
- * It sets compressed_size to the correct value.
- *
- * - Use lzma_block_header_encode() to encode the Block Header.
- * Because space was reserved in the first step, you don't need
- * to call lzma_block_header_size() anymore, because due to
- * reserving, header_size has to be big enough. If it is "too big",
- * lzma_block_header_encode() will add enough Header Padding to
- * make Block Header to match the size specified by header_size.
- *
- * Read by:
- * - lzma_block_header_size()
- * - lzma_block_header_encode()
- * - lzma_block_compressed_size()
- * - lzma_block_unpadded_size()
- * - lzma_block_total_size()
- * - lzma_block_decoder()
- * - lzma_block_buffer_decode()
- *
- * Written by:
- * - lzma_block_header_decode()
- * - lzma_block_compressed_size()
- * - lzma_block_encoder()
- * - lzma_block_decoder()
- * - lzma_block_buffer_encode()
- * - lzma_block_buffer_decode()
- */
- lzma_vli compressed_size;
-
- /**
- * \brief Uncompressed Size in bytes
- *
- * This is handled very similarly to compressed_size above.
- *
- * uncompressed_size is needed by fewer functions than
- * compressed_size. This is because uncompressed_size isn't
- * needed to validate that Block stays within proper limits.
- *
- * Read by:
- * - lzma_block_header_size()
- * - lzma_block_header_encode()
- * - lzma_block_decoder()
- * - lzma_block_buffer_decode()
- *
- * Written by:
- * - lzma_block_header_decode()
- * - lzma_block_encoder()
- * - lzma_block_decoder()
- * - lzma_block_buffer_encode()
- * - lzma_block_buffer_decode()
- */
- lzma_vli uncompressed_size;
-
- /**
- * \brief Array of filters
- *
- * There can be 1-4 filters. The end of the array is marked with
- * .id = LZMA_VLI_UNKNOWN.
- *
- * Read by:
- * - lzma_block_header_size()
- * - lzma_block_header_encode()
- * - lzma_block_encoder()
- * - lzma_block_decoder()
- * - lzma_block_buffer_encode()
- * - lzma_block_buffer_decode()
- *
- * Written by:
- * - lzma_block_header_decode(): Note that this does NOT free()
- * the old filter options structures. All unused filters[] will
- * have .id == LZMA_VLI_UNKNOWN and .options == NULL. If
- * decoding fails, all filters[] are guaranteed to be
- * LZMA_VLI_UNKNOWN and NULL.
- *
- * \note Because of the array is terminated with
- * .id = LZMA_VLI_UNKNOWN, the actual array must
- * have LZMA_FILTERS_MAX + 1 members or the Block
- * Header decoder will overflow the buffer.
- */
- lzma_filter *filters;
-
- /**
- * \brief Raw value stored in the Check field
- *
- * After successful coding, the first lzma_check_size(check) bytes
- * of this array contain the raw value stored in the Check field.
- *
- * Note that CRC32 and CRC64 are stored in little endian byte order.
- * Take it into account if you display the Check values to the user.
- *
- * Written by:
- * - lzma_block_encoder()
- * - lzma_block_decoder()
- * - lzma_block_buffer_encode()
- * - lzma_block_buffer_decode()
- */
- uint8_t raw_check[LZMA_CHECK_SIZE_MAX];
-
- /*
- * Reserved space to allow possible future extensions without
- * breaking the ABI. You should not touch these, because the names
- * of these variables may change. These are and will never be used
- * with the currently supported options, so it is safe to leave these
- * uninitialized.
- */
- void *reserved_ptr1;
- void *reserved_ptr2;
- void *reserved_ptr3;
- uint32_t reserved_int1;
- uint32_t reserved_int2;
- lzma_vli reserved_int3;
- lzma_vli reserved_int4;
- lzma_vli reserved_int5;
- lzma_vli reserved_int6;
- lzma_vli reserved_int7;
- lzma_vli reserved_int8;
- lzma_reserved_enum reserved_enum1;
- lzma_reserved_enum reserved_enum2;
- lzma_reserved_enum reserved_enum3;
- lzma_reserved_enum reserved_enum4;
- lzma_bool reserved_bool1;
- lzma_bool reserved_bool2;
- lzma_bool reserved_bool3;
- lzma_bool reserved_bool4;
- lzma_bool reserved_bool5;
- lzma_bool reserved_bool6;
- lzma_bool reserved_bool7;
- lzma_bool reserved_bool8;
-
-} lzma_block;
-
-
-/**
- * \brief Decode the Block Header Size field
- *
- * To decode Block Header using lzma_block_header_decode(), the size of the
- * Block Header has to be known and stored into lzma_block.header_size.
- * The size can be calculated from the first byte of a Block using this macro.
- * Note that if the first byte is 0x00, it indicates beginning of Index; use
- * this macro only when the byte is not 0x00.
- *
- * There is no encoding macro, because Block Header encoder is enough for that.
- */
-#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4)
-
-
-/**
- * \brief Calculate Block Header Size
- *
- * Calculate the minimum size needed for the Block Header field using the
- * settings specified in the lzma_block structure. Note that it is OK to
- * increase the calculated header_size value as long as it is a multiple of
- * four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size
- * just means that lzma_block_header_encode() will add Header Padding.
- *
- * \return - LZMA_OK: Size calculated successfully and stored to
- * block->header_size.
- * - LZMA_OPTIONS_ERROR: Unsupported version, filters or
- * filter options.
- * - LZMA_PROG_ERROR: Invalid values like compressed_size == 0.
- *
- * \note This doesn't check that all the options are valid i.e. this
- * may return LZMA_OK even if lzma_block_header_encode() or
- * lzma_block_encoder() would fail. If you want to validate the
- * filter chain, consider using lzma_memlimit_encoder() which as
- * a side-effect validates the filter chain.
- */
-extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Encode Block Header
- *
- * The caller must have calculated the size of the Block Header already with
- * lzma_block_header_size(). If a value larger than the one calculated by
- * lzma_block_header_size() is used, the Block Header will be padded to the
- * specified size.
- *
- * \param out Beginning of the output buffer. This must be
- * at least block->header_size bytes.
- * \param block Block options to be encoded.
- *
- * \return - LZMA_OK: Encoding was successful. block->header_size
- * bytes were written to output buffer.
- * - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
- * - LZMA_PROG_ERROR: Invalid arguments, for example
- * block->header_size is invalid or block->filters is NULL.
- */
-extern LZMA_API(lzma_ret) lzma_block_header_encode(
- const lzma_block *block, uint8_t *out)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Decode Block Header
- *
- * block->version should be set to the highest value supported by the
- * application; currently the only possible version is zero. This function
- * will set version to the lowest value that still supports all the features
- * required by the Block Header.
- *
- * The size of the Block Header must have already been decoded with
- * lzma_block_header_size_decode() macro and stored to block->header_size.
- *
- * The integrity check type from Stream Header must have been stored
- * to block->check.
- *
- * block->filters must have been allocated, but they don't need to be
- * initialized (possible existing filter options are not freed).
- *
- * \param block Destination for Block options.
- * \param allocator lzma_allocator for custom allocator functions.
- * Set to NULL to use malloc() (and also free()
- * if an error occurs).
- * \param in Beginning of the input buffer. This must be
- * at least block->header_size bytes.
- *
- * \return - LZMA_OK: Decoding was successful. block->header_size
- * bytes were read from the input buffer.
- * - LZMA_OPTIONS_ERROR: The Block Header specifies some
- * unsupported options such as unsupported filters. This can
- * happen also if block->version was set to a too low value
- * compared to what would be required to properly represent
- * the information stored in the Block Header.
- * - LZMA_DATA_ERROR: Block Header is corrupt, for example,
- * the CRC32 doesn't match.
- * - LZMA_PROG_ERROR: Invalid arguments, for example
- * block->header_size is invalid or block->filters is NULL.
- */
-extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block,
- lzma_allocator *allocator, const uint8_t *in)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Validate and set Compressed Size according to Unpadded Size
- *
- * Block Header stores Compressed Size, but Index has Unpadded Size. If the
- * application has already parsed the Index and is now decoding Blocks,
- * it can calculate Compressed Size from Unpadded Size. This function does
- * exactly that with error checking:
- *
- * - Compressed Size calculated from Unpadded Size must be positive integer,
- * that is, Unpadded Size must be big enough that after Block Header and
- * Check fields there's still at least one byte for Compressed Size.
- *
- * - If Compressed Size was present in Block Header, the new value
- * calculated from Unpadded Size is compared against the value
- * from Block Header.
- *
- * \note This function must be called _after_ decoding the Block Header
- * field so that it can properly validate Compressed Size if it
- * was present in Block Header.
- *
- * \return - LZMA_OK: block->compressed_size was set successfully.
- * - LZMA_DATA_ERROR: unpadded_size is too small compared to
- * block->header_size and lzma_check_size(block->check).
- * - LZMA_PROG_ERROR: Some values are invalid. For example,
- * block->header_size must be a multiple of four and
- * between 8 and 1024 inclusive.
- */
-extern LZMA_API(lzma_ret) lzma_block_compressed_size(
- lzma_block *block, lzma_vli unpadded_size)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Calculate Unpadded Size
- *
- * The Index field stores Unpadded Size and Uncompressed Size. The latter
- * can be taken directly from the lzma_block structure after coding a Block,
- * but Unpadded Size needs to be calculated from Block Header Size,
- * Compressed Size, and size of the Check field. This is where this function
- * is needed.
- *
- * \return Unpadded Size on success, or zero on error.
- */
-extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Calculate the total encoded size of a Block
- *
- * This is equivalent to lzma_block_unpadded_size() except that the returned
- * value includes the size of the Block Padding field.
- *
- * \return On success, total encoded size of the Block. On error,
- * zero is returned.
- */
-extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Initialize .xz Block encoder
- *
- * Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the
- * filter chain supports it), and LZMA_FINISH.
- *
- * \return - LZMA_OK: All good, continue with lzma_code().
- * - LZMA_MEM_ERROR
- * - LZMA_OPTIONS_ERROR
- * - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID
- * that is not supported by this buid of liblzma. Initializing
- * the encoder failed.
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_block_encoder(
- lzma_stream *strm, lzma_block *block)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Initialize .xz Block decoder
- *
- * Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using
- * LZMA_FINISH is not required. It is supported only for convenience.
- *
- * \return - LZMA_OK: All good, continue with lzma_code().
- * - LZMA_UNSUPPORTED_CHECK: Initialization was successful, but
- * the given Check ID is not supported, thus Check will be
- * ignored.
- * - LZMA_PROG_ERROR
- * - LZMA_MEM_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_block_decoder(
- lzma_stream *strm, lzma_block *block)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Calculate maximum output size for single-call Block encoding
- *
- * This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks.
- * See the documentation of lzma_stream_buffer_bound().
- */
-extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size)
- lzma_nothrow;
-
-
-/**
- * \brief Single-call .xz Block encoder
- *
- * In contrast to the multi-call encoder initialized with
- * lzma_block_encoder(), this function encodes also the Block Header. This
- * is required to make it possible to write appropriate Block Header also
- * in case the data isn't compressible, and different filter chain has to be
- * used to encode the data in uncompressed form using uncompressed chunks
- * of the LZMA2 filter.
- *
- * When the data isn't compressible, header_size, compressed_size, and
- * uncompressed_size are set just like when the data was compressible, but
- * it is possible that header_size is too small to hold the filter chain
- * specified in block->filters, because that isn't necessarily the filter
- * chain that was actually used to encode the data. lzma_block_unpadded_size()
- * still works normally, because it doesn't read the filters array.
- *
- * \param block Block options: block->version, block->check,
- * and block->filters must have been initialized.
- * \param allocator lzma_allocator for custom allocator functions.
- * Set to NULL to use malloc() and free().
- * \param in Beginning of the input buffer
- * \param in_size Size of the input buffer
- * \param out Beginning of the output buffer
- * \param out_pos The next byte will be written to out[*out_pos].
- * *out_pos is updated only if encoding succeeds.
- * \param out_size Size of the out buffer; the first byte into
- * which no data is written to is out[out_size].
- *
- * \return - LZMA_OK: Encoding was successful.
- * - LZMA_BUF_ERROR: Not enough output buffer space.
- * - LZMA_UNSUPPORTED_CHECK
- * - LZMA_OPTIONS_ERROR
- * - LZMA_MEM_ERROR
- * - LZMA_DATA_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_block_buffer_encode(
- lzma_block *block, lzma_allocator *allocator,
- const uint8_t *in, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Single-call .xz Block decoder
- *
- * This is single-call equivalent of lzma_block_decoder(), and requires that
- * the caller has already decoded Block Header and checked its memory usage.
- *
- * \param block Block options just like with lzma_block_decoder().
- * \param allocator lzma_allocator for custom allocator functions.
- * Set to NULL to use malloc() and free().
- * \param in Beginning of the input buffer
- * \param in_pos The next byte will be read from in[*in_pos].
- * *in_pos is updated only if decoding succeeds.
- * \param in_size Size of the input buffer; the first byte that
- * won't be read is in[in_size].
- * \param out Beginning of the output buffer
- * \param out_pos The next byte will be written to out[*out_pos].
- * *out_pos is updated only if encoding succeeds.
- * \param out_size Size of the out buffer; the first byte into
- * which no data is written to is out[out_size].
- *
- * \return - LZMA_OK: Decoding was successful.
- * - LZMA_OPTIONS_ERROR
- * - LZMA_DATA_ERROR
- * - LZMA_MEM_ERROR
- * - LZMA_BUF_ERROR: Output buffer was too small.
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_block_buffer_decode(
- lzma_block *block, lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
- lzma_nothrow;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/check.h r-base-3.3.1/src/extra/xz/api/lzma/check.h
--- r-base-3.2.3/src/extra/xz/api/lzma/check.h 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/check.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,150 +0,0 @@
-/**
- * \file lzma/check.h
- * \brief Integrity checks
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/**
- * \brief Type of the integrity check (Check ID)
- *
- * The .xz format supports multiple types of checks that are calculated
- * from the uncompressed data. They vary in both speed and ability to
- * detect errors.
- */
-typedef enum {
- LZMA_CHECK_NONE = 0,
- /**<
- * No Check is calculated.
- *
- * Size of the Check field: 0 bytes
- */
-
- LZMA_CHECK_CRC32 = 1,
- /**<
- * CRC32 using the polynomial from the IEEE 802.3 standard
- *
- * Size of the Check field: 4 bytes
- */
-
- LZMA_CHECK_CRC64 = 4,
- /**<
- * CRC64 using the polynomial from the ECMA-182 standard
- *
- * Size of the Check field: 8 bytes
- */
-
- LZMA_CHECK_SHA256 = 10
- /**<
- * SHA-256
- *
- * Size of the Check field: 32 bytes
- */
-} lzma_check;
-
-
-/**
- * \brief Maximum valid Check ID
- *
- * The .xz file format specification specifies 16 Check IDs (0-15). Some
- * of them are only reserved, that is, no actual Check algorithm has been
- * assigned. When decoding, liblzma still accepts unknown Check IDs for
- * future compatibility. If a valid but unsupported Check ID is detected,
- * liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK,
- * LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h.
- */
-#define LZMA_CHECK_ID_MAX 15
-
-
-/**
- * \brief Test if the given Check ID is supported
- *
- * Return true if the given Check ID is supported by this liblzma build.
- * Otherwise false is returned. It is safe to call this with a value that
- * is not in the range [0, 15]; in that case the return value is always false.
- *
- * You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always
- * supported (even if liblzma is built with limited features).
- */
-extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check)
- lzma_nothrow lzma_attr_const;
-
-
-/**
- * \brief Get the size of the Check field with the given Check ID
- *
- * Although not all Check IDs have a check algorithm associated, the size of
- * every Check is already frozen. This function returns the size (in bytes) of
- * the Check field with the specified Check ID. The values are:
- * { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 }
- *
- * If the argument is not in the range [0, 15], UINT32_MAX is returned.
- */
-extern LZMA_API(uint32_t) lzma_check_size(lzma_check check)
- lzma_nothrow lzma_attr_const;
-
-
-/**
- * \brief Maximum size of a Check field
- */
-#define LZMA_CHECK_SIZE_MAX 64
-
-
-/**
- * \brief Calculate CRC32
- *
- * Calculate CRC32 using the polynomial from the IEEE 802.3 standard.
- *
- * \param buf Pointer to the input buffer
- * \param size Size of the input buffer
- * \param crc Previously returned CRC value. This is used to
- * calculate the CRC of a big buffer in smaller chunks.
- * Set to zero when starting a new calculation.
- *
- * \return Updated CRC value, which can be passed to this function
- * again to continue CRC calculation.
- */
-extern LZMA_API(uint32_t) lzma_crc32(
- const uint8_t *buf, size_t size, uint32_t crc)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Calculate CRC64
- *
- * Calculate CRC64 using the polynomial from the ECMA-182 standard.
- *
- * This function is used similarly to lzma_crc32(). See its documentation.
- */
-extern LZMA_API(uint64_t) lzma_crc64(
- const uint8_t *buf, size_t size, uint64_t crc)
- lzma_nothrow lzma_attr_pure;
-
-
-/*
- * SHA-256 functions are currently not exported to public API.
- * Contact Lasse Collin if you think it should be.
- */
-
-
-/**
- * \brief Get the type of the integrity check
- *
- * This function can be called only immediately after lzma_code() has
- * returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK.
- * Calling this function in any other situation has undefined behavior.
- */
-extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm)
- lzma_nothrow;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/container.h r-base-3.3.1/src/extra/xz/api/lzma/container.h
--- r-base-3.2.3/src/extra/xz/api/lzma/container.h 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/container.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,424 +0,0 @@
-/**
- * \file lzma/container.h
- * \brief File formats
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/************
- * Encoding *
- ************/
-
-/**
- * \brief Default compression preset
- *
- * It's not straightforward to recommend a default preset, because in some
- * cases keeping the resource usage relatively low is more important that
- * getting the maximum compression ratio.
- */
-#define LZMA_PRESET_DEFAULT UINT32_C(6)
-
-
-/**
- * \brief Mask for preset level
- *
- * This is useful only if you need to extract the level from the preset
- * variable. That should be rare.
- */
-#define LZMA_PRESET_LEVEL_MASK UINT32_C(0x1F)
-
-
-/*
- * Preset flags
- *
- * Currently only one flag is defined.
- */
-
-/**
- * \brief Extreme compression preset
- *
- * This flag modifies the preset to make the encoding significantly slower
- * while improving the compression ratio only marginally. This is useful
- * when you don't mind wasting time to get as small result as possible.
- *
- * This flag doesn't affect the memory usage requirements of the decoder (at
- * least not significantly). The memory usage of the encoder may be increased
- * a little but only at the lowest preset levels (0-3).
- */
-#define LZMA_PRESET_EXTREME (UINT32_C(1) << 31)
-
-
-/**
- * \brief Calculate approximate memory usage of easy encoder
- *
- * This function is a wrapper for lzma_raw_encoder_memusage().
- *
- * \param preset Compression preset (level and possible flags)
- *
- * \return Number of bytes of memory required for the given
- * preset when encoding. If an error occurs, for example
- * due to unsupported preset, UINT64_MAX is returned.
- */
-extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Calculate approximate decoder memory usage of a preset
- *
- * This function is a wrapper for lzma_raw_decoder_memusage().
- *
- * \param preset Compression preset (level and possible flags)
- *
- * \return Number of bytes of memory required to decompress a file
- * that was compressed using the given preset. If an error
- * occurs, for example due to unsupported preset, UINT64_MAX
- * is returned.
- */
-extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Initialize .xz Stream encoder using a preset number
- *
- * This function is intended for those who just want to use the basic features
- * if liblzma (that is, most developers out there).
- *
- * \param strm Pointer to lzma_stream that is at least initialized
- * with LZMA_STREAM_INIT.
- * \param preset Compression preset to use. A preset consist of level
- * number and zero or more flags. Usually flags aren't
- * used, so preset is simply a number [0, 9] which match
- * the options -0 ... -9 of the xz command line tool.
- * Additional flags can be be set using bitwise-or with
- * the preset level number, e.g. 6 | LZMA_PRESET_EXTREME.
- * \param check Integrity check type to use. See check.h for available
- * checks. The xz command line tool defaults to
- * LZMA_CHECK_CRC64, which is a good choice if you are
- * unsure. LZMA_CHECK_CRC32 is good too as long as the
- * uncompressed file is not many gigabytes.
- *
- * \return - LZMA_OK: Initialization succeeded. Use lzma_code() to
- * encode your data.
- * - LZMA_MEM_ERROR: Memory allocation failed.
- * - LZMA_OPTIONS_ERROR: The given compression preset is not
- * supported by this build of liblzma.
- * - LZMA_UNSUPPORTED_CHECK: The given check type is not
- * supported by this liblzma build.
- * - LZMA_PROG_ERROR: One or more of the parameters have values
- * that will never be valid. For example, strm == NULL.
- *
- * If initialization fails (return value is not LZMA_OK), all the memory
- * allocated for *strm by liblzma is always freed. Thus, there is no need
- * to call lzma_end() after failed initialization.
- *
- * If initialization succeeds, use lzma_code() to do the actual encoding.
- * Valid values for `action' (the second argument of lzma_code()) are
- * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future,
- * there may be compression levels or flags that don't support LZMA_SYNC_FLUSH.
- */
-extern LZMA_API(lzma_ret) lzma_easy_encoder(
- lzma_stream *strm, uint32_t preset, lzma_check check)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Single-call .xz Stream encoding using a preset number
- *
- * The maximum required output buffer size can be calculated with
- * lzma_stream_buffer_bound().
- *
- * \param preset Compression preset to use. See the description
- * in lzma_easy_encoder().
- * \param check Type of the integrity check to calculate from
- * uncompressed data.
- * \param allocator lzma_allocator for custom allocator functions.
- * Set to NULL to use malloc() and free().
- * \param in Beginning of the input buffer
- * \param in_size Size of the input buffer
- * \param out Beginning of the output buffer
- * \param out_pos The next byte will be written to out[*out_pos].
- * *out_pos is updated only if encoding succeeds.
- * \param out_size Size of the out buffer; the first byte into
- * which no data is written to is out[out_size].
- *
- * \return - LZMA_OK: Encoding was successful.
- * - LZMA_BUF_ERROR: Not enough output buffer space.
- * - LZMA_UNSUPPORTED_CHECK
- * - LZMA_OPTIONS_ERROR
- * - LZMA_MEM_ERROR
- * - LZMA_DATA_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_easy_buffer_encode(
- uint32_t preset, lzma_check check,
- lzma_allocator *allocator, const uint8_t *in, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
-
-
-/**
- * \brief Initialize .xz Stream encoder using a custom filter chain
- *
- * \param strm Pointer to properly prepared lzma_stream
- * \param filters Array of filters. This must be terminated with
- * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h for
- * more information.
- * \param check Type of the integrity check to calculate from
- * uncompressed data.
- *
- * \return - LZMA_OK: Initialization was successful.
- * - LZMA_MEM_ERROR
- * - LZMA_UNSUPPORTED_CHECK
- * - LZMA_OPTIONS_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm,
- const lzma_filter *filters, lzma_check check)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Initialize .lzma encoder (legacy file format)
- *
- * The .lzma format is sometimes called the LZMA_Alone format, which is the
- * reason for the name of this function. The .lzma format supports only the
- * LZMA1 filter. There is no support for integrity checks like CRC32.
- *
- * Use this function if and only if you need to create files readable by
- * legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format
- * is strongly recommended.
- *
- * The valid action values for lzma_code() are LZMA_RUN and LZMA_FINISH.
- * No kind of flushing is supported, because the file format doesn't make
- * it possible.
- *
- * \return - LZMA_OK
- * - LZMA_MEM_ERROR
- * - LZMA_OPTIONS_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_alone_encoder(
- lzma_stream *strm, const lzma_options_lzma *options)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Calculate output buffer size for single-call Stream encoder
- *
- * When trying to compress uncompressible data, the encoded size will be
- * slightly bigger than the input data. This function calculates how much
- * output buffer space is required to be sure that lzma_stream_buffer_encode()
- * doesn't return LZMA_BUF_ERROR.
- *
- * The calculated value is not exact, but it is guaranteed to be big enough.
- * The actual maximum output space required may be slightly smaller (up to
- * about 100 bytes). This should not be a problem in practice.
- *
- * If the calculated maximum size doesn't fit into size_t or would make the
- * Stream grow past LZMA_VLI_MAX (which should never happen in practice),
- * zero is returned to indicate the error.
- *
- * \note The limit calculated by this function applies only to
- * single-call encoding. Multi-call encoding may (and probably
- * will) have larger maximum expansion when encoding
- * uncompressible data. Currently there is no function to
- * calculate the maximum expansion of multi-call encoding.
- */
-extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size)
- lzma_nothrow;
-
-
-/**
- * \brief Single-call .xz Stream encoder
- *
- * \param filters Array of filters. This must be terminated with
- * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h
- * for more information.
- * \param check Type of the integrity check to calculate from
- * uncompressed data.
- * \param allocator lzma_allocator for custom allocator functions.
- * Set to NULL to use malloc() and free().
- * \param in Beginning of the input buffer
- * \param in_size Size of the input buffer
- * \param out Beginning of the output buffer
- * \param out_pos The next byte will be written to out[*out_pos].
- * *out_pos is updated only if encoding succeeds.
- * \param out_size Size of the out buffer; the first byte into
- * which no data is written to is out[out_size].
- *
- * \return - LZMA_OK: Encoding was successful.
- * - LZMA_BUF_ERROR: Not enough output buffer space.
- * - LZMA_UNSUPPORTED_CHECK
- * - LZMA_OPTIONS_ERROR
- * - LZMA_MEM_ERROR
- * - LZMA_DATA_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_stream_buffer_encode(
- lzma_filter *filters, lzma_check check,
- lzma_allocator *allocator, const uint8_t *in, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/************
- * Decoding *
- ************/
-
-/**
- * This flag makes lzma_code() return LZMA_NO_CHECK if the input stream
- * being decoded has no integrity check. Note that when used with
- * lzma_auto_decoder(), all .lzma files will trigger LZMA_NO_CHECK
- * if LZMA_TELL_NO_CHECK is used.
- */
-#define LZMA_TELL_NO_CHECK UINT32_C(0x01)
-
-
-/**
- * This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input
- * stream has an integrity check, but the type of the integrity check is not
- * supported by this liblzma version or build. Such files can still be
- * decoded, but the integrity check cannot be verified.
- */
-#define LZMA_TELL_UNSUPPORTED_CHECK UINT32_C(0x02)
-
-
-/**
- * This flag makes lzma_code() return LZMA_GET_CHECK as soon as the type
- * of the integrity check is known. The type can then be got with
- * lzma_get_check().
- */
-#define LZMA_TELL_ANY_CHECK UINT32_C(0x04)
-
-
-/**
- * This flag enables decoding of concatenated files with file formats that
- * allow concatenating compressed files as is. From the formats currently
- * supported by liblzma, only the .xz format allows concatenated files.
- * Concatenated files are not allowed with the legacy .lzma format.
- *
- * This flag also affects the usage of the `action' argument for lzma_code().
- * When LZMA_CONCATENATED is used, lzma_code() won't return LZMA_STREAM_END
- * unless LZMA_FINISH is used as `action'. Thus, the application has to set
- * LZMA_FINISH in the same way as it does when encoding.
- *
- * If LZMA_CONCATENATED is not used, the decoders still accept LZMA_FINISH
- * as `action' for lzma_code(), but the usage of LZMA_FINISH isn't required.
- */
-#define LZMA_CONCATENATED UINT32_C(0x08)
-
-
-/**
- * \brief Initialize .xz Stream decoder
- *
- * \param strm Pointer to properly prepared lzma_stream
- * \param memlimit Memory usage limit as bytes. Use UINT64_MAX
- * to effectively disable the limiter.
- * \param flags Bitwise-or of zero or more of the decoder flags:
- * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
- * LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED
- *
- * \return - LZMA_OK: Initialization was successful.
- * - LZMA_MEM_ERROR: Cannot allocate memory.
- * - LZMA_OPTIONS_ERROR: Unsupported flags
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_stream_decoder(
- lzma_stream *strm, uint64_t memlimit, uint32_t flags)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Decode .xz Streams and .lzma files with autodetection
- *
- * This decoder autodetects between the .xz and .lzma file formats, and
- * calls lzma_stream_decoder() or lzma_alone_decoder() once the type
- * of the input file has been detected.
- *
- * \param strm Pointer to properly prepared lzma_stream
- * \param memlimit Memory usage limit as bytes. Use UINT64_MAX
- * to effectively disable the limiter.
- * \param flags Bitwise-or of flags, or zero for no flags.
- *
- * \return - LZMA_OK: Initialization was successful.
- * - LZMA_MEM_ERROR: Cannot allocate memory.
- * - LZMA_OPTIONS_ERROR: Unsupported flags
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_auto_decoder(
- lzma_stream *strm, uint64_t memlimit, uint32_t flags)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Initialize .lzma decoder (legacy file format)
- *
- * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.
- * There is no need to use LZMA_FINISH, but allowing it may simplify
- * certain types of applications.
- *
- * \return - LZMA_OK
- * - LZMA_MEM_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_alone_decoder(
- lzma_stream *strm, uint64_t memlimit)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Single-call .xz Stream decoder
- *
- * \param memlimit Pointer to how much memory the decoder is allowed
- * to allocate. The value pointed by this pointer is
- * modified if and only if LZMA_MEMLIMIT_ERROR is
- * returned.
- * \param flags Bitwise-or of zero or more of the decoder flags:
- * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
- * LZMA_CONCATENATED. Note that LZMA_TELL_ANY_CHECK
- * is not allowed and will return LZMA_PROG_ERROR.
- * \param allocator lzma_allocator for custom allocator functions.
- * Set to NULL to use malloc() and free().
- * \param in Beginning of the input buffer
- * \param in_pos The next byte will be read from in[*in_pos].
- * *in_pos is updated only if decoding succeeds.
- * \param in_size Size of the input buffer; the first byte that
- * won't be read is in[in_size].
- * \param out Beginning of the output buffer
- * \param out_pos The next byte will be written to out[*out_pos].
- * *out_pos is updated only if decoding succeeds.
- * \param out_size Size of the out buffer; the first byte into
- * which no data is written to is out[out_size].
- *
- * \return - LZMA_OK: Decoding was successful.
- * - LZMA_FORMAT_ERROR
- * - LZMA_OPTIONS_ERROR
- * - LZMA_DATA_ERROR
- * - LZMA_NO_CHECK: This can be returned only if using
- * the LZMA_TELL_NO_CHECK flag.
- * - LZMA_UNSUPPORTED_CHECK: This can be returned only if using
- * the LZMA_TELL_UNSUPPORTED_CHECK flag.
- * - LZMA_MEM_ERROR
- * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.
- * The minimum required memlimit value was stored to *memlimit.
- * - LZMA_BUF_ERROR: Output buffer was too small.
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_stream_buffer_decode(
- uint64_t *memlimit, uint32_t flags, lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
- lzma_nothrow lzma_attr_warn_unused_result;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/delta.h r-base-3.3.1/src/extra/xz/api/lzma/delta.h
--- r-base-3.2.3/src/extra/xz/api/lzma/delta.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/delta.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,77 +0,0 @@
-/**
- * \file lzma/delta.h
- * \brief Delta filter
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/**
- * \brief Filter ID
- *
- * Filter ID of the Delta filter. This is used as lzma_filter.id.
- */
-#define LZMA_FILTER_DELTA LZMA_VLI_C(0x03)
-
-
-/**
- * \brief Type of the delta calculation
- *
- * Currently only byte-wise delta is supported. Other possible types could
- * be, for example, delta of 16/32/64-bit little/big endian integers, but
- * these are not currently planned since byte-wise delta is almost as good.
- */
-typedef enum {
- LZMA_DELTA_TYPE_BYTE
-} lzma_delta_type;
-
-
-/**
- * \brief Options for the Delta filter
- *
- * These options are needed by both encoder and decoder.
- */
-typedef struct {
- /** For now, this must always be LZMA_DELTA_TYPE_BYTE. */
- lzma_delta_type type;
-
- /**
- * \brief Delta distance
- *
- * With the only currently supported type, LZMA_DELTA_TYPE_BYTE,
- * the distance is as bytes.
- *
- * Examples:
- * - 16-bit stereo audio: distance = 4 bytes
- * - 24-bit RGB image data: distance = 3 bytes
- */
- uint32_t dist;
-# define LZMA_DELTA_DIST_MIN 1
-# define LZMA_DELTA_DIST_MAX 256
-
- /*
- * Reserved space to allow possible future extensions without
- * breaking the ABI. You should not touch these, because the names
- * of these variables may change. These are and will never be used
- * when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these
- * uninitialized.
- */
- uint32_t reserved_int1;
- uint32_t reserved_int2;
- uint32_t reserved_int3;
- uint32_t reserved_int4;
- void *reserved_ptr1;
- void *reserved_ptr2;
-
-} lzma_options_delta;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/filter.h r-base-3.3.1/src/extra/xz/api/lzma/filter.h
--- r-base-3.2.3/src/extra/xz/api/lzma/filter.h 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/filter.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,424 +0,0 @@
-/**
- * \file lzma/filter.h
- * \brief Common filter related types and functions
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/**
- * \brief Maximum number of filters in a chain
- *
- * A filter chain can have 1-4 filters, of which three are allowed to change
- * the size of the data. Usually only one or two filters are needed.
- */
-#define LZMA_FILTERS_MAX 4
-
-
-/**
- * \brief Filter options
- *
- * This structure is used to pass Filter ID and a pointer filter's
- * options to liblzma. A few functions work with a single lzma_filter
- * structure, while most functions expect a filter chain.
- *
- * A filter chain is indicated with an array of lzma_filter structures.
- * The array is terminated with .id = LZMA_VLI_UNKNOWN. Thus, the filter
- * array must have LZMA_FILTERS_MAX + 1 elements (that is, five) to
- * be able to hold any arbitrary filter chain. This is important when
- * using lzma_block_header_decode() from block.h, because too small
- * array would make liblzma write past the end of the filters array.
- */
-typedef struct {
- /**
- * \brief Filter ID
- *
- * Use constants whose name begin with `LZMA_FILTER_' to specify
- * different filters. In an array of lzma_filter structures, use
- * LZMA_VLI_UNKNOWN to indicate end of filters.
- *
- * \note This is not an enum, because on some systems enums
- * cannot be 64-bit.
- */
- lzma_vli id;
-
- /**
- * \brief Pointer to filter-specific options structure
- *
- * If the filter doesn't need options, set this to NULL. If id is
- * set to LZMA_VLI_UNKNOWN, options is ignored, and thus
- * doesn't need be initialized.
- */
- void *options;
-
-} lzma_filter;
-
-
-/**
- * \brief Test if the given Filter ID is supported for encoding
- *
- * Return true if the give Filter ID is supported for encoding by this
- * liblzma build. Otherwise false is returned.
- *
- * There is no way to list which filters are available in this particular
- * liblzma version and build. It would be useless, because the application
- * couldn't know what kind of options the filter would need.
- */
-extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id)
- lzma_nothrow lzma_attr_const;
-
-
-/**
- * \brief Test if the given Filter ID is supported for decoding
- *
- * Return true if the give Filter ID is supported for decoding by this
- * liblzma build. Otherwise false is returned.
- */
-extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id)
- lzma_nothrow lzma_attr_const;
-
-
-/**
- * \brief Copy the filters array
- *
- * Copy the Filter IDs and filter-specific options from src to dest.
- * Up to LZMA_FILTERS_MAX filters are copied, plus the terminating
- * .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least
- * LZMA_FILTERS_MAX + 1 elements space unless the caller knows that
- * src is smaller than that.
- *
- * Unless the filter-specific options is NULL, the Filter ID has to be
- * supported by liblzma, because liblzma needs to know the size of every
- * filter-specific options structure. The filter-specific options are not
- * validated. If options is NULL, any unsupported Filter IDs are copied
- * without returning an error.
- *
- * Old filter-specific options in dest are not freed, so dest doesn't
- * need to be initialized by the caller in any way.
- *
- * If an error occurs, memory possibly already allocated by this function
- * is always freed.
- *
- * \return - LZMA_OK
- * - LZMA_MEM_ERROR
- * - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options
- * is not NULL.
- * - LZMA_PROG_ERROR: src or dest is NULL.
- */
-extern LZMA_API(lzma_ret) lzma_filters_copy(const lzma_filter *src,
- lzma_filter *dest, lzma_allocator *allocator) lzma_nothrow;
-
-
-/**
- * \brief Calculate approximate memory requirements for raw encoder
- *
- * This function can be used to calculate the memory requirements for
- * Block and Stream encoders too because Block and Stream encoders don't
- * need significantly more memory than raw encoder.
- *
- * \param filters Array of filters terminated with
- * .id == LZMA_VLI_UNKNOWN.
- *
- * \return Number of bytes of memory required for the given
- * filter chain when encoding. If an error occurs,
- * for example due to unsupported filter chain,
- * UINT64_MAX is returned.
- */
-extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Calculate approximate memory requirements for raw decoder
- *
- * This function can be used to calculate the memory requirements for
- * Block and Stream decoders too because Block and Stream decoders don't
- * need significantly more memory than raw decoder.
- *
- * \param filters Array of filters terminated with
- * .id == LZMA_VLI_UNKNOWN.
- *
- * \return Number of bytes of memory required for the given
- * filter chain when decoding. If an error occurs,
- * for example due to unsupported filter chain,
- * UINT64_MAX is returned.
- */
-extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Initialize raw encoder
- *
- * This function may be useful when implementing custom file formats.
- *
- * \param strm Pointer to properly prepared lzma_stream
- * \param filters Array of lzma_filter structures. The end of the
- * array must be marked with .id = LZMA_VLI_UNKNOWN.
- *
- * The `action' with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the
- * filter chain supports it), or LZMA_FINISH.
- *
- * \return - LZMA_OK
- * - LZMA_MEM_ERROR
- * - LZMA_OPTIONS_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_raw_encoder(
- lzma_stream *strm, const lzma_filter *filters)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Initialize raw decoder
- *
- * The initialization of raw decoder goes similarly to raw encoder.
- *
- * The `action' with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using
- * LZMA_FINISH is not required, it is supported just for convenience.
- *
- * \return - LZMA_OK
- * - LZMA_MEM_ERROR
- * - LZMA_OPTIONS_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_raw_decoder(
- lzma_stream *strm, const lzma_filter *filters)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Update the filter chain in the encoder
- *
- * This function is for advanced users only. This function has two slightly
- * different purposes:
- *
- * - After LZMA_FULL_FLUSH when using Stream encoder: Set a new filter
- * chain, which will be used starting from the next Block.
- *
- * - After LZMA_SYNC_FLUSH using Raw, Block, or Stream encoder: Change
- * the filter-specific options in the middle of encoding. The actual
- * filters in the chain (Filter IDs) cannot be changed. In the future,
- * it might become possible to change the filter options without
- * using LZMA_SYNC_FLUSH.
- *
- * While rarely useful, this function may be called also when no data has
- * been compressed yet. In that case, this function will behave as if
- * LZMA_FULL_FLUSH (Stream encoder) or LZMA_SYNC_FLUSH (Raw or Block
- * encoder) had been used right before calling this function.
- *
- * \return - LZMA_OK
- * - LZMA_MEM_ERROR
- * - LZMA_MEMLIMIT_ERROR
- * - LZMA_OPTIONS_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_filters_update(
- lzma_stream *strm, const lzma_filter *filters) lzma_nothrow;
-
-
-/**
- * \brief Single-call raw encoder
- *
- * \param filters Array of lzma_filter structures. The end of the
- * array must be marked with .id = LZMA_VLI_UNKNOWN.
- * \param allocator lzma_allocator for custom allocator functions.
- * Set to NULL to use malloc() and free().
- * \param in Beginning of the input buffer
- * \param in_size Size of the input buffer
- * \param out Beginning of the output buffer
- * \param out_pos The next byte will be written to out[*out_pos].
- * *out_pos is updated only if encoding succeeds.
- * \param out_size Size of the out buffer; the first byte into
- * which no data is written to is out[out_size].
- *
- * \return - LZMA_OK: Encoding was successful.
- * - LZMA_BUF_ERROR: Not enough output buffer space.
- * - LZMA_OPTIONS_ERROR
- * - LZMA_MEM_ERROR
- * - LZMA_DATA_ERROR
- * - LZMA_PROG_ERROR
- *
- * \note There is no function to calculate how big output buffer
- * would surely be big enough. (lzma_stream_buffer_bound()
- * works only for lzma_stream_buffer_encode(); raw encoder
- * won't necessarily meet that bound.)
- */
-extern LZMA_API(lzma_ret) lzma_raw_buffer_encode(
- const lzma_filter *filters, lzma_allocator *allocator,
- const uint8_t *in, size_t in_size, uint8_t *out,
- size_t *out_pos, size_t out_size) lzma_nothrow;
-
-
-/**
- * \brief Single-call raw decoder
- *
- * \param filters Array of lzma_filter structures. The end of the
- * array must be marked with .id = LZMA_VLI_UNKNOWN.
- * \param allocator lzma_allocator for custom allocator functions.
- * Set to NULL to use malloc() and free().
- * \param in Beginning of the input buffer
- * \param in_pos The next byte will be read from in[*in_pos].
- * *in_pos is updated only if decoding succeeds.
- * \param in_size Size of the input buffer; the first byte that
- * won't be read is in[in_size].
- * \param out Beginning of the output buffer
- * \param out_pos The next byte will be written to out[*out_pos].
- * *out_pos is updated only if encoding succeeds.
- * \param out_size Size of the out buffer; the first byte into
- * which no data is written to is out[out_size].
- */
-extern LZMA_API(lzma_ret) lzma_raw_buffer_decode(
- const lzma_filter *filters, lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
-
-
-/**
- * \brief Get the size of the Filter Properties field
- *
- * This function may be useful when implementing custom file formats
- * using the raw encoder and decoder.
- *
- * \param size Pointer to uint32_t to hold the size of the properties
- * \param filter Filter ID and options (the size of the properties may
- * vary depending on the options)
- *
- * \return - LZMA_OK
- * - LZMA_OPTIONS_ERROR
- * - LZMA_PROG_ERROR
- *
- * \note This function validates the Filter ID, but does not
- * necessarily validate the options. Thus, it is possible
- * that this returns LZMA_OK while the following call to
- * lzma_properties_encode() returns LZMA_OPTIONS_ERROR.
- */
-extern LZMA_API(lzma_ret) lzma_properties_size(
- uint32_t *size, const lzma_filter *filter) lzma_nothrow;
-
-
-/**
- * \brief Encode the Filter Properties field
- *
- * \param filter Filter ID and options
- * \param props Buffer to hold the encoded options. The size of
- * buffer must have been already determined with
- * lzma_properties_size().
- *
- * \return - LZMA_OK
- * - LZMA_OPTIONS_ERROR
- * - LZMA_PROG_ERROR
- *
- * \note Even this function won't validate more options than actually
- * necessary. Thus, it is possible that encoding the properties
- * succeeds but using the same options to initialize the encoder
- * will fail.
- *
- * \note If lzma_properties_size() indicated that the size
- * of the Filter Properties field is zero, calling
- * lzma_properties_encode() is not required, but it
- * won't do any harm either.
- */
-extern LZMA_API(lzma_ret) lzma_properties_encode(
- const lzma_filter *filter, uint8_t *props) lzma_nothrow;
-
-
-/**
- * \brief Decode the Filter Properties field
- *
- * \param filter filter->id must have been set to the correct
- * Filter ID. filter->options doesn't need to be
- * initialized (it's not freed by this function). The
- * decoded options will be stored to filter->options.
- * filter->options is set to NULL if there are no
- * properties or if an error occurs.
- * \param allocator Custom memory allocator used to allocate the
- * options. Set to NULL to use the default malloc(),
- * and in case of an error, also free().
- * \param props Input buffer containing the properties.
- * \param props_size Size of the properties. This must be the exact
- * size; giving too much or too little input will
- * return LZMA_OPTIONS_ERROR.
- *
- * \return - LZMA_OK
- * - LZMA_OPTIONS_ERROR
- * - LZMA_MEM_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_properties_decode(
- lzma_filter *filter, lzma_allocator *allocator,
- const uint8_t *props, size_t props_size) lzma_nothrow;
-
-
-/**
- * \brief Calculate encoded size of a Filter Flags field
- *
- * Knowing the size of Filter Flags is useful to know when allocating
- * memory to hold the encoded Filter Flags.
- *
- * \param size Pointer to integer to hold the calculated size
- * \param filter Filter ID and associated options whose encoded
- * size is to be calculated
- *
- * \return - LZMA_OK: *size set successfully. Note that this doesn't
- * guarantee that filter->options is valid, thus
- * lzma_filter_flags_encode() may still fail.
- * - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options.
- * - LZMA_PROG_ERROR: Invalid options
- *
- * \note If you need to calculate size of List of Filter Flags,
- * you need to loop over every lzma_filter entry.
- */
-extern LZMA_API(lzma_ret) lzma_filter_flags_size(
- uint32_t *size, const lzma_filter *filter)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Encode Filter Flags into given buffer
- *
- * In contrast to some functions, this doesn't allocate the needed buffer.
- * This is due to how this function is used internally by liblzma.
- *
- * \param filter Filter ID and options to be encoded
- * \param out Beginning of the output buffer
- * \param out_pos out[*out_pos] is the next write position. This
- * is updated by the encoder.
- * \param out_size out[out_size] is the first byte to not write.
- *
- * \return - LZMA_OK: Encoding was successful.
- * - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
- * - LZMA_PROG_ERROR: Invalid options or not enough output
- * buffer space (you should have checked it with
- * lzma_filter_flags_size()).
- */
-extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter,
- uint8_t *out, size_t *out_pos, size_t out_size)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Decode Filter Flags from given buffer
- *
- * The decoded result is stored into *filter. The old value of
- * filter->options is not free()d.
- *
- * \return - LZMA_OK
- * - LZMA_OPTIONS_ERROR
- * - LZMA_MEM_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_filter_flags_decode(
- lzma_filter *filter, lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos, size_t in_size)
- lzma_nothrow lzma_attr_warn_unused_result;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/hardware.h r-base-3.3.1/src/extra/xz/api/lzma/hardware.h
--- r-base-3.2.3/src/extra/xz/api/lzma/hardware.h 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/hardware.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,50 +0,0 @@
-/**
- * \file lzma/hardware.h
- * \brief Hardware information
- *
- * Since liblzma can consume a lot of system resources, it also provides
- * ways to limit the resource usage. Applications linking against liblzma
- * need to do the actual decisions how much resources to let liblzma to use.
- * To ease making these decisions, liblzma provides functions to find out
- * the relevant capabilities of the underlaying hardware. Currently there
- * is only a function to find out the amount of RAM, but in the future there
- * will be also a function to detect how many concurrent threads the system
- * can run.
- *
- * \note On some operating systems, these function may temporarily
- * load a shared library or open file descriptor(s) to find out
- * the requested hardware information. Unless the application
- * assumes that specific file descriptors are not touched by
- * other threads, this should have no effect on thread safety.
- * Possible operations involving file descriptors will restart
- * the syscalls if they return EINTR.
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/**
- * \brief Get the total amount of physical memory (RAM) in bytes
- *
- * This function may be useful when determining a reasonable memory
- * usage limit for decompressing or how much memory it is OK to use
- * for compressing.
- *
- * \return On success, the total amount of physical memory in bytes
- * is returned. If the amount of RAM cannot be determined,
- * zero is returned. This can happen if an error occurs
- * or if there is no code in liblzma to detect the amount
- * of RAM on the specific operating system.
- */
-extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/index.h r-base-3.3.1/src/extra/xz/api/lzma/index.h
--- r-base-3.2.3/src/extra/xz/api/lzma/index.h 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/index.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,682 +0,0 @@
-/**
- * \file lzma/index.h
- * \brief Handling of .xz Index and related information
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/**
- * \brief Opaque data type to hold the Index(es) and other information
- *
- * lzma_index often holds just one .xz Index and possibly the Stream Flags
- * of the same Stream and size of the Stream Padding field. However,
- * multiple lzma_indexes can be concatenated with lzma_index_cat() and then
- * there may be information about multiple Streams in the same lzma_index.
- *
- * Notes about thread safety: Only one thread may modify lzma_index at
- * a time. All functions that take non-const pointer to lzma_index
- * modify it. As long as no thread is modifying the lzma_index, getting
- * information from the same lzma_index can be done from multiple threads
- * at the same time with functions that take a const pointer to
- * lzma_index or use lzma_index_iter. The same iterator must be used
- * only by one thread at a time, of course, but there can be as many
- * iterators for the same lzma_index as needed.
- */
-typedef struct lzma_index_s lzma_index;
-
-
-/**
- * \brief Iterator to get information about Blocks and Streams
- */
-typedef struct {
- struct {
- /**
- * \brief Pointer to Stream Flags
- *
- * This is NULL if Stream Flags have not been set for
- * this Stream with lzma_index_stream_flags().
- */
- const lzma_stream_flags *flags;
-
- const void *reserved_ptr1;
- const void *reserved_ptr2;
- const void *reserved_ptr3;
-
- /**
- * \brief Stream number in the lzma_index
- *
- * The first Stream is 1.
- */
- lzma_vli number;
-
- /**
- * \brief Number of Blocks in the Stream
- *
- * If this is zero, the block structure below has
- * undefined values.
- */
- lzma_vli block_count;
-
- /**
- * \brief Compressed start offset of this Stream
- *
- * The offset is relative to the beginning of the lzma_index
- * (i.e. usually the beginning of the .xz file).
- */
- lzma_vli compressed_offset;
-
- /**
- * \brief Uncompressed start offset of this Stream
- *
- * The offset is relative to the beginning of the lzma_index
- * (i.e. usually the beginning of the .xz file).
- */
- lzma_vli uncompressed_offset;
-
- /**
- * \brief Compressed size of this Stream
- *
- * This includes all headers except the possible
- * Stream Padding after this Stream.
- */
- lzma_vli compressed_size;
-
- /**
- * \brief Uncompressed size of this Stream
- */
- lzma_vli uncompressed_size;
-
- /**
- * \brief Size of Stream Padding after this Stream
- *
- * If it hasn't been set with lzma_index_stream_padding(),
- * this defaults to zero. Stream Padding is always
- * a multiple of four bytes.
- */
- lzma_vli padding;
-
- lzma_vli reserved_vli1;
- lzma_vli reserved_vli2;
- lzma_vli reserved_vli3;
- lzma_vli reserved_vli4;
- } stream;
-
- struct {
- /**
- * \brief Block number in the file
- *
- * The first Block is 1.
- */
- lzma_vli number_in_file;
-
- /**
- * \brief Compressed start offset of this Block
- *
- * This offset is relative to the beginning of the
- * lzma_index (i.e. usually the beginning of the .xz file).
- * Normally this is where you should seek in the .xz file
- * to start decompressing this Block.
- */
- lzma_vli compressed_file_offset;
-
- /**
- * \brief Uncompressed start offset of this Block
- *
- * This offset is relative to the beginning of the lzma_index
- * (i.e. usually the beginning of the .xz file).
- *
- * When doing random-access reading, it is possible that
- * the target offset is not exactly at Block boundary. One
- * will need to compare the target offset against
- * uncompressed_file_offset or uncompressed_stream_offset,
- * and possibly decode and throw away some amount of data
- * before reaching the target offset.
- */
- lzma_vli uncompressed_file_offset;
-
- /**
- * \brief Block number in this Stream
- *
- * The first Block is 1.
- */
- lzma_vli number_in_stream;
-
- /**
- * \brief Compressed start offset of this Block
- *
- * This offset is relative to the beginning of the Stream
- * containing this Block.
- */
- lzma_vli compressed_stream_offset;
-
- /**
- * \brief Uncompressed start offset of this Block
- *
- * This offset is relative to the beginning of the Stream
- * containing this Block.
- */
- lzma_vli uncompressed_stream_offset;
-
- /**
- * \brief Uncompressed size of this Block
- *
- * You should pass this to the Block decoder if you will
- * decode this Block. It will allow the Block decoder to
- * validate the uncompressed size.
- */
- lzma_vli uncompressed_size;
-
- /**
- * \brief Unpadded size of this Block
- *
- * You should pass this to the Block decoder if you will
- * decode this Block. It will allow the Block decoder to
- * validate the unpadded size.
- */
- lzma_vli unpadded_size;
-
- /**
- * \brief Total compressed size
- *
- * This includes all headers and padding in this Block.
- * This is useful if you need to know how many bytes
- * the Block decoder will actually read.
- */
- lzma_vli total_size;
-
- lzma_vli reserved_vli1;
- lzma_vli reserved_vli2;
- lzma_vli reserved_vli3;
- lzma_vli reserved_vli4;
-
- const void *reserved_ptr1;
- const void *reserved_ptr2;
- const void *reserved_ptr3;
- const void *reserved_ptr4;
- } block;
-
- /*
- * Internal data which is used to store the state of the iterator.
- * The exact format may vary between liblzma versions, so don't
- * touch these in any way.
- */
- union {
- const void *p;
- size_t s;
- lzma_vli v;
- } internal[6];
-} lzma_index_iter;
-
-
-/**
- * \brief Operation mode for lzma_index_iter_next()
- */
-typedef enum {
- LZMA_INDEX_ITER_ANY = 0,
- /**<
- * \brief Get the next Block or Stream
- *
- * Go to the next Block if the current Stream has at least
- * one Block left. Otherwise go to the next Stream even if
- * it has no Blocks. If the Stream has no Blocks
- * (lzma_index_iter.stream.block_count == 0),
- * lzma_index_iter.block will have undefined values.
- */
-
- LZMA_INDEX_ITER_STREAM = 1,
- /**<
- * \brief Get the next Stream
- *
- * Go to the next Stream even if the current Stream has
- * unread Blocks left. If the next Stream has at least one
- * Block, the iterator will point to the first Block.
- * If there are no Blocks, lzma_index_iter.block will have
- * undefined values.
- */
-
- LZMA_INDEX_ITER_BLOCK = 2,
- /**<
- * \brief Get the next Block
- *
- * Go to the next Block if the current Stream has at least
- * one Block left. If the current Stream has no Blocks left,
- * the next Stream with at least one Block is located and
- * the iterator will be made to point to the first Block of
- * that Stream.
- */
-
- LZMA_INDEX_ITER_NONEMPTY_BLOCK = 3
- /**<
- * \brief Get the next non-empty Block
- *
- * This is like LZMA_INDEX_ITER_BLOCK except that it will
- * skip Blocks whose Uncompressed Size is zero.
- */
-
-} lzma_index_iter_mode;
-
-
-/**
- * \brief Calculate memory usage of lzma_index
- *
- * On disk, the size of the Index field depends on both the number of Records
- * stored and how big values the Records store (due to variable-length integer
- * encoding). When the Index is kept in lzma_index structure, the memory usage
- * depends only on the number of Records/Blocks stored in the Index(es), and
- * in case of concatenated lzma_indexes, the number of Streams. The size in
- * RAM is almost always significantly bigger than in the encoded form on disk.
- *
- * This function calculates an approximate amount of memory needed hold
- * the given number of Streams and Blocks in lzma_index structure. This
- * value may vary between CPU architectures and also between liblzma versions
- * if the internal implementation is modified.
- */
-extern LZMA_API(uint64_t) lzma_index_memusage(
- lzma_vli streams, lzma_vli blocks) lzma_nothrow;
-
-
-/**
- * \brief Calculate the memory usage of an existing lzma_index
- *
- * This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i),
- * lzma_index_block_count(i)).
- */
-extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i)
- lzma_nothrow;
-
-
-/**
- * \brief Allocate and initialize a new lzma_index structure
- *
- * \return On success, a pointer to an empty initialized lzma_index is
- * returned. If allocation fails, NULL is returned.
- */
-extern LZMA_API(lzma_index *) lzma_index_init(lzma_allocator *allocator)
- lzma_nothrow;
-
-
-/**
- * \brief Deallocate lzma_index
- *
- * If i is NULL, this does nothing.
- */
-extern LZMA_API(void) lzma_index_end(lzma_index *i, lzma_allocator *allocator)
- lzma_nothrow;
-
-
-/**
- * \brief Add a new Block to lzma_index
- *
- * \param i Pointer to a lzma_index structure
- * \param allocator Pointer to lzma_allocator, or NULL to
- * use malloc()
- * \param unpadded_size Unpadded Size of a Block. This can be
- * calculated with lzma_block_unpadded_size()
- * after encoding or decoding the Block.
- * \param uncompressed_size Uncompressed Size of a Block. This can be
- * taken directly from lzma_block structure
- * after encoding or decoding the Block.
- *
- * Appending a new Block does not invalidate iterators. For example,
- * if an iterator was pointing to the end of the lzma_index, after
- * lzma_index_append() it is possible to read the next Block with
- * an existing iterator.
- *
- * \return - LZMA_OK
- * - LZMA_MEM_ERROR
- * - LZMA_DATA_ERROR: Compressed or uncompressed size of the
- * Stream or size of the Index field would grow too big.
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_index_append(
- lzma_index *i, lzma_allocator *allocator,
- lzma_vli unpadded_size, lzma_vli uncompressed_size)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Set the Stream Flags
- *
- * Set the Stream Flags of the last (and typically the only) Stream
- * in lzma_index. This can be useful when reading information from the
- * lzma_index, because to decode Blocks, knowing the integrity check type
- * is needed.
- *
- * The given Stream Flags are copied into internal preallocated structure
- * in the lzma_index, thus the caller doesn't need to keep the *stream_flags
- * available after calling this function.
- *
- * \return - LZMA_OK
- * - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version.
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_index_stream_flags(
- lzma_index *i, const lzma_stream_flags *stream_flags)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Get the types of integrity Checks
- *
- * If lzma_index_stream_flags() is used to set the Stream Flags for
- * every Stream, lzma_index_checks() can be used to get a bitmask to
- * indicate which Check types have been used. It can be useful e.g. if
- * showing the Check types to the user.
- *
- * The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10.
- */
-extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Set the amount of Stream Padding
- *
- * Set the amount of Stream Padding of the last (and typically the only)
- * Stream in the lzma_index. This is needed when planning to do random-access
- * reading within multiple concatenated Streams.
- *
- * By default, the amount of Stream Padding is assumed to be zero bytes.
- *
- * \return - LZMA_OK
- * - LZMA_DATA_ERROR: The file size would grow too big.
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_index_stream_padding(
- lzma_index *i, lzma_vli stream_padding)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Get the number of Streams
- */
-extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Get the number of Blocks
- *
- * This returns the total number of Blocks in lzma_index. To get number
- * of Blocks in individual Streams, use lzma_index_iter.
- */
-extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Get the size of the Index field as bytes
- *
- * This is needed to verify the Backward Size field in the Stream Footer.
- */
-extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Get the total size of the Stream
- *
- * If multiple lzma_indexes have been combined, this works as if the Blocks
- * were in a single Stream. This is useful if you are going to combine
- * Blocks from multiple Streams into a single new Stream.
- */
-extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Get the total size of the Blocks
- *
- * This doesn't include the Stream Header, Stream Footer, Stream Padding,
- * or Index fields.
- */
-extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Get the total size of the file
- *
- * When no lzma_indexes have been combined with lzma_index_cat() and there is
- * no Stream Padding, this function is identical to lzma_index_stream_size().
- * If multiple lzma_indexes have been combined, this includes also the headers
- * of each separate Stream and the possible Stream Padding fields.
- */
-extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Get the uncompressed size of the file
- */
-extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i)
- lzma_nothrow lzma_attr_pure;
-
-
-/**
- * \brief Initialize an iterator
- *
- * \param iter Pointer to a lzma_index_iter structure
- * \param i lzma_index to which the iterator will be associated
- *
- * This function associates the iterator with the given lzma_index, and calls
- * lzma_index_iter_rewind() on the iterator.
- *
- * This function doesn't allocate any memory, thus there is no
- * lzma_index_iter_end(). The iterator is valid as long as the
- * associated lzma_index is valid, that is, until lzma_index_end() or
- * using it as source in lzma_index_cat(). Specifically, lzma_index doesn't
- * become invalid if new Blocks are added to it with lzma_index_append() or
- * if it is used as the destination in lzma_index_cat().
- *
- * It is safe to make copies of an initialized lzma_index_iter, for example,
- * to easily restart reading at some particular position.
- */
-extern LZMA_API(void) lzma_index_iter_init(
- lzma_index_iter *iter, const lzma_index *i) lzma_nothrow;
-
-
-/**
- * \brief Rewind the iterator
- *
- * Rewind the iterator so that next call to lzma_index_iter_next() will
- * return the first Block or Stream.
- */
-extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter)
- lzma_nothrow;
-
-
-/**
- * \brief Get the next Block or Stream
- *
- * \param iter Iterator initialized with lzma_index_iter_init()
- * \param mode Specify what kind of information the caller wants
- * to get. See lzma_index_iter_mode for details.
- *
- * \return If next Block or Stream matching the mode was found, *iter
- * is updated and this function returns false. If no Block or
- * Stream matching the mode is found, *iter is not modified
- * and this function returns true. If mode is set to an unknown
- * value, *iter is not modified and this function returns true.
- */
-extern LZMA_API(lzma_bool) lzma_index_iter_next(
- lzma_index_iter *iter, lzma_index_iter_mode mode)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Locate a Block
- *
- * If it is possible to seek in the .xz file, it is possible to parse
- * the Index field(s) and use lzma_index_iter_locate() to do random-access
- * reading with granularity of Block size.
- *
- * \param iter Iterator that was earlier initialized with
- * lzma_index_iter_init().
- * \param target Uncompressed target offset which the caller would
- * like to locate from the Stream
- *
- * If the target is smaller than the uncompressed size of the Stream (can be
- * checked with lzma_index_uncompressed_size()):
- * - Information about the Stream and Block containing the requested
- * uncompressed offset is stored into *iter.
- * - Internal state of the iterator is adjusted so that
- * lzma_index_iter_next() can be used to read subsequent Blocks or Streams.
- * - This function returns false.
- *
- * If target is greater than the uncompressed size of the Stream, *iter
- * is not modified, and this function returns true.
- */
-extern LZMA_API(lzma_bool) lzma_index_iter_locate(
- lzma_index_iter *iter, lzma_vli target) lzma_nothrow;
-
-
-/**
- * \brief Concatenate lzma_indexes
- *
- * Concatenating lzma_indexes is useful when doing random-access reading in
- * multi-Stream .xz file, or when combining multiple Streams into single
- * Stream.
- *
- * \param dest lzma_index after which src is appended
- * \param src lzma_index to be appended after dest. If this
- * function succeeds, the memory allocated for src
- * is freed or moved to be part of dest, and all
- * iterators pointing to src will become invalid.
- * \param allocator Custom memory allocator; can be NULL to use
- * malloc() and free().
- *
- * \return - LZMA_OK: lzma_indexes were concatenated successfully.
- * src is now a dangling pointer.
- * - LZMA_DATA_ERROR: *dest would grow too big.
- * - LZMA_MEM_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_index_cat(
- lzma_index *dest, lzma_index *src, lzma_allocator *allocator)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Duplicate lzma_index
- *
- * \return A copy of the lzma_index, or NULL if memory allocation failed.
- */
-extern LZMA_API(lzma_index *) lzma_index_dup(
- const lzma_index *i, lzma_allocator *allocator)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Initialize .xz Index encoder
- *
- * \param strm Pointer to properly prepared lzma_stream
- * \param i Pointer to lzma_index which should be encoded.
- *
- * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
- * It is enough to use only one of them (you can choose freely; use LZMA_RUN
- * to support liblzma versions older than 5.0.0).
- *
- * \return - LZMA_OK: Initialization succeeded, continue with lzma_code().
- * - LZMA_MEM_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_index_encoder(
- lzma_stream *strm, const lzma_index *i)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Initialize .xz Index decoder
- *
- * \param strm Pointer to properly prepared lzma_stream
- * \param i The decoded Index will be made available via
- * this pointer. Initially this function will
- * set *i to NULL (the old value is ignored). If
- * decoding succeeds (lzma_code() returns
- * LZMA_STREAM_END), *i will be set to point
- * to a new lzma_index, which the application
- * has to later free with lzma_index_end().
- * \param memlimit How much memory the resulting lzma_index is
- * allowed to require.
- *
- * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
- * It is enough to use only one of them (you can choose freely; use LZMA_RUN
- * to support liblzma versions older than 5.0.0).
- *
- * \return - LZMA_OK: Initialization succeeded, continue with lzma_code().
- * - LZMA_MEM_ERROR
- * - LZMA_MEMLIMIT_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_index_decoder(
- lzma_stream *strm, lzma_index **i, uint64_t memlimit)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Single-call .xz Index encoder
- *
- * \param i lzma_index to be encoded
- * \param out Beginning of the output buffer
- * \param out_pos The next byte will be written to out[*out_pos].
- * *out_pos is updated only if encoding succeeds.
- * \param out_size Size of the out buffer; the first byte into
- * which no data is written to is out[out_size].
- *
- * \return - LZMA_OK: Encoding was successful.
- * - LZMA_BUF_ERROR: Output buffer is too small. Use
- * lzma_index_size() to find out how much output
- * space is needed.
- * - LZMA_PROG_ERROR
- *
- * \note This function doesn't take allocator argument since all
- * the internal data is allocated on stack.
- */
-extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i,
- uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
-
-
-/**
- * \brief Single-call .xz Index decoder
- *
- * \param i If decoding succeeds, *i will point to a new
- * lzma_index, which the application has to
- * later free with lzma_index_end(). If an error
- * occurs, *i will be NULL. The old value of *i
- * is always ignored and thus doesn't need to be
- * initialized by the caller.
- * \param memlimit Pointer to how much memory the resulting
- * lzma_index is allowed to require. The value
- * pointed by this pointer is modified if and only
- * if LZMA_MEMLIMIT_ERROR is returned.
- * \param allocator Pointer to lzma_allocator, or NULL to use malloc()
- * \param in Beginning of the input buffer
- * \param in_pos The next byte will be read from in[*in_pos].
- * *in_pos is updated only if decoding succeeds.
- * \param in_size Size of the input buffer; the first byte that
- * won't be read is in[in_size].
- *
- * \return - LZMA_OK: Decoding was successful.
- * - LZMA_MEM_ERROR
- * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.
- * The minimum required memlimit value was stored to *memlimit.
- * - LZMA_DATA_ERROR
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i,
- uint64_t *memlimit, lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos, size_t in_size)
- lzma_nothrow;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/index_hash.h r-base-3.3.1/src/extra/xz/api/lzma/index_hash.h
--- r-base-3.2.3/src/extra/xz/api/lzma/index_hash.h 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/index_hash.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,107 +0,0 @@
-/**
- * \file lzma/index_hash.h
- * \brief Validate Index by using a hash function
- *
- * Hashing makes it possible to use constant amount of memory to validate
- * Index of arbitrary size.
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-/**
- * \brief Opaque data type to hold the Index hash
- */
-typedef struct lzma_index_hash_s lzma_index_hash;
-
-
-/**
- * \brief Allocate and initialize a new lzma_index_hash structure
- *
- * If index_hash is NULL, a new lzma_index_hash structure is allocated,
- * initialized, and a pointer to it returned. If allocation fails, NULL
- * is returned.
- *
- * If index_hash is non-NULL, it is reinitialized and the same pointer
- * returned. In this case, return value cannot be NULL or a different
- * pointer than the index_hash that was given as an argument.
- */
-extern LZMA_API(lzma_index_hash *) lzma_index_hash_init(
- lzma_index_hash *index_hash, lzma_allocator *allocator)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Deallocate lzma_index_hash structure
- */
-extern LZMA_API(void) lzma_index_hash_end(
- lzma_index_hash *index_hash, lzma_allocator *allocator)
- lzma_nothrow;
-
-
-/**
- * \brief Add a new Record to an Index hash
- *
- * \param index Pointer to a lzma_index_hash structure
- * \param unpadded_size Unpadded Size of a Block
- * \param uncompressed_size Uncompressed Size of a Block
- *
- * \return - LZMA_OK
- * - LZMA_DATA_ERROR: Compressed or uncompressed size of the
- * Stream or size of the Index field would grow too big.
- * - LZMA_PROG_ERROR: Invalid arguments or this function is being
- * used when lzma_index_hash_decode() has already been used.
- */
-extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash,
- lzma_vli unpadded_size, lzma_vli uncompressed_size)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Decode and validate the Index field
- *
- * After telling the sizes of all Blocks with lzma_index_hash_append(),
- * the actual Index field is decoded with this function. Specifically,
- * once decoding of the Index field has been started, no more Records
- * can be added using lzma_index_hash_append().
- *
- * This function doesn't use lzma_stream structure to pass the input data.
- * Instead, the input buffer is specified using three arguments. This is
- * because it matches better the internal APIs of liblzma.
- *
- * \param index_hash Pointer to a lzma_index_hash structure
- * \param in Pointer to the beginning of the input buffer
- * \param in_pos in[*in_pos] is the next byte to process
- * \param in_size in[in_size] is the first byte not to process
- *
- * \return - LZMA_OK: So far good, but more input is needed.
- * - LZMA_STREAM_END: Index decoded successfully and it matches
- * the Records given with lzma_index_hash_append().
- * - LZMA_DATA_ERROR: Index is corrupt or doesn't match the
- * information given with lzma_index_hash_append().
- * - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size.
- * - LZMA_PROG_ERROR
- */
-extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash,
- const uint8_t *in, size_t *in_pos, size_t in_size)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Get the size of the Index field as bytes
- *
- * This is needed to verify the Backward Size field in the Stream Footer.
- */
-extern LZMA_API(lzma_vli) lzma_index_hash_size(
- const lzma_index_hash *index_hash)
- lzma_nothrow lzma_attr_pure;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/lzma.h r-base-3.3.1/src/extra/xz/api/lzma/lzma.h
--- r-base-3.2.3/src/extra/xz/api/lzma/lzma.h 2011-03-15 23:02:23.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/lzma.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,420 +0,0 @@
-/**
- * \file lzma/lzma.h
- * \brief LZMA1 and LZMA2 filters
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/**
- * \brief LZMA1 Filter ID
- *
- * LZMA1 is the very same thing as what was called just LZMA in LZMA Utils,
- * 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from
- * accidentally using LZMA when they actually want LZMA2.
- *
- * LZMA1 shouldn't be used for new applications unless you _really_ know
- * what you are doing. LZMA2 is almost always a better choice.
- */
-#define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001)
-
-/**
- * \brief LZMA2 Filter ID
- *
- * Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds
- * support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion
- * when trying to compress uncompressible data), possibility to change
- * lc/lp/pb in the middle of encoding, and some other internal improvements.
- */
-#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21)
-
-
-/**
- * \brief Match finders
- *
- * Match finder has major effect on both speed and compression ratio.
- * Usually hash chains are faster than binary trees.
- *
- * If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better
- * choice, because binary trees get much higher compression ratio penalty
- * with LZMA_SYNC_FLUSH.
- *
- * The memory usage formulas are only rough estimates, which are closest to
- * reality when dict_size is a power of two. The formulas are more complex
- * in reality, and can also change a little between liblzma versions. Use
- * lzma_raw_encoder_memusage() to get more accurate estimate of memory usage.
- */
-typedef enum {
- LZMA_MF_HC3 = 0x03,
- /**<
- * \brief Hash Chain with 2- and 3-byte hashing
- *
- * Minimum nice_len: 3
- *
- * Memory usage:
- * - dict_size <= 16 MiB: dict_size * 7.5
- * - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB
- */
-
- LZMA_MF_HC4 = 0x04,
- /**<
- * \brief Hash Chain with 2-, 3-, and 4-byte hashing
- *
- * Minimum nice_len: 4
- *
- * Memory usage:
- * - dict_size <= 32 MiB: dict_size * 7.5
- * - dict_size > 32 MiB: dict_size * 6.5
- */
-
- LZMA_MF_BT2 = 0x12,
- /**<
- * \brief Binary Tree with 2-byte hashing
- *
- * Minimum nice_len: 2
- *
- * Memory usage: dict_size * 9.5
- */
-
- LZMA_MF_BT3 = 0x13,
- /**<
- * \brief Binary Tree with 2- and 3-byte hashing
- *
- * Minimum nice_len: 3
- *
- * Memory usage:
- * - dict_size <= 16 MiB: dict_size * 11.5
- * - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB
- */
-
- LZMA_MF_BT4 = 0x14
- /**<
- * \brief Binary Tree with 2-, 3-, and 4-byte hashing
- *
- * Minimum nice_len: 4
- *
- * Memory usage:
- * - dict_size <= 32 MiB: dict_size * 11.5
- * - dict_size > 32 MiB: dict_size * 10.5
- */
-} lzma_match_finder;
-
-
-/**
- * \brief Test if given match finder is supported
- *
- * Return true if the given match finder is supported by this liblzma build.
- * Otherwise false is returned. It is safe to call this with a value that
- * isn't listed in lzma_match_finder enumeration; the return value will be
- * false.
- *
- * There is no way to list which match finders are available in this
- * particular liblzma version and build. It would be useless, because
- * a new match finder, which the application developer wasn't aware,
- * could require giving additional options to the encoder that the older
- * match finders don't need.
- */
-extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder)
- lzma_nothrow lzma_attr_const;
-
-
-/**
- * \brief Compression modes
- *
- * This selects the function used to analyze the data produced by the match
- * finder.
- */
-typedef enum {
- LZMA_MODE_FAST = 1,
- /**<
- * \brief Fast compression
- *
- * Fast mode is usually at its best when combined with
- * a hash chain match finder.
- */
-
- LZMA_MODE_NORMAL = 2
- /**<
- * \brief Normal compression
- *
- * This is usually notably slower than fast mode. Use this
- * together with binary tree match finders to expose the
- * full potential of the LZMA1 or LZMA2 encoder.
- */
-} lzma_mode;
-
-
-/**
- * \brief Test if given compression mode is supported
- *
- * Return true if the given compression mode is supported by this liblzma
- * build. Otherwise false is returned. It is safe to call this with a value
- * that isn't listed in lzma_mode enumeration; the return value will be false.
- *
- * There is no way to list which modes are available in this particular
- * liblzma version and build. It would be useless, because a new compression
- * mode, which the application developer wasn't aware, could require giving
- * additional options to the encoder that the older modes don't need.
- */
-extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode)
- lzma_nothrow lzma_attr_const;
-
-
-/**
- * \brief Options specific to the LZMA1 and LZMA2 filters
- *
- * Since LZMA1 and LZMA2 share most of the code, it's simplest to share
- * the options structure too. For encoding, all but the reserved variables
- * need to be initialized unless specifically mentioned otherwise.
- * lzma_lzma_preset() can be used to get a good starting point.
- *
- * For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and
- * preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb.
- */
-typedef struct {
- /**
- * \brief Dictionary size in bytes
- *
- * Dictionary size indicates how many bytes of the recently processed
- * uncompressed data is kept in memory. One method to reduce size of
- * the uncompressed data is to store distance-length pairs, which
- * indicate what data to repeat from the dictionary buffer. Thus,
- * the bigger the dictionary, the better the compression ratio
- * usually is.
- *
- * Maximum size of the dictionary depends on multiple things:
- * - Memory usage limit
- * - Available address space (not a problem on 64-bit systems)
- * - Selected match finder (encoder only)
- *
- * Currently the maximum dictionary size for encoding is 1.5 GiB
- * (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit
- * systems for certain match finder implementation reasons. In the
- * future, there may be match finders that support bigger
- * dictionaries.
- *
- * Decoder already supports dictionaries up to 4 GiB - 1 B (i.e.
- * UINT32_MAX), so increasing the maximum dictionary size of the
- * encoder won't cause problems for old decoders.
- *
- * Because extremely small dictionaries sizes would have unneeded
- * overhead in the decoder, the minimum dictionary size is 4096 bytes.
- *
- * \note When decoding, too big dictionary does no other harm
- * than wasting memory.
- */
- uint32_t dict_size;
-# define LZMA_DICT_SIZE_MIN UINT32_C(4096)
-# define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23)
-
- /**
- * \brief Pointer to an initial dictionary
- *
- * It is possible to initialize the LZ77 history window using
- * a preset dictionary. It is useful when compressing many
- * similar, relatively small chunks of data independently from
- * each other. The preset dictionary should contain typical
- * strings that occur in the files being compressed. The most
- * probable strings should be near the end of the preset dictionary.
- *
- * This feature should be used only in special situations. For
- * now, it works correctly only with raw encoding and decoding.
- * Currently none of the container formats supported by
- * liblzma allow preset dictionary when decoding, thus if
- * you create a .xz or .lzma file with preset dictionary, it
- * cannot be decoded with the regular decoder functions. In the
- * future, the .xz format will likely get support for preset
- * dictionary though.
- */
- const uint8_t *preset_dict;
-
- /**
- * \brief Size of the preset dictionary
- *
- * Specifies the size of the preset dictionary. If the size is
- * bigger than dict_size, only the last dict_size bytes are
- * processed.
- *
- * This variable is read only when preset_dict is not NULL.
- * If preset_dict is not NULL but preset_dict_size is zero,
- * no preset dictionary is used (identical to only setting
- * preset_dict to NULL).
- */
- uint32_t preset_dict_size;
-
- /**
- * \brief Number of literal context bits
- *
- * How many of the highest bits of the previous uncompressed
- * eight-bit byte (also known as `literal') are taken into
- * account when predicting the bits of the next literal.
- *
- * E.g. in typical English text, an upper-case letter is
- * often followed by a lower-case letter, and a lower-case
- * letter is usually followed by another lower-case letter.
- * In the US-ASCII character set, the highest three bits are 010
- * for upper-case letters and 011 for lower-case letters.
- * When lc is at least 3, the literal coding can take advantage of
- * this property in the uncompressed data.
- *
- * There is a limit that applies to literal context bits and literal
- * position bits together: lc + lp <= 4. Without this limit the
- * decoding could become very slow, which could have security related
- * results in some cases like email servers doing virus scanning.
- * This limit also simplifies the internal implementation in liblzma.
- *
- * There may be LZMA1 streams that have lc + lp > 4 (maximum possible
- * lc would be 8). It is not possible to decode such streams with
- * liblzma.
- */
- uint32_t lc;
-# define LZMA_LCLP_MIN 0
-# define LZMA_LCLP_MAX 4
-# define LZMA_LC_DEFAULT 3
-
- /**
- * \brief Number of literal position bits
- *
- * lp affects what kind of alignment in the uncompressed data is
- * assumed when encoding literals. A literal is a single 8-bit byte.
- * See pb below for more information about alignment.
- */
- uint32_t lp;
-# define LZMA_LP_DEFAULT 0
-
- /**
- * \brief Number of position bits
- *
- * pb affects what kind of alignment in the uncompressed data is
- * assumed in general. The default means four-byte alignment
- * (2^ pb =2^2=4), which is often a good choice when there's
- * no better guess.
- *
- * When the aligment is known, setting pb accordingly may reduce
- * the file size a little. E.g. with text files having one-byte
- * alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can
- * improve compression slightly. For UTF-16 text, pb=1 is a good
- * choice. If the alignment is an odd number like 3 bytes, pb=0
- * might be the best choice.
- *
- * Even though the assumed alignment can be adjusted with pb and
- * lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment.
- * It might be worth taking into account when designing file formats
- * that are likely to be often compressed with LZMA1 or LZMA2.
- */
- uint32_t pb;
-# define LZMA_PB_MIN 0
-# define LZMA_PB_MAX 4
-# define LZMA_PB_DEFAULT 2
-
- /** Compression mode */
- lzma_mode mode;
-
- /**
- * \brief Nice length of a match
- *
- * This determines how many bytes the encoder compares from the match
- * candidates when looking for the best match. Once a match of at
- * least nice_len bytes long is found, the encoder stops looking for
- * better candidates and encodes the match. (Naturally, if the found
- * match is actually longer than nice_len, the actual length is
- * encoded; it's not truncated to nice_len.)
- *
- * Bigger values usually increase the compression ratio and
- * compression time. For most files, 32 to 128 is a good value,
- * which gives very good compression ratio at good speed.
- *
- * The exact minimum value depends on the match finder. The maximum
- * is 273, which is the maximum length of a match that LZMA1 and
- * LZMA2 can encode.
- */
- uint32_t nice_len;
-
- /** Match finder ID */
- lzma_match_finder mf;
-
- /**
- * \brief Maximum search depth in the match finder
- *
- * For every input byte, match finder searches through the hash chain
- * or binary tree in a loop, each iteration going one step deeper in
- * the chain or tree. The searching stops if
- * - a match of at least nice_len bytes long is found;
- * - all match candidates from the hash chain or binary tree have
- * been checked; or
- * - maximum search depth is reached.
- *
- * Maximum search depth is needed to prevent the match finder from
- * wasting too much time in case there are lots of short match
- * candidates. On the other hand, stopping the search before all
- * candidates have been checked can reduce compression ratio.
- *
- * Setting depth to zero tells liblzma to use an automatic default
- * value, that depends on the selected match finder and nice_len.
- * The default is in the range [4, 200] or so (it may vary between
- * liblzma versions).
- *
- * Using a bigger depth value than the default can increase
- * compression ratio in some cases. There is no strict maximum value,
- * but high values (thousands or millions) should be used with care:
- * the encoder could remain fast enough with typical input, but
- * malicious input could cause the match finder to slow down
- * dramatically, possibly creating a denial of service attack.
- */
- uint32_t depth;
-
- /*
- * Reserved space to allow possible future extensions without
- * breaking the ABI. You should not touch these, because the names
- * of these variables may change. These are and will never be used
- * with the currently supported options, so it is safe to leave these
- * uninitialized.
- */
- uint32_t reserved_int1;
- uint32_t reserved_int2;
- uint32_t reserved_int3;
- uint32_t reserved_int4;
- uint32_t reserved_int5;
- uint32_t reserved_int6;
- uint32_t reserved_int7;
- uint32_t reserved_int8;
- lzma_reserved_enum reserved_enum1;
- lzma_reserved_enum reserved_enum2;
- lzma_reserved_enum reserved_enum3;
- lzma_reserved_enum reserved_enum4;
- void *reserved_ptr1;
- void *reserved_ptr2;
-
-} lzma_options_lzma;
-
-
-/**
- * \brief Set a compression preset to lzma_options_lzma structure
- *
- * 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9
- * of the xz command line tool. In addition, it is possible to bitwise-or
- * flags to the preset. Currently only LZMA_PRESET_EXTREME is supported.
- * The flags are defined in container.h, because the flags are used also
- * with lzma_easy_encoder().
- *
- * The preset values are subject to changes between liblzma versions.
- *
- * This function is available only if LZMA1 or LZMA2 encoder has been enabled
- * when building liblzma.
- *
- * \return On success, false is returned. If the preset is not
- * supported, true is returned.
- */
-extern LZMA_API(lzma_bool) lzma_lzma_preset(
- lzma_options_lzma *options, uint32_t preset) lzma_nothrow;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/stream_flags.h r-base-3.3.1/src/extra/xz/api/lzma/stream_flags.h
--- r-base-3.2.3/src/extra/xz/api/lzma/stream_flags.h 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/stream_flags.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,223 +0,0 @@
-/**
- * \file lzma/stream_flags.h
- * \brief .xz Stream Header and Stream Footer encoder and decoder
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/**
- * \brief Size of Stream Header and Stream Footer
- *
- * Stream Header and Stream Footer have the same size and they are not
- * going to change even if a newer version of the .xz file format is
- * developed in future.
- */
-#define LZMA_STREAM_HEADER_SIZE 12
-
-
-/**
- * \brief Options for encoding/decoding Stream Header and Stream Footer
- */
-typedef struct {
- /**
- * \brief Stream Flags format version
- *
- * To prevent API and ABI breakages if new features are needed in
- * Stream Header or Stream Footer, a version number is used to
- * indicate which fields in this structure are in use. For now,
- * version must always be zero. With non-zero version, the
- * lzma_stream_header_encode() and lzma_stream_footer_encode()
- * will return LZMA_OPTIONS_ERROR.
- *
- * lzma_stream_header_decode() and lzma_stream_footer_decode()
- * will always set this to the lowest value that supports all the
- * features indicated by the Stream Flags field. The application
- * must check that the version number set by the decoding functions
- * is supported by the application. Otherwise it is possible that
- * the application will decode the Stream incorrectly.
- */
- uint32_t version;
-
- /**
- * \brief Backward Size
- *
- * Backward Size must be a multiple of four bytes. In this Stream
- * format version, Backward Size is the size of the Index field.
- *
- * Backward Size isn't actually part of the Stream Flags field, but
- * it is convenient to include in this structure anyway. Backward
- * Size is present only in the Stream Footer. There is no need to
- * initialize backward_size when encoding Stream Header.
- *
- * lzma_stream_header_decode() always sets backward_size to
- * LZMA_VLI_UNKNOWN so that it is convenient to use
- * lzma_stream_flags_compare() when both Stream Header and Stream
- * Footer have been decoded.
- */
- lzma_vli backward_size;
-# define LZMA_BACKWARD_SIZE_MIN 4
-# define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34)
-
- /**
- * \brief Check ID
- *
- * This indicates the type of the integrity check calculated from
- * uncompressed data.
- */
- lzma_check check;
-
- /*
- * Reserved space to allow possible future extensions without
- * breaking the ABI. You should not touch these, because the
- * names of these variables may change.
- *
- * (We will never be able to use all of these since Stream Flags
- * is just two bytes plus Backward Size of four bytes. But it's
- * nice to have the proper types when they are needed.)
- */
- lzma_reserved_enum reserved_enum1;
- lzma_reserved_enum reserved_enum2;
- lzma_reserved_enum reserved_enum3;
- lzma_reserved_enum reserved_enum4;
- lzma_bool reserved_bool1;
- lzma_bool reserved_bool2;
- lzma_bool reserved_bool3;
- lzma_bool reserved_bool4;
- lzma_bool reserved_bool5;
- lzma_bool reserved_bool6;
- lzma_bool reserved_bool7;
- lzma_bool reserved_bool8;
- uint32_t reserved_int1;
- uint32_t reserved_int2;
-
-} lzma_stream_flags;
-
-
-/**
- * \brief Encode Stream Header
- *
- * \param options Stream Header options to be encoded.
- * options->backward_size is ignored and doesn't
- * need to be initialized.
- * \param out Beginning of the output buffer of
- * LZMA_STREAM_HEADER_SIZE bytes.
- *
- * \return - LZMA_OK: Encoding was successful.
- * - LZMA_OPTIONS_ERROR: options->version is not supported by
- * this liblzma version.
- * - LZMA_PROG_ERROR: Invalid options.
- */
-extern LZMA_API(lzma_ret) lzma_stream_header_encode(
- const lzma_stream_flags *options, uint8_t *out)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Encode Stream Footer
- *
- * \param options Stream Footer options to be encoded.
- * \param out Beginning of the output buffer of
- * LZMA_STREAM_HEADER_SIZE bytes.
- *
- * \return - LZMA_OK: Encoding was successful.
- * - LZMA_OPTIONS_ERROR: options->version is not supported by
- * this liblzma version.
- * - LZMA_PROG_ERROR: Invalid options.
- */
-extern LZMA_API(lzma_ret) lzma_stream_footer_encode(
- const lzma_stream_flags *options, uint8_t *out)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Decode Stream Header
- *
- * \param options Target for the decoded Stream Header options.
- * \param in Beginning of the input buffer of
- * LZMA_STREAM_HEADER_SIZE bytes.
- *
- * options->backward_size is always set to LZMA_VLI_UNKNOWN. This is to
- * help comparing Stream Flags from Stream Header and Stream Footer with
- * lzma_stream_flags_compare().
- *
- * \return - LZMA_OK: Decoding was successful.
- * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
- * buffer cannot be Stream Header.
- * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header
- * is corrupt.
- * - LZMA_OPTIONS_ERROR: Unsupported options are present
- * in the header.
- *
- * \note When decoding .xz files that contain multiple Streams, it may
- * make sense to print "file format not recognized" only if
- * decoding of the Stream Header of the _first_ Stream gives
- * LZMA_FORMAT_ERROR. If non-first Stream Header gives
- * LZMA_FORMAT_ERROR, the message used for LZMA_DATA_ERROR is
- * probably more appropriate.
- *
- * For example, Stream decoder in liblzma uses LZMA_DATA_ERROR if
- * LZMA_FORMAT_ERROR is returned by lzma_stream_header_decode()
- * when decoding non-first Stream.
- */
-extern LZMA_API(lzma_ret) lzma_stream_header_decode(
- lzma_stream_flags *options, const uint8_t *in)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Decode Stream Footer
- *
- * \param options Target for the decoded Stream Header options.
- * \param in Beginning of the input buffer of
- * LZMA_STREAM_HEADER_SIZE bytes.
- *
- * \return - LZMA_OK: Decoding was successful.
- * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
- * buffer cannot be Stream Footer.
- * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the Stream Footer
- * is corrupt.
- * - LZMA_OPTIONS_ERROR: Unsupported options are present
- * in Stream Footer.
- *
- * \note If Stream Header was already decoded successfully, but
- * decoding Stream Footer returns LZMA_FORMAT_ERROR, the
- * application should probably report some other error message
- * than "file format not recognized", since the file more likely
- * is corrupt (possibly truncated). Stream decoder in liblzma
- * uses LZMA_DATA_ERROR in this situation.
- */
-extern LZMA_API(lzma_ret) lzma_stream_footer_decode(
- lzma_stream_flags *options, const uint8_t *in)
- lzma_nothrow lzma_attr_warn_unused_result;
-
-
-/**
- * \brief Compare two lzma_stream_flags structures
- *
- * backward_size values are compared only if both are not
- * LZMA_VLI_UNKNOWN.
- *
- * \return - LZMA_OK: Both are equal. If either had backward_size set
- * to LZMA_VLI_UNKNOWN, backward_size values were not
- * compared or validated.
- * - LZMA_DATA_ERROR: The structures differ.
- * - LZMA_OPTIONS_ERROR: version in either structure is greater
- * than the maximum supported version (currently zero).
- * - LZMA_PROG_ERROR: Invalid value, e.g. invalid check or
- * backward_size.
- */
-extern LZMA_API(lzma_ret) lzma_stream_flags_compare(
- const lzma_stream_flags *a, const lzma_stream_flags *b)
- lzma_nothrow lzma_attr_pure;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/version.h r-base-3.3.1/src/extra/xz/api/lzma/version.h
--- r-base-3.2.3/src/extra/xz/api/lzma/version.h 2015-03-18 23:02:07.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/version.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,121 +0,0 @@
-/**
- * \file lzma/version.h
- * \brief Version number
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/*
- * Version number split into components
- */
-#define LZMA_VERSION_MAJOR 5
-#define LZMA_VERSION_MINOR 0
-#define LZMA_VERSION_PATCH 7
-#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE
-
-#ifndef LZMA_VERSION_COMMIT
-# define LZMA_VERSION_COMMIT ""
-#endif
-
-
-/*
- * Map symbolic stability levels to integers.
- */
-#define LZMA_VERSION_STABILITY_ALPHA 0
-#define LZMA_VERSION_STABILITY_BETA 1
-#define LZMA_VERSION_STABILITY_STABLE 2
-
-
-/**
- * \brief Compile-time version number
- *
- * The version number is of format xyyyzzzs where
- * - x = major
- * - yyy = minor
- * - zzz = revision
- * - s indicates stability: 0 = alpha, 1 = beta, 2 = stable
- *
- * The same xyyyzzz triplet is never reused with different stability levels.
- * For example, if 5.1.0alpha has been released, there will never be 5.1.0beta
- * or 5.1.0 stable.
- *
- * \note The version number of liblzma has nothing to with
- * the version number of Igor Pavlov's LZMA SDK.
- */
-#define LZMA_VERSION (LZMA_VERSION_MAJOR * UINT32_C(10000000) \
- + LZMA_VERSION_MINOR * UINT32_C(10000) \
- + LZMA_VERSION_PATCH * UINT32_C(10) \
- + LZMA_VERSION_STABILITY)
-
-
-/*
- * Macros to construct the compile-time version string
- */
-#if LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_ALPHA
-# define LZMA_VERSION_STABILITY_STRING "alpha"
-#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_BETA
-# define LZMA_VERSION_STABILITY_STRING "beta"
-#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_STABLE
-# define LZMA_VERSION_STABILITY_STRING ""
-#else
-# error Incorrect LZMA_VERSION_STABILITY
-#endif
-
-#define LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) \
- #major "." #minor "." #patch stability commit
-
-#define LZMA_VERSION_STRING_C(major, minor, patch, stability, commit) \
- LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit)
-
-
-/**
- * \brief Compile-time version as a string
- *
- * This can be for example "4.999.5alpha", "4.999.8beta", or "5.0.0" (stable
- * versions don't have any "stable" suffix). In future, a snapshot built
- * from source code repository may include an additional suffix, for example
- * "4.999.8beta-21-g1d92". The commit ID won't be available in numeric form
- * in LZMA_VERSION macro.
- */
-#define LZMA_VERSION_STRING LZMA_VERSION_STRING_C( \
- LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, \
- LZMA_VERSION_PATCH, LZMA_VERSION_STABILITY_STRING, \
- LZMA_VERSION_COMMIT)
-
-
-/* #ifndef is needed for use with windres (MinGW or Cygwin). */
-#ifndef LZMA_H_INTERNAL_RC
-
-/**
- * \brief Run-time version number as an integer
- *
- * Return the value of LZMA_VERSION macro at the compile time of liblzma.
- * This allows the application to compare if it was built against the same,
- * older, or newer version of liblzma that is currently running.
- */
-extern LZMA_API(uint32_t) lzma_version_number(void)
- lzma_nothrow lzma_attr_const;
-
-
-/**
- * \brief Run-time version as a string
- *
- * This function may be useful if you want to display which version of
- * liblzma your application is currently using.
- */
-extern LZMA_API(const char *) lzma_version_string(void)
- lzma_nothrow lzma_attr_const;
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma/vli.h r-base-3.3.1/src/extra/xz/api/lzma/vli.h
--- r-base-3.2.3/src/extra/xz/api/lzma/vli.h 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma/vli.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,166 +0,0 @@
-/**
- * \file lzma/vli.h
- * \brief Variable-length integer handling
- *
- * In the .xz format, most integers are encoded in a variable-length
- * representation, which is sometimes called little endian base-128 encoding.
- * This saves space when smaller values are more likely than bigger values.
- *
- * The encoding scheme encodes seven bits to every byte, using minimum
- * number of bytes required to represent the given value. Encodings that use
- * non-minimum number of bytes are invalid, thus every integer has exactly
- * one encoded representation. The maximum number of bits in a VLI is 63,
- * thus the vli argument must be less than or equal to UINT64_MAX / 2. You
- * should use LZMA_VLI_MAX for clarity.
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use instead.
-#endif
-
-
-/**
- * \brief Maximum supported value of a variable-length integer
- */
-#define LZMA_VLI_MAX (UINT64_MAX / 2)
-
-/**
- * \brief VLI value to denote that the value is unknown
- */
-#define LZMA_VLI_UNKNOWN UINT64_MAX
-
-/**
- * \brief Maximum supported encoded length of variable length integers
- */
-#define LZMA_VLI_BYTES_MAX 9
-
-/**
- * \brief VLI constant suffix
- */
-#define LZMA_VLI_C(n) UINT64_C(n)
-
-
-/**
- * \brief Variable-length integer type
- *
- * Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is
- * indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the
- * underlaying integer type.
- *
- * lzma_vli will be uint64_t for the foreseeable future. If a bigger size
- * is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will
- * not overflow lzma_vli. This simplifies integer overflow detection.
- */
-typedef uint64_t lzma_vli;
-
-
-/**
- * \brief Validate a variable-length integer
- *
- * This is useful to test that application has given acceptable values
- * for example in the uncompressed_size and compressed_size variables.
- *
- * \return True if the integer is representable as VLI or if it
- * indicates unknown value.
- */
-#define lzma_vli_is_valid(vli) \
- ((vli) <= LZMA_VLI_MAX || (vli) == LZMA_VLI_UNKNOWN)
-
-
-/**
- * \brief Encode a variable-length integer
- *
- * This function has two modes: single-call and multi-call. Single-call mode
- * encodes the whole integer at once; it is an error if the output buffer is
- * too small. Multi-call mode saves the position in *vli_pos, and thus it is
- * possible to continue encoding if the buffer becomes full before the whole
- * integer has been encoded.
- *
- * \param vli Integer to be encoded
- * \param vli_pos How many VLI-encoded bytes have already been written
- * out. When starting to encode a new integer in
- * multi-call mode, *vli_pos must be set to zero.
- * To use single-call encoding, set vli_pos to NULL.
- * \param out Beginning of the output buffer
- * \param out_pos The next byte will be written to out[*out_pos].
- * \param out_size Size of the out buffer; the first byte into
- * which no data is written to is out[out_size].
- *
- * \return Slightly different return values are used in multi-call and
- * single-call modes.
- *
- * Single-call (vli_pos == NULL):
- * - LZMA_OK: Integer successfully encoded.
- * - LZMA_PROG_ERROR: Arguments are not sane. This can be due
- * to too little output space; single-call mode doesn't use
- * LZMA_BUF_ERROR, since the application should have checked
- * the encoded size with lzma_vli_size().
- *
- * Multi-call (vli_pos != NULL):
- * - LZMA_OK: So far all OK, but the integer is not
- * completely written out yet.
- * - LZMA_STREAM_END: Integer successfully encoded.
- * - LZMA_BUF_ERROR: No output space was provided.
- * - LZMA_PROG_ERROR: Arguments are not sane.
- */
-extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos,
- uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
-
-
-/**
- * \brief Decode a variable-length integer
- *
- * Like lzma_vli_encode(), this function has single-call and multi-call modes.
- *
- * \param vli Pointer to decoded integer. The decoder will
- * initialize it to zero when *vli_pos == 0, so
- * application isn't required to initialize *vli.
- * \param vli_pos How many bytes have already been decoded. When
- * starting to decode a new integer in multi-call
- * mode, *vli_pos must be initialized to zero. To
- * use single-call decoding, set vli_pos to NULL.
- * \param in Beginning of the input buffer
- * \param in_pos The next byte will be read from in[*in_pos].
- * \param in_size Size of the input buffer; the first byte that
- * won't be read is in[in_size].
- *
- * \return Slightly different return values are used in multi-call and
- * single-call modes.
- *
- * Single-call (vli_pos == NULL):
- * - LZMA_OK: Integer successfully decoded.
- * - LZMA_DATA_ERROR: Integer is corrupt. This includes hitting
- * the end of the input buffer before the whole integer was
- * decoded; providing no input at all will use LZMA_DATA_ERROR.
- * - LZMA_PROG_ERROR: Arguments are not sane.
- *
- * Multi-call (vli_pos != NULL):
- * - LZMA_OK: So far all OK, but the integer is not
- * completely decoded yet.
- * - LZMA_STREAM_END: Integer successfully decoded.
- * - LZMA_DATA_ERROR: Integer is corrupt.
- * - LZMA_BUF_ERROR: No input was provided.
- * - LZMA_PROG_ERROR: Arguments are not sane.
- */
-extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *vli, size_t *vli_pos,
- const uint8_t *in, size_t *in_pos, size_t in_size)
- lzma_nothrow;
-
-
-/**
- * \brief Get the number of bytes required to encode a VLI
- *
- * \return Number of bytes on success (1-9). If vli isn't valid,
- * zero is returned.
- */
-extern LZMA_API(uint32_t) lzma_vli_size(lzma_vli vli)
- lzma_nothrow lzma_attr_pure;
diff -Nru r-base-3.2.3/src/extra/xz/api/lzma.h r-base-3.3.1/src/extra/xz/api/lzma.h
--- r-base-3.2.3/src/extra/xz/api/lzma.h 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/api/lzma.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,313 +0,0 @@
-/**
- * \file api/lzma.h
- * \brief The public API of liblzma data compression library
- *
- * liblzma is a public domain general-purpose data compression library with
- * a zlib-like API. The native file format is .xz, but also the old .lzma
- * format and raw (no headers) streams are supported. Multiple compression
- * algorithms (filters) are supported. Currently LZMA2 is the primary filter.
- *
- * liblzma is part of XZ Utils . XZ Utils includes
- * a gzip-like command line tool named xz and some other tools. XZ Utils
- * is developed and maintained by Lasse Collin.
- *
- * Major parts of liblzma are based on Igor Pavlov's public domain LZMA SDK
- * .
- *
- * The SHA-256 implementation is based on the public domain code found from
- * 7-Zip , which has a modified version of the public
- * domain SHA-256 code found from Crypto++ .
- * The SHA-256 code in Crypto++ was written by Kevin Springle and Wei Dai.
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- */
-
-#ifndef LZMA_H
-#define LZMA_H
-
-/*****************************
- * Required standard headers *
- *****************************/
-
-/*
- * liblzma API headers need some standard types and macros. To allow
- * including lzma.h without requiring the application to include other
- * headers first, lzma.h includes the required standard headers unless
- * they already seem to be included already or if LZMA_MANUAL_HEADERS
- * has been defined.
- *
- * Here's what types and macros are needed and from which headers:
- * - stddef.h: size_t, NULL
- * - stdint.h: uint8_t, uint32_t, uint64_t, UINT32_C(n), uint64_C(n),
- * UINT32_MAX, UINT64_MAX
- *
- * However, inttypes.h is a little more portable than stdint.h, although
- * inttypes.h declares some unneeded things compared to plain stdint.h.
- *
- * The hacks below aren't perfect, specifically they assume that inttypes.h
- * exists and that it typedefs at least uint8_t, uint32_t, and uint64_t,
- * and that, in case of incomplete inttypes.h, unsigned int is 32-bit.
- * If the application already takes care of setting up all the types and
- * macros properly (for example by using gnulib's stdint.h or inttypes.h),
- * we try to detect that the macros are already defined and don't include
- * inttypes.h here again. However, you may define LZMA_MANUAL_HEADERS to
- * force this file to never include any system headers.
- *
- * Some could argue that liblzma API should provide all the required types,
- * for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was
- * seen as an unnecessary mess, since most systems already provide all the
- * necessary types and macros in the standard headers.
- *
- * Note that liblzma API still has lzma_bool, because using stdbool.h would
- * break C89 and C++ programs on many systems. sizeof(bool) in C99 isn't
- * necessarily the same as sizeof(bool) in C++.
- */
-
-#ifndef LZMA_MANUAL_HEADERS
- /*
- * I suppose this works portably also in C++. Note that in C++,
- * we need to get size_t into the global namespace.
- */
-# include
-
- /*
- * Skip inttypes.h if we already have all the required macros. If we
- * have the macros, we assume that we have the matching typedefs too.
- */
-# if !defined(UINT32_C) || !defined(UINT64_C) \
- || !defined(UINT32_MAX) || !defined(UINT64_MAX)
- /*
- * MSVC has no C99 support, and thus it cannot be used to
- * compile liblzma. The liblzma API has to still be usable
- * from MSVC, so we need to define the required standard
- * integer types here.
- */
-# if defined(_WIN32) && defined(_MSC_VER)
- typedef unsigned __int8 uint8_t;
- typedef unsigned __int32 uint32_t;
- typedef unsigned __int64 uint64_t;
-# else
- /* Use the standard inttypes.h. */
-# ifdef __cplusplus
- /*
- * C99 sections 7.18.2 and 7.18.4 specify
- * that C++ implementations define the limit
- * and constant macros only if specifically
- * requested. Note that if you want the
- * format macros (PRIu64 etc.) too, you need
- * to define __STDC_FORMAT_MACROS before
- * including lzma.h, since re-including
- * inttypes.h with __STDC_FORMAT_MACROS
- * defined doesn't necessarily work.
- */
-# ifndef __STDC_LIMIT_MACROS
-# define __STDC_LIMIT_MACROS 1
-# endif
-# ifndef __STDC_CONSTANT_MACROS
-# define __STDC_CONSTANT_MACROS 1
-# endif
-# endif
-
-# include
-# endif
-
- /*
- * Some old systems have only the typedefs in inttypes.h, and
- * lack all the macros. For those systems, we need a few more
- * hacks. We assume that unsigned int is 32-bit and unsigned
- * long is either 32-bit or 64-bit. If these hacks aren't
- * enough, the application has to setup the types manually
- * before including lzma.h.
- */
-# ifndef UINT32_C
-# if defined(_WIN32) && defined(_MSC_VER)
-# define UINT32_C(n) n ## UI32
-# else
-# define UINT32_C(n) n ## U
-# endif
-# endif
-
-# ifndef UINT64_C
-# if defined(_WIN32) && defined(_MSC_VER)
-# define UINT64_C(n) n ## UI64
-# else
- /* Get ULONG_MAX. */
-# include
-# if ULONG_MAX == 4294967295UL
-# define UINT64_C(n) n ## ULL
-# else
-# define UINT64_C(n) n ## UL
-# endif
-# endif
-# endif
-
-# ifndef UINT32_MAX
-# define UINT32_MAX (UINT32_C(4294967295))
-# endif
-
-# ifndef UINT64_MAX
-# define UINT64_MAX (UINT64_C(18446744073709551615))
-# endif
-# endif
-#endif /* ifdef LZMA_MANUAL_HEADERS */
-
-
-/******************
- * LZMA_API macro *
- ******************/
-
-/*
- * Some systems require that the functions and function pointers are
- * declared specially in the headers. LZMA_API_IMPORT is for importing
- * symbols and LZMA_API_CALL is to specify the calling convention.
- *
- * By default it is assumed that the application will link dynamically
- * against liblzma. #define LZMA_API_STATIC in your application if you
- * want to link against static liblzma. If you don't care about portability
- * to operating systems like Windows, or at least don't care about linking
- * against static liblzma on them, don't worry about LZMA_API_STATIC. That
- * is, most developers will never need to use LZMA_API_STATIC.
- *
- * The GCC variants are a special case on Windows (Cygwin and MinGW).
- * We rely on GCC doing the right thing with its auto-import feature,
- * and thus don't use __declspec(dllimport). This way developers don't
- * need to worry about LZMA_API_STATIC. Also the calling convention is
- * omitted on Cygwin but not on MinGW.
- */
-#ifndef LZMA_API_IMPORT
-# if !defined(LZMA_API_STATIC) && defined(_WIN32) && !defined(__GNUC__)
-# define LZMA_API_IMPORT __declspec(dllimport)
-# else
-# define LZMA_API_IMPORT
-# endif
-#endif
-
-#ifndef LZMA_API_CALL
-# if defined(_WIN32) && !defined(__CYGWIN__)
-# define LZMA_API_CALL __cdecl
-# else
-# define LZMA_API_CALL
-# endif
-#endif
-
-#ifndef LZMA_API
-# define LZMA_API(type) LZMA_API_IMPORT type LZMA_API_CALL
-#endif
-
-
-/***********
- * nothrow *
- ***********/
-
-/*
- * None of the functions in liblzma may throw an exception. Even
- * the functions that use callback functions won't throw exceptions,
- * because liblzma would break if a callback function threw an exception.
- */
-#ifndef lzma_nothrow
-# if defined(__cplusplus)
-# define lzma_nothrow throw()
-# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
-# define lzma_nothrow __attribute__((__nothrow__))
-# else
-# define lzma_nothrow
-# endif
-#endif
-
-
-/********************
- * GNU C extensions *
- ********************/
-
-/*
- * GNU C extensions are used conditionally in the public API. It doesn't
- * break anything if these are sometimes enabled and sometimes not, only
- * affects warnings and optimizations.
- */
-#if __GNUC__ >= 3
-# ifndef lzma_attribute
-# define lzma_attribute(attr) __attribute__(attr)
-# endif
-
- /* warn_unused_result was added in GCC 3.4. */
-# ifndef lzma_attr_warn_unused_result
-# if __GNUC__ == 3 && __GNUC_MINOR__ < 4
-# define lzma_attr_warn_unused_result
-# endif
-# endif
-
-#else
-# ifndef lzma_attribute
-# define lzma_attribute(attr)
-# endif
-#endif
-
-
-#ifndef lzma_attr_pure
-# define lzma_attr_pure lzma_attribute((__pure__))
-#endif
-
-#ifndef lzma_attr_const
-# define lzma_attr_const lzma_attribute((__const__))
-#endif
-
-#ifndef lzma_attr_warn_unused_result
-# define lzma_attr_warn_unused_result \
- lzma_attribute((__warn_unused_result__))
-#endif
-
-
-/**************
- * Subheaders *
- **************/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Subheaders check that this is defined. It is to prevent including
- * them directly from applications.
- */
-#define LZMA_H_INTERNAL 1
-
-/* Basic features */
-#include "lzma/version.h"
-#include "lzma/base.h"
-#include "lzma/vli.h"
-#include "lzma/check.h"
-
-/* Filters */
-#include "lzma/filter.h"
-#include "lzma/bcj.h"
-#include "lzma/delta.h"
-#include "lzma/lzma.h"
-
-/* Container formats */
-#include "lzma/container.h"
-
-/* Advanced features */
-#include "lzma/stream_flags.h"
-#include "lzma/block.h"
-#include "lzma/index.h"
-#include "lzma/index_hash.h"
-
-/* Hardware information */
-#include "lzma/hardware.h"
-
-/*
- * All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications
- * re-including the subheaders.
- */
-#undef LZMA_H_INTERNAL
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ifndef LZMA_H */
diff -Nru r-base-3.2.3/src/extra/xz/check/check.c r-base-3.3.1/src/extra/xz/check/check.c
--- r-base-3.2.3/src/extra/xz/check/check.c 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/check.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,174 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file check.c
-/// \brief Single API to access different integrity checks
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "check.h"
-
-
-extern LZMA_API(lzma_bool)
-lzma_check_is_supported(lzma_check type)
-{
- if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
- return false;
-
- static const lzma_bool available_checks[LZMA_CHECK_ID_MAX + 1] = {
- true, // LZMA_CHECK_NONE
-
-#ifdef HAVE_CHECK_CRC32
- true,
-#else
- false,
-#endif
-
- false, // Reserved
- false, // Reserved
-
-#ifdef HAVE_CHECK_CRC64
- true,
-#else
- false,
-#endif
-
- false, // Reserved
- false, // Reserved
- false, // Reserved
- false, // Reserved
- false, // Reserved
-
-#ifdef HAVE_CHECK_SHA256
- true,
-#else
- false,
-#endif
-
- false, // Reserved
- false, // Reserved
- false, // Reserved
- false, // Reserved
- false, // Reserved
- };
-
- return available_checks[(unsigned int)(type)];
-}
-
-
-extern LZMA_API(uint32_t)
-lzma_check_size(lzma_check type)
-{
- if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)
- return UINT32_MAX;
-
- // See file-format.txt section 2.1.1.2.
- static const uint8_t check_sizes[LZMA_CHECK_ID_MAX + 1] = {
- 0,
- 4, 4, 4,
- 8, 8, 8,
- 16, 16, 16,
- 32, 32, 32,
- 64, 64, 64
- };
-
- return check_sizes[(unsigned int)(type)];
-}
-
-
-extern void
-lzma_check_init(lzma_check_state *check, lzma_check type)
-{
- switch (type) {
- case LZMA_CHECK_NONE:
- break;
-
-#ifdef HAVE_CHECK_CRC32
- case LZMA_CHECK_CRC32:
- check->state.crc32 = 0;
- break;
-#endif
-
-#ifdef HAVE_CHECK_CRC64
- case LZMA_CHECK_CRC64:
- check->state.crc64 = 0;
- break;
-#endif
-
-#ifdef HAVE_CHECK_SHA256
- case LZMA_CHECK_SHA256:
- lzma_sha256_init(check);
- break;
-#endif
-
- default:
- break;
- }
-
- return;
-}
-
-
-extern void
-lzma_check_update(lzma_check_state *check, lzma_check type,
- const uint8_t *buf, size_t size)
-{
- switch (type) {
-#ifdef HAVE_CHECK_CRC32
- case LZMA_CHECK_CRC32:
- check->state.crc32 = lzma_crc32(buf, size, check->state.crc32);
- break;
-#endif
-
-#ifdef HAVE_CHECK_CRC64
- case LZMA_CHECK_CRC64:
- check->state.crc64 = lzma_crc64(buf, size, check->state.crc64);
- break;
-#endif
-
-#ifdef HAVE_CHECK_SHA256
- case LZMA_CHECK_SHA256:
- lzma_sha256_update(buf, size, check);
- break;
-#endif
-
- default:
- break;
- }
-
- return;
-}
-
-
-extern void
-lzma_check_finish(lzma_check_state *check, lzma_check type)
-{
- switch (type) {
-#ifdef HAVE_CHECK_CRC32
- case LZMA_CHECK_CRC32:
- check->buffer.u32[0] = conv32le(check->state.crc32);
- break;
-#endif
-
-#ifdef HAVE_CHECK_CRC64
- case LZMA_CHECK_CRC64:
- check->buffer.u64[0] = conv64le(check->state.crc64);
- break;
-#endif
-
-#ifdef HAVE_CHECK_SHA256
- case LZMA_CHECK_SHA256:
- lzma_sha256_finish(check);
- break;
-#endif
-
- default:
- break;
- }
-
- return;
-}
diff -Nru r-base-3.2.3/src/extra/xz/check/check.h r-base-3.3.1/src/extra/xz/check/check.h
--- r-base-3.2.3/src/extra/xz/check/check.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/check.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,95 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file check.h
-/// \brief Internal API to different integrity check functions
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_CHECK_H
-#define LZMA_CHECK_H
-
-#include "common.h"
-
-
-// Index hashing needs the best possible hash function (preferably
-// a cryptographic hash) for maximum reliability.
-#if defined(HAVE_CHECK_SHA256)
-# define LZMA_CHECK_BEST LZMA_CHECK_SHA256
-#elif defined(HAVE_CHECK_CRC64)
-# define LZMA_CHECK_BEST LZMA_CHECK_CRC64
-#else
-# define LZMA_CHECK_BEST LZMA_CHECK_CRC32
-#endif
-
-
-/// \brief Structure to hold internal state of the check being calculated
-///
-/// \note This is not in the public API because this structure may
-/// change in future if new integrity check algorithms are added.
-typedef struct {
- /// Buffer to hold the final result and a temporary buffer for SHA256.
- union {
- uint8_t u8[64];
- uint32_t u32[16];
- uint64_t u64[8];
- } buffer;
-
- /// Check-specific data
- union {
- uint32_t crc32;
- uint64_t crc64;
-
- struct {
- /// Internal state
- uint32_t state[8];
-
- /// Size of the message excluding padding
- uint64_t size;
- } sha256;
- } state;
-
-} lzma_check_state;
-
-
-/// lzma_crc32_table[0] is needed by LZ encoder so we need to keep
-/// the array two-dimensional.
-#ifdef HAVE_SMALL
-extern uint32_t lzma_crc32_table[1][256];
-extern void lzma_crc32_init(void);
-#else
-extern const uint32_t lzma_crc32_table[8][256];
-extern const uint64_t lzma_crc64_table[4][256];
-#endif
-
-
-/// \brief Initialize *check depending on type
-///
-/// \return LZMA_OK on success. LZMA_UNSUPPORTED_CHECK if the type is not
-/// supported by the current version or build of liblzma.
-/// LZMA_PROG_ERROR if type > LZMA_CHECK_ID_MAX.
-extern void lzma_check_init(lzma_check_state *check, lzma_check type);
-
-/// Update the check state
-extern void lzma_check_update(lzma_check_state *check, lzma_check type,
- const uint8_t *buf, size_t size);
-
-/// Finish the check calculation and store the result to check->buffer.u8.
-extern void lzma_check_finish(lzma_check_state *check, lzma_check type);
-
-
-/// Prepare SHA-256 state for new input.
-extern void lzma_sha256_init(lzma_check_state *check);
-
-/// Update the SHA-256 hash state
-extern void lzma_sha256_update(
- const uint8_t *buf, size_t size, lzma_check_state *check);
-
-/// Finish the SHA-256 calculation and store the result to check->buffer.u8.
-extern void lzma_sha256_finish(lzma_check_state *check);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/check/crc32_fast.c r-base-3.3.1/src/extra/xz/check/crc32_fast.c
--- r-base-3.2.3/src/extra/xz/check/crc32_fast.c 2015-03-18 23:02:08.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc32_fast.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,82 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file crc32.c
-/// \brief CRC32 calculation
-///
-/// Calculate the CRC32 using the slice-by-eight algorithm.
-/// It is explained in this document:
-/// http://www.intel.com/technology/comms/perfnet/download/CRC_generators.pdf
-/// The code in this file is not the same as in Intel's paper, but
-/// the basic principle is identical.
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "check.h"
-#include "crc_macros.h"
-
-
-// If you make any changes, do some benchmarking! Seemingly unrelated
-// changes can very easily ruin the performance (and very probably is
-// very compiler dependent).
-extern LZMA_API(uint32_t)
-lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
-{
- crc = ~crc;
-
-#ifdef WORDS_BIGENDIAN
- crc = bswap32(crc);
-#endif
-
- if (size > 8) {
- // Fix the alignment, if needed. The if statement above
- // ensures that this won't read past the end of buf[].
- while ((uintptr_t)(buf) & 7) {
- crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc);
- --size;
- }
-
- // Calculate the position where to stop.
- const uint8_t *const limit = buf + (size & ~(size_t)(7));
-
- // Calculate how many bytes must be calculated separately
- // before returning the result.
- size &= (size_t)(7);
-
- // Calculate the CRC32 using the slice-by-eight algorithm.
- while (buf < limit) {
- crc ^= *(const uint32_t *)(buf);
- buf += 4;
-
- crc = lzma_crc32_table[7][A(crc)]
- ^ lzma_crc32_table[6][B(crc)]
- ^ lzma_crc32_table[5][C(crc)]
- ^ lzma_crc32_table[4][D(crc)];
-
- const uint32_t tmp = *(const uint32_t *)(buf);
- buf += 4;
-
- // At least with some compilers, it is critical for
- // performance, that the crc variable is XORed
- // between the two table-lookup pairs.
- crc = lzma_crc32_table[3][A(tmp)]
- ^ lzma_crc32_table[2][B(tmp)]
- ^ crc
- ^ lzma_crc32_table[1][C(tmp)]
- ^ lzma_crc32_table[0][D(tmp)];
- }
- }
-
- while (size-- != 0)
- crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc);
-
-#ifdef WORDS_BIGENDIAN
- crc = bswap32(crc);
-#endif
-
- return ~crc;
-}
diff -Nru r-base-3.2.3/src/extra/xz/check/crc32_small.c r-base-3.3.1/src/extra/xz/check/crc32_small.c
--- r-base-3.2.3/src/extra/xz/check/crc32_small.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc32_small.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,61 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file crc32_small.c
-/// \brief CRC32 calculation (size-optimized)
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "check.h"
-
-
-uint32_t lzma_crc32_table[1][256];
-
-
-static void
-crc32_init(void)
-{
- static const uint32_t poly32 = UINT32_C(0xEDB88320);
-
- for (size_t b = 0; b < 256; ++b) {
- uint32_t r = b;
- for (size_t i = 0; i < 8; ++i) {
- if (r & 1)
- r = (r >> 1) ^ poly32;
- else
- r >>= 1;
- }
-
- lzma_crc32_table[0][b] = r;
- }
-
- return;
-}
-
-
-extern void
-lzma_crc32_init(void)
-{
- mythread_once(crc32_init);
- return;
-}
-
-
-extern LZMA_API(uint32_t)
-lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)
-{
- lzma_crc32_init();
-
- crc = ~crc;
-
- while (size != 0) {
- crc = lzma_crc32_table[0][*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
- --size;
- }
-
- return ~crc;
-}
diff -Nru r-base-3.2.3/src/extra/xz/check/crc32_table_be.h r-base-3.3.1/src/extra/xz/check/crc32_table_be.h
--- r-base-3.2.3/src/extra/xz/check/crc32_table_be.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc32_table_be.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,525 +0,0 @@
-/* This file has been automatically generated by crc32_tablegen.c. */
-
-const uint32_t lzma_crc32_table[8][256] = {
- {
- 0x00000000, 0x96300777, 0x2C610EEE, 0xBA510999,
- 0x19C46D07, 0x8FF46A70, 0x35A563E9, 0xA395649E,
- 0x3288DB0E, 0xA4B8DC79, 0x1EE9D5E0, 0x88D9D297,
- 0x2B4CB609, 0xBD7CB17E, 0x072DB8E7, 0x911DBF90,
- 0x6410B71D, 0xF220B06A, 0x4871B9F3, 0xDE41BE84,
- 0x7DD4DA1A, 0xEBE4DD6D, 0x51B5D4F4, 0xC785D383,
- 0x56986C13, 0xC0A86B64, 0x7AF962FD, 0xECC9658A,
- 0x4F5C0114, 0xD96C0663, 0x633D0FFA, 0xF50D088D,
- 0xC8206E3B, 0x5E10694C, 0xE44160D5, 0x727167A2,
- 0xD1E4033C, 0x47D4044B, 0xFD850DD2, 0x6BB50AA5,
- 0xFAA8B535, 0x6C98B242, 0xD6C9BBDB, 0x40F9BCAC,
- 0xE36CD832, 0x755CDF45, 0xCF0DD6DC, 0x593DD1AB,
- 0xAC30D926, 0x3A00DE51, 0x8051D7C8, 0x1661D0BF,
- 0xB5F4B421, 0x23C4B356, 0x9995BACF, 0x0FA5BDB8,
- 0x9EB80228, 0x0888055F, 0xB2D90CC6, 0x24E90BB1,
- 0x877C6F2F, 0x114C6858, 0xAB1D61C1, 0x3D2D66B6,
- 0x9041DC76, 0x0671DB01, 0xBC20D298, 0x2A10D5EF,
- 0x8985B171, 0x1FB5B606, 0xA5E4BF9F, 0x33D4B8E8,
- 0xA2C90778, 0x34F9000F, 0x8EA80996, 0x18980EE1,
- 0xBB0D6A7F, 0x2D3D6D08, 0x976C6491, 0x015C63E6,
- 0xF4516B6B, 0x62616C1C, 0xD8306585, 0x4E0062F2,
- 0xED95066C, 0x7BA5011B, 0xC1F40882, 0x57C40FF5,
- 0xC6D9B065, 0x50E9B712, 0xEAB8BE8B, 0x7C88B9FC,
- 0xDF1DDD62, 0x492DDA15, 0xF37CD38C, 0x654CD4FB,
- 0x5861B24D, 0xCE51B53A, 0x7400BCA3, 0xE230BBD4,
- 0x41A5DF4A, 0xD795D83D, 0x6DC4D1A4, 0xFBF4D6D3,
- 0x6AE96943, 0xFCD96E34, 0x468867AD, 0xD0B860DA,
- 0x732D0444, 0xE51D0333, 0x5F4C0AAA, 0xC97C0DDD,
- 0x3C710550, 0xAA410227, 0x10100BBE, 0x86200CC9,
- 0x25B56857, 0xB3856F20, 0x09D466B9, 0x9FE461CE,
- 0x0EF9DE5E, 0x98C9D929, 0x2298D0B0, 0xB4A8D7C7,
- 0x173DB359, 0x810DB42E, 0x3B5CBDB7, 0xAD6CBAC0,
- 0x2083B8ED, 0xB6B3BF9A, 0x0CE2B603, 0x9AD2B174,
- 0x3947D5EA, 0xAF77D29D, 0x1526DB04, 0x8316DC73,
- 0x120B63E3, 0x843B6494, 0x3E6A6D0D, 0xA85A6A7A,
- 0x0BCF0EE4, 0x9DFF0993, 0x27AE000A, 0xB19E077D,
- 0x44930FF0, 0xD2A30887, 0x68F2011E, 0xFEC20669,
- 0x5D5762F7, 0xCB676580, 0x71366C19, 0xE7066B6E,
- 0x761BD4FE, 0xE02BD389, 0x5A7ADA10, 0xCC4ADD67,
- 0x6FDFB9F9, 0xF9EFBE8E, 0x43BEB717, 0xD58EB060,
- 0xE8A3D6D6, 0x7E93D1A1, 0xC4C2D838, 0x52F2DF4F,
- 0xF167BBD1, 0x6757BCA6, 0xDD06B53F, 0x4B36B248,
- 0xDA2B0DD8, 0x4C1B0AAF, 0xF64A0336, 0x607A0441,
- 0xC3EF60DF, 0x55DF67A8, 0xEF8E6E31, 0x79BE6946,
- 0x8CB361CB, 0x1A8366BC, 0xA0D26F25, 0x36E26852,
- 0x95770CCC, 0x03470BBB, 0xB9160222, 0x2F260555,
- 0xBE3BBAC5, 0x280BBDB2, 0x925AB42B, 0x046AB35C,
- 0xA7FFD7C2, 0x31CFD0B5, 0x8B9ED92C, 0x1DAEDE5B,
- 0xB0C2649B, 0x26F263EC, 0x9CA36A75, 0x0A936D02,
- 0xA906099C, 0x3F360EEB, 0x85670772, 0x13570005,
- 0x824ABF95, 0x147AB8E2, 0xAE2BB17B, 0x381BB60C,
- 0x9B8ED292, 0x0DBED5E5, 0xB7EFDC7C, 0x21DFDB0B,
- 0xD4D2D386, 0x42E2D4F1, 0xF8B3DD68, 0x6E83DA1F,
- 0xCD16BE81, 0x5B26B9F6, 0xE177B06F, 0x7747B718,
- 0xE65A0888, 0x706A0FFF, 0xCA3B0666, 0x5C0B0111,
- 0xFF9E658F, 0x69AE62F8, 0xD3FF6B61, 0x45CF6C16,
- 0x78E20AA0, 0xEED20DD7, 0x5483044E, 0xC2B30339,
- 0x612667A7, 0xF71660D0, 0x4D476949, 0xDB776E3E,
- 0x4A6AD1AE, 0xDC5AD6D9, 0x660BDF40, 0xF03BD837,
- 0x53AEBCA9, 0xC59EBBDE, 0x7FCFB247, 0xE9FFB530,
- 0x1CF2BDBD, 0x8AC2BACA, 0x3093B353, 0xA6A3B424,
- 0x0536D0BA, 0x9306D7CD, 0x2957DE54, 0xBF67D923,
- 0x2E7A66B3, 0xB84A61C4, 0x021B685D, 0x942B6F2A,
- 0x37BE0BB4, 0xA18E0CC3, 0x1BDF055A, 0x8DEF022D
- }, {
- 0x00000000, 0x41311B19, 0x82623632, 0xC3532D2B,
- 0x04C56C64, 0x45F4777D, 0x86A75A56, 0xC796414F,
- 0x088AD9C8, 0x49BBC2D1, 0x8AE8EFFA, 0xCBD9F4E3,
- 0x0C4FB5AC, 0x4D7EAEB5, 0x8E2D839E, 0xCF1C9887,
- 0x5112C24A, 0x1023D953, 0xD370F478, 0x9241EF61,
- 0x55D7AE2E, 0x14E6B537, 0xD7B5981C, 0x96848305,
- 0x59981B82, 0x18A9009B, 0xDBFA2DB0, 0x9ACB36A9,
- 0x5D5D77E6, 0x1C6C6CFF, 0xDF3F41D4, 0x9E0E5ACD,
- 0xA2248495, 0xE3159F8C, 0x2046B2A7, 0x6177A9BE,
- 0xA6E1E8F1, 0xE7D0F3E8, 0x2483DEC3, 0x65B2C5DA,
- 0xAAAE5D5D, 0xEB9F4644, 0x28CC6B6F, 0x69FD7076,
- 0xAE6B3139, 0xEF5A2A20, 0x2C09070B, 0x6D381C12,
- 0xF33646DF, 0xB2075DC6, 0x715470ED, 0x30656BF4,
- 0xF7F32ABB, 0xB6C231A2, 0x75911C89, 0x34A00790,
- 0xFBBC9F17, 0xBA8D840E, 0x79DEA925, 0x38EFB23C,
- 0xFF79F373, 0xBE48E86A, 0x7D1BC541, 0x3C2ADE58,
- 0x054F79F0, 0x447E62E9, 0x872D4FC2, 0xC61C54DB,
- 0x018A1594, 0x40BB0E8D, 0x83E823A6, 0xC2D938BF,
- 0x0DC5A038, 0x4CF4BB21, 0x8FA7960A, 0xCE968D13,
- 0x0900CC5C, 0x4831D745, 0x8B62FA6E, 0xCA53E177,
- 0x545DBBBA, 0x156CA0A3, 0xD63F8D88, 0x970E9691,
- 0x5098D7DE, 0x11A9CCC7, 0xD2FAE1EC, 0x93CBFAF5,
- 0x5CD76272, 0x1DE6796B, 0xDEB55440, 0x9F844F59,
- 0x58120E16, 0x1923150F, 0xDA703824, 0x9B41233D,
- 0xA76BFD65, 0xE65AE67C, 0x2509CB57, 0x6438D04E,
- 0xA3AE9101, 0xE29F8A18, 0x21CCA733, 0x60FDBC2A,
- 0xAFE124AD, 0xEED03FB4, 0x2D83129F, 0x6CB20986,
- 0xAB2448C9, 0xEA1553D0, 0x29467EFB, 0x687765E2,
- 0xF6793F2F, 0xB7482436, 0x741B091D, 0x352A1204,
- 0xF2BC534B, 0xB38D4852, 0x70DE6579, 0x31EF7E60,
- 0xFEF3E6E7, 0xBFC2FDFE, 0x7C91D0D5, 0x3DA0CBCC,
- 0xFA368A83, 0xBB07919A, 0x7854BCB1, 0x3965A7A8,
- 0x4B98833B, 0x0AA99822, 0xC9FAB509, 0x88CBAE10,
- 0x4F5DEF5F, 0x0E6CF446, 0xCD3FD96D, 0x8C0EC274,
- 0x43125AF3, 0x022341EA, 0xC1706CC1, 0x804177D8,
- 0x47D73697, 0x06E62D8E, 0xC5B500A5, 0x84841BBC,
- 0x1A8A4171, 0x5BBB5A68, 0x98E87743, 0xD9D96C5A,
- 0x1E4F2D15, 0x5F7E360C, 0x9C2D1B27, 0xDD1C003E,
- 0x120098B9, 0x533183A0, 0x9062AE8B, 0xD153B592,
- 0x16C5F4DD, 0x57F4EFC4, 0x94A7C2EF, 0xD596D9F6,
- 0xE9BC07AE, 0xA88D1CB7, 0x6BDE319C, 0x2AEF2A85,
- 0xED796BCA, 0xAC4870D3, 0x6F1B5DF8, 0x2E2A46E1,
- 0xE136DE66, 0xA007C57F, 0x6354E854, 0x2265F34D,
- 0xE5F3B202, 0xA4C2A91B, 0x67918430, 0x26A09F29,
- 0xB8AEC5E4, 0xF99FDEFD, 0x3ACCF3D6, 0x7BFDE8CF,
- 0xBC6BA980, 0xFD5AB299, 0x3E099FB2, 0x7F3884AB,
- 0xB0241C2C, 0xF1150735, 0x32462A1E, 0x73773107,
- 0xB4E17048, 0xF5D06B51, 0x3683467A, 0x77B25D63,
- 0x4ED7FACB, 0x0FE6E1D2, 0xCCB5CCF9, 0x8D84D7E0,
- 0x4A1296AF, 0x0B238DB6, 0xC870A09D, 0x8941BB84,
- 0x465D2303, 0x076C381A, 0xC43F1531, 0x850E0E28,
- 0x42984F67, 0x03A9547E, 0xC0FA7955, 0x81CB624C,
- 0x1FC53881, 0x5EF42398, 0x9DA70EB3, 0xDC9615AA,
- 0x1B0054E5, 0x5A314FFC, 0x996262D7, 0xD85379CE,
- 0x174FE149, 0x567EFA50, 0x952DD77B, 0xD41CCC62,
- 0x138A8D2D, 0x52BB9634, 0x91E8BB1F, 0xD0D9A006,
- 0xECF37E5E, 0xADC26547, 0x6E91486C, 0x2FA05375,
- 0xE836123A, 0xA9070923, 0x6A542408, 0x2B653F11,
- 0xE479A796, 0xA548BC8F, 0x661B91A4, 0x272A8ABD,
- 0xE0BCCBF2, 0xA18DD0EB, 0x62DEFDC0, 0x23EFE6D9,
- 0xBDE1BC14, 0xFCD0A70D, 0x3F838A26, 0x7EB2913F,
- 0xB924D070, 0xF815CB69, 0x3B46E642, 0x7A77FD5B,
- 0xB56B65DC, 0xF45A7EC5, 0x370953EE, 0x763848F7,
- 0xB1AE09B8, 0xF09F12A1, 0x33CC3F8A, 0x72FD2493
- }, {
- 0x00000000, 0x376AC201, 0x6ED48403, 0x59BE4602,
- 0xDCA80907, 0xEBC2CB06, 0xB27C8D04, 0x85164F05,
- 0xB851130E, 0x8F3BD10F, 0xD685970D, 0xE1EF550C,
- 0x64F91A09, 0x5393D808, 0x0A2D9E0A, 0x3D475C0B,
- 0x70A3261C, 0x47C9E41D, 0x1E77A21F, 0x291D601E,
- 0xAC0B2F1B, 0x9B61ED1A, 0xC2DFAB18, 0xF5B56919,
- 0xC8F23512, 0xFF98F713, 0xA626B111, 0x914C7310,
- 0x145A3C15, 0x2330FE14, 0x7A8EB816, 0x4DE47A17,
- 0xE0464D38, 0xD72C8F39, 0x8E92C93B, 0xB9F80B3A,
- 0x3CEE443F, 0x0B84863E, 0x523AC03C, 0x6550023D,
- 0x58175E36, 0x6F7D9C37, 0x36C3DA35, 0x01A91834,
- 0x84BF5731, 0xB3D59530, 0xEA6BD332, 0xDD011133,
- 0x90E56B24, 0xA78FA925, 0xFE31EF27, 0xC95B2D26,
- 0x4C4D6223, 0x7B27A022, 0x2299E620, 0x15F32421,
- 0x28B4782A, 0x1FDEBA2B, 0x4660FC29, 0x710A3E28,
- 0xF41C712D, 0xC376B32C, 0x9AC8F52E, 0xADA2372F,
- 0xC08D9A70, 0xF7E75871, 0xAE591E73, 0x9933DC72,
- 0x1C259377, 0x2B4F5176, 0x72F11774, 0x459BD575,
- 0x78DC897E, 0x4FB64B7F, 0x16080D7D, 0x2162CF7C,
- 0xA4748079, 0x931E4278, 0xCAA0047A, 0xFDCAC67B,
- 0xB02EBC6C, 0x87447E6D, 0xDEFA386F, 0xE990FA6E,
- 0x6C86B56B, 0x5BEC776A, 0x02523168, 0x3538F369,
- 0x087FAF62, 0x3F156D63, 0x66AB2B61, 0x51C1E960,
- 0xD4D7A665, 0xE3BD6464, 0xBA032266, 0x8D69E067,
- 0x20CBD748, 0x17A11549, 0x4E1F534B, 0x7975914A,
- 0xFC63DE4F, 0xCB091C4E, 0x92B75A4C, 0xA5DD984D,
- 0x989AC446, 0xAFF00647, 0xF64E4045, 0xC1248244,
- 0x4432CD41, 0x73580F40, 0x2AE64942, 0x1D8C8B43,
- 0x5068F154, 0x67023355, 0x3EBC7557, 0x09D6B756,
- 0x8CC0F853, 0xBBAA3A52, 0xE2147C50, 0xD57EBE51,
- 0xE839E25A, 0xDF53205B, 0x86ED6659, 0xB187A458,
- 0x3491EB5D, 0x03FB295C, 0x5A456F5E, 0x6D2FAD5F,
- 0x801B35E1, 0xB771F7E0, 0xEECFB1E2, 0xD9A573E3,
- 0x5CB33CE6, 0x6BD9FEE7, 0x3267B8E5, 0x050D7AE4,
- 0x384A26EF, 0x0F20E4EE, 0x569EA2EC, 0x61F460ED,
- 0xE4E22FE8, 0xD388EDE9, 0x8A36ABEB, 0xBD5C69EA,
- 0xF0B813FD, 0xC7D2D1FC, 0x9E6C97FE, 0xA90655FF,
- 0x2C101AFA, 0x1B7AD8FB, 0x42C49EF9, 0x75AE5CF8,
- 0x48E900F3, 0x7F83C2F2, 0x263D84F0, 0x115746F1,
- 0x944109F4, 0xA32BCBF5, 0xFA958DF7, 0xCDFF4FF6,
- 0x605D78D9, 0x5737BAD8, 0x0E89FCDA, 0x39E33EDB,
- 0xBCF571DE, 0x8B9FB3DF, 0xD221F5DD, 0xE54B37DC,
- 0xD80C6BD7, 0xEF66A9D6, 0xB6D8EFD4, 0x81B22DD5,
- 0x04A462D0, 0x33CEA0D1, 0x6A70E6D3, 0x5D1A24D2,
- 0x10FE5EC5, 0x27949CC4, 0x7E2ADAC6, 0x494018C7,
- 0xCC5657C2, 0xFB3C95C3, 0xA282D3C1, 0x95E811C0,
- 0xA8AF4DCB, 0x9FC58FCA, 0xC67BC9C8, 0xF1110BC9,
- 0x740744CC, 0x436D86CD, 0x1AD3C0CF, 0x2DB902CE,
- 0x4096AF91, 0x77FC6D90, 0x2E422B92, 0x1928E993,
- 0x9C3EA696, 0xAB546497, 0xF2EA2295, 0xC580E094,
- 0xF8C7BC9F, 0xCFAD7E9E, 0x9613389C, 0xA179FA9D,
- 0x246FB598, 0x13057799, 0x4ABB319B, 0x7DD1F39A,
- 0x3035898D, 0x075F4B8C, 0x5EE10D8E, 0x698BCF8F,
- 0xEC9D808A, 0xDBF7428B, 0x82490489, 0xB523C688,
- 0x88649A83, 0xBF0E5882, 0xE6B01E80, 0xD1DADC81,
- 0x54CC9384, 0x63A65185, 0x3A181787, 0x0D72D586,
- 0xA0D0E2A9, 0x97BA20A8, 0xCE0466AA, 0xF96EA4AB,
- 0x7C78EBAE, 0x4B1229AF, 0x12AC6FAD, 0x25C6ADAC,
- 0x1881F1A7, 0x2FEB33A6, 0x765575A4, 0x413FB7A5,
- 0xC429F8A0, 0xF3433AA1, 0xAAFD7CA3, 0x9D97BEA2,
- 0xD073C4B5, 0xE71906B4, 0xBEA740B6, 0x89CD82B7,
- 0x0CDBCDB2, 0x3BB10FB3, 0x620F49B1, 0x55658BB0,
- 0x6822D7BB, 0x5F4815BA, 0x06F653B8, 0x319C91B9,
- 0xB48ADEBC, 0x83E01CBD, 0xDA5E5ABF, 0xED3498BE
- }, {
- 0x00000000, 0x6567BCB8, 0x8BC809AA, 0xEEAFB512,
- 0x5797628F, 0x32F0DE37, 0xDC5F6B25, 0xB938D79D,
- 0xEF28B4C5, 0x8A4F087D, 0x64E0BD6F, 0x018701D7,
- 0xB8BFD64A, 0xDDD86AF2, 0x3377DFE0, 0x56106358,
- 0x9F571950, 0xFA30A5E8, 0x149F10FA, 0x71F8AC42,
- 0xC8C07BDF, 0xADA7C767, 0x43087275, 0x266FCECD,
- 0x707FAD95, 0x1518112D, 0xFBB7A43F, 0x9ED01887,
- 0x27E8CF1A, 0x428F73A2, 0xAC20C6B0, 0xC9477A08,
- 0x3EAF32A0, 0x5BC88E18, 0xB5673B0A, 0xD00087B2,
- 0x6938502F, 0x0C5FEC97, 0xE2F05985, 0x8797E53D,
- 0xD1878665, 0xB4E03ADD, 0x5A4F8FCF, 0x3F283377,
- 0x8610E4EA, 0xE3775852, 0x0DD8ED40, 0x68BF51F8,
- 0xA1F82BF0, 0xC49F9748, 0x2A30225A, 0x4F579EE2,
- 0xF66F497F, 0x9308F5C7, 0x7DA740D5, 0x18C0FC6D,
- 0x4ED09F35, 0x2BB7238D, 0xC518969F, 0xA07F2A27,
- 0x1947FDBA, 0x7C204102, 0x928FF410, 0xF7E848A8,
- 0x3D58149B, 0x583FA823, 0xB6901D31, 0xD3F7A189,
- 0x6ACF7614, 0x0FA8CAAC, 0xE1077FBE, 0x8460C306,
- 0xD270A05E, 0xB7171CE6, 0x59B8A9F4, 0x3CDF154C,
- 0x85E7C2D1, 0xE0807E69, 0x0E2FCB7B, 0x6B4877C3,
- 0xA20F0DCB, 0xC768B173, 0x29C70461, 0x4CA0B8D9,
- 0xF5986F44, 0x90FFD3FC, 0x7E5066EE, 0x1B37DA56,
- 0x4D27B90E, 0x284005B6, 0xC6EFB0A4, 0xA3880C1C,
- 0x1AB0DB81, 0x7FD76739, 0x9178D22B, 0xF41F6E93,
- 0x03F7263B, 0x66909A83, 0x883F2F91, 0xED589329,
- 0x546044B4, 0x3107F80C, 0xDFA84D1E, 0xBACFF1A6,
- 0xECDF92FE, 0x89B82E46, 0x67179B54, 0x027027EC,
- 0xBB48F071, 0xDE2F4CC9, 0x3080F9DB, 0x55E74563,
- 0x9CA03F6B, 0xF9C783D3, 0x176836C1, 0x720F8A79,
- 0xCB375DE4, 0xAE50E15C, 0x40FF544E, 0x2598E8F6,
- 0x73888BAE, 0x16EF3716, 0xF8408204, 0x9D273EBC,
- 0x241FE921, 0x41785599, 0xAFD7E08B, 0xCAB05C33,
- 0x3BB659ED, 0x5ED1E555, 0xB07E5047, 0xD519ECFF,
- 0x6C213B62, 0x094687DA, 0xE7E932C8, 0x828E8E70,
- 0xD49EED28, 0xB1F95190, 0x5F56E482, 0x3A31583A,
- 0x83098FA7, 0xE66E331F, 0x08C1860D, 0x6DA63AB5,
- 0xA4E140BD, 0xC186FC05, 0x2F294917, 0x4A4EF5AF,
- 0xF3762232, 0x96119E8A, 0x78BE2B98, 0x1DD99720,
- 0x4BC9F478, 0x2EAE48C0, 0xC001FDD2, 0xA566416A,
- 0x1C5E96F7, 0x79392A4F, 0x97969F5D, 0xF2F123E5,
- 0x05196B4D, 0x607ED7F5, 0x8ED162E7, 0xEBB6DE5F,
- 0x528E09C2, 0x37E9B57A, 0xD9460068, 0xBC21BCD0,
- 0xEA31DF88, 0x8F566330, 0x61F9D622, 0x049E6A9A,
- 0xBDA6BD07, 0xD8C101BF, 0x366EB4AD, 0x53090815,
- 0x9A4E721D, 0xFF29CEA5, 0x11867BB7, 0x74E1C70F,
- 0xCDD91092, 0xA8BEAC2A, 0x46111938, 0x2376A580,
- 0x7566C6D8, 0x10017A60, 0xFEAECF72, 0x9BC973CA,
- 0x22F1A457, 0x479618EF, 0xA939ADFD, 0xCC5E1145,
- 0x06EE4D76, 0x6389F1CE, 0x8D2644DC, 0xE841F864,
- 0x51792FF9, 0x341E9341, 0xDAB12653, 0xBFD69AEB,
- 0xE9C6F9B3, 0x8CA1450B, 0x620EF019, 0x07694CA1,
- 0xBE519B3C, 0xDB362784, 0x35999296, 0x50FE2E2E,
- 0x99B95426, 0xFCDEE89E, 0x12715D8C, 0x7716E134,
- 0xCE2E36A9, 0xAB498A11, 0x45E63F03, 0x208183BB,
- 0x7691E0E3, 0x13F65C5B, 0xFD59E949, 0x983E55F1,
- 0x2106826C, 0x44613ED4, 0xAACE8BC6, 0xCFA9377E,
- 0x38417FD6, 0x5D26C36E, 0xB389767C, 0xD6EECAC4,
- 0x6FD61D59, 0x0AB1A1E1, 0xE41E14F3, 0x8179A84B,
- 0xD769CB13, 0xB20E77AB, 0x5CA1C2B9, 0x39C67E01,
- 0x80FEA99C, 0xE5991524, 0x0B36A036, 0x6E511C8E,
- 0xA7166686, 0xC271DA3E, 0x2CDE6F2C, 0x49B9D394,
- 0xF0810409, 0x95E6B8B1, 0x7B490DA3, 0x1E2EB11B,
- 0x483ED243, 0x2D596EFB, 0xC3F6DBE9, 0xA6916751,
- 0x1FA9B0CC, 0x7ACE0C74, 0x9461B966, 0xF10605DE
- }, {
- 0x00000000, 0xB029603D, 0x6053C07A, 0xD07AA047,
- 0xC0A680F5, 0x708FE0C8, 0xA0F5408F, 0x10DC20B2,
- 0xC14B7030, 0x7162100D, 0xA118B04A, 0x1131D077,
- 0x01EDF0C5, 0xB1C490F8, 0x61BE30BF, 0xD1975082,
- 0x8297E060, 0x32BE805D, 0xE2C4201A, 0x52ED4027,
- 0x42316095, 0xF21800A8, 0x2262A0EF, 0x924BC0D2,
- 0x43DC9050, 0xF3F5F06D, 0x238F502A, 0x93A63017,
- 0x837A10A5, 0x33537098, 0xE329D0DF, 0x5300B0E2,
- 0x042FC1C1, 0xB406A1FC, 0x647C01BB, 0xD4556186,
- 0xC4894134, 0x74A02109, 0xA4DA814E, 0x14F3E173,
- 0xC564B1F1, 0x754DD1CC, 0xA537718B, 0x151E11B6,
- 0x05C23104, 0xB5EB5139, 0x6591F17E, 0xD5B89143,
- 0x86B821A1, 0x3691419C, 0xE6EBE1DB, 0x56C281E6,
- 0x461EA154, 0xF637C169, 0x264D612E, 0x96640113,
- 0x47F35191, 0xF7DA31AC, 0x27A091EB, 0x9789F1D6,
- 0x8755D164, 0x377CB159, 0xE706111E, 0x572F7123,
- 0x4958F358, 0xF9719365, 0x290B3322, 0x9922531F,
- 0x89FE73AD, 0x39D71390, 0xE9ADB3D7, 0x5984D3EA,
- 0x88138368, 0x383AE355, 0xE8404312, 0x5869232F,
- 0x48B5039D, 0xF89C63A0, 0x28E6C3E7, 0x98CFA3DA,
- 0xCBCF1338, 0x7BE67305, 0xAB9CD342, 0x1BB5B37F,
- 0x0B6993CD, 0xBB40F3F0, 0x6B3A53B7, 0xDB13338A,
- 0x0A846308, 0xBAAD0335, 0x6AD7A372, 0xDAFEC34F,
- 0xCA22E3FD, 0x7A0B83C0, 0xAA712387, 0x1A5843BA,
- 0x4D773299, 0xFD5E52A4, 0x2D24F2E3, 0x9D0D92DE,
- 0x8DD1B26C, 0x3DF8D251, 0xED827216, 0x5DAB122B,
- 0x8C3C42A9, 0x3C152294, 0xEC6F82D3, 0x5C46E2EE,
- 0x4C9AC25C, 0xFCB3A261, 0x2CC90226, 0x9CE0621B,
- 0xCFE0D2F9, 0x7FC9B2C4, 0xAFB31283, 0x1F9A72BE,
- 0x0F46520C, 0xBF6F3231, 0x6F159276, 0xDF3CF24B,
- 0x0EABA2C9, 0xBE82C2F4, 0x6EF862B3, 0xDED1028E,
- 0xCE0D223C, 0x7E244201, 0xAE5EE246, 0x1E77827B,
- 0x92B0E6B1, 0x2299868C, 0xF2E326CB, 0x42CA46F6,
- 0x52166644, 0xE23F0679, 0x3245A63E, 0x826CC603,
- 0x53FB9681, 0xE3D2F6BC, 0x33A856FB, 0x838136C6,
- 0x935D1674, 0x23747649, 0xF30ED60E, 0x4327B633,
- 0x102706D1, 0xA00E66EC, 0x7074C6AB, 0xC05DA696,
- 0xD0818624, 0x60A8E619, 0xB0D2465E, 0x00FB2663,
- 0xD16C76E1, 0x614516DC, 0xB13FB69B, 0x0116D6A6,
- 0x11CAF614, 0xA1E39629, 0x7199366E, 0xC1B05653,
- 0x969F2770, 0x26B6474D, 0xF6CCE70A, 0x46E58737,
- 0x5639A785, 0xE610C7B8, 0x366A67FF, 0x864307C2,
- 0x57D45740, 0xE7FD377D, 0x3787973A, 0x87AEF707,
- 0x9772D7B5, 0x275BB788, 0xF72117CF, 0x470877F2,
- 0x1408C710, 0xA421A72D, 0x745B076A, 0xC4726757,
- 0xD4AE47E5, 0x648727D8, 0xB4FD879F, 0x04D4E7A2,
- 0xD543B720, 0x656AD71D, 0xB510775A, 0x05391767,
- 0x15E537D5, 0xA5CC57E8, 0x75B6F7AF, 0xC59F9792,
- 0xDBE815E9, 0x6BC175D4, 0xBBBBD593, 0x0B92B5AE,
- 0x1B4E951C, 0xAB67F521, 0x7B1D5566, 0xCB34355B,
- 0x1AA365D9, 0xAA8A05E4, 0x7AF0A5A3, 0xCAD9C59E,
- 0xDA05E52C, 0x6A2C8511, 0xBA562556, 0x0A7F456B,
- 0x597FF589, 0xE95695B4, 0x392C35F3, 0x890555CE,
- 0x99D9757C, 0x29F01541, 0xF98AB506, 0x49A3D53B,
- 0x983485B9, 0x281DE584, 0xF86745C3, 0x484E25FE,
- 0x5892054C, 0xE8BB6571, 0x38C1C536, 0x88E8A50B,
- 0xDFC7D428, 0x6FEEB415, 0xBF941452, 0x0FBD746F,
- 0x1F6154DD, 0xAF4834E0, 0x7F3294A7, 0xCF1BF49A,
- 0x1E8CA418, 0xAEA5C425, 0x7EDF6462, 0xCEF6045F,
- 0xDE2A24ED, 0x6E0344D0, 0xBE79E497, 0x0E5084AA,
- 0x5D503448, 0xED795475, 0x3D03F432, 0x8D2A940F,
- 0x9DF6B4BD, 0x2DDFD480, 0xFDA574C7, 0x4D8C14FA,
- 0x9C1B4478, 0x2C322445, 0xFC488402, 0x4C61E43F,
- 0x5CBDC48D, 0xEC94A4B0, 0x3CEE04F7, 0x8CC764CA
- }, {
- 0x00000000, 0xA5D35CCB, 0x0BA1C84D, 0xAE729486,
- 0x1642919B, 0xB391CD50, 0x1DE359D6, 0xB830051D,
- 0x6D8253EC, 0xC8510F27, 0x66239BA1, 0xC3F0C76A,
- 0x7BC0C277, 0xDE139EBC, 0x70610A3A, 0xD5B256F1,
- 0x9B02D603, 0x3ED18AC8, 0x90A31E4E, 0x35704285,
- 0x8D404798, 0x28931B53, 0x86E18FD5, 0x2332D31E,
- 0xF68085EF, 0x5353D924, 0xFD214DA2, 0x58F21169,
- 0xE0C21474, 0x451148BF, 0xEB63DC39, 0x4EB080F2,
- 0x3605AC07, 0x93D6F0CC, 0x3DA4644A, 0x98773881,
- 0x20473D9C, 0x85946157, 0x2BE6F5D1, 0x8E35A91A,
- 0x5B87FFEB, 0xFE54A320, 0x502637A6, 0xF5F56B6D,
- 0x4DC56E70, 0xE81632BB, 0x4664A63D, 0xE3B7FAF6,
- 0xAD077A04, 0x08D426CF, 0xA6A6B249, 0x0375EE82,
- 0xBB45EB9F, 0x1E96B754, 0xB0E423D2, 0x15377F19,
- 0xC08529E8, 0x65567523, 0xCB24E1A5, 0x6EF7BD6E,
- 0xD6C7B873, 0x7314E4B8, 0xDD66703E, 0x78B52CF5,
- 0x6C0A580F, 0xC9D904C4, 0x67AB9042, 0xC278CC89,
- 0x7A48C994, 0xDF9B955F, 0x71E901D9, 0xD43A5D12,
- 0x01880BE3, 0xA45B5728, 0x0A29C3AE, 0xAFFA9F65,
- 0x17CA9A78, 0xB219C6B3, 0x1C6B5235, 0xB9B80EFE,
- 0xF7088E0C, 0x52DBD2C7, 0xFCA94641, 0x597A1A8A,
- 0xE14A1F97, 0x4499435C, 0xEAEBD7DA, 0x4F388B11,
- 0x9A8ADDE0, 0x3F59812B, 0x912B15AD, 0x34F84966,
- 0x8CC84C7B, 0x291B10B0, 0x87698436, 0x22BAD8FD,
- 0x5A0FF408, 0xFFDCA8C3, 0x51AE3C45, 0xF47D608E,
- 0x4C4D6593, 0xE99E3958, 0x47ECADDE, 0xE23FF115,
- 0x378DA7E4, 0x925EFB2F, 0x3C2C6FA9, 0x99FF3362,
- 0x21CF367F, 0x841C6AB4, 0x2A6EFE32, 0x8FBDA2F9,
- 0xC10D220B, 0x64DE7EC0, 0xCAACEA46, 0x6F7FB68D,
- 0xD74FB390, 0x729CEF5B, 0xDCEE7BDD, 0x793D2716,
- 0xAC8F71E7, 0x095C2D2C, 0xA72EB9AA, 0x02FDE561,
- 0xBACDE07C, 0x1F1EBCB7, 0xB16C2831, 0x14BF74FA,
- 0xD814B01E, 0x7DC7ECD5, 0xD3B57853, 0x76662498,
- 0xCE562185, 0x6B857D4E, 0xC5F7E9C8, 0x6024B503,
- 0xB596E3F2, 0x1045BF39, 0xBE372BBF, 0x1BE47774,
- 0xA3D47269, 0x06072EA2, 0xA875BA24, 0x0DA6E6EF,
- 0x4316661D, 0xE6C53AD6, 0x48B7AE50, 0xED64F29B,
- 0x5554F786, 0xF087AB4D, 0x5EF53FCB, 0xFB266300,
- 0x2E9435F1, 0x8B47693A, 0x2535FDBC, 0x80E6A177,
- 0x38D6A46A, 0x9D05F8A1, 0x33776C27, 0x96A430EC,
- 0xEE111C19, 0x4BC240D2, 0xE5B0D454, 0x4063889F,
- 0xF8538D82, 0x5D80D149, 0xF3F245CF, 0x56211904,
- 0x83934FF5, 0x2640133E, 0x883287B8, 0x2DE1DB73,
- 0x95D1DE6E, 0x300282A5, 0x9E701623, 0x3BA34AE8,
- 0x7513CA1A, 0xD0C096D1, 0x7EB20257, 0xDB615E9C,
- 0x63515B81, 0xC682074A, 0x68F093CC, 0xCD23CF07,
- 0x189199F6, 0xBD42C53D, 0x133051BB, 0xB6E30D70,
- 0x0ED3086D, 0xAB0054A6, 0x0572C020, 0xA0A19CEB,
- 0xB41EE811, 0x11CDB4DA, 0xBFBF205C, 0x1A6C7C97,
- 0xA25C798A, 0x078F2541, 0xA9FDB1C7, 0x0C2EED0C,
- 0xD99CBBFD, 0x7C4FE736, 0xD23D73B0, 0x77EE2F7B,
- 0xCFDE2A66, 0x6A0D76AD, 0xC47FE22B, 0x61ACBEE0,
- 0x2F1C3E12, 0x8ACF62D9, 0x24BDF65F, 0x816EAA94,
- 0x395EAF89, 0x9C8DF342, 0x32FF67C4, 0x972C3B0F,
- 0x429E6DFE, 0xE74D3135, 0x493FA5B3, 0xECECF978,
- 0x54DCFC65, 0xF10FA0AE, 0x5F7D3428, 0xFAAE68E3,
- 0x821B4416, 0x27C818DD, 0x89BA8C5B, 0x2C69D090,
- 0x9459D58D, 0x318A8946, 0x9FF81DC0, 0x3A2B410B,
- 0xEF9917FA, 0x4A4A4B31, 0xE438DFB7, 0x41EB837C,
- 0xF9DB8661, 0x5C08DAAA, 0xF27A4E2C, 0x57A912E7,
- 0x19199215, 0xBCCACEDE, 0x12B85A58, 0xB76B0693,
- 0x0F5B038E, 0xAA885F45, 0x04FACBC3, 0xA1299708,
- 0x749BC1F9, 0xD1489D32, 0x7F3A09B4, 0xDAE9557F,
- 0x62D95062, 0xC70A0CA9, 0x6978982F, 0xCCABC4E4
- }, {
- 0x00000000, 0xB40B77A6, 0x29119F97, 0x9D1AE831,
- 0x13244FF4, 0xA72F3852, 0x3A35D063, 0x8E3EA7C5,
- 0x674EEF33, 0xD3459895, 0x4E5F70A4, 0xFA540702,
- 0x746AA0C7, 0xC061D761, 0x5D7B3F50, 0xE97048F6,
- 0xCE9CDE67, 0x7A97A9C1, 0xE78D41F0, 0x53863656,
- 0xDDB89193, 0x69B3E635, 0xF4A90E04, 0x40A279A2,
- 0xA9D23154, 0x1DD946F2, 0x80C3AEC3, 0x34C8D965,
- 0xBAF67EA0, 0x0EFD0906, 0x93E7E137, 0x27EC9691,
- 0x9C39BDCF, 0x2832CA69, 0xB5282258, 0x012355FE,
- 0x8F1DF23B, 0x3B16859D, 0xA60C6DAC, 0x12071A0A,
- 0xFB7752FC, 0x4F7C255A, 0xD266CD6B, 0x666DBACD,
- 0xE8531D08, 0x5C586AAE, 0xC142829F, 0x7549F539,
- 0x52A563A8, 0xE6AE140E, 0x7BB4FC3F, 0xCFBF8B99,
- 0x41812C5C, 0xF58A5BFA, 0x6890B3CB, 0xDC9BC46D,
- 0x35EB8C9B, 0x81E0FB3D, 0x1CFA130C, 0xA8F164AA,
- 0x26CFC36F, 0x92C4B4C9, 0x0FDE5CF8, 0xBBD52B5E,
- 0x79750B44, 0xCD7E7CE2, 0x506494D3, 0xE46FE375,
- 0x6A5144B0, 0xDE5A3316, 0x4340DB27, 0xF74BAC81,
- 0x1E3BE477, 0xAA3093D1, 0x372A7BE0, 0x83210C46,
- 0x0D1FAB83, 0xB914DC25, 0x240E3414, 0x900543B2,
- 0xB7E9D523, 0x03E2A285, 0x9EF84AB4, 0x2AF33D12,
- 0xA4CD9AD7, 0x10C6ED71, 0x8DDC0540, 0x39D772E6,
- 0xD0A73A10, 0x64AC4DB6, 0xF9B6A587, 0x4DBDD221,
- 0xC38375E4, 0x77880242, 0xEA92EA73, 0x5E999DD5,
- 0xE54CB68B, 0x5147C12D, 0xCC5D291C, 0x78565EBA,
- 0xF668F97F, 0x42638ED9, 0xDF7966E8, 0x6B72114E,
- 0x820259B8, 0x36092E1E, 0xAB13C62F, 0x1F18B189,
- 0x9126164C, 0x252D61EA, 0xB83789DB, 0x0C3CFE7D,
- 0x2BD068EC, 0x9FDB1F4A, 0x02C1F77B, 0xB6CA80DD,
- 0x38F42718, 0x8CFF50BE, 0x11E5B88F, 0xA5EECF29,
- 0x4C9E87DF, 0xF895F079, 0x658F1848, 0xD1846FEE,
- 0x5FBAC82B, 0xEBB1BF8D, 0x76AB57BC, 0xC2A0201A,
- 0xF2EA1688, 0x46E1612E, 0xDBFB891F, 0x6FF0FEB9,
- 0xE1CE597C, 0x55C52EDA, 0xC8DFC6EB, 0x7CD4B14D,
- 0x95A4F9BB, 0x21AF8E1D, 0xBCB5662C, 0x08BE118A,
- 0x8680B64F, 0x328BC1E9, 0xAF9129D8, 0x1B9A5E7E,
- 0x3C76C8EF, 0x887DBF49, 0x15675778, 0xA16C20DE,
- 0x2F52871B, 0x9B59F0BD, 0x0643188C, 0xB2486F2A,
- 0x5B3827DC, 0xEF33507A, 0x7229B84B, 0xC622CFED,
- 0x481C6828, 0xFC171F8E, 0x610DF7BF, 0xD5068019,
- 0x6ED3AB47, 0xDAD8DCE1, 0x47C234D0, 0xF3C94376,
- 0x7DF7E4B3, 0xC9FC9315, 0x54E67B24, 0xE0ED0C82,
- 0x099D4474, 0xBD9633D2, 0x208CDBE3, 0x9487AC45,
- 0x1AB90B80, 0xAEB27C26, 0x33A89417, 0x87A3E3B1,
- 0xA04F7520, 0x14440286, 0x895EEAB7, 0x3D559D11,
- 0xB36B3AD4, 0x07604D72, 0x9A7AA543, 0x2E71D2E5,
- 0xC7019A13, 0x730AEDB5, 0xEE100584, 0x5A1B7222,
- 0xD425D5E7, 0x602EA241, 0xFD344A70, 0x493F3DD6,
- 0x8B9F1DCC, 0x3F946A6A, 0xA28E825B, 0x1685F5FD,
- 0x98BB5238, 0x2CB0259E, 0xB1AACDAF, 0x05A1BA09,
- 0xECD1F2FF, 0x58DA8559, 0xC5C06D68, 0x71CB1ACE,
- 0xFFF5BD0B, 0x4BFECAAD, 0xD6E4229C, 0x62EF553A,
- 0x4503C3AB, 0xF108B40D, 0x6C125C3C, 0xD8192B9A,
- 0x56278C5F, 0xE22CFBF9, 0x7F3613C8, 0xCB3D646E,
- 0x224D2C98, 0x96465B3E, 0x0B5CB30F, 0xBF57C4A9,
- 0x3169636C, 0x856214CA, 0x1878FCFB, 0xAC738B5D,
- 0x17A6A003, 0xA3ADD7A5, 0x3EB73F94, 0x8ABC4832,
- 0x0482EFF7, 0xB0899851, 0x2D937060, 0x999807C6,
- 0x70E84F30, 0xC4E33896, 0x59F9D0A7, 0xEDF2A701,
- 0x63CC00C4, 0xD7C77762, 0x4ADD9F53, 0xFED6E8F5,
- 0xD93A7E64, 0x6D3109C2, 0xF02BE1F3, 0x44209655,
- 0xCA1E3190, 0x7E154636, 0xE30FAE07, 0x5704D9A1,
- 0xBE749157, 0x0A7FE6F1, 0x97650EC0, 0x236E7966,
- 0xAD50DEA3, 0x195BA905, 0x84414134, 0x304A3692
- }, {
- 0x00000000, 0x9E00AACC, 0x7D072542, 0xE3078F8E,
- 0xFA0E4A84, 0x640EE048, 0x87096FC6, 0x1909C50A,
- 0xB51BE5D3, 0x2B1B4F1F, 0xC81CC091, 0x561C6A5D,
- 0x4F15AF57, 0xD115059B, 0x32128A15, 0xAC1220D9,
- 0x2B31BB7C, 0xB53111B0, 0x56369E3E, 0xC83634F2,
- 0xD13FF1F8, 0x4F3F5B34, 0xAC38D4BA, 0x32387E76,
- 0x9E2A5EAF, 0x002AF463, 0xE32D7BED, 0x7D2DD121,
- 0x6424142B, 0xFA24BEE7, 0x19233169, 0x87239BA5,
- 0x566276F9, 0xC862DC35, 0x2B6553BB, 0xB565F977,
- 0xAC6C3C7D, 0x326C96B1, 0xD16B193F, 0x4F6BB3F3,
- 0xE379932A, 0x7D7939E6, 0x9E7EB668, 0x007E1CA4,
- 0x1977D9AE, 0x87777362, 0x6470FCEC, 0xFA705620,
- 0x7D53CD85, 0xE3536749, 0x0054E8C7, 0x9E54420B,
- 0x875D8701, 0x195D2DCD, 0xFA5AA243, 0x645A088F,
- 0xC8482856, 0x5648829A, 0xB54F0D14, 0x2B4FA7D8,
- 0x324662D2, 0xAC46C81E, 0x4F414790, 0xD141ED5C,
- 0xEDC29D29, 0x73C237E5, 0x90C5B86B, 0x0EC512A7,
- 0x17CCD7AD, 0x89CC7D61, 0x6ACBF2EF, 0xF4CB5823,
- 0x58D978FA, 0xC6D9D236, 0x25DE5DB8, 0xBBDEF774,
- 0xA2D7327E, 0x3CD798B2, 0xDFD0173C, 0x41D0BDF0,
- 0xC6F32655, 0x58F38C99, 0xBBF40317, 0x25F4A9DB,
- 0x3CFD6CD1, 0xA2FDC61D, 0x41FA4993, 0xDFFAE35F,
- 0x73E8C386, 0xEDE8694A, 0x0EEFE6C4, 0x90EF4C08,
- 0x89E68902, 0x17E623CE, 0xF4E1AC40, 0x6AE1068C,
- 0xBBA0EBD0, 0x25A0411C, 0xC6A7CE92, 0x58A7645E,
- 0x41AEA154, 0xDFAE0B98, 0x3CA98416, 0xA2A92EDA,
- 0x0EBB0E03, 0x90BBA4CF, 0x73BC2B41, 0xEDBC818D,
- 0xF4B54487, 0x6AB5EE4B, 0x89B261C5, 0x17B2CB09,
- 0x909150AC, 0x0E91FA60, 0xED9675EE, 0x7396DF22,
- 0x6A9F1A28, 0xF49FB0E4, 0x17983F6A, 0x899895A6,
- 0x258AB57F, 0xBB8A1FB3, 0x588D903D, 0xC68D3AF1,
- 0xDF84FFFB, 0x41845537, 0xA283DAB9, 0x3C837075,
- 0xDA853B53, 0x4485919F, 0xA7821E11, 0x3982B4DD,
- 0x208B71D7, 0xBE8BDB1B, 0x5D8C5495, 0xC38CFE59,
- 0x6F9EDE80, 0xF19E744C, 0x1299FBC2, 0x8C99510E,
- 0x95909404, 0x0B903EC8, 0xE897B146, 0x76971B8A,
- 0xF1B4802F, 0x6FB42AE3, 0x8CB3A56D, 0x12B30FA1,
- 0x0BBACAAB, 0x95BA6067, 0x76BDEFE9, 0xE8BD4525,
- 0x44AF65FC, 0xDAAFCF30, 0x39A840BE, 0xA7A8EA72,
- 0xBEA12F78, 0x20A185B4, 0xC3A60A3A, 0x5DA6A0F6,
- 0x8CE74DAA, 0x12E7E766, 0xF1E068E8, 0x6FE0C224,
- 0x76E9072E, 0xE8E9ADE2, 0x0BEE226C, 0x95EE88A0,
- 0x39FCA879, 0xA7FC02B5, 0x44FB8D3B, 0xDAFB27F7,
- 0xC3F2E2FD, 0x5DF24831, 0xBEF5C7BF, 0x20F56D73,
- 0xA7D6F6D6, 0x39D65C1A, 0xDAD1D394, 0x44D17958,
- 0x5DD8BC52, 0xC3D8169E, 0x20DF9910, 0xBEDF33DC,
- 0x12CD1305, 0x8CCDB9C9, 0x6FCA3647, 0xF1CA9C8B,
- 0xE8C35981, 0x76C3F34D, 0x95C47CC3, 0x0BC4D60F,
- 0x3747A67A, 0xA9470CB6, 0x4A408338, 0xD44029F4,
- 0xCD49ECFE, 0x53494632, 0xB04EC9BC, 0x2E4E6370,
- 0x825C43A9, 0x1C5CE965, 0xFF5B66EB, 0x615BCC27,
- 0x7852092D, 0xE652A3E1, 0x05552C6F, 0x9B5586A3,
- 0x1C761D06, 0x8276B7CA, 0x61713844, 0xFF719288,
- 0xE6785782, 0x7878FD4E, 0x9B7F72C0, 0x057FD80C,
- 0xA96DF8D5, 0x376D5219, 0xD46ADD97, 0x4A6A775B,
- 0x5363B251, 0xCD63189D, 0x2E649713, 0xB0643DDF,
- 0x6125D083, 0xFF257A4F, 0x1C22F5C1, 0x82225F0D,
- 0x9B2B9A07, 0x052B30CB, 0xE62CBF45, 0x782C1589,
- 0xD43E3550, 0x4A3E9F9C, 0xA9391012, 0x3739BADE,
- 0x2E307FD4, 0xB030D518, 0x53375A96, 0xCD37F05A,
- 0x4A146BFF, 0xD414C133, 0x37134EBD, 0xA913E471,
- 0xB01A217B, 0x2E1A8BB7, 0xCD1D0439, 0x531DAEF5,
- 0xFF0F8E2C, 0x610F24E0, 0x8208AB6E, 0x1C0801A2,
- 0x0501C4A8, 0x9B016E64, 0x7806E1EA, 0xE6064B26
- }
-};
diff -Nru r-base-3.2.3/src/extra/xz/check/crc32_table.c r-base-3.3.1/src/extra/xz/check/crc32_table.c
--- r-base-3.2.3/src/extra/xz/check/crc32_table.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc32_table.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,19 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file crc32_table.c
-/// \brief Precalculated CRC32 table with correct endianness
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-
-#ifdef WORDS_BIGENDIAN
-# include "crc32_table_be.h"
-#else
-# include "crc32_table_le.h"
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/check/crc32_tablegen.c r-base-3.3.1/src/extra/xz/check/crc32_tablegen.c
--- r-base-3.2.3/src/extra/xz/check/crc32_tablegen.c 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc32_tablegen.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,117 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file crc32_tablegen.c
-/// \brief Generate crc32_table_le.h and crc32_table_be.h
-///
-/// Compiling: gcc -std=c99 -o crc32_tablegen crc32_tablegen.c
-/// Add -DWORDS_BIGENDIAN to generate big endian table.
-/// Add -DLZ_HASH_TABLE to generate lz_encoder_hash_table.h (little endian).
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include
-#include "../../common/tuklib_integer.h"
-
-
-static uint32_t crc32_table[8][256];
-
-
-static void
-init_crc32_table(void)
-{
- static const uint32_t poly32 = UINT32_C(0xEDB88320);
-
- for (size_t s = 0; s < 8; ++s) {
- for (size_t b = 0; b < 256; ++b) {
- uint32_t r = s == 0 ? b : crc32_table[s - 1][b];
-
- for (size_t i = 0; i < 8; ++i) {
- if (r & 1)
- r = (r >> 1) ^ poly32;
- else
- r >>= 1;
- }
-
- crc32_table[s][b] = r;
- }
- }
-
-#ifdef WORDS_BIGENDIAN
- for (size_t s = 0; s < 8; ++s)
- for (size_t b = 0; b < 256; ++b)
- crc32_table[s][b] = bswap32(crc32_table[s][b]);
-#endif
-
- return;
-}
-
-
-static void
-print_crc32_table(void)
-{
- printf("/* This file has been automatically generated by "
- "crc32_tablegen.c. */\n\n"
- "const uint32_t lzma_crc32_table[8][256] = {\n\t{");
-
- for (size_t s = 0; s < 8; ++s) {
- for (size_t b = 0; b < 256; ++b) {
- if ((b % 4) == 0)
- printf("\n\t\t");
-
- printf("0x%08" PRIX32, crc32_table[s][b]);
-
- if (b != 255)
- printf(",%s", (b+1) % 4 == 0 ? "" : " ");
- }
-
- if (s == 7)
- printf("\n\t}\n};\n");
- else
- printf("\n\t}, {");
- }
-
- return;
-}
-
-
-static void
-print_lz_table(void)
-{
- printf("/* This file has been automatically generated by "
- "crc32_tablegen.c. */\n\n"
- "const uint32_t lzma_lz_hash_table[256] = {");
-
- for (size_t b = 0; b < 256; ++b) {
- if ((b % 4) == 0)
- printf("\n\t");
-
- printf("0x%08" PRIX32, crc32_table[0][b]);
-
- if (b != 255)
- printf(",%s", (b+1) % 4 == 0 ? "" : " ");
- }
-
- printf("\n};\n");
-
- return;
-}
-
-
-int
-main(void)
-{
- init_crc32_table();
-
-#ifdef LZ_HASH_TABLE
- print_lz_table();
-#else
- print_crc32_table();
-#endif
-
- return 0;
-}
diff -Nru r-base-3.2.3/src/extra/xz/check/crc32_table_le.h r-base-3.3.1/src/extra/xz/check/crc32_table_le.h
--- r-base-3.2.3/src/extra/xz/check/crc32_table_le.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc32_table_le.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,525 +0,0 @@
-/* This file has been automatically generated by crc32_tablegen.c. */
-
-const uint32_t lzma_crc32_table[8][256] = {
- {
- 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
- 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
- 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
- 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
- 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
- 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
- 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
- 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
- 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
- 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
- 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
- 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
- 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
- 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
- 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
- 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
- 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
- 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
- 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
- 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
- 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
- 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
- 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
- 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
- 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
- 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
- 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
- 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
- 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
- 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
- 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
- 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
- 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
- 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
- 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
- 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
- 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
- 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
- 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
- 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
- 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
- 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
- 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
- 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
- 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
- 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
- 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
- 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
- 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
- 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
- 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
- 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
- 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
- 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
- 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
- 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
- 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
- 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
- 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
- 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
- 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
- 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
- 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
- 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
- }, {
- 0x00000000, 0x191B3141, 0x32366282, 0x2B2D53C3,
- 0x646CC504, 0x7D77F445, 0x565AA786, 0x4F4196C7,
- 0xC8D98A08, 0xD1C2BB49, 0xFAEFE88A, 0xE3F4D9CB,
- 0xACB54F0C, 0xB5AE7E4D, 0x9E832D8E, 0x87981CCF,
- 0x4AC21251, 0x53D92310, 0x78F470D3, 0x61EF4192,
- 0x2EAED755, 0x37B5E614, 0x1C98B5D7, 0x05838496,
- 0x821B9859, 0x9B00A918, 0xB02DFADB, 0xA936CB9A,
- 0xE6775D5D, 0xFF6C6C1C, 0xD4413FDF, 0xCD5A0E9E,
- 0x958424A2, 0x8C9F15E3, 0xA7B24620, 0xBEA97761,
- 0xF1E8E1A6, 0xE8F3D0E7, 0xC3DE8324, 0xDAC5B265,
- 0x5D5DAEAA, 0x44469FEB, 0x6F6BCC28, 0x7670FD69,
- 0x39316BAE, 0x202A5AEF, 0x0B07092C, 0x121C386D,
- 0xDF4636F3, 0xC65D07B2, 0xED705471, 0xF46B6530,
- 0xBB2AF3F7, 0xA231C2B6, 0x891C9175, 0x9007A034,
- 0x179FBCFB, 0x0E848DBA, 0x25A9DE79, 0x3CB2EF38,
- 0x73F379FF, 0x6AE848BE, 0x41C51B7D, 0x58DE2A3C,
- 0xF0794F05, 0xE9627E44, 0xC24F2D87, 0xDB541CC6,
- 0x94158A01, 0x8D0EBB40, 0xA623E883, 0xBF38D9C2,
- 0x38A0C50D, 0x21BBF44C, 0x0A96A78F, 0x138D96CE,
- 0x5CCC0009, 0x45D73148, 0x6EFA628B, 0x77E153CA,
- 0xBABB5D54, 0xA3A06C15, 0x888D3FD6, 0x91960E97,
- 0xDED79850, 0xC7CCA911, 0xECE1FAD2, 0xF5FACB93,
- 0x7262D75C, 0x6B79E61D, 0x4054B5DE, 0x594F849F,
- 0x160E1258, 0x0F152319, 0x243870DA, 0x3D23419B,
- 0x65FD6BA7, 0x7CE65AE6, 0x57CB0925, 0x4ED03864,
- 0x0191AEA3, 0x188A9FE2, 0x33A7CC21, 0x2ABCFD60,
- 0xAD24E1AF, 0xB43FD0EE, 0x9F12832D, 0x8609B26C,
- 0xC94824AB, 0xD05315EA, 0xFB7E4629, 0xE2657768,
- 0x2F3F79F6, 0x362448B7, 0x1D091B74, 0x04122A35,
- 0x4B53BCF2, 0x52488DB3, 0x7965DE70, 0x607EEF31,
- 0xE7E6F3FE, 0xFEFDC2BF, 0xD5D0917C, 0xCCCBA03D,
- 0x838A36FA, 0x9A9107BB, 0xB1BC5478, 0xA8A76539,
- 0x3B83984B, 0x2298A90A, 0x09B5FAC9, 0x10AECB88,
- 0x5FEF5D4F, 0x46F46C0E, 0x6DD93FCD, 0x74C20E8C,
- 0xF35A1243, 0xEA412302, 0xC16C70C1, 0xD8774180,
- 0x9736D747, 0x8E2DE606, 0xA500B5C5, 0xBC1B8484,
- 0x71418A1A, 0x685ABB5B, 0x4377E898, 0x5A6CD9D9,
- 0x152D4F1E, 0x0C367E5F, 0x271B2D9C, 0x3E001CDD,
- 0xB9980012, 0xA0833153, 0x8BAE6290, 0x92B553D1,
- 0xDDF4C516, 0xC4EFF457, 0xEFC2A794, 0xF6D996D5,
- 0xAE07BCE9, 0xB71C8DA8, 0x9C31DE6B, 0x852AEF2A,
- 0xCA6B79ED, 0xD37048AC, 0xF85D1B6F, 0xE1462A2E,
- 0x66DE36E1, 0x7FC507A0, 0x54E85463, 0x4DF36522,
- 0x02B2F3E5, 0x1BA9C2A4, 0x30849167, 0x299FA026,
- 0xE4C5AEB8, 0xFDDE9FF9, 0xD6F3CC3A, 0xCFE8FD7B,
- 0x80A96BBC, 0x99B25AFD, 0xB29F093E, 0xAB84387F,
- 0x2C1C24B0, 0x350715F1, 0x1E2A4632, 0x07317773,
- 0x4870E1B4, 0x516BD0F5, 0x7A468336, 0x635DB277,
- 0xCBFAD74E, 0xD2E1E60F, 0xF9CCB5CC, 0xE0D7848D,
- 0xAF96124A, 0xB68D230B, 0x9DA070C8, 0x84BB4189,
- 0x03235D46, 0x1A386C07, 0x31153FC4, 0x280E0E85,
- 0x674F9842, 0x7E54A903, 0x5579FAC0, 0x4C62CB81,
- 0x8138C51F, 0x9823F45E, 0xB30EA79D, 0xAA1596DC,
- 0xE554001B, 0xFC4F315A, 0xD7626299, 0xCE7953D8,
- 0x49E14F17, 0x50FA7E56, 0x7BD72D95, 0x62CC1CD4,
- 0x2D8D8A13, 0x3496BB52, 0x1FBBE891, 0x06A0D9D0,
- 0x5E7EF3EC, 0x4765C2AD, 0x6C48916E, 0x7553A02F,
- 0x3A1236E8, 0x230907A9, 0x0824546A, 0x113F652B,
- 0x96A779E4, 0x8FBC48A5, 0xA4911B66, 0xBD8A2A27,
- 0xF2CBBCE0, 0xEBD08DA1, 0xC0FDDE62, 0xD9E6EF23,
- 0x14BCE1BD, 0x0DA7D0FC, 0x268A833F, 0x3F91B27E,
- 0x70D024B9, 0x69CB15F8, 0x42E6463B, 0x5BFD777A,
- 0xDC656BB5, 0xC57E5AF4, 0xEE530937, 0xF7483876,
- 0xB809AEB1, 0xA1129FF0, 0x8A3FCC33, 0x9324FD72
- }, {
- 0x00000000, 0x01C26A37, 0x0384D46E, 0x0246BE59,
- 0x0709A8DC, 0x06CBC2EB, 0x048D7CB2, 0x054F1685,
- 0x0E1351B8, 0x0FD13B8F, 0x0D9785D6, 0x0C55EFE1,
- 0x091AF964, 0x08D89353, 0x0A9E2D0A, 0x0B5C473D,
- 0x1C26A370, 0x1DE4C947, 0x1FA2771E, 0x1E601D29,
- 0x1B2F0BAC, 0x1AED619B, 0x18ABDFC2, 0x1969B5F5,
- 0x1235F2C8, 0x13F798FF, 0x11B126A6, 0x10734C91,
- 0x153C5A14, 0x14FE3023, 0x16B88E7A, 0x177AE44D,
- 0x384D46E0, 0x398F2CD7, 0x3BC9928E, 0x3A0BF8B9,
- 0x3F44EE3C, 0x3E86840B, 0x3CC03A52, 0x3D025065,
- 0x365E1758, 0x379C7D6F, 0x35DAC336, 0x3418A901,
- 0x3157BF84, 0x3095D5B3, 0x32D36BEA, 0x331101DD,
- 0x246BE590, 0x25A98FA7, 0x27EF31FE, 0x262D5BC9,
- 0x23624D4C, 0x22A0277B, 0x20E69922, 0x2124F315,
- 0x2A78B428, 0x2BBADE1F, 0x29FC6046, 0x283E0A71,
- 0x2D711CF4, 0x2CB376C3, 0x2EF5C89A, 0x2F37A2AD,
- 0x709A8DC0, 0x7158E7F7, 0x731E59AE, 0x72DC3399,
- 0x7793251C, 0x76514F2B, 0x7417F172, 0x75D59B45,
- 0x7E89DC78, 0x7F4BB64F, 0x7D0D0816, 0x7CCF6221,
- 0x798074A4, 0x78421E93, 0x7A04A0CA, 0x7BC6CAFD,
- 0x6CBC2EB0, 0x6D7E4487, 0x6F38FADE, 0x6EFA90E9,
- 0x6BB5866C, 0x6A77EC5B, 0x68315202, 0x69F33835,
- 0x62AF7F08, 0x636D153F, 0x612BAB66, 0x60E9C151,
- 0x65A6D7D4, 0x6464BDE3, 0x662203BA, 0x67E0698D,
- 0x48D7CB20, 0x4915A117, 0x4B531F4E, 0x4A917579,
- 0x4FDE63FC, 0x4E1C09CB, 0x4C5AB792, 0x4D98DDA5,
- 0x46C49A98, 0x4706F0AF, 0x45404EF6, 0x448224C1,
- 0x41CD3244, 0x400F5873, 0x4249E62A, 0x438B8C1D,
- 0x54F16850, 0x55330267, 0x5775BC3E, 0x56B7D609,
- 0x53F8C08C, 0x523AAABB, 0x507C14E2, 0x51BE7ED5,
- 0x5AE239E8, 0x5B2053DF, 0x5966ED86, 0x58A487B1,
- 0x5DEB9134, 0x5C29FB03, 0x5E6F455A, 0x5FAD2F6D,
- 0xE1351B80, 0xE0F771B7, 0xE2B1CFEE, 0xE373A5D9,
- 0xE63CB35C, 0xE7FED96B, 0xE5B86732, 0xE47A0D05,
- 0xEF264A38, 0xEEE4200F, 0xECA29E56, 0xED60F461,
- 0xE82FE2E4, 0xE9ED88D3, 0xEBAB368A, 0xEA695CBD,
- 0xFD13B8F0, 0xFCD1D2C7, 0xFE976C9E, 0xFF5506A9,
- 0xFA1A102C, 0xFBD87A1B, 0xF99EC442, 0xF85CAE75,
- 0xF300E948, 0xF2C2837F, 0xF0843D26, 0xF1465711,
- 0xF4094194, 0xF5CB2BA3, 0xF78D95FA, 0xF64FFFCD,
- 0xD9785D60, 0xD8BA3757, 0xDAFC890E, 0xDB3EE339,
- 0xDE71F5BC, 0xDFB39F8B, 0xDDF521D2, 0xDC374BE5,
- 0xD76B0CD8, 0xD6A966EF, 0xD4EFD8B6, 0xD52DB281,
- 0xD062A404, 0xD1A0CE33, 0xD3E6706A, 0xD2241A5D,
- 0xC55EFE10, 0xC49C9427, 0xC6DA2A7E, 0xC7184049,
- 0xC25756CC, 0xC3953CFB, 0xC1D382A2, 0xC011E895,
- 0xCB4DAFA8, 0xCA8FC59F, 0xC8C97BC6, 0xC90B11F1,
- 0xCC440774, 0xCD866D43, 0xCFC0D31A, 0xCE02B92D,
- 0x91AF9640, 0x906DFC77, 0x922B422E, 0x93E92819,
- 0x96A63E9C, 0x976454AB, 0x9522EAF2, 0x94E080C5,
- 0x9FBCC7F8, 0x9E7EADCF, 0x9C381396, 0x9DFA79A1,
- 0x98B56F24, 0x99770513, 0x9B31BB4A, 0x9AF3D17D,
- 0x8D893530, 0x8C4B5F07, 0x8E0DE15E, 0x8FCF8B69,
- 0x8A809DEC, 0x8B42F7DB, 0x89044982, 0x88C623B5,
- 0x839A6488, 0x82580EBF, 0x801EB0E6, 0x81DCDAD1,
- 0x8493CC54, 0x8551A663, 0x8717183A, 0x86D5720D,
- 0xA9E2D0A0, 0xA820BA97, 0xAA6604CE, 0xABA46EF9,
- 0xAEEB787C, 0xAF29124B, 0xAD6FAC12, 0xACADC625,
- 0xA7F18118, 0xA633EB2F, 0xA4755576, 0xA5B73F41,
- 0xA0F829C4, 0xA13A43F3, 0xA37CFDAA, 0xA2BE979D,
- 0xB5C473D0, 0xB40619E7, 0xB640A7BE, 0xB782CD89,
- 0xB2CDDB0C, 0xB30FB13B, 0xB1490F62, 0xB08B6555,
- 0xBBD72268, 0xBA15485F, 0xB853F606, 0xB9919C31,
- 0xBCDE8AB4, 0xBD1CE083, 0xBF5A5EDA, 0xBE9834ED
- }, {
- 0x00000000, 0xB8BC6765, 0xAA09C88B, 0x12B5AFEE,
- 0x8F629757, 0x37DEF032, 0x256B5FDC, 0x9DD738B9,
- 0xC5B428EF, 0x7D084F8A, 0x6FBDE064, 0xD7018701,
- 0x4AD6BFB8, 0xF26AD8DD, 0xE0DF7733, 0x58631056,
- 0x5019579F, 0xE8A530FA, 0xFA109F14, 0x42ACF871,
- 0xDF7BC0C8, 0x67C7A7AD, 0x75720843, 0xCDCE6F26,
- 0x95AD7F70, 0x2D111815, 0x3FA4B7FB, 0x8718D09E,
- 0x1ACFE827, 0xA2738F42, 0xB0C620AC, 0x087A47C9,
- 0xA032AF3E, 0x188EC85B, 0x0A3B67B5, 0xB28700D0,
- 0x2F503869, 0x97EC5F0C, 0x8559F0E2, 0x3DE59787,
- 0x658687D1, 0xDD3AE0B4, 0xCF8F4F5A, 0x7733283F,
- 0xEAE41086, 0x525877E3, 0x40EDD80D, 0xF851BF68,
- 0xF02BF8A1, 0x48979FC4, 0x5A22302A, 0xE29E574F,
- 0x7F496FF6, 0xC7F50893, 0xD540A77D, 0x6DFCC018,
- 0x359FD04E, 0x8D23B72B, 0x9F9618C5, 0x272A7FA0,
- 0xBAFD4719, 0x0241207C, 0x10F48F92, 0xA848E8F7,
- 0x9B14583D, 0x23A83F58, 0x311D90B6, 0x89A1F7D3,
- 0x1476CF6A, 0xACCAA80F, 0xBE7F07E1, 0x06C36084,
- 0x5EA070D2, 0xE61C17B7, 0xF4A9B859, 0x4C15DF3C,
- 0xD1C2E785, 0x697E80E0, 0x7BCB2F0E, 0xC377486B,
- 0xCB0D0FA2, 0x73B168C7, 0x6104C729, 0xD9B8A04C,
- 0x446F98F5, 0xFCD3FF90, 0xEE66507E, 0x56DA371B,
- 0x0EB9274D, 0xB6054028, 0xA4B0EFC6, 0x1C0C88A3,
- 0x81DBB01A, 0x3967D77F, 0x2BD27891, 0x936E1FF4,
- 0x3B26F703, 0x839A9066, 0x912F3F88, 0x299358ED,
- 0xB4446054, 0x0CF80731, 0x1E4DA8DF, 0xA6F1CFBA,
- 0xFE92DFEC, 0x462EB889, 0x549B1767, 0xEC277002,
- 0x71F048BB, 0xC94C2FDE, 0xDBF98030, 0x6345E755,
- 0x6B3FA09C, 0xD383C7F9, 0xC1366817, 0x798A0F72,
- 0xE45D37CB, 0x5CE150AE, 0x4E54FF40, 0xF6E89825,
- 0xAE8B8873, 0x1637EF16, 0x048240F8, 0xBC3E279D,
- 0x21E91F24, 0x99557841, 0x8BE0D7AF, 0x335CB0CA,
- 0xED59B63B, 0x55E5D15E, 0x47507EB0, 0xFFEC19D5,
- 0x623B216C, 0xDA874609, 0xC832E9E7, 0x708E8E82,
- 0x28ED9ED4, 0x9051F9B1, 0x82E4565F, 0x3A58313A,
- 0xA78F0983, 0x1F336EE6, 0x0D86C108, 0xB53AA66D,
- 0xBD40E1A4, 0x05FC86C1, 0x1749292F, 0xAFF54E4A,
- 0x322276F3, 0x8A9E1196, 0x982BBE78, 0x2097D91D,
- 0x78F4C94B, 0xC048AE2E, 0xD2FD01C0, 0x6A4166A5,
- 0xF7965E1C, 0x4F2A3979, 0x5D9F9697, 0xE523F1F2,
- 0x4D6B1905, 0xF5D77E60, 0xE762D18E, 0x5FDEB6EB,
- 0xC2098E52, 0x7AB5E937, 0x680046D9, 0xD0BC21BC,
- 0x88DF31EA, 0x3063568F, 0x22D6F961, 0x9A6A9E04,
- 0x07BDA6BD, 0xBF01C1D8, 0xADB46E36, 0x15080953,
- 0x1D724E9A, 0xA5CE29FF, 0xB77B8611, 0x0FC7E174,
- 0x9210D9CD, 0x2AACBEA8, 0x38191146, 0x80A57623,
- 0xD8C66675, 0x607A0110, 0x72CFAEFE, 0xCA73C99B,
- 0x57A4F122, 0xEF189647, 0xFDAD39A9, 0x45115ECC,
- 0x764DEE06, 0xCEF18963, 0xDC44268D, 0x64F841E8,
- 0xF92F7951, 0x41931E34, 0x5326B1DA, 0xEB9AD6BF,
- 0xB3F9C6E9, 0x0B45A18C, 0x19F00E62, 0xA14C6907,
- 0x3C9B51BE, 0x842736DB, 0x96929935, 0x2E2EFE50,
- 0x2654B999, 0x9EE8DEFC, 0x8C5D7112, 0x34E11677,
- 0xA9362ECE, 0x118A49AB, 0x033FE645, 0xBB838120,
- 0xE3E09176, 0x5B5CF613, 0x49E959FD, 0xF1553E98,
- 0x6C820621, 0xD43E6144, 0xC68BCEAA, 0x7E37A9CF,
- 0xD67F4138, 0x6EC3265D, 0x7C7689B3, 0xC4CAEED6,
- 0x591DD66F, 0xE1A1B10A, 0xF3141EE4, 0x4BA87981,
- 0x13CB69D7, 0xAB770EB2, 0xB9C2A15C, 0x017EC639,
- 0x9CA9FE80, 0x241599E5, 0x36A0360B, 0x8E1C516E,
- 0x866616A7, 0x3EDA71C2, 0x2C6FDE2C, 0x94D3B949,
- 0x090481F0, 0xB1B8E695, 0xA30D497B, 0x1BB12E1E,
- 0x43D23E48, 0xFB6E592D, 0xE9DBF6C3, 0x516791A6,
- 0xCCB0A91F, 0x740CCE7A, 0x66B96194, 0xDE0506F1
- }, {
- 0x00000000, 0x3D6029B0, 0x7AC05360, 0x47A07AD0,
- 0xF580A6C0, 0xC8E08F70, 0x8F40F5A0, 0xB220DC10,
- 0x30704BC1, 0x0D106271, 0x4AB018A1, 0x77D03111,
- 0xC5F0ED01, 0xF890C4B1, 0xBF30BE61, 0x825097D1,
- 0x60E09782, 0x5D80BE32, 0x1A20C4E2, 0x2740ED52,
- 0x95603142, 0xA80018F2, 0xEFA06222, 0xD2C04B92,
- 0x5090DC43, 0x6DF0F5F3, 0x2A508F23, 0x1730A693,
- 0xA5107A83, 0x98705333, 0xDFD029E3, 0xE2B00053,
- 0xC1C12F04, 0xFCA106B4, 0xBB017C64, 0x866155D4,
- 0x344189C4, 0x0921A074, 0x4E81DAA4, 0x73E1F314,
- 0xF1B164C5, 0xCCD14D75, 0x8B7137A5, 0xB6111E15,
- 0x0431C205, 0x3951EBB5, 0x7EF19165, 0x4391B8D5,
- 0xA121B886, 0x9C419136, 0xDBE1EBE6, 0xE681C256,
- 0x54A11E46, 0x69C137F6, 0x2E614D26, 0x13016496,
- 0x9151F347, 0xAC31DAF7, 0xEB91A027, 0xD6F18997,
- 0x64D15587, 0x59B17C37, 0x1E1106E7, 0x23712F57,
- 0x58F35849, 0x659371F9, 0x22330B29, 0x1F532299,
- 0xAD73FE89, 0x9013D739, 0xD7B3ADE9, 0xEAD38459,
- 0x68831388, 0x55E33A38, 0x124340E8, 0x2F236958,
- 0x9D03B548, 0xA0639CF8, 0xE7C3E628, 0xDAA3CF98,
- 0x3813CFCB, 0x0573E67B, 0x42D39CAB, 0x7FB3B51B,
- 0xCD93690B, 0xF0F340BB, 0xB7533A6B, 0x8A3313DB,
- 0x0863840A, 0x3503ADBA, 0x72A3D76A, 0x4FC3FEDA,
- 0xFDE322CA, 0xC0830B7A, 0x872371AA, 0xBA43581A,
- 0x9932774D, 0xA4525EFD, 0xE3F2242D, 0xDE920D9D,
- 0x6CB2D18D, 0x51D2F83D, 0x167282ED, 0x2B12AB5D,
- 0xA9423C8C, 0x9422153C, 0xD3826FEC, 0xEEE2465C,
- 0x5CC29A4C, 0x61A2B3FC, 0x2602C92C, 0x1B62E09C,
- 0xF9D2E0CF, 0xC4B2C97F, 0x8312B3AF, 0xBE729A1F,
- 0x0C52460F, 0x31326FBF, 0x7692156F, 0x4BF23CDF,
- 0xC9A2AB0E, 0xF4C282BE, 0xB362F86E, 0x8E02D1DE,
- 0x3C220DCE, 0x0142247E, 0x46E25EAE, 0x7B82771E,
- 0xB1E6B092, 0x8C869922, 0xCB26E3F2, 0xF646CA42,
- 0x44661652, 0x79063FE2, 0x3EA64532, 0x03C66C82,
- 0x8196FB53, 0xBCF6D2E3, 0xFB56A833, 0xC6368183,
- 0x74165D93, 0x49767423, 0x0ED60EF3, 0x33B62743,
- 0xD1062710, 0xEC660EA0, 0xABC67470, 0x96A65DC0,
- 0x248681D0, 0x19E6A860, 0x5E46D2B0, 0x6326FB00,
- 0xE1766CD1, 0xDC164561, 0x9BB63FB1, 0xA6D61601,
- 0x14F6CA11, 0x2996E3A1, 0x6E369971, 0x5356B0C1,
- 0x70279F96, 0x4D47B626, 0x0AE7CCF6, 0x3787E546,
- 0x85A73956, 0xB8C710E6, 0xFF676A36, 0xC2074386,
- 0x4057D457, 0x7D37FDE7, 0x3A978737, 0x07F7AE87,
- 0xB5D77297, 0x88B75B27, 0xCF1721F7, 0xF2770847,
- 0x10C70814, 0x2DA721A4, 0x6A075B74, 0x576772C4,
- 0xE547AED4, 0xD8278764, 0x9F87FDB4, 0xA2E7D404,
- 0x20B743D5, 0x1DD76A65, 0x5A7710B5, 0x67173905,
- 0xD537E515, 0xE857CCA5, 0xAFF7B675, 0x92979FC5,
- 0xE915E8DB, 0xD475C16B, 0x93D5BBBB, 0xAEB5920B,
- 0x1C954E1B, 0x21F567AB, 0x66551D7B, 0x5B3534CB,
- 0xD965A31A, 0xE4058AAA, 0xA3A5F07A, 0x9EC5D9CA,
- 0x2CE505DA, 0x11852C6A, 0x562556BA, 0x6B457F0A,
- 0x89F57F59, 0xB49556E9, 0xF3352C39, 0xCE550589,
- 0x7C75D999, 0x4115F029, 0x06B58AF9, 0x3BD5A349,
- 0xB9853498, 0x84E51D28, 0xC34567F8, 0xFE254E48,
- 0x4C059258, 0x7165BBE8, 0x36C5C138, 0x0BA5E888,
- 0x28D4C7DF, 0x15B4EE6F, 0x521494BF, 0x6F74BD0F,
- 0xDD54611F, 0xE03448AF, 0xA794327F, 0x9AF41BCF,
- 0x18A48C1E, 0x25C4A5AE, 0x6264DF7E, 0x5F04F6CE,
- 0xED242ADE, 0xD044036E, 0x97E479BE, 0xAA84500E,
- 0x4834505D, 0x755479ED, 0x32F4033D, 0x0F942A8D,
- 0xBDB4F69D, 0x80D4DF2D, 0xC774A5FD, 0xFA148C4D,
- 0x78441B9C, 0x4524322C, 0x028448FC, 0x3FE4614C,
- 0x8DC4BD5C, 0xB0A494EC, 0xF704EE3C, 0xCA64C78C
- }, {
- 0x00000000, 0xCB5CD3A5, 0x4DC8A10B, 0x869472AE,
- 0x9B914216, 0x50CD91B3, 0xD659E31D, 0x1D0530B8,
- 0xEC53826D, 0x270F51C8, 0xA19B2366, 0x6AC7F0C3,
- 0x77C2C07B, 0xBC9E13DE, 0x3A0A6170, 0xF156B2D5,
- 0x03D6029B, 0xC88AD13E, 0x4E1EA390, 0x85427035,
- 0x9847408D, 0x531B9328, 0xD58FE186, 0x1ED33223,
- 0xEF8580F6, 0x24D95353, 0xA24D21FD, 0x6911F258,
- 0x7414C2E0, 0xBF481145, 0x39DC63EB, 0xF280B04E,
- 0x07AC0536, 0xCCF0D693, 0x4A64A43D, 0x81387798,
- 0x9C3D4720, 0x57619485, 0xD1F5E62B, 0x1AA9358E,
- 0xEBFF875B, 0x20A354FE, 0xA6372650, 0x6D6BF5F5,
- 0x706EC54D, 0xBB3216E8, 0x3DA66446, 0xF6FAB7E3,
- 0x047A07AD, 0xCF26D408, 0x49B2A6A6, 0x82EE7503,
- 0x9FEB45BB, 0x54B7961E, 0xD223E4B0, 0x197F3715,
- 0xE82985C0, 0x23755665, 0xA5E124CB, 0x6EBDF76E,
- 0x73B8C7D6, 0xB8E41473, 0x3E7066DD, 0xF52CB578,
- 0x0F580A6C, 0xC404D9C9, 0x4290AB67, 0x89CC78C2,
- 0x94C9487A, 0x5F959BDF, 0xD901E971, 0x125D3AD4,
- 0xE30B8801, 0x28575BA4, 0xAEC3290A, 0x659FFAAF,
- 0x789ACA17, 0xB3C619B2, 0x35526B1C, 0xFE0EB8B9,
- 0x0C8E08F7, 0xC7D2DB52, 0x4146A9FC, 0x8A1A7A59,
- 0x971F4AE1, 0x5C439944, 0xDAD7EBEA, 0x118B384F,
- 0xE0DD8A9A, 0x2B81593F, 0xAD152B91, 0x6649F834,
- 0x7B4CC88C, 0xB0101B29, 0x36846987, 0xFDD8BA22,
- 0x08F40F5A, 0xC3A8DCFF, 0x453CAE51, 0x8E607DF4,
- 0x93654D4C, 0x58399EE9, 0xDEADEC47, 0x15F13FE2,
- 0xE4A78D37, 0x2FFB5E92, 0xA96F2C3C, 0x6233FF99,
- 0x7F36CF21, 0xB46A1C84, 0x32FE6E2A, 0xF9A2BD8F,
- 0x0B220DC1, 0xC07EDE64, 0x46EAACCA, 0x8DB67F6F,
- 0x90B34FD7, 0x5BEF9C72, 0xDD7BEEDC, 0x16273D79,
- 0xE7718FAC, 0x2C2D5C09, 0xAAB92EA7, 0x61E5FD02,
- 0x7CE0CDBA, 0xB7BC1E1F, 0x31286CB1, 0xFA74BF14,
- 0x1EB014D8, 0xD5ECC77D, 0x5378B5D3, 0x98246676,
- 0x852156CE, 0x4E7D856B, 0xC8E9F7C5, 0x03B52460,
- 0xF2E396B5, 0x39BF4510, 0xBF2B37BE, 0x7477E41B,
- 0x6972D4A3, 0xA22E0706, 0x24BA75A8, 0xEFE6A60D,
- 0x1D661643, 0xD63AC5E6, 0x50AEB748, 0x9BF264ED,
- 0x86F75455, 0x4DAB87F0, 0xCB3FF55E, 0x006326FB,
- 0xF135942E, 0x3A69478B, 0xBCFD3525, 0x77A1E680,
- 0x6AA4D638, 0xA1F8059D, 0x276C7733, 0xEC30A496,
- 0x191C11EE, 0xD240C24B, 0x54D4B0E5, 0x9F886340,
- 0x828D53F8, 0x49D1805D, 0xCF45F2F3, 0x04192156,
- 0xF54F9383, 0x3E134026, 0xB8873288, 0x73DBE12D,
- 0x6EDED195, 0xA5820230, 0x2316709E, 0xE84AA33B,
- 0x1ACA1375, 0xD196C0D0, 0x5702B27E, 0x9C5E61DB,
- 0x815B5163, 0x4A0782C6, 0xCC93F068, 0x07CF23CD,
- 0xF6999118, 0x3DC542BD, 0xBB513013, 0x700DE3B6,
- 0x6D08D30E, 0xA65400AB, 0x20C07205, 0xEB9CA1A0,
- 0x11E81EB4, 0xDAB4CD11, 0x5C20BFBF, 0x977C6C1A,
- 0x8A795CA2, 0x41258F07, 0xC7B1FDA9, 0x0CED2E0C,
- 0xFDBB9CD9, 0x36E74F7C, 0xB0733DD2, 0x7B2FEE77,
- 0x662ADECF, 0xAD760D6A, 0x2BE27FC4, 0xE0BEAC61,
- 0x123E1C2F, 0xD962CF8A, 0x5FF6BD24, 0x94AA6E81,
- 0x89AF5E39, 0x42F38D9C, 0xC467FF32, 0x0F3B2C97,
- 0xFE6D9E42, 0x35314DE7, 0xB3A53F49, 0x78F9ECEC,
- 0x65FCDC54, 0xAEA00FF1, 0x28347D5F, 0xE368AEFA,
- 0x16441B82, 0xDD18C827, 0x5B8CBA89, 0x90D0692C,
- 0x8DD55994, 0x46898A31, 0xC01DF89F, 0x0B412B3A,
- 0xFA1799EF, 0x314B4A4A, 0xB7DF38E4, 0x7C83EB41,
- 0x6186DBF9, 0xAADA085C, 0x2C4E7AF2, 0xE712A957,
- 0x15921919, 0xDECECABC, 0x585AB812, 0x93066BB7,
- 0x8E035B0F, 0x455F88AA, 0xC3CBFA04, 0x089729A1,
- 0xF9C19B74, 0x329D48D1, 0xB4093A7F, 0x7F55E9DA,
- 0x6250D962, 0xA90C0AC7, 0x2F987869, 0xE4C4ABCC
- }, {
- 0x00000000, 0xA6770BB4, 0x979F1129, 0x31E81A9D,
- 0xF44F2413, 0x52382FA7, 0x63D0353A, 0xC5A73E8E,
- 0x33EF4E67, 0x959845D3, 0xA4705F4E, 0x020754FA,
- 0xC7A06A74, 0x61D761C0, 0x503F7B5D, 0xF64870E9,
- 0x67DE9CCE, 0xC1A9977A, 0xF0418DE7, 0x56368653,
- 0x9391B8DD, 0x35E6B369, 0x040EA9F4, 0xA279A240,
- 0x5431D2A9, 0xF246D91D, 0xC3AEC380, 0x65D9C834,
- 0xA07EF6BA, 0x0609FD0E, 0x37E1E793, 0x9196EC27,
- 0xCFBD399C, 0x69CA3228, 0x582228B5, 0xFE552301,
- 0x3BF21D8F, 0x9D85163B, 0xAC6D0CA6, 0x0A1A0712,
- 0xFC5277FB, 0x5A257C4F, 0x6BCD66D2, 0xCDBA6D66,
- 0x081D53E8, 0xAE6A585C, 0x9F8242C1, 0x39F54975,
- 0xA863A552, 0x0E14AEE6, 0x3FFCB47B, 0x998BBFCF,
- 0x5C2C8141, 0xFA5B8AF5, 0xCBB39068, 0x6DC49BDC,
- 0x9B8CEB35, 0x3DFBE081, 0x0C13FA1C, 0xAA64F1A8,
- 0x6FC3CF26, 0xC9B4C492, 0xF85CDE0F, 0x5E2BD5BB,
- 0x440B7579, 0xE27C7ECD, 0xD3946450, 0x75E36FE4,
- 0xB044516A, 0x16335ADE, 0x27DB4043, 0x81AC4BF7,
- 0x77E43B1E, 0xD19330AA, 0xE07B2A37, 0x460C2183,
- 0x83AB1F0D, 0x25DC14B9, 0x14340E24, 0xB2430590,
- 0x23D5E9B7, 0x85A2E203, 0xB44AF89E, 0x123DF32A,
- 0xD79ACDA4, 0x71EDC610, 0x4005DC8D, 0xE672D739,
- 0x103AA7D0, 0xB64DAC64, 0x87A5B6F9, 0x21D2BD4D,
- 0xE47583C3, 0x42028877, 0x73EA92EA, 0xD59D995E,
- 0x8BB64CE5, 0x2DC14751, 0x1C295DCC, 0xBA5E5678,
- 0x7FF968F6, 0xD98E6342, 0xE86679DF, 0x4E11726B,
- 0xB8590282, 0x1E2E0936, 0x2FC613AB, 0x89B1181F,
- 0x4C162691, 0xEA612D25, 0xDB8937B8, 0x7DFE3C0C,
- 0xEC68D02B, 0x4A1FDB9F, 0x7BF7C102, 0xDD80CAB6,
- 0x1827F438, 0xBE50FF8C, 0x8FB8E511, 0x29CFEEA5,
- 0xDF879E4C, 0x79F095F8, 0x48188F65, 0xEE6F84D1,
- 0x2BC8BA5F, 0x8DBFB1EB, 0xBC57AB76, 0x1A20A0C2,
- 0x8816EAF2, 0x2E61E146, 0x1F89FBDB, 0xB9FEF06F,
- 0x7C59CEE1, 0xDA2EC555, 0xEBC6DFC8, 0x4DB1D47C,
- 0xBBF9A495, 0x1D8EAF21, 0x2C66B5BC, 0x8A11BE08,
- 0x4FB68086, 0xE9C18B32, 0xD82991AF, 0x7E5E9A1B,
- 0xEFC8763C, 0x49BF7D88, 0x78576715, 0xDE206CA1,
- 0x1B87522F, 0xBDF0599B, 0x8C184306, 0x2A6F48B2,
- 0xDC27385B, 0x7A5033EF, 0x4BB82972, 0xEDCF22C6,
- 0x28681C48, 0x8E1F17FC, 0xBFF70D61, 0x198006D5,
- 0x47ABD36E, 0xE1DCD8DA, 0xD034C247, 0x7643C9F3,
- 0xB3E4F77D, 0x1593FCC9, 0x247BE654, 0x820CEDE0,
- 0x74449D09, 0xD23396BD, 0xE3DB8C20, 0x45AC8794,
- 0x800BB91A, 0x267CB2AE, 0x1794A833, 0xB1E3A387,
- 0x20754FA0, 0x86024414, 0xB7EA5E89, 0x119D553D,
- 0xD43A6BB3, 0x724D6007, 0x43A57A9A, 0xE5D2712E,
- 0x139A01C7, 0xB5ED0A73, 0x840510EE, 0x22721B5A,
- 0xE7D525D4, 0x41A22E60, 0x704A34FD, 0xD63D3F49,
- 0xCC1D9F8B, 0x6A6A943F, 0x5B828EA2, 0xFDF58516,
- 0x3852BB98, 0x9E25B02C, 0xAFCDAAB1, 0x09BAA105,
- 0xFFF2D1EC, 0x5985DA58, 0x686DC0C5, 0xCE1ACB71,
- 0x0BBDF5FF, 0xADCAFE4B, 0x9C22E4D6, 0x3A55EF62,
- 0xABC30345, 0x0DB408F1, 0x3C5C126C, 0x9A2B19D8,
- 0x5F8C2756, 0xF9FB2CE2, 0xC813367F, 0x6E643DCB,
- 0x982C4D22, 0x3E5B4696, 0x0FB35C0B, 0xA9C457BF,
- 0x6C636931, 0xCA146285, 0xFBFC7818, 0x5D8B73AC,
- 0x03A0A617, 0xA5D7ADA3, 0x943FB73E, 0x3248BC8A,
- 0xF7EF8204, 0x519889B0, 0x6070932D, 0xC6079899,
- 0x304FE870, 0x9638E3C4, 0xA7D0F959, 0x01A7F2ED,
- 0xC400CC63, 0x6277C7D7, 0x539FDD4A, 0xF5E8D6FE,
- 0x647E3AD9, 0xC209316D, 0xF3E12BF0, 0x55962044,
- 0x90311ECA, 0x3646157E, 0x07AE0FE3, 0xA1D90457,
- 0x579174BE, 0xF1E67F0A, 0xC00E6597, 0x66796E23,
- 0xA3DE50AD, 0x05A95B19, 0x34414184, 0x92364A30
- }, {
- 0x00000000, 0xCCAA009E, 0x4225077D, 0x8E8F07E3,
- 0x844A0EFA, 0x48E00E64, 0xC66F0987, 0x0AC50919,
- 0xD3E51BB5, 0x1F4F1B2B, 0x91C01CC8, 0x5D6A1C56,
- 0x57AF154F, 0x9B0515D1, 0x158A1232, 0xD92012AC,
- 0x7CBB312B, 0xB01131B5, 0x3E9E3656, 0xF23436C8,
- 0xF8F13FD1, 0x345B3F4F, 0xBAD438AC, 0x767E3832,
- 0xAF5E2A9E, 0x63F42A00, 0xED7B2DE3, 0x21D12D7D,
- 0x2B142464, 0xE7BE24FA, 0x69312319, 0xA59B2387,
- 0xF9766256, 0x35DC62C8, 0xBB53652B, 0x77F965B5,
- 0x7D3C6CAC, 0xB1966C32, 0x3F196BD1, 0xF3B36B4F,
- 0x2A9379E3, 0xE639797D, 0x68B67E9E, 0xA41C7E00,
- 0xAED97719, 0x62737787, 0xECFC7064, 0x205670FA,
- 0x85CD537D, 0x496753E3, 0xC7E85400, 0x0B42549E,
- 0x01875D87, 0xCD2D5D19, 0x43A25AFA, 0x8F085A64,
- 0x562848C8, 0x9A824856, 0x140D4FB5, 0xD8A74F2B,
- 0xD2624632, 0x1EC846AC, 0x9047414F, 0x5CED41D1,
- 0x299DC2ED, 0xE537C273, 0x6BB8C590, 0xA712C50E,
- 0xADD7CC17, 0x617DCC89, 0xEFF2CB6A, 0x2358CBF4,
- 0xFA78D958, 0x36D2D9C6, 0xB85DDE25, 0x74F7DEBB,
- 0x7E32D7A2, 0xB298D73C, 0x3C17D0DF, 0xF0BDD041,
- 0x5526F3C6, 0x998CF358, 0x1703F4BB, 0xDBA9F425,
- 0xD16CFD3C, 0x1DC6FDA2, 0x9349FA41, 0x5FE3FADF,
- 0x86C3E873, 0x4A69E8ED, 0xC4E6EF0E, 0x084CEF90,
- 0x0289E689, 0xCE23E617, 0x40ACE1F4, 0x8C06E16A,
- 0xD0EBA0BB, 0x1C41A025, 0x92CEA7C6, 0x5E64A758,
- 0x54A1AE41, 0x980BAEDF, 0x1684A93C, 0xDA2EA9A2,
- 0x030EBB0E, 0xCFA4BB90, 0x412BBC73, 0x8D81BCED,
- 0x8744B5F4, 0x4BEEB56A, 0xC561B289, 0x09CBB217,
- 0xAC509190, 0x60FA910E, 0xEE7596ED, 0x22DF9673,
- 0x281A9F6A, 0xE4B09FF4, 0x6A3F9817, 0xA6959889,
- 0x7FB58A25, 0xB31F8ABB, 0x3D908D58, 0xF13A8DC6,
- 0xFBFF84DF, 0x37558441, 0xB9DA83A2, 0x7570833C,
- 0x533B85DA, 0x9F918544, 0x111E82A7, 0xDDB48239,
- 0xD7718B20, 0x1BDB8BBE, 0x95548C5D, 0x59FE8CC3,
- 0x80DE9E6F, 0x4C749EF1, 0xC2FB9912, 0x0E51998C,
- 0x04949095, 0xC83E900B, 0x46B197E8, 0x8A1B9776,
- 0x2F80B4F1, 0xE32AB46F, 0x6DA5B38C, 0xA10FB312,
- 0xABCABA0B, 0x6760BA95, 0xE9EFBD76, 0x2545BDE8,
- 0xFC65AF44, 0x30CFAFDA, 0xBE40A839, 0x72EAA8A7,
- 0x782FA1BE, 0xB485A120, 0x3A0AA6C3, 0xF6A0A65D,
- 0xAA4DE78C, 0x66E7E712, 0xE868E0F1, 0x24C2E06F,
- 0x2E07E976, 0xE2ADE9E8, 0x6C22EE0B, 0xA088EE95,
- 0x79A8FC39, 0xB502FCA7, 0x3B8DFB44, 0xF727FBDA,
- 0xFDE2F2C3, 0x3148F25D, 0xBFC7F5BE, 0x736DF520,
- 0xD6F6D6A7, 0x1A5CD639, 0x94D3D1DA, 0x5879D144,
- 0x52BCD85D, 0x9E16D8C3, 0x1099DF20, 0xDC33DFBE,
- 0x0513CD12, 0xC9B9CD8C, 0x4736CA6F, 0x8B9CCAF1,
- 0x8159C3E8, 0x4DF3C376, 0xC37CC495, 0x0FD6C40B,
- 0x7AA64737, 0xB60C47A9, 0x3883404A, 0xF42940D4,
- 0xFEEC49CD, 0x32464953, 0xBCC94EB0, 0x70634E2E,
- 0xA9435C82, 0x65E95C1C, 0xEB665BFF, 0x27CC5B61,
- 0x2D095278, 0xE1A352E6, 0x6F2C5505, 0xA386559B,
- 0x061D761C, 0xCAB77682, 0x44387161, 0x889271FF,
- 0x825778E6, 0x4EFD7878, 0xC0727F9B, 0x0CD87F05,
- 0xD5F86DA9, 0x19526D37, 0x97DD6AD4, 0x5B776A4A,
- 0x51B26353, 0x9D1863CD, 0x1397642E, 0xDF3D64B0,
- 0x83D02561, 0x4F7A25FF, 0xC1F5221C, 0x0D5F2282,
- 0x079A2B9B, 0xCB302B05, 0x45BF2CE6, 0x89152C78,
- 0x50353ED4, 0x9C9F3E4A, 0x121039A9, 0xDEBA3937,
- 0xD47F302E, 0x18D530B0, 0x965A3753, 0x5AF037CD,
- 0xFF6B144A, 0x33C114D4, 0xBD4E1337, 0x71E413A9,
- 0x7B211AB0, 0xB78B1A2E, 0x39041DCD, 0xF5AE1D53,
- 0x2C8E0FFF, 0xE0240F61, 0x6EAB0882, 0xA201081C,
- 0xA8C40105, 0x646E019B, 0xEAE10678, 0x264B06E6
- }
-};
diff -Nru r-base-3.2.3/src/extra/xz/check/crc32_x86.S r-base-3.3.1/src/extra/xz/check/crc32_x86.S
--- r-base-3.2.3/src/extra/xz/check/crc32_x86.S 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc32_x86.S 1970-01-01 00:00:00.000000000 +0000
@@ -1,304 +0,0 @@
-/*
- * Speed-optimized CRC32 using slicing-by-eight algorithm
- *
- * This uses only i386 instructions, but it is optimized for i686 and later
- * (including e.g. Pentium II/III/IV, Athlon XP, and Core 2). For i586
- * (e.g. Pentium), slicing-by-four would be better, and even the C version
- * of slicing-by-eight built with gcc -march=i586 tends to be a little bit
- * better than this. Very few probably run this code on i586 or older x86
- * so this shouldn't be a problem in practice.
- *
- * Authors: Igor Pavlov (original version)
- * Lasse Collin (AT&T syntax, PIC support, better portability)
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * This code needs lzma_crc32_table, which can be created using the
- * following C code:
-
-uint32_t lzma_crc32_table[8][256];
-
-void
-init_table(void)
-{
- // IEEE-802.3
- static const uint32_t poly32 = UINT32_C(0xEDB88320);
-
- // Castagnoli
- // static const uint32_t poly32 = UINT32_C(0x82F63B78);
-
- // Koopman
- // static const uint32_t poly32 = UINT32_C(0xEB31D82E);
-
- for (size_t s = 0; s < 8; ++s) {
- for (size_t b = 0; b < 256; ++b) {
- uint32_t r = s == 0 ? b : lzma_crc32_table[s - 1][b];
-
- for (size_t i = 0; i < 8; ++i) {
- if (r & 1)
- r = (r >> 1) ^ poly32;
- else
- r >>= 1;
- }
-
- lzma_crc32_table[s][b] = r;
- }
- }
-}
-
- * The prototype of the CRC32 function:
- * extern uint32_t lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc);
- */
-
-/*
- * On some systems, the functions need to be prefixed. The prefix is
- * usually an underscore.
- */
-#ifndef __USER_LABEL_PREFIX__
-# define __USER_LABEL_PREFIX__
-#endif
-#define MAKE_SYM_CAT(prefix, sym) prefix ## sym
-#define MAKE_SYM(prefix, sym) MAKE_SYM_CAT(prefix, sym)
-#define LZMA_CRC32 MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc32)
-#define LZMA_CRC32_TABLE MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc32_table)
-
-/*
- * Solaris assembler doesn't have .p2align, and Darwin uses .align
- * differently than GNU/Linux and Solaris.
- */
-#if defined(__APPLE__) || defined(__MSDOS__)
-# define ALIGN(pow2, abs) .align pow2
-#else
-# define ALIGN(pow2, abs) .align abs
-#endif
-
- .text
- .globl LZMA_CRC32
-
-#if !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) \
- && !defined(__MSDOS__)
- .type LZMA_CRC32, @function
-#endif
-
- ALIGN(4, 16)
-LZMA_CRC32:
- /*
- * Register usage:
- * %eax crc
- * %esi buf
- * %edi size or buf + size
- * %ebx lzma_crc32_table
- * %ebp Table index
- * %ecx Temporary
- * %edx Temporary
- */
- pushl %ebx
- pushl %esi
- pushl %edi
- pushl %ebp
- movl 0x14(%esp), %esi /* buf */
- movl 0x18(%esp), %edi /* size */
- movl 0x1C(%esp), %eax /* crc */
-
- /*
- * Store the address of lzma_crc32_table to %ebx. This is needed to
- * get position-independent code (PIC).
- *
- * The PIC macro is defined by libtool, while __PIC__ is defined
- * by GCC but only on some systems. Testing for both makes it simpler
- * to test this code without libtool, and keeps the code working also
- * when built with libtool but using something else than GCC.
- *
- * I understood that libtool may define PIC on Windows even though
- * the code in Windows DLLs is not PIC in sense that it is in ELF
- * binaries, so we need a separate check to always use the non-PIC
- * code on Windows.
- */
-#if (!defined(PIC) && !defined(__PIC__)) \
- || (defined(_WIN32) || defined(__CYGWIN__))
- /* Not PIC */
- movl $ LZMA_CRC32_TABLE, %ebx
-#elif defined(__APPLE__)
- /* Mach-O */
- call .L_get_pc
-.L_pic:
- leal .L_lzma_crc32_table$non_lazy_ptr-.L_pic(%ebx), %ebx
- movl (%ebx), %ebx
-#else
- /* ELF */
- call .L_get_pc
- addl $_GLOBAL_OFFSET_TABLE_, %ebx
- movl LZMA_CRC32_TABLE@GOT(%ebx), %ebx
-#endif
-
- /* Complement the initial value. */
- notl %eax
-
- ALIGN(4, 16)
-.L_align:
- /*
- * Check if there is enough input to use slicing-by-eight.
- * We need 16 bytes, because the loop pre-reads eight bytes.
- */
- cmpl $16, %edi
- jb .L_rest
-
- /* Check if we have reached alignment of eight bytes. */
- testl $7, %esi
- jz .L_slice
-
- /* Calculate CRC of the next input byte. */
- movzbl (%esi), %ebp
- incl %esi
- movzbl %al, %ecx
- xorl %ecx, %ebp
- shrl $8, %eax
- xorl (%ebx, %ebp, 4), %eax
- decl %edi
- jmp .L_align
-
- ALIGN(2, 4)
-.L_slice:
- /*
- * If we get here, there's at least 16 bytes of aligned input
- * available. Make %edi multiple of eight bytes. Store the possible
- * remainder over the "size" variable in the argument stack.
- */
- movl %edi, 0x18(%esp)
- andl $-8, %edi
- subl %edi, 0x18(%esp)
-
- /*
- * Let %edi be buf + size - 8 while running the main loop. This way
- * we can compare for equality to determine when exit the loop.
- */
- addl %esi, %edi
- subl $8, %edi
-
- /* Read in the first eight aligned bytes. */
- xorl (%esi), %eax
- movl 4(%esi), %ecx
- movzbl %cl, %ebp
-
-.L_loop:
- movl 0x0C00(%ebx, %ebp, 4), %edx
- movzbl %ch, %ebp
- xorl 0x0800(%ebx, %ebp, 4), %edx
- shrl $16, %ecx
- xorl 8(%esi), %edx
- movzbl %cl, %ebp
- xorl 0x0400(%ebx, %ebp, 4), %edx
- movzbl %ch, %ebp
- xorl (%ebx, %ebp, 4), %edx
- movzbl %al, %ebp
-
- /*
- * Read the next four bytes, for which the CRC is calculated
- * on the next interation of the loop.
- */
- movl 12(%esi), %ecx
-
- xorl 0x1C00(%ebx, %ebp, 4), %edx
- movzbl %ah, %ebp
- shrl $16, %eax
- xorl 0x1800(%ebx, %ebp, 4), %edx
- movzbl %ah, %ebp
- movzbl %al, %eax
- movl 0x1400(%ebx, %eax, 4), %eax
- addl $8, %esi
- xorl %edx, %eax
- xorl 0x1000(%ebx, %ebp, 4), %eax
-
- /* Check for end of aligned input. */
- cmpl %edi, %esi
- movzbl %cl, %ebp
- jne .L_loop
-
- /*
- * Process the remaining eight bytes, which we have already
- * copied to %ecx and %edx.
- */
- movl 0x0C00(%ebx, %ebp, 4), %edx
- movzbl %ch, %ebp
- xorl 0x0800(%ebx, %ebp, 4), %edx
- shrl $16, %ecx
- movzbl %cl, %ebp
- xorl 0x0400(%ebx, %ebp, 4), %edx
- movzbl %ch, %ebp
- xorl (%ebx, %ebp, 4), %edx
- movzbl %al, %ebp
-
- xorl 0x1C00(%ebx, %ebp, 4), %edx
- movzbl %ah, %ebp
- shrl $16, %eax
- xorl 0x1800(%ebx, %ebp, 4), %edx
- movzbl %ah, %ebp
- movzbl %al, %eax
- movl 0x1400(%ebx, %eax, 4), %eax
- addl $8, %esi
- xorl %edx, %eax
- xorl 0x1000(%ebx, %ebp, 4), %eax
-
- /* Copy the number of remaining bytes to %edi. */
- movl 0x18(%esp), %edi
-
-.L_rest:
- /* Check for end of input. */
- testl %edi, %edi
- jz .L_return
-
- /* Calculate CRC of the next input byte. */
- movzbl (%esi), %ebp
- incl %esi
- movzbl %al, %ecx
- xorl %ecx, %ebp
- shrl $8, %eax
- xorl (%ebx, %ebp, 4), %eax
- decl %edi
- jmp .L_rest
-
-.L_return:
- /* Complement the final value. */
- notl %eax
-
- popl %ebp
- popl %edi
- popl %esi
- popl %ebx
- ret
-
-#if defined(PIC) || defined(__PIC__)
- ALIGN(4, 16)
-.L_get_pc:
- movl (%esp), %ebx
- ret
-#endif
-
-#if defined(__APPLE__) && (defined(PIC) || defined(__PIC__))
- /* Mach-O PIC */
- .section __IMPORT,__pointers,non_lazy_symbol_pointers
-.L_lzma_crc32_table$non_lazy_ptr:
- .indirect_symbol LZMA_CRC32_TABLE
- .long 0
-
-#elif defined(_WIN32) || defined(__CYGWIN__)
-# ifdef DLL_EXPORT
- /* This is equivalent of __declspec(dllexport). */
- .section .drectve
- .ascii " -export:lzma_crc32"
-# endif
-
-#elif !defined(__MSDOS__)
- /* ELF */
- .size LZMA_CRC32, .-LZMA_CRC32
-#endif
-
-/*
- * This is needed to support non-executable stack. It's ugly to
- * use __linux__ here, but I don't know a way to detect when
- * we are using GNU assembler.
- */
-#if defined(__ELF__) && defined(__linux__)
- .section .note.GNU-stack,"",@progbits
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/check/crc64_fast.c r-base-3.3.1/src/extra/xz/check/crc64_fast.c
--- r-base-3.2.3/src/extra/xz/check/crc64_fast.c 2015-03-18 23:02:08.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc64_fast.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,74 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file crc64.c
-/// \brief CRC64 calculation
-///
-/// Calculate the CRC64 using the slice-by-four algorithm. This is the same
-/// idea that is used in crc32_fast.c, but for CRC64 we use only four tables
-/// instead of eight to avoid increasing CPU cache usage.
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "check.h"
-#include "crc_macros.h"
-
-
-#ifdef WORDS_BIGENDIAN
-# define A1(x) ((x) >> 56)
-#else
-# define A1 A
-#endif
-
-
-// R_Change: Used in package utils, so needs to be visible
-#include
-// See the comments in crc32_fast.c. They aren't duplicated here.
-extern attribute_visible LZMA_API(uint64_t)
-lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
-{
- crc = ~crc;
-
-#ifdef WORDS_BIGENDIAN
- crc = bswap64(crc);
-#endif
-
- if (size > 4) {
- while ((uintptr_t)(buf) & 3) {
- crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
- --size;
- }
-
- const uint8_t *const limit = buf + (size & ~(size_t)(3));
- size &= (size_t)(3);
-
- while (buf < limit) {
-#ifdef WORDS_BIGENDIAN
- const uint32_t tmp = (crc >> 32)
- ^ *(const uint32_t *)(buf);
-#else
- const uint32_t tmp = crc ^ *(const uint32_t *)(buf);
-#endif
- buf += 4;
-
- crc = lzma_crc64_table[3][A(tmp)]
- ^ lzma_crc64_table[2][B(tmp)]
- ^ S32(crc)
- ^ lzma_crc64_table[1][C(tmp)]
- ^ lzma_crc64_table[0][D(tmp)];
- }
- }
-
- while (size-- != 0)
- crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);
-
-#ifdef WORDS_BIGENDIAN
- crc = bswap64(crc);
-#endif
-
- return ~crc;
-}
diff -Nru r-base-3.2.3/src/extra/xz/check/crc64_small.c r-base-3.3.1/src/extra/xz/check/crc64_small.c
--- r-base-3.2.3/src/extra/xz/check/crc64_small.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc64_small.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,53 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file crc64_small.c
-/// \brief CRC64 calculation (size-optimized)
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "check.h"
-
-
-static uint64_t crc64_table[256];
-
-
-static void
-crc64_init(void)
-{
- static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42);
-
- for (size_t b = 0; b < 256; ++b) {
- uint64_t r = b;
- for (size_t i = 0; i < 8; ++i) {
- if (r & 1)
- r = (r >> 1) ^ poly64;
- else
- r >>= 1;
- }
-
- crc64_table[b] = r;
- }
-
- return;
-}
-
-
-extern LZMA_API(uint64_t)
-lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
-{
- mythread_once(crc64_init);
-
- crc = ~crc;
-
- while (size != 0) {
- crc = crc64_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
- --size;
- }
-
- return ~crc;
-}
diff -Nru r-base-3.2.3/src/extra/xz/check/crc64_table_be.h r-base-3.3.1/src/extra/xz/check/crc64_table_be.h
--- r-base-3.2.3/src/extra/xz/check/crc64_table_be.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc64_table_be.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,521 +0,0 @@
-/* This file has been automatically generated by crc64_tablegen.c. */
-
-const uint64_t lzma_crc64_table[4][256] = {
- {
- UINT64_C(0x0000000000000000), UINT64_C(0x6F5FA703BE4C2EB3),
- UINT64_C(0x5BA040A8573684F4), UINT64_C(0x34FFE7ABE97AAA47),
- UINT64_C(0x335E8FFF84C3D07B), UINT64_C(0x5C0128FC3A8FFEC8),
- UINT64_C(0x68FECF57D3F5548F), UINT64_C(0x07A168546DB97A3C),
- UINT64_C(0x66BC1EFF0987A1F7), UINT64_C(0x09E3B9FCB7CB8F44),
- UINT64_C(0x3D1C5E575EB12503), UINT64_C(0x5243F954E0FD0BB0),
- UINT64_C(0x55E291008D44718C), UINT64_C(0x3ABD360333085F3F),
- UINT64_C(0x0E42D1A8DA72F578), UINT64_C(0x611D76AB643EDBCB),
- UINT64_C(0x4966335138A19B7D), UINT64_C(0x2639945286EDB5CE),
- UINT64_C(0x12C673F96F971F89), UINT64_C(0x7D99D4FAD1DB313A),
- UINT64_C(0x7A38BCAEBC624B06), UINT64_C(0x15671BAD022E65B5),
- UINT64_C(0x2198FC06EB54CFF2), UINT64_C(0x4EC75B055518E141),
- UINT64_C(0x2FDA2DAE31263A8A), UINT64_C(0x40858AAD8F6A1439),
- UINT64_C(0x747A6D066610BE7E), UINT64_C(0x1B25CA05D85C90CD),
- UINT64_C(0x1C84A251B5E5EAF1), UINT64_C(0x73DB05520BA9C442),
- UINT64_C(0x4724E2F9E2D36E05), UINT64_C(0x287B45FA5C9F40B6),
- UINT64_C(0x92CC66A2704237FB), UINT64_C(0xFD93C1A1CE0E1948),
- UINT64_C(0xC96C260A2774B30F), UINT64_C(0xA633810999389DBC),
- UINT64_C(0xA192E95DF481E780), UINT64_C(0xCECD4E5E4ACDC933),
- UINT64_C(0xFA32A9F5A3B76374), UINT64_C(0x956D0EF61DFB4DC7),
- UINT64_C(0xF470785D79C5960C), UINT64_C(0x9B2FDF5EC789B8BF),
- UINT64_C(0xAFD038F52EF312F8), UINT64_C(0xC08F9FF690BF3C4B),
- UINT64_C(0xC72EF7A2FD064677), UINT64_C(0xA87150A1434A68C4),
- UINT64_C(0x9C8EB70AAA30C283), UINT64_C(0xF3D11009147CEC30),
- UINT64_C(0xDBAA55F348E3AC86), UINT64_C(0xB4F5F2F0F6AF8235),
- UINT64_C(0x800A155B1FD52872), UINT64_C(0xEF55B258A19906C1),
- UINT64_C(0xE8F4DA0CCC207CFD), UINT64_C(0x87AB7D0F726C524E),
- UINT64_C(0xB3549AA49B16F809), UINT64_C(0xDC0B3DA7255AD6BA),
- UINT64_C(0xBD164B0C41640D71), UINT64_C(0xD249EC0FFF2823C2),
- UINT64_C(0xE6B60BA416528985), UINT64_C(0x89E9ACA7A81EA736),
- UINT64_C(0x8E48C4F3C5A7DD0A), UINT64_C(0xE11763F07BEBF3B9),
- UINT64_C(0xD5E8845B929159FE), UINT64_C(0xBAB723582CDD774D),
- UINT64_C(0xA187C3EBCA2BB664), UINT64_C(0xCED864E8746798D7),
- UINT64_C(0xFA2783439D1D3290), UINT64_C(0x9578244023511C23),
- UINT64_C(0x92D94C144EE8661F), UINT64_C(0xFD86EB17F0A448AC),
- UINT64_C(0xC9790CBC19DEE2EB), UINT64_C(0xA626ABBFA792CC58),
- UINT64_C(0xC73BDD14C3AC1793), UINT64_C(0xA8647A177DE03920),
- UINT64_C(0x9C9B9DBC949A9367), UINT64_C(0xF3C43ABF2AD6BDD4),
- UINT64_C(0xF46552EB476FC7E8), UINT64_C(0x9B3AF5E8F923E95B),
- UINT64_C(0xAFC512431059431C), UINT64_C(0xC09AB540AE156DAF),
- UINT64_C(0xE8E1F0BAF28A2D19), UINT64_C(0x87BE57B94CC603AA),
- UINT64_C(0xB341B012A5BCA9ED), UINT64_C(0xDC1E17111BF0875E),
- UINT64_C(0xDBBF7F457649FD62), UINT64_C(0xB4E0D846C805D3D1),
- UINT64_C(0x801F3FED217F7996), UINT64_C(0xEF4098EE9F335725),
- UINT64_C(0x8E5DEE45FB0D8CEE), UINT64_C(0xE10249464541A25D),
- UINT64_C(0xD5FDAEEDAC3B081A), UINT64_C(0xBAA209EE127726A9),
- UINT64_C(0xBD0361BA7FCE5C95), UINT64_C(0xD25CC6B9C1827226),
- UINT64_C(0xE6A3211228F8D861), UINT64_C(0x89FC861196B4F6D2),
- UINT64_C(0x334BA549BA69819F), UINT64_C(0x5C14024A0425AF2C),
- UINT64_C(0x68EBE5E1ED5F056B), UINT64_C(0x07B442E253132BD8),
- UINT64_C(0x00152AB63EAA51E4), UINT64_C(0x6F4A8DB580E67F57),
- UINT64_C(0x5BB56A1E699CD510), UINT64_C(0x34EACD1DD7D0FBA3),
- UINT64_C(0x55F7BBB6B3EE2068), UINT64_C(0x3AA81CB50DA20EDB),
- UINT64_C(0x0E57FB1EE4D8A49C), UINT64_C(0x61085C1D5A948A2F),
- UINT64_C(0x66A93449372DF013), UINT64_C(0x09F6934A8961DEA0),
- UINT64_C(0x3D0974E1601B74E7), UINT64_C(0x5256D3E2DE575A54),
- UINT64_C(0x7A2D961882C81AE2), UINT64_C(0x1572311B3C843451),
- UINT64_C(0x218DD6B0D5FE9E16), UINT64_C(0x4ED271B36BB2B0A5),
- UINT64_C(0x497319E7060BCA99), UINT64_C(0x262CBEE4B847E42A),
- UINT64_C(0x12D3594F513D4E6D), UINT64_C(0x7D8CFE4CEF7160DE),
- UINT64_C(0x1C9188E78B4FBB15), UINT64_C(0x73CE2FE4350395A6),
- UINT64_C(0x4731C84FDC793FE1), UINT64_C(0x286E6F4C62351152),
- UINT64_C(0x2FCF07180F8C6B6E), UINT64_C(0x4090A01BB1C045DD),
- UINT64_C(0x746F47B058BAEF9A), UINT64_C(0x1B30E0B3E6F6C129),
- UINT64_C(0x420F87D795576CC9), UINT64_C(0x2D5020D42B1B427A),
- UINT64_C(0x19AFC77FC261E83D), UINT64_C(0x76F0607C7C2DC68E),
- UINT64_C(0x715108281194BCB2), UINT64_C(0x1E0EAF2BAFD89201),
- UINT64_C(0x2AF1488046A23846), UINT64_C(0x45AEEF83F8EE16F5),
- UINT64_C(0x24B399289CD0CD3E), UINT64_C(0x4BEC3E2B229CE38D),
- UINT64_C(0x7F13D980CBE649CA), UINT64_C(0x104C7E8375AA6779),
- UINT64_C(0x17ED16D718131D45), UINT64_C(0x78B2B1D4A65F33F6),
- UINT64_C(0x4C4D567F4F2599B1), UINT64_C(0x2312F17CF169B702),
- UINT64_C(0x0B69B486ADF6F7B4), UINT64_C(0x6436138513BAD907),
- UINT64_C(0x50C9F42EFAC07340), UINT64_C(0x3F96532D448C5DF3),
- UINT64_C(0x38373B79293527CF), UINT64_C(0x57689C7A9779097C),
- UINT64_C(0x63977BD17E03A33B), UINT64_C(0x0CC8DCD2C04F8D88),
- UINT64_C(0x6DD5AA79A4715643), UINT64_C(0x028A0D7A1A3D78F0),
- UINT64_C(0x3675EAD1F347D2B7), UINT64_C(0x592A4DD24D0BFC04),
- UINT64_C(0x5E8B258620B28638), UINT64_C(0x31D482859EFEA88B),
- UINT64_C(0x052B652E778402CC), UINT64_C(0x6A74C22DC9C82C7F),
- UINT64_C(0xD0C3E175E5155B32), UINT64_C(0xBF9C46765B597581),
- UINT64_C(0x8B63A1DDB223DFC6), UINT64_C(0xE43C06DE0C6FF175),
- UINT64_C(0xE39D6E8A61D68B49), UINT64_C(0x8CC2C989DF9AA5FA),
- UINT64_C(0xB83D2E2236E00FBD), UINT64_C(0xD762892188AC210E),
- UINT64_C(0xB67FFF8AEC92FAC5), UINT64_C(0xD920588952DED476),
- UINT64_C(0xEDDFBF22BBA47E31), UINT64_C(0x8280182105E85082),
- UINT64_C(0x8521707568512ABE), UINT64_C(0xEA7ED776D61D040D),
- UINT64_C(0xDE8130DD3F67AE4A), UINT64_C(0xB1DE97DE812B80F9),
- UINT64_C(0x99A5D224DDB4C04F), UINT64_C(0xF6FA752763F8EEFC),
- UINT64_C(0xC205928C8A8244BB), UINT64_C(0xAD5A358F34CE6A08),
- UINT64_C(0xAAFB5DDB59771034), UINT64_C(0xC5A4FAD8E73B3E87),
- UINT64_C(0xF15B1D730E4194C0), UINT64_C(0x9E04BA70B00DBA73),
- UINT64_C(0xFF19CCDBD43361B8), UINT64_C(0x90466BD86A7F4F0B),
- UINT64_C(0xA4B98C738305E54C), UINT64_C(0xCBE62B703D49CBFF),
- UINT64_C(0xCC47432450F0B1C3), UINT64_C(0xA318E427EEBC9F70),
- UINT64_C(0x97E7038C07C63537), UINT64_C(0xF8B8A48FB98A1B84),
- UINT64_C(0xE388443C5F7CDAAD), UINT64_C(0x8CD7E33FE130F41E),
- UINT64_C(0xB8280494084A5E59), UINT64_C(0xD777A397B60670EA),
- UINT64_C(0xD0D6CBC3DBBF0AD6), UINT64_C(0xBF896CC065F32465),
- UINT64_C(0x8B768B6B8C898E22), UINT64_C(0xE4292C6832C5A091),
- UINT64_C(0x85345AC356FB7B5A), UINT64_C(0xEA6BFDC0E8B755E9),
- UINT64_C(0xDE941A6B01CDFFAE), UINT64_C(0xB1CBBD68BF81D11D),
- UINT64_C(0xB66AD53CD238AB21), UINT64_C(0xD935723F6C748592),
- UINT64_C(0xEDCA9594850E2FD5), UINT64_C(0x829532973B420166),
- UINT64_C(0xAAEE776D67DD41D0), UINT64_C(0xC5B1D06ED9916F63),
- UINT64_C(0xF14E37C530EBC524), UINT64_C(0x9E1190C68EA7EB97),
- UINT64_C(0x99B0F892E31E91AB), UINT64_C(0xF6EF5F915D52BF18),
- UINT64_C(0xC210B83AB428155F), UINT64_C(0xAD4F1F390A643BEC),
- UINT64_C(0xCC5269926E5AE027), UINT64_C(0xA30DCE91D016CE94),
- UINT64_C(0x97F2293A396C64D3), UINT64_C(0xF8AD8E3987204A60),
- UINT64_C(0xFF0CE66DEA99305C), UINT64_C(0x9053416E54D51EEF),
- UINT64_C(0xA4ACA6C5BDAFB4A8), UINT64_C(0xCBF301C603E39A1B),
- UINT64_C(0x7144229E2F3EED56), UINT64_C(0x1E1B859D9172C3E5),
- UINT64_C(0x2AE46236780869A2), UINT64_C(0x45BBC535C6444711),
- UINT64_C(0x421AAD61ABFD3D2D), UINT64_C(0x2D450A6215B1139E),
- UINT64_C(0x19BAEDC9FCCBB9D9), UINT64_C(0x76E54ACA4287976A),
- UINT64_C(0x17F83C6126B94CA1), UINT64_C(0x78A79B6298F56212),
- UINT64_C(0x4C587CC9718FC855), UINT64_C(0x2307DBCACFC3E6E6),
- UINT64_C(0x24A6B39EA27A9CDA), UINT64_C(0x4BF9149D1C36B269),
- UINT64_C(0x7F06F336F54C182E), UINT64_C(0x105954354B00369D),
- UINT64_C(0x382211CF179F762B), UINT64_C(0x577DB6CCA9D35898),
- UINT64_C(0x6382516740A9F2DF), UINT64_C(0x0CDDF664FEE5DC6C),
- UINT64_C(0x0B7C9E30935CA650), UINT64_C(0x642339332D1088E3),
- UINT64_C(0x50DCDE98C46A22A4), UINT64_C(0x3F83799B7A260C17),
- UINT64_C(0x5E9E0F301E18D7DC), UINT64_C(0x31C1A833A054F96F),
- UINT64_C(0x053E4F98492E5328), UINT64_C(0x6A61E89BF7627D9B),
- UINT64_C(0x6DC080CF9ADB07A7), UINT64_C(0x029F27CC24972914),
- UINT64_C(0x3660C067CDED8353), UINT64_C(0x593F676473A1ADE0)
- }, {
- UINT64_C(0x0000000000000000), UINT64_C(0x0DF1D05C9279E954),
- UINT64_C(0x1AE2A1B924F3D2A9), UINT64_C(0x171371E5B68A3BFD),
- UINT64_C(0xB1DA4DDC62497DC1), UINT64_C(0xBC2B9D80F0309495),
- UINT64_C(0xAB38EC6546BAAF68), UINT64_C(0xA6C93C39D4C3463C),
- UINT64_C(0xE7AB9517EE3D2210), UINT64_C(0xEA5A454B7C44CB44),
- UINT64_C(0xFD4934AECACEF0B9), UINT64_C(0xF0B8E4F258B719ED),
- UINT64_C(0x5671D8CB8C745FD1), UINT64_C(0x5B8008971E0DB685),
- UINT64_C(0x4C937972A8878D78), UINT64_C(0x4162A92E3AFE642C),
- UINT64_C(0xCE572B2FDC7B4420), UINT64_C(0xC3A6FB734E02AD74),
- UINT64_C(0xD4B58A96F8889689), UINT64_C(0xD9445ACA6AF17FDD),
- UINT64_C(0x7F8D66F3BE3239E1), UINT64_C(0x727CB6AF2C4BD0B5),
- UINT64_C(0x656FC74A9AC1EB48), UINT64_C(0x689E171608B8021C),
- UINT64_C(0x29FCBE3832466630), UINT64_C(0x240D6E64A03F8F64),
- UINT64_C(0x331E1F8116B5B499), UINT64_C(0x3EEFCFDD84CC5DCD),
- UINT64_C(0x9826F3E4500F1BF1), UINT64_C(0x95D723B8C276F2A5),
- UINT64_C(0x82C4525D74FCC958), UINT64_C(0x8F358201E685200C),
- UINT64_C(0x9CAF565EB8F78840), UINT64_C(0x915E86022A8E6114),
- UINT64_C(0x864DF7E79C045AE9), UINT64_C(0x8BBC27BB0E7DB3BD),
- UINT64_C(0x2D751B82DABEF581), UINT64_C(0x2084CBDE48C71CD5),
- UINT64_C(0x3797BA3BFE4D2728), UINT64_C(0x3A666A676C34CE7C),
- UINT64_C(0x7B04C34956CAAA50), UINT64_C(0x76F51315C4B34304),
- UINT64_C(0x61E662F0723978F9), UINT64_C(0x6C17B2ACE04091AD),
- UINT64_C(0xCADE8E953483D791), UINT64_C(0xC72F5EC9A6FA3EC5),
- UINT64_C(0xD03C2F2C10700538), UINT64_C(0xDDCDFF708209EC6C),
- UINT64_C(0x52F87D71648CCC60), UINT64_C(0x5F09AD2DF6F52534),
- UINT64_C(0x481ADCC8407F1EC9), UINT64_C(0x45EB0C94D206F79D),
- UINT64_C(0xE32230AD06C5B1A1), UINT64_C(0xEED3E0F194BC58F5),
- UINT64_C(0xF9C0911422366308), UINT64_C(0xF4314148B04F8A5C),
- UINT64_C(0xB553E8668AB1EE70), UINT64_C(0xB8A2383A18C80724),
- UINT64_C(0xAFB149DFAE423CD9), UINT64_C(0xA24099833C3BD58D),
- UINT64_C(0x0489A5BAE8F893B1), UINT64_C(0x097875E67A817AE5),
- UINT64_C(0x1E6B0403CC0B4118), UINT64_C(0x139AD45F5E72A84C),
- UINT64_C(0x385FADBC70EF1181), UINT64_C(0x35AE7DE0E296F8D5),
- UINT64_C(0x22BD0C05541CC328), UINT64_C(0x2F4CDC59C6652A7C),
- UINT64_C(0x8985E06012A66C40), UINT64_C(0x8474303C80DF8514),
- UINT64_C(0x936741D93655BEE9), UINT64_C(0x9E969185A42C57BD),
- UINT64_C(0xDFF438AB9ED23391), UINT64_C(0xD205E8F70CABDAC5),
- UINT64_C(0xC5169912BA21E138), UINT64_C(0xC8E7494E2858086C),
- UINT64_C(0x6E2E7577FC9B4E50), UINT64_C(0x63DFA52B6EE2A704),
- UINT64_C(0x74CCD4CED8689CF9), UINT64_C(0x793D04924A1175AD),
- UINT64_C(0xF6088693AC9455A1), UINT64_C(0xFBF956CF3EEDBCF5),
- UINT64_C(0xECEA272A88678708), UINT64_C(0xE11BF7761A1E6E5C),
- UINT64_C(0x47D2CB4FCEDD2860), UINT64_C(0x4A231B135CA4C134),
- UINT64_C(0x5D306AF6EA2EFAC9), UINT64_C(0x50C1BAAA7857139D),
- UINT64_C(0x11A3138442A977B1), UINT64_C(0x1C52C3D8D0D09EE5),
- UINT64_C(0x0B41B23D665AA518), UINT64_C(0x06B06261F4234C4C),
- UINT64_C(0xA0795E5820E00A70), UINT64_C(0xAD888E04B299E324),
- UINT64_C(0xBA9BFFE10413D8D9), UINT64_C(0xB76A2FBD966A318D),
- UINT64_C(0xA4F0FBE2C81899C1), UINT64_C(0xA9012BBE5A617095),
- UINT64_C(0xBE125A5BECEB4B68), UINT64_C(0xB3E38A077E92A23C),
- UINT64_C(0x152AB63EAA51E400), UINT64_C(0x18DB666238280D54),
- UINT64_C(0x0FC817878EA236A9), UINT64_C(0x0239C7DB1CDBDFFD),
- UINT64_C(0x435B6EF52625BBD1), UINT64_C(0x4EAABEA9B45C5285),
- UINT64_C(0x59B9CF4C02D66978), UINT64_C(0x54481F1090AF802C),
- UINT64_C(0xF2812329446CC610), UINT64_C(0xFF70F375D6152F44),
- UINT64_C(0xE8638290609F14B9), UINT64_C(0xE59252CCF2E6FDED),
- UINT64_C(0x6AA7D0CD1463DDE1), UINT64_C(0x67560091861A34B5),
- UINT64_C(0x7045717430900F48), UINT64_C(0x7DB4A128A2E9E61C),
- UINT64_C(0xDB7D9D11762AA020), UINT64_C(0xD68C4D4DE4534974),
- UINT64_C(0xC19F3CA852D97289), UINT64_C(0xCC6EECF4C0A09BDD),
- UINT64_C(0x8D0C45DAFA5EFFF1), UINT64_C(0x80FD9586682716A5),
- UINT64_C(0x97EEE463DEAD2D58), UINT64_C(0x9A1F343F4CD4C40C),
- UINT64_C(0x3CD6080698178230), UINT64_C(0x3127D85A0A6E6B64),
- UINT64_C(0x2634A9BFBCE45099), UINT64_C(0x2BC579E32E9DB9CD),
- UINT64_C(0xF5A054D6CA71FB90), UINT64_C(0xF851848A580812C4),
- UINT64_C(0xEF42F56FEE822939), UINT64_C(0xE2B325337CFBC06D),
- UINT64_C(0x447A190AA8388651), UINT64_C(0x498BC9563A416F05),
- UINT64_C(0x5E98B8B38CCB54F8), UINT64_C(0x536968EF1EB2BDAC),
- UINT64_C(0x120BC1C1244CD980), UINT64_C(0x1FFA119DB63530D4),
- UINT64_C(0x08E9607800BF0B29), UINT64_C(0x0518B02492C6E27D),
- UINT64_C(0xA3D18C1D4605A441), UINT64_C(0xAE205C41D47C4D15),
- UINT64_C(0xB9332DA462F676E8), UINT64_C(0xB4C2FDF8F08F9FBC),
- UINT64_C(0x3BF77FF9160ABFB0), UINT64_C(0x3606AFA5847356E4),
- UINT64_C(0x2115DE4032F96D19), UINT64_C(0x2CE40E1CA080844D),
- UINT64_C(0x8A2D32257443C271), UINT64_C(0x87DCE279E63A2B25),
- UINT64_C(0x90CF939C50B010D8), UINT64_C(0x9D3E43C0C2C9F98C),
- UINT64_C(0xDC5CEAEEF8379DA0), UINT64_C(0xD1AD3AB26A4E74F4),
- UINT64_C(0xC6BE4B57DCC44F09), UINT64_C(0xCB4F9B0B4EBDA65D),
- UINT64_C(0x6D86A7329A7EE061), UINT64_C(0x6077776E08070935),
- UINT64_C(0x7764068BBE8D32C8), UINT64_C(0x7A95D6D72CF4DB9C),
- UINT64_C(0x690F0288728673D0), UINT64_C(0x64FED2D4E0FF9A84),
- UINT64_C(0x73EDA3315675A179), UINT64_C(0x7E1C736DC40C482D),
- UINT64_C(0xD8D54F5410CF0E11), UINT64_C(0xD5249F0882B6E745),
- UINT64_C(0xC237EEED343CDCB8), UINT64_C(0xCFC63EB1A64535EC),
- UINT64_C(0x8EA4979F9CBB51C0), UINT64_C(0x835547C30EC2B894),
- UINT64_C(0x94463626B8488369), UINT64_C(0x99B7E67A2A316A3D),
- UINT64_C(0x3F7EDA43FEF22C01), UINT64_C(0x328F0A1F6C8BC555),
- UINT64_C(0x259C7BFADA01FEA8), UINT64_C(0x286DABA6487817FC),
- UINT64_C(0xA75829A7AEFD37F0), UINT64_C(0xAAA9F9FB3C84DEA4),
- UINT64_C(0xBDBA881E8A0EE559), UINT64_C(0xB04B584218770C0D),
- UINT64_C(0x1682647BCCB44A31), UINT64_C(0x1B73B4275ECDA365),
- UINT64_C(0x0C60C5C2E8479898), UINT64_C(0x0191159E7A3E71CC),
- UINT64_C(0x40F3BCB040C015E0), UINT64_C(0x4D026CECD2B9FCB4),
- UINT64_C(0x5A111D096433C749), UINT64_C(0x57E0CD55F64A2E1D),
- UINT64_C(0xF129F16C22896821), UINT64_C(0xFCD82130B0F08175),
- UINT64_C(0xEBCB50D5067ABA88), UINT64_C(0xE63A8089940353DC),
- UINT64_C(0xCDFFF96ABA9EEA11), UINT64_C(0xC00E293628E70345),
- UINT64_C(0xD71D58D39E6D38B8), UINT64_C(0xDAEC888F0C14D1EC),
- UINT64_C(0x7C25B4B6D8D797D0), UINT64_C(0x71D464EA4AAE7E84),
- UINT64_C(0x66C7150FFC244579), UINT64_C(0x6B36C5536E5DAC2D),
- UINT64_C(0x2A546C7D54A3C801), UINT64_C(0x27A5BC21C6DA2155),
- UINT64_C(0x30B6CDC470501AA8), UINT64_C(0x3D471D98E229F3FC),
- UINT64_C(0x9B8E21A136EAB5C0), UINT64_C(0x967FF1FDA4935C94),
- UINT64_C(0x816C801812196769), UINT64_C(0x8C9D504480608E3D),
- UINT64_C(0x03A8D24566E5AE31), UINT64_C(0x0E590219F49C4765),
- UINT64_C(0x194A73FC42167C98), UINT64_C(0x14BBA3A0D06F95CC),
- UINT64_C(0xB2729F9904ACD3F0), UINT64_C(0xBF834FC596D53AA4),
- UINT64_C(0xA8903E20205F0159), UINT64_C(0xA561EE7CB226E80D),
- UINT64_C(0xE403475288D88C21), UINT64_C(0xE9F2970E1AA16575),
- UINT64_C(0xFEE1E6EBAC2B5E88), UINT64_C(0xF31036B73E52B7DC),
- UINT64_C(0x55D90A8EEA91F1E0), UINT64_C(0x5828DAD278E818B4),
- UINT64_C(0x4F3BAB37CE622349), UINT64_C(0x42CA7B6B5C1BCA1D),
- UINT64_C(0x5150AF3402696251), UINT64_C(0x5CA17F6890108B05),
- UINT64_C(0x4BB20E8D269AB0F8), UINT64_C(0x4643DED1B4E359AC),
- UINT64_C(0xE08AE2E860201F90), UINT64_C(0xED7B32B4F259F6C4),
- UINT64_C(0xFA68435144D3CD39), UINT64_C(0xF799930DD6AA246D),
- UINT64_C(0xB6FB3A23EC544041), UINT64_C(0xBB0AEA7F7E2DA915),
- UINT64_C(0xAC199B9AC8A792E8), UINT64_C(0xA1E84BC65ADE7BBC),
- UINT64_C(0x072177FF8E1D3D80), UINT64_C(0x0AD0A7A31C64D4D4),
- UINT64_C(0x1DC3D646AAEEEF29), UINT64_C(0x1032061A3897067D),
- UINT64_C(0x9F07841BDE122671), UINT64_C(0x92F654474C6BCF25),
- UINT64_C(0x85E525A2FAE1F4D8), UINT64_C(0x8814F5FE68981D8C),
- UINT64_C(0x2EDDC9C7BC5B5BB0), UINT64_C(0x232C199B2E22B2E4),
- UINT64_C(0x343F687E98A88919), UINT64_C(0x39CEB8220AD1604D),
- UINT64_C(0x78AC110C302F0461), UINT64_C(0x755DC150A256ED35),
- UINT64_C(0x624EB0B514DCD6C8), UINT64_C(0x6FBF60E986A53F9C),
- UINT64_C(0xC9765CD0526679A0), UINT64_C(0xC4878C8CC01F90F4),
- UINT64_C(0xD394FD697695AB09), UINT64_C(0xDE652D35E4EC425D)
- }, {
- UINT64_C(0x0000000000000000), UINT64_C(0xCB6D6A914AE10B3F),
- UINT64_C(0x96DBD42295C2177E), UINT64_C(0x5DB6BEB3DF231C41),
- UINT64_C(0x2CB7A9452A852FFC), UINT64_C(0xE7DAC3D4606424C3),
- UINT64_C(0xBA6C7D67BF473882), UINT64_C(0x710117F6F5A633BD),
- UINT64_C(0xDD705D247FA5876A), UINT64_C(0x161D37B535448C55),
- UINT64_C(0x4BAB8906EA679014), UINT64_C(0x80C6E397A0869B2B),
- UINT64_C(0xF1C7F4615520A896), UINT64_C(0x3AAA9EF01FC1A3A9),
- UINT64_C(0x671C2043C0E2BFE8), UINT64_C(0xAC714AD28A03B4D7),
- UINT64_C(0xBAE1BA48FE4A0FD5), UINT64_C(0x718CD0D9B4AB04EA),
- UINT64_C(0x2C3A6E6A6B8818AB), UINT64_C(0xE75704FB21691394),
- UINT64_C(0x9656130DD4CF2029), UINT64_C(0x5D3B799C9E2E2B16),
- UINT64_C(0x008DC72F410D3757), UINT64_C(0xCBE0ADBE0BEC3C68),
- UINT64_C(0x6791E76C81EF88BF), UINT64_C(0xACFC8DFDCB0E8380),
- UINT64_C(0xF14A334E142D9FC1), UINT64_C(0x3A2759DF5ECC94FE),
- UINT64_C(0x4B264E29AB6AA743), UINT64_C(0x804B24B8E18BAC7C),
- UINT64_C(0xDDFD9A0B3EA8B03D), UINT64_C(0x1690F09A7449BB02),
- UINT64_C(0xF1DD7B3ED73AC638), UINT64_C(0x3AB011AF9DDBCD07),
- UINT64_C(0x6706AF1C42F8D146), UINT64_C(0xAC6BC58D0819DA79),
- UINT64_C(0xDD6AD27BFDBFE9C4), UINT64_C(0x1607B8EAB75EE2FB),
- UINT64_C(0x4BB10659687DFEBA), UINT64_C(0x80DC6CC8229CF585),
- UINT64_C(0x2CAD261AA89F4152), UINT64_C(0xE7C04C8BE27E4A6D),
- UINT64_C(0xBA76F2383D5D562C), UINT64_C(0x711B98A977BC5D13),
- UINT64_C(0x001A8F5F821A6EAE), UINT64_C(0xCB77E5CEC8FB6591),
- UINT64_C(0x96C15B7D17D879D0), UINT64_C(0x5DAC31EC5D3972EF),
- UINT64_C(0x4B3CC1762970C9ED), UINT64_C(0x8051ABE76391C2D2),
- UINT64_C(0xDDE71554BCB2DE93), UINT64_C(0x168A7FC5F653D5AC),
- UINT64_C(0x678B683303F5E611), UINT64_C(0xACE602A24914ED2E),
- UINT64_C(0xF150BC119637F16F), UINT64_C(0x3A3DD680DCD6FA50),
- UINT64_C(0x964C9C5256D54E87), UINT64_C(0x5D21F6C31C3445B8),
- UINT64_C(0x00974870C31759F9), UINT64_C(0xCBFA22E189F652C6),
- UINT64_C(0xBAFB35177C50617B), UINT64_C(0x71965F8636B16A44),
- UINT64_C(0x2C20E135E9927605), UINT64_C(0xE74D8BA4A3737D3A),
- UINT64_C(0xE2BBF77CAE758C71), UINT64_C(0x29D69DEDE494874E),
- UINT64_C(0x7460235E3BB79B0F), UINT64_C(0xBF0D49CF71569030),
- UINT64_C(0xCE0C5E3984F0A38D), UINT64_C(0x056134A8CE11A8B2),
- UINT64_C(0x58D78A1B1132B4F3), UINT64_C(0x93BAE08A5BD3BFCC),
- UINT64_C(0x3FCBAA58D1D00B1B), UINT64_C(0xF4A6C0C99B310024),
- UINT64_C(0xA9107E7A44121C65), UINT64_C(0x627D14EB0EF3175A),
- UINT64_C(0x137C031DFB5524E7), UINT64_C(0xD811698CB1B42FD8),
- UINT64_C(0x85A7D73F6E973399), UINT64_C(0x4ECABDAE247638A6),
- UINT64_C(0x585A4D34503F83A4), UINT64_C(0x933727A51ADE889B),
- UINT64_C(0xCE819916C5FD94DA), UINT64_C(0x05ECF3878F1C9FE5),
- UINT64_C(0x74EDE4717ABAAC58), UINT64_C(0xBF808EE0305BA767),
- UINT64_C(0xE2363053EF78BB26), UINT64_C(0x295B5AC2A599B019),
- UINT64_C(0x852A10102F9A04CE), UINT64_C(0x4E477A81657B0FF1),
- UINT64_C(0x13F1C432BA5813B0), UINT64_C(0xD89CAEA3F0B9188F),
- UINT64_C(0xA99DB955051F2B32), UINT64_C(0x62F0D3C44FFE200D),
- UINT64_C(0x3F466D7790DD3C4C), UINT64_C(0xF42B07E6DA3C3773),
- UINT64_C(0x13668C42794F4A49), UINT64_C(0xD80BE6D333AE4176),
- UINT64_C(0x85BD5860EC8D5D37), UINT64_C(0x4ED032F1A66C5608),
- UINT64_C(0x3FD1250753CA65B5), UINT64_C(0xF4BC4F96192B6E8A),
- UINT64_C(0xA90AF125C60872CB), UINT64_C(0x62679BB48CE979F4),
- UINT64_C(0xCE16D16606EACD23), UINT64_C(0x057BBBF74C0BC61C),
- UINT64_C(0x58CD05449328DA5D), UINT64_C(0x93A06FD5D9C9D162),
- UINT64_C(0xE2A178232C6FE2DF), UINT64_C(0x29CC12B2668EE9E0),
- UINT64_C(0x747AAC01B9ADF5A1), UINT64_C(0xBF17C690F34CFE9E),
- UINT64_C(0xA987360A8705459C), UINT64_C(0x62EA5C9BCDE44EA3),
- UINT64_C(0x3F5CE22812C752E2), UINT64_C(0xF43188B9582659DD),
- UINT64_C(0x85309F4FAD806A60), UINT64_C(0x4E5DF5DEE761615F),
- UINT64_C(0x13EB4B6D38427D1E), UINT64_C(0xD88621FC72A37621),
- UINT64_C(0x74F76B2EF8A0C2F6), UINT64_C(0xBF9A01BFB241C9C9),
- UINT64_C(0xE22CBF0C6D62D588), UINT64_C(0x2941D59D2783DEB7),
- UINT64_C(0x5840C26BD225ED0A), UINT64_C(0x932DA8FA98C4E635),
- UINT64_C(0xCE9B164947E7FA74), UINT64_C(0x05F67CD80D06F14B),
- UINT64_C(0xC477EFF95CEB18E3), UINT64_C(0x0F1A8568160A13DC),
- UINT64_C(0x52AC3BDBC9290F9D), UINT64_C(0x99C1514A83C804A2),
- UINT64_C(0xE8C046BC766E371F), UINT64_C(0x23AD2C2D3C8F3C20),
- UINT64_C(0x7E1B929EE3AC2061), UINT64_C(0xB576F80FA94D2B5E),
- UINT64_C(0x1907B2DD234E9F89), UINT64_C(0xD26AD84C69AF94B6),
- UINT64_C(0x8FDC66FFB68C88F7), UINT64_C(0x44B10C6EFC6D83C8),
- UINT64_C(0x35B01B9809CBB075), UINT64_C(0xFEDD7109432ABB4A),
- UINT64_C(0xA36BCFBA9C09A70B), UINT64_C(0x6806A52BD6E8AC34),
- UINT64_C(0x7E9655B1A2A11736), UINT64_C(0xB5FB3F20E8401C09),
- UINT64_C(0xE84D819337630048), UINT64_C(0x2320EB027D820B77),
- UINT64_C(0x5221FCF4882438CA), UINT64_C(0x994C9665C2C533F5),
- UINT64_C(0xC4FA28D61DE62FB4), UINT64_C(0x0F9742475707248B),
- UINT64_C(0xA3E60895DD04905C), UINT64_C(0x688B620497E59B63),
- UINT64_C(0x353DDCB748C68722), UINT64_C(0xFE50B62602278C1D),
- UINT64_C(0x8F51A1D0F781BFA0), UINT64_C(0x443CCB41BD60B49F),
- UINT64_C(0x198A75F26243A8DE), UINT64_C(0xD2E71F6328A2A3E1),
- UINT64_C(0x35AA94C78BD1DEDB), UINT64_C(0xFEC7FE56C130D5E4),
- UINT64_C(0xA37140E51E13C9A5), UINT64_C(0x681C2A7454F2C29A),
- UINT64_C(0x191D3D82A154F127), UINT64_C(0xD2705713EBB5FA18),
- UINT64_C(0x8FC6E9A03496E659), UINT64_C(0x44AB83317E77ED66),
- UINT64_C(0xE8DAC9E3F47459B1), UINT64_C(0x23B7A372BE95528E),
- UINT64_C(0x7E011DC161B64ECF), UINT64_C(0xB56C77502B5745F0),
- UINT64_C(0xC46D60A6DEF1764D), UINT64_C(0x0F000A3794107D72),
- UINT64_C(0x52B6B4844B336133), UINT64_C(0x99DBDE1501D26A0C),
- UINT64_C(0x8F4B2E8F759BD10E), UINT64_C(0x4426441E3F7ADA31),
- UINT64_C(0x1990FAADE059C670), UINT64_C(0xD2FD903CAAB8CD4F),
- UINT64_C(0xA3FC87CA5F1EFEF2), UINT64_C(0x6891ED5B15FFF5CD),
- UINT64_C(0x352753E8CADCE98C), UINT64_C(0xFE4A3979803DE2B3),
- UINT64_C(0x523B73AB0A3E5664), UINT64_C(0x9956193A40DF5D5B),
- UINT64_C(0xC4E0A7899FFC411A), UINT64_C(0x0F8DCD18D51D4A25),
- UINT64_C(0x7E8CDAEE20BB7998), UINT64_C(0xB5E1B07F6A5A72A7),
- UINT64_C(0xE8570ECCB5796EE6), UINT64_C(0x233A645DFF9865D9),
- UINT64_C(0x26CC1885F29E9492), UINT64_C(0xEDA17214B87F9FAD),
- UINT64_C(0xB017CCA7675C83EC), UINT64_C(0x7B7AA6362DBD88D3),
- UINT64_C(0x0A7BB1C0D81BBB6E), UINT64_C(0xC116DB5192FAB051),
- UINT64_C(0x9CA065E24DD9AC10), UINT64_C(0x57CD0F730738A72F),
- UINT64_C(0xFBBC45A18D3B13F8), UINT64_C(0x30D12F30C7DA18C7),
- UINT64_C(0x6D67918318F90486), UINT64_C(0xA60AFB1252180FB9),
- UINT64_C(0xD70BECE4A7BE3C04), UINT64_C(0x1C668675ED5F373B),
- UINT64_C(0x41D038C6327C2B7A), UINT64_C(0x8ABD5257789D2045),
- UINT64_C(0x9C2DA2CD0CD49B47), UINT64_C(0x5740C85C46359078),
- UINT64_C(0x0AF676EF99168C39), UINT64_C(0xC19B1C7ED3F78706),
- UINT64_C(0xB09A0B882651B4BB), UINT64_C(0x7BF761196CB0BF84),
- UINT64_C(0x2641DFAAB393A3C5), UINT64_C(0xED2CB53BF972A8FA),
- UINT64_C(0x415DFFE973711C2D), UINT64_C(0x8A30957839901712),
- UINT64_C(0xD7862BCBE6B30B53), UINT64_C(0x1CEB415AAC52006C),
- UINT64_C(0x6DEA56AC59F433D1), UINT64_C(0xA6873C3D131538EE),
- UINT64_C(0xFB31828ECC3624AF), UINT64_C(0x305CE81F86D72F90),
- UINT64_C(0xD71163BB25A452AA), UINT64_C(0x1C7C092A6F455995),
- UINT64_C(0x41CAB799B06645D4), UINT64_C(0x8AA7DD08FA874EEB),
- UINT64_C(0xFBA6CAFE0F217D56), UINT64_C(0x30CBA06F45C07669),
- UINT64_C(0x6D7D1EDC9AE36A28), UINT64_C(0xA610744DD0026117),
- UINT64_C(0x0A613E9F5A01D5C0), UINT64_C(0xC10C540E10E0DEFF),
- UINT64_C(0x9CBAEABDCFC3C2BE), UINT64_C(0x57D7802C8522C981),
- UINT64_C(0x26D697DA7084FA3C), UINT64_C(0xEDBBFD4B3A65F103),
- UINT64_C(0xB00D43F8E546ED42), UINT64_C(0x7B602969AFA7E67D),
- UINT64_C(0x6DF0D9F3DBEE5D7F), UINT64_C(0xA69DB362910F5640),
- UINT64_C(0xFB2B0DD14E2C4A01), UINT64_C(0x3046674004CD413E),
- UINT64_C(0x414770B6F16B7283), UINT64_C(0x8A2A1A27BB8A79BC),
- UINT64_C(0xD79CA49464A965FD), UINT64_C(0x1CF1CE052E486EC2),
- UINT64_C(0xB08084D7A44BDA15), UINT64_C(0x7BEDEE46EEAAD12A),
- UINT64_C(0x265B50F53189CD6B), UINT64_C(0xED363A647B68C654),
- UINT64_C(0x9C372D928ECEF5E9), UINT64_C(0x575A4703C42FFED6),
- UINT64_C(0x0AECF9B01B0CE297), UINT64_C(0xC181932151EDE9A8)
- }, {
- UINT64_C(0x0000000000000000), UINT64_C(0xDCA12C225E8AEE1D),
- UINT64_C(0xB8435944BC14DD3B), UINT64_C(0x64E27566E29E3326),
- UINT64_C(0x7087B2887829BA77), UINT64_C(0xAC269EAA26A3546A),
- UINT64_C(0xC8C4EBCCC43D674C), UINT64_C(0x1465C7EE9AB78951),
- UINT64_C(0xE00E6511F15274EF), UINT64_C(0x3CAF4933AFD89AF2),
- UINT64_C(0x584D3C554D46A9D4), UINT64_C(0x84EC107713CC47C9),
- UINT64_C(0x9089D799897BCE98), UINT64_C(0x4C28FBBBD7F12085),
- UINT64_C(0x28CA8EDD356F13A3), UINT64_C(0xF46BA2FF6BE5FDBE),
- UINT64_C(0x4503C48DC90A304C), UINT64_C(0x99A2E8AF9780DE51),
- UINT64_C(0xFD409DC9751EED77), UINT64_C(0x21E1B1EB2B94036A),
- UINT64_C(0x35847605B1238A3B), UINT64_C(0xE9255A27EFA96426),
- UINT64_C(0x8DC72F410D375700), UINT64_C(0x5166036353BDB91D),
- UINT64_C(0xA50DA19C385844A3), UINT64_C(0x79AC8DBE66D2AABE),
- UINT64_C(0x1D4EF8D8844C9998), UINT64_C(0xC1EFD4FADAC67785),
- UINT64_C(0xD58A13144071FED4), UINT64_C(0x092B3F361EFB10C9),
- UINT64_C(0x6DC94A50FC6523EF), UINT64_C(0xB1686672A2EFCDF2),
- UINT64_C(0x8A06881B93156098), UINT64_C(0x56A7A439CD9F8E85),
- UINT64_C(0x3245D15F2F01BDA3), UINT64_C(0xEEE4FD7D718B53BE),
- UINT64_C(0xFA813A93EB3CDAEF), UINT64_C(0x262016B1B5B634F2),
- UINT64_C(0x42C263D7572807D4), UINT64_C(0x9E634FF509A2E9C9),
- UINT64_C(0x6A08ED0A62471477), UINT64_C(0xB6A9C1283CCDFA6A),
- UINT64_C(0xD24BB44EDE53C94C), UINT64_C(0x0EEA986C80D92751),
- UINT64_C(0x1A8F5F821A6EAE00), UINT64_C(0xC62E73A044E4401D),
- UINT64_C(0xA2CC06C6A67A733B), UINT64_C(0x7E6D2AE4F8F09D26),
- UINT64_C(0xCF054C965A1F50D4), UINT64_C(0x13A460B40495BEC9),
- UINT64_C(0x774615D2E60B8DEF), UINT64_C(0xABE739F0B88163F2),
- UINT64_C(0xBF82FE1E2236EAA3), UINT64_C(0x6323D23C7CBC04BE),
- UINT64_C(0x07C1A75A9E223798), UINT64_C(0xDB608B78C0A8D985),
- UINT64_C(0x2F0B2987AB4D243B), UINT64_C(0xF3AA05A5F5C7CA26),
- UINT64_C(0x974870C31759F900), UINT64_C(0x4BE95CE149D3171D),
- UINT64_C(0x5F8C9B0FD3649E4C), UINT64_C(0x832DB72D8DEE7051),
- UINT64_C(0xE7CFC24B6F704377), UINT64_C(0x3B6EEE6931FAAD6A),
- UINT64_C(0x91131E980D8418A2), UINT64_C(0x4DB232BA530EF6BF),
- UINT64_C(0x295047DCB190C599), UINT64_C(0xF5F16BFEEF1A2B84),
- UINT64_C(0xE194AC1075ADA2D5), UINT64_C(0x3D3580322B274CC8),
- UINT64_C(0x59D7F554C9B97FEE), UINT64_C(0x8576D976973391F3),
- UINT64_C(0x711D7B89FCD66C4D), UINT64_C(0xADBC57ABA25C8250),
- UINT64_C(0xC95E22CD40C2B176), UINT64_C(0x15FF0EEF1E485F6B),
- UINT64_C(0x019AC90184FFD63A), UINT64_C(0xDD3BE523DA753827),
- UINT64_C(0xB9D9904538EB0B01), UINT64_C(0x6578BC676661E51C),
- UINT64_C(0xD410DA15C48E28EE), UINT64_C(0x08B1F6379A04C6F3),
- UINT64_C(0x6C538351789AF5D5), UINT64_C(0xB0F2AF7326101BC8),
- UINT64_C(0xA497689DBCA79299), UINT64_C(0x783644BFE22D7C84),
- UINT64_C(0x1CD431D900B34FA2), UINT64_C(0xC0751DFB5E39A1BF),
- UINT64_C(0x341EBF0435DC5C01), UINT64_C(0xE8BF93266B56B21C),
- UINT64_C(0x8C5DE64089C8813A), UINT64_C(0x50FCCA62D7426F27),
- UINT64_C(0x44990D8C4DF5E676), UINT64_C(0x983821AE137F086B),
- UINT64_C(0xFCDA54C8F1E13B4D), UINT64_C(0x207B78EAAF6BD550),
- UINT64_C(0x1B1596839E91783A), UINT64_C(0xC7B4BAA1C01B9627),
- UINT64_C(0xA356CFC72285A501), UINT64_C(0x7FF7E3E57C0F4B1C),
- UINT64_C(0x6B92240BE6B8C24D), UINT64_C(0xB7330829B8322C50),
- UINT64_C(0xD3D17D4F5AAC1F76), UINT64_C(0x0F70516D0426F16B),
- UINT64_C(0xFB1BF3926FC30CD5), UINT64_C(0x27BADFB03149E2C8),
- UINT64_C(0x4358AAD6D3D7D1EE), UINT64_C(0x9FF986F48D5D3FF3),
- UINT64_C(0x8B9C411A17EAB6A2), UINT64_C(0x573D6D38496058BF),
- UINT64_C(0x33DF185EABFE6B99), UINT64_C(0xEF7E347CF5748584),
- UINT64_C(0x5E16520E579B4876), UINT64_C(0x82B77E2C0911A66B),
- UINT64_C(0xE6550B4AEB8F954D), UINT64_C(0x3AF42768B5057B50),
- UINT64_C(0x2E91E0862FB2F201), UINT64_C(0xF230CCA471381C1C),
- UINT64_C(0x96D2B9C293A62F3A), UINT64_C(0x4A7395E0CD2CC127),
- UINT64_C(0xBE18371FA6C93C99), UINT64_C(0x62B91B3DF843D284),
- UINT64_C(0x065B6E5B1ADDE1A2), UINT64_C(0xDAFA427944570FBF),
- UINT64_C(0xCE9F8597DEE086EE), UINT64_C(0x123EA9B5806A68F3),
- UINT64_C(0x76DCDCD362F45BD5), UINT64_C(0xAA7DF0F13C7EB5C8),
- UINT64_C(0xA739329F30A7E9D6), UINT64_C(0x7B981EBD6E2D07CB),
- UINT64_C(0x1F7A6BDB8CB334ED), UINT64_C(0xC3DB47F9D239DAF0),
- UINT64_C(0xD7BE8017488E53A1), UINT64_C(0x0B1FAC351604BDBC),
- UINT64_C(0x6FFDD953F49A8E9A), UINT64_C(0xB35CF571AA106087),
- UINT64_C(0x4737578EC1F59D39), UINT64_C(0x9B967BAC9F7F7324),
- UINT64_C(0xFF740ECA7DE14002), UINT64_C(0x23D522E8236BAE1F),
- UINT64_C(0x37B0E506B9DC274E), UINT64_C(0xEB11C924E756C953),
- UINT64_C(0x8FF3BC4205C8FA75), UINT64_C(0x535290605B421468),
- UINT64_C(0xE23AF612F9ADD99A), UINT64_C(0x3E9BDA30A7273787),
- UINT64_C(0x5A79AF5645B904A1), UINT64_C(0x86D883741B33EABC),
- UINT64_C(0x92BD449A818463ED), UINT64_C(0x4E1C68B8DF0E8DF0),
- UINT64_C(0x2AFE1DDE3D90BED6), UINT64_C(0xF65F31FC631A50CB),
- UINT64_C(0x0234930308FFAD75), UINT64_C(0xDE95BF2156754368),
- UINT64_C(0xBA77CA47B4EB704E), UINT64_C(0x66D6E665EA619E53),
- UINT64_C(0x72B3218B70D61702), UINT64_C(0xAE120DA92E5CF91F),
- UINT64_C(0xCAF078CFCCC2CA39), UINT64_C(0x165154ED92482424),
- UINT64_C(0x2D3FBA84A3B2894E), UINT64_C(0xF19E96A6FD386753),
- UINT64_C(0x957CE3C01FA65475), UINT64_C(0x49DDCFE2412CBA68),
- UINT64_C(0x5DB8080CDB9B3339), UINT64_C(0x8119242E8511DD24),
- UINT64_C(0xE5FB5148678FEE02), UINT64_C(0x395A7D6A3905001F),
- UINT64_C(0xCD31DF9552E0FDA1), UINT64_C(0x1190F3B70C6A13BC),
- UINT64_C(0x757286D1EEF4209A), UINT64_C(0xA9D3AAF3B07ECE87),
- UINT64_C(0xBDB66D1D2AC947D6), UINT64_C(0x6117413F7443A9CB),
- UINT64_C(0x05F5345996DD9AED), UINT64_C(0xD954187BC85774F0),
- UINT64_C(0x683C7E096AB8B902), UINT64_C(0xB49D522B3432571F),
- UINT64_C(0xD07F274DD6AC6439), UINT64_C(0x0CDE0B6F88268A24),
- UINT64_C(0x18BBCC8112910375), UINT64_C(0xC41AE0A34C1BED68),
- UINT64_C(0xA0F895C5AE85DE4E), UINT64_C(0x7C59B9E7F00F3053),
- UINT64_C(0x88321B189BEACDED), UINT64_C(0x5493373AC56023F0),
- UINT64_C(0x3071425C27FE10D6), UINT64_C(0xECD06E7E7974FECB),
- UINT64_C(0xF8B5A990E3C3779A), UINT64_C(0x241485B2BD499987),
- UINT64_C(0x40F6F0D45FD7AAA1), UINT64_C(0x9C57DCF6015D44BC),
- UINT64_C(0x362A2C073D23F174), UINT64_C(0xEA8B002563A91F69),
- UINT64_C(0x8E69754381372C4F), UINT64_C(0x52C85961DFBDC252),
- UINT64_C(0x46AD9E8F450A4B03), UINT64_C(0x9A0CB2AD1B80A51E),
- UINT64_C(0xFEEEC7CBF91E9638), UINT64_C(0x224FEBE9A7947825),
- UINT64_C(0xD6244916CC71859B), UINT64_C(0x0A85653492FB6B86),
- UINT64_C(0x6E671052706558A0), UINT64_C(0xB2C63C702EEFB6BD),
- UINT64_C(0xA6A3FB9EB4583FEC), UINT64_C(0x7A02D7BCEAD2D1F1),
- UINT64_C(0x1EE0A2DA084CE2D7), UINT64_C(0xC2418EF856C60CCA),
- UINT64_C(0x7329E88AF429C138), UINT64_C(0xAF88C4A8AAA32F25),
- UINT64_C(0xCB6AB1CE483D1C03), UINT64_C(0x17CB9DEC16B7F21E),
- UINT64_C(0x03AE5A028C007B4F), UINT64_C(0xDF0F7620D28A9552),
- UINT64_C(0xBBED03463014A674), UINT64_C(0x674C2F646E9E4869),
- UINT64_C(0x93278D9B057BB5D7), UINT64_C(0x4F86A1B95BF15BCA),
- UINT64_C(0x2B64D4DFB96F68EC), UINT64_C(0xF7C5F8FDE7E586F1),
- UINT64_C(0xE3A03F137D520FA0), UINT64_C(0x3F01133123D8E1BD),
- UINT64_C(0x5BE36657C146D29B), UINT64_C(0x87424A759FCC3C86),
- UINT64_C(0xBC2CA41CAE3691EC), UINT64_C(0x608D883EF0BC7FF1),
- UINT64_C(0x046FFD5812224CD7), UINT64_C(0xD8CED17A4CA8A2CA),
- UINT64_C(0xCCAB1694D61F2B9B), UINT64_C(0x100A3AB68895C586),
- UINT64_C(0x74E84FD06A0BF6A0), UINT64_C(0xA84963F2348118BD),
- UINT64_C(0x5C22C10D5F64E503), UINT64_C(0x8083ED2F01EE0B1E),
- UINT64_C(0xE4619849E3703838), UINT64_C(0x38C0B46BBDFAD625),
- UINT64_C(0x2CA57385274D5F74), UINT64_C(0xF0045FA779C7B169),
- UINT64_C(0x94E62AC19B59824F), UINT64_C(0x484706E3C5D36C52),
- UINT64_C(0xF92F6091673CA1A0), UINT64_C(0x258E4CB339B64FBD),
- UINT64_C(0x416C39D5DB287C9B), UINT64_C(0x9DCD15F785A29286),
- UINT64_C(0x89A8D2191F151BD7), UINT64_C(0x5509FE3B419FF5CA),
- UINT64_C(0x31EB8B5DA301C6EC), UINT64_C(0xED4AA77FFD8B28F1),
- UINT64_C(0x19210580966ED54F), UINT64_C(0xC58029A2C8E43B52),
- UINT64_C(0xA1625CC42A7A0874), UINT64_C(0x7DC370E674F0E669),
- UINT64_C(0x69A6B708EE476F38), UINT64_C(0xB5079B2AB0CD8125),
- UINT64_C(0xD1E5EE4C5253B203), UINT64_C(0x0D44C26E0CD95C1E)
- }
-};
diff -Nru r-base-3.2.3/src/extra/xz/check/crc64_table.c r-base-3.3.1/src/extra/xz/check/crc64_table.c
--- r-base-3.2.3/src/extra/xz/check/crc64_table.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc64_table.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,19 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file crc64_table.c
-/// \brief Precalculated CRC64 table with correct endianness
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-
-#ifdef WORDS_BIGENDIAN
-# include "crc64_table_be.h"
-#else
-# include "crc64_table_le.h"
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/check/crc64_tablegen.c r-base-3.3.1/src/extra/xz/check/crc64_tablegen.c
--- r-base-3.2.3/src/extra/xz/check/crc64_tablegen.c 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc64_tablegen.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,88 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file crc64_tablegen.c
-/// \brief Generate crc64_table_le.h and crc64_table_be.h
-///
-/// Compiling: gcc -std=c99 -o crc64_tablegen crc64_tablegen.c
-/// Add -DWORDS_BIGENDIAN to generate big endian table.
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include
-#include "../../common/tuklib_integer.h"
-
-
-static uint64_t crc64_table[4][256];
-
-
-extern void
-init_crc64_table(void)
-{
- static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42);
-
- for (size_t s = 0; s < 4; ++s) {
- for (size_t b = 0; b < 256; ++b) {
- uint64_t r = s == 0 ? b : crc64_table[s - 1][b];
-
- for (size_t i = 0; i < 8; ++i) {
- if (r & 1)
- r = (r >> 1) ^ poly64;
- else
- r >>= 1;
- }
-
- crc64_table[s][b] = r;
- }
- }
-
-#ifdef WORDS_BIGENDIAN
- for (size_t s = 0; s < 4; ++s)
- for (size_t b = 0; b < 256; ++b)
- crc64_table[s][b] = bswap64(crc64_table[s][b]);
-#endif
-
- return;
-}
-
-
-static void
-print_crc64_table(void)
-{
- printf("/* This file has been automatically generated by "
- "crc64_tablegen.c. */\n\n"
- "const uint64_t lzma_crc64_table[4][256] = {\n\t{");
-
- for (size_t s = 0; s < 4; ++s) {
- for (size_t b = 0; b < 256; ++b) {
- if ((b % 2) == 0)
- printf("\n\t\t");
-
- printf("UINT64_C(0x%016" PRIX64 ")",
- crc64_table[s][b]);
-
- if (b != 255)
- printf(",%s", (b+1) % 2 == 0 ? "" : " ");
- }
-
- if (s == 3)
- printf("\n\t}\n};\n");
- else
- printf("\n\t}, {");
- }
-
- return;
-}
-
-
-int
-main(void)
-{
- init_crc64_table();
- print_crc64_table();
- return 0;
-}
diff -Nru r-base-3.2.3/src/extra/xz/check/crc64_table_le.h r-base-3.3.1/src/extra/xz/check/crc64_table_le.h
--- r-base-3.2.3/src/extra/xz/check/crc64_table_le.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc64_table_le.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,521 +0,0 @@
-/* This file has been automatically generated by crc64_tablegen.c. */
-
-const uint64_t lzma_crc64_table[4][256] = {
- {
- UINT64_C(0x0000000000000000), UINT64_C(0xB32E4CBE03A75F6F),
- UINT64_C(0xF4843657A840A05B), UINT64_C(0x47AA7AE9ABE7FF34),
- UINT64_C(0x7BD0C384FF8F5E33), UINT64_C(0xC8FE8F3AFC28015C),
- UINT64_C(0x8F54F5D357CFFE68), UINT64_C(0x3C7AB96D5468A107),
- UINT64_C(0xF7A18709FF1EBC66), UINT64_C(0x448FCBB7FCB9E309),
- UINT64_C(0x0325B15E575E1C3D), UINT64_C(0xB00BFDE054F94352),
- UINT64_C(0x8C71448D0091E255), UINT64_C(0x3F5F08330336BD3A),
- UINT64_C(0x78F572DAA8D1420E), UINT64_C(0xCBDB3E64AB761D61),
- UINT64_C(0x7D9BA13851336649), UINT64_C(0xCEB5ED8652943926),
- UINT64_C(0x891F976FF973C612), UINT64_C(0x3A31DBD1FAD4997D),
- UINT64_C(0x064B62BCAEBC387A), UINT64_C(0xB5652E02AD1B6715),
- UINT64_C(0xF2CF54EB06FC9821), UINT64_C(0x41E11855055BC74E),
- UINT64_C(0x8A3A2631AE2DDA2F), UINT64_C(0x39146A8FAD8A8540),
- UINT64_C(0x7EBE1066066D7A74), UINT64_C(0xCD905CD805CA251B),
- UINT64_C(0xF1EAE5B551A2841C), UINT64_C(0x42C4A90B5205DB73),
- UINT64_C(0x056ED3E2F9E22447), UINT64_C(0xB6409F5CFA457B28),
- UINT64_C(0xFB374270A266CC92), UINT64_C(0x48190ECEA1C193FD),
- UINT64_C(0x0FB374270A266CC9), UINT64_C(0xBC9D3899098133A6),
- UINT64_C(0x80E781F45DE992A1), UINT64_C(0x33C9CD4A5E4ECDCE),
- UINT64_C(0x7463B7A3F5A932FA), UINT64_C(0xC74DFB1DF60E6D95),
- UINT64_C(0x0C96C5795D7870F4), UINT64_C(0xBFB889C75EDF2F9B),
- UINT64_C(0xF812F32EF538D0AF), UINT64_C(0x4B3CBF90F69F8FC0),
- UINT64_C(0x774606FDA2F72EC7), UINT64_C(0xC4684A43A15071A8),
- UINT64_C(0x83C230AA0AB78E9C), UINT64_C(0x30EC7C140910D1F3),
- UINT64_C(0x86ACE348F355AADB), UINT64_C(0x3582AFF6F0F2F5B4),
- UINT64_C(0x7228D51F5B150A80), UINT64_C(0xC10699A158B255EF),
- UINT64_C(0xFD7C20CC0CDAF4E8), UINT64_C(0x4E526C720F7DAB87),
- UINT64_C(0x09F8169BA49A54B3), UINT64_C(0xBAD65A25A73D0BDC),
- UINT64_C(0x710D64410C4B16BD), UINT64_C(0xC22328FF0FEC49D2),
- UINT64_C(0x85895216A40BB6E6), UINT64_C(0x36A71EA8A7ACE989),
- UINT64_C(0x0ADDA7C5F3C4488E), UINT64_C(0xB9F3EB7BF06317E1),
- UINT64_C(0xFE5991925B84E8D5), UINT64_C(0x4D77DD2C5823B7BA),
- UINT64_C(0x64B62BCAEBC387A1), UINT64_C(0xD7986774E864D8CE),
- UINT64_C(0x90321D9D438327FA), UINT64_C(0x231C512340247895),
- UINT64_C(0x1F66E84E144CD992), UINT64_C(0xAC48A4F017EB86FD),
- UINT64_C(0xEBE2DE19BC0C79C9), UINT64_C(0x58CC92A7BFAB26A6),
- UINT64_C(0x9317ACC314DD3BC7), UINT64_C(0x2039E07D177A64A8),
- UINT64_C(0x67939A94BC9D9B9C), UINT64_C(0xD4BDD62ABF3AC4F3),
- UINT64_C(0xE8C76F47EB5265F4), UINT64_C(0x5BE923F9E8F53A9B),
- UINT64_C(0x1C4359104312C5AF), UINT64_C(0xAF6D15AE40B59AC0),
- UINT64_C(0x192D8AF2BAF0E1E8), UINT64_C(0xAA03C64CB957BE87),
- UINT64_C(0xEDA9BCA512B041B3), UINT64_C(0x5E87F01B11171EDC),
- UINT64_C(0x62FD4976457FBFDB), UINT64_C(0xD1D305C846D8E0B4),
- UINT64_C(0x96797F21ED3F1F80), UINT64_C(0x2557339FEE9840EF),
- UINT64_C(0xEE8C0DFB45EE5D8E), UINT64_C(0x5DA24145464902E1),
- UINT64_C(0x1A083BACEDAEFDD5), UINT64_C(0xA9267712EE09A2BA),
- UINT64_C(0x955CCE7FBA6103BD), UINT64_C(0x267282C1B9C65CD2),
- UINT64_C(0x61D8F8281221A3E6), UINT64_C(0xD2F6B4961186FC89),
- UINT64_C(0x9F8169BA49A54B33), UINT64_C(0x2CAF25044A02145C),
- UINT64_C(0x6B055FEDE1E5EB68), UINT64_C(0xD82B1353E242B407),
- UINT64_C(0xE451AA3EB62A1500), UINT64_C(0x577FE680B58D4A6F),
- UINT64_C(0x10D59C691E6AB55B), UINT64_C(0xA3FBD0D71DCDEA34),
- UINT64_C(0x6820EEB3B6BBF755), UINT64_C(0xDB0EA20DB51CA83A),
- UINT64_C(0x9CA4D8E41EFB570E), UINT64_C(0x2F8A945A1D5C0861),
- UINT64_C(0x13F02D374934A966), UINT64_C(0xA0DE61894A93F609),
- UINT64_C(0xE7741B60E174093D), UINT64_C(0x545A57DEE2D35652),
- UINT64_C(0xE21AC88218962D7A), UINT64_C(0x5134843C1B317215),
- UINT64_C(0x169EFED5B0D68D21), UINT64_C(0xA5B0B26BB371D24E),
- UINT64_C(0x99CA0B06E7197349), UINT64_C(0x2AE447B8E4BE2C26),
- UINT64_C(0x6D4E3D514F59D312), UINT64_C(0xDE6071EF4CFE8C7D),
- UINT64_C(0x15BB4F8BE788911C), UINT64_C(0xA6950335E42FCE73),
- UINT64_C(0xE13F79DC4FC83147), UINT64_C(0x521135624C6F6E28),
- UINT64_C(0x6E6B8C0F1807CF2F), UINT64_C(0xDD45C0B11BA09040),
- UINT64_C(0x9AEFBA58B0476F74), UINT64_C(0x29C1F6E6B3E0301B),
- UINT64_C(0xC96C5795D7870F42), UINT64_C(0x7A421B2BD420502D),
- UINT64_C(0x3DE861C27FC7AF19), UINT64_C(0x8EC62D7C7C60F076),
- UINT64_C(0xB2BC941128085171), UINT64_C(0x0192D8AF2BAF0E1E),
- UINT64_C(0x4638A2468048F12A), UINT64_C(0xF516EEF883EFAE45),
- UINT64_C(0x3ECDD09C2899B324), UINT64_C(0x8DE39C222B3EEC4B),
- UINT64_C(0xCA49E6CB80D9137F), UINT64_C(0x7967AA75837E4C10),
- UINT64_C(0x451D1318D716ED17), UINT64_C(0xF6335FA6D4B1B278),
- UINT64_C(0xB199254F7F564D4C), UINT64_C(0x02B769F17CF11223),
- UINT64_C(0xB4F7F6AD86B4690B), UINT64_C(0x07D9BA1385133664),
- UINT64_C(0x4073C0FA2EF4C950), UINT64_C(0xF35D8C442D53963F),
- UINT64_C(0xCF273529793B3738), UINT64_C(0x7C0979977A9C6857),
- UINT64_C(0x3BA3037ED17B9763), UINT64_C(0x888D4FC0D2DCC80C),
- UINT64_C(0x435671A479AAD56D), UINT64_C(0xF0783D1A7A0D8A02),
- UINT64_C(0xB7D247F3D1EA7536), UINT64_C(0x04FC0B4DD24D2A59),
- UINT64_C(0x3886B22086258B5E), UINT64_C(0x8BA8FE9E8582D431),
- UINT64_C(0xCC0284772E652B05), UINT64_C(0x7F2CC8C92DC2746A),
- UINT64_C(0x325B15E575E1C3D0), UINT64_C(0x8175595B76469CBF),
- UINT64_C(0xC6DF23B2DDA1638B), UINT64_C(0x75F16F0CDE063CE4),
- UINT64_C(0x498BD6618A6E9DE3), UINT64_C(0xFAA59ADF89C9C28C),
- UINT64_C(0xBD0FE036222E3DB8), UINT64_C(0x0E21AC88218962D7),
- UINT64_C(0xC5FA92EC8AFF7FB6), UINT64_C(0x76D4DE52895820D9),
- UINT64_C(0x317EA4BB22BFDFED), UINT64_C(0x8250E80521188082),
- UINT64_C(0xBE2A516875702185), UINT64_C(0x0D041DD676D77EEA),
- UINT64_C(0x4AAE673FDD3081DE), UINT64_C(0xF9802B81DE97DEB1),
- UINT64_C(0x4FC0B4DD24D2A599), UINT64_C(0xFCEEF8632775FAF6),
- UINT64_C(0xBB44828A8C9205C2), UINT64_C(0x086ACE348F355AAD),
- UINT64_C(0x34107759DB5DFBAA), UINT64_C(0x873E3BE7D8FAA4C5),
- UINT64_C(0xC094410E731D5BF1), UINT64_C(0x73BA0DB070BA049E),
- UINT64_C(0xB86133D4DBCC19FF), UINT64_C(0x0B4F7F6AD86B4690),
- UINT64_C(0x4CE50583738CB9A4), UINT64_C(0xFFCB493D702BE6CB),
- UINT64_C(0xC3B1F050244347CC), UINT64_C(0x709FBCEE27E418A3),
- UINT64_C(0x3735C6078C03E797), UINT64_C(0x841B8AB98FA4B8F8),
- UINT64_C(0xADDA7C5F3C4488E3), UINT64_C(0x1EF430E13FE3D78C),
- UINT64_C(0x595E4A08940428B8), UINT64_C(0xEA7006B697A377D7),
- UINT64_C(0xD60ABFDBC3CBD6D0), UINT64_C(0x6524F365C06C89BF),
- UINT64_C(0x228E898C6B8B768B), UINT64_C(0x91A0C532682C29E4),
- UINT64_C(0x5A7BFB56C35A3485), UINT64_C(0xE955B7E8C0FD6BEA),
- UINT64_C(0xAEFFCD016B1A94DE), UINT64_C(0x1DD181BF68BDCBB1),
- UINT64_C(0x21AB38D23CD56AB6), UINT64_C(0x9285746C3F7235D9),
- UINT64_C(0xD52F0E859495CAED), UINT64_C(0x6601423B97329582),
- UINT64_C(0xD041DD676D77EEAA), UINT64_C(0x636F91D96ED0B1C5),
- UINT64_C(0x24C5EB30C5374EF1), UINT64_C(0x97EBA78EC690119E),
- UINT64_C(0xAB911EE392F8B099), UINT64_C(0x18BF525D915FEFF6),
- UINT64_C(0x5F1528B43AB810C2), UINT64_C(0xEC3B640A391F4FAD),
- UINT64_C(0x27E05A6E926952CC), UINT64_C(0x94CE16D091CE0DA3),
- UINT64_C(0xD3646C393A29F297), UINT64_C(0x604A2087398EADF8),
- UINT64_C(0x5C3099EA6DE60CFF), UINT64_C(0xEF1ED5546E415390),
- UINT64_C(0xA8B4AFBDC5A6ACA4), UINT64_C(0x1B9AE303C601F3CB),
- UINT64_C(0x56ED3E2F9E224471), UINT64_C(0xE5C372919D851B1E),
- UINT64_C(0xA26908783662E42A), UINT64_C(0x114744C635C5BB45),
- UINT64_C(0x2D3DFDAB61AD1A42), UINT64_C(0x9E13B115620A452D),
- UINT64_C(0xD9B9CBFCC9EDBA19), UINT64_C(0x6A978742CA4AE576),
- UINT64_C(0xA14CB926613CF817), UINT64_C(0x1262F598629BA778),
- UINT64_C(0x55C88F71C97C584C), UINT64_C(0xE6E6C3CFCADB0723),
- UINT64_C(0xDA9C7AA29EB3A624), UINT64_C(0x69B2361C9D14F94B),
- UINT64_C(0x2E184CF536F3067F), UINT64_C(0x9D36004B35545910),
- UINT64_C(0x2B769F17CF112238), UINT64_C(0x9858D3A9CCB67D57),
- UINT64_C(0xDFF2A94067518263), UINT64_C(0x6CDCE5FE64F6DD0C),
- UINT64_C(0x50A65C93309E7C0B), UINT64_C(0xE388102D33392364),
- UINT64_C(0xA4226AC498DEDC50), UINT64_C(0x170C267A9B79833F),
- UINT64_C(0xDCD7181E300F9E5E), UINT64_C(0x6FF954A033A8C131),
- UINT64_C(0x28532E49984F3E05), UINT64_C(0x9B7D62F79BE8616A),
- UINT64_C(0xA707DB9ACF80C06D), UINT64_C(0x14299724CC279F02),
- UINT64_C(0x5383EDCD67C06036), UINT64_C(0xE0ADA17364673F59)
- }, {
- UINT64_C(0x0000000000000000), UINT64_C(0x54E979925CD0F10D),
- UINT64_C(0xA9D2F324B9A1E21A), UINT64_C(0xFD3B8AB6E5711317),
- UINT64_C(0xC17D4962DC4DDAB1), UINT64_C(0x959430F0809D2BBC),
- UINT64_C(0x68AFBA4665EC38AB), UINT64_C(0x3C46C3D4393CC9A6),
- UINT64_C(0x10223DEE1795ABE7), UINT64_C(0x44CB447C4B455AEA),
- UINT64_C(0xB9F0CECAAE3449FD), UINT64_C(0xED19B758F2E4B8F0),
- UINT64_C(0xD15F748CCBD87156), UINT64_C(0x85B60D1E9708805B),
- UINT64_C(0x788D87A87279934C), UINT64_C(0x2C64FE3A2EA96241),
- UINT64_C(0x20447BDC2F2B57CE), UINT64_C(0x74AD024E73FBA6C3),
- UINT64_C(0x899688F8968AB5D4), UINT64_C(0xDD7FF16ACA5A44D9),
- UINT64_C(0xE13932BEF3668D7F), UINT64_C(0xB5D04B2CAFB67C72),
- UINT64_C(0x48EBC19A4AC76F65), UINT64_C(0x1C02B80816179E68),
- UINT64_C(0x3066463238BEFC29), UINT64_C(0x648F3FA0646E0D24),
- UINT64_C(0x99B4B516811F1E33), UINT64_C(0xCD5DCC84DDCFEF3E),
- UINT64_C(0xF11B0F50E4F32698), UINT64_C(0xA5F276C2B823D795),
- UINT64_C(0x58C9FC745D52C482), UINT64_C(0x0C2085E60182358F),
- UINT64_C(0x4088F7B85E56AF9C), UINT64_C(0x14618E2A02865E91),
- UINT64_C(0xE95A049CE7F74D86), UINT64_C(0xBDB37D0EBB27BC8B),
- UINT64_C(0x81F5BEDA821B752D), UINT64_C(0xD51CC748DECB8420),
- UINT64_C(0x28274DFE3BBA9737), UINT64_C(0x7CCE346C676A663A),
- UINT64_C(0x50AACA5649C3047B), UINT64_C(0x0443B3C41513F576),
- UINT64_C(0xF9783972F062E661), UINT64_C(0xAD9140E0ACB2176C),
- UINT64_C(0x91D78334958EDECA), UINT64_C(0xC53EFAA6C95E2FC7),
- UINT64_C(0x380570102C2F3CD0), UINT64_C(0x6CEC098270FFCDDD),
- UINT64_C(0x60CC8C64717DF852), UINT64_C(0x3425F5F62DAD095F),
- UINT64_C(0xC91E7F40C8DC1A48), UINT64_C(0x9DF706D2940CEB45),
- UINT64_C(0xA1B1C506AD3022E3), UINT64_C(0xF558BC94F1E0D3EE),
- UINT64_C(0x086336221491C0F9), UINT64_C(0x5C8A4FB0484131F4),
- UINT64_C(0x70EEB18A66E853B5), UINT64_C(0x2407C8183A38A2B8),
- UINT64_C(0xD93C42AEDF49B1AF), UINT64_C(0x8DD53B3C839940A2),
- UINT64_C(0xB193F8E8BAA58904), UINT64_C(0xE57A817AE6757809),
- UINT64_C(0x18410BCC03046B1E), UINT64_C(0x4CA8725E5FD49A13),
- UINT64_C(0x8111EF70BCAD5F38), UINT64_C(0xD5F896E2E07DAE35),
- UINT64_C(0x28C31C54050CBD22), UINT64_C(0x7C2A65C659DC4C2F),
- UINT64_C(0x406CA61260E08589), UINT64_C(0x1485DF803C307484),
- UINT64_C(0xE9BE5536D9416793), UINT64_C(0xBD572CA48591969E),
- UINT64_C(0x9133D29EAB38F4DF), UINT64_C(0xC5DAAB0CF7E805D2),
- UINT64_C(0x38E121BA129916C5), UINT64_C(0x6C0858284E49E7C8),
- UINT64_C(0x504E9BFC77752E6E), UINT64_C(0x04A7E26E2BA5DF63),
- UINT64_C(0xF99C68D8CED4CC74), UINT64_C(0xAD75114A92043D79),
- UINT64_C(0xA15594AC938608F6), UINT64_C(0xF5BCED3ECF56F9FB),
- UINT64_C(0x088767882A27EAEC), UINT64_C(0x5C6E1E1A76F71BE1),
- UINT64_C(0x6028DDCE4FCBD247), UINT64_C(0x34C1A45C131B234A),
- UINT64_C(0xC9FA2EEAF66A305D), UINT64_C(0x9D135778AABAC150),
- UINT64_C(0xB177A9428413A311), UINT64_C(0xE59ED0D0D8C3521C),
- UINT64_C(0x18A55A663DB2410B), UINT64_C(0x4C4C23F46162B006),
- UINT64_C(0x700AE020585E79A0), UINT64_C(0x24E399B2048E88AD),
- UINT64_C(0xD9D81304E1FF9BBA), UINT64_C(0x8D316A96BD2F6AB7),
- UINT64_C(0xC19918C8E2FBF0A4), UINT64_C(0x9570615ABE2B01A9),
- UINT64_C(0x684BEBEC5B5A12BE), UINT64_C(0x3CA2927E078AE3B3),
- UINT64_C(0x00E451AA3EB62A15), UINT64_C(0x540D28386266DB18),
- UINT64_C(0xA936A28E8717C80F), UINT64_C(0xFDDFDB1CDBC73902),
- UINT64_C(0xD1BB2526F56E5B43), UINT64_C(0x85525CB4A9BEAA4E),
- UINT64_C(0x7869D6024CCFB959), UINT64_C(0x2C80AF90101F4854),
- UINT64_C(0x10C66C44292381F2), UINT64_C(0x442F15D675F370FF),
- UINT64_C(0xB9149F60908263E8), UINT64_C(0xEDFDE6F2CC5292E5),
- UINT64_C(0xE1DD6314CDD0A76A), UINT64_C(0xB5341A8691005667),
- UINT64_C(0x480F903074714570), UINT64_C(0x1CE6E9A228A1B47D),
- UINT64_C(0x20A02A76119D7DDB), UINT64_C(0x744953E44D4D8CD6),
- UINT64_C(0x8972D952A83C9FC1), UINT64_C(0xDD9BA0C0F4EC6ECC),
- UINT64_C(0xF1FF5EFADA450C8D), UINT64_C(0xA51627688695FD80),
- UINT64_C(0x582DADDE63E4EE97), UINT64_C(0x0CC4D44C3F341F9A),
- UINT64_C(0x308217980608D63C), UINT64_C(0x646B6E0A5AD82731),
- UINT64_C(0x9950E4BCBFA93426), UINT64_C(0xCDB99D2EE379C52B),
- UINT64_C(0x90FB71CAD654A0F5), UINT64_C(0xC41208588A8451F8),
- UINT64_C(0x392982EE6FF542EF), UINT64_C(0x6DC0FB7C3325B3E2),
- UINT64_C(0x518638A80A197A44), UINT64_C(0x056F413A56C98B49),
- UINT64_C(0xF854CB8CB3B8985E), UINT64_C(0xACBDB21EEF686953),
- UINT64_C(0x80D94C24C1C10B12), UINT64_C(0xD43035B69D11FA1F),
- UINT64_C(0x290BBF007860E908), UINT64_C(0x7DE2C69224B01805),
- UINT64_C(0x41A405461D8CD1A3), UINT64_C(0x154D7CD4415C20AE),
- UINT64_C(0xE876F662A42D33B9), UINT64_C(0xBC9F8FF0F8FDC2B4),
- UINT64_C(0xB0BF0A16F97FF73B), UINT64_C(0xE4567384A5AF0636),
- UINT64_C(0x196DF93240DE1521), UINT64_C(0x4D8480A01C0EE42C),
- UINT64_C(0x71C2437425322D8A), UINT64_C(0x252B3AE679E2DC87),
- UINT64_C(0xD810B0509C93CF90), UINT64_C(0x8CF9C9C2C0433E9D),
- UINT64_C(0xA09D37F8EEEA5CDC), UINT64_C(0xF4744E6AB23AADD1),
- UINT64_C(0x094FC4DC574BBEC6), UINT64_C(0x5DA6BD4E0B9B4FCB),
- UINT64_C(0x61E07E9A32A7866D), UINT64_C(0x350907086E777760),
- UINT64_C(0xC8328DBE8B066477), UINT64_C(0x9CDBF42CD7D6957A),
- UINT64_C(0xD073867288020F69), UINT64_C(0x849AFFE0D4D2FE64),
- UINT64_C(0x79A1755631A3ED73), UINT64_C(0x2D480CC46D731C7E),
- UINT64_C(0x110ECF10544FD5D8), UINT64_C(0x45E7B682089F24D5),
- UINT64_C(0xB8DC3C34EDEE37C2), UINT64_C(0xEC3545A6B13EC6CF),
- UINT64_C(0xC051BB9C9F97A48E), UINT64_C(0x94B8C20EC3475583),
- UINT64_C(0x698348B826364694), UINT64_C(0x3D6A312A7AE6B799),
- UINT64_C(0x012CF2FE43DA7E3F), UINT64_C(0x55C58B6C1F0A8F32),
- UINT64_C(0xA8FE01DAFA7B9C25), UINT64_C(0xFC177848A6AB6D28),
- UINT64_C(0xF037FDAEA72958A7), UINT64_C(0xA4DE843CFBF9A9AA),
- UINT64_C(0x59E50E8A1E88BABD), UINT64_C(0x0D0C771842584BB0),
- UINT64_C(0x314AB4CC7B648216), UINT64_C(0x65A3CD5E27B4731B),
- UINT64_C(0x989847E8C2C5600C), UINT64_C(0xCC713E7A9E159101),
- UINT64_C(0xE015C040B0BCF340), UINT64_C(0xB4FCB9D2EC6C024D),
- UINT64_C(0x49C73364091D115A), UINT64_C(0x1D2E4AF655CDE057),
- UINT64_C(0x216889226CF129F1), UINT64_C(0x7581F0B03021D8FC),
- UINT64_C(0x88BA7A06D550CBEB), UINT64_C(0xDC53039489803AE6),
- UINT64_C(0x11EA9EBA6AF9FFCD), UINT64_C(0x4503E72836290EC0),
- UINT64_C(0xB8386D9ED3581DD7), UINT64_C(0xECD1140C8F88ECDA),
- UINT64_C(0xD097D7D8B6B4257C), UINT64_C(0x847EAE4AEA64D471),
- UINT64_C(0x794524FC0F15C766), UINT64_C(0x2DAC5D6E53C5366B),
- UINT64_C(0x01C8A3547D6C542A), UINT64_C(0x5521DAC621BCA527),
- UINT64_C(0xA81A5070C4CDB630), UINT64_C(0xFCF329E2981D473D),
- UINT64_C(0xC0B5EA36A1218E9B), UINT64_C(0x945C93A4FDF17F96),
- UINT64_C(0x6967191218806C81), UINT64_C(0x3D8E608044509D8C),
- UINT64_C(0x31AEE56645D2A803), UINT64_C(0x65479CF41902590E),
- UINT64_C(0x987C1642FC734A19), UINT64_C(0xCC956FD0A0A3BB14),
- UINT64_C(0xF0D3AC04999F72B2), UINT64_C(0xA43AD596C54F83BF),
- UINT64_C(0x59015F20203E90A8), UINT64_C(0x0DE826B27CEE61A5),
- UINT64_C(0x218CD888524703E4), UINT64_C(0x7565A11A0E97F2E9),
- UINT64_C(0x885E2BACEBE6E1FE), UINT64_C(0xDCB7523EB73610F3),
- UINT64_C(0xE0F191EA8E0AD955), UINT64_C(0xB418E878D2DA2858),
- UINT64_C(0x492362CE37AB3B4F), UINT64_C(0x1DCA1B5C6B7BCA42),
- UINT64_C(0x5162690234AF5051), UINT64_C(0x058B1090687FA15C),
- UINT64_C(0xF8B09A268D0EB24B), UINT64_C(0xAC59E3B4D1DE4346),
- UINT64_C(0x901F2060E8E28AE0), UINT64_C(0xC4F659F2B4327BED),
- UINT64_C(0x39CDD344514368FA), UINT64_C(0x6D24AAD60D9399F7),
- UINT64_C(0x414054EC233AFBB6), UINT64_C(0x15A92D7E7FEA0ABB),
- UINT64_C(0xE892A7C89A9B19AC), UINT64_C(0xBC7BDE5AC64BE8A1),
- UINT64_C(0x803D1D8EFF772107), UINT64_C(0xD4D4641CA3A7D00A),
- UINT64_C(0x29EFEEAA46D6C31D), UINT64_C(0x7D0697381A063210),
- UINT64_C(0x712612DE1B84079F), UINT64_C(0x25CF6B4C4754F692),
- UINT64_C(0xD8F4E1FAA225E585), UINT64_C(0x8C1D9868FEF51488),
- UINT64_C(0xB05B5BBCC7C9DD2E), UINT64_C(0xE4B2222E9B192C23),
- UINT64_C(0x1989A8987E683F34), UINT64_C(0x4D60D10A22B8CE39),
- UINT64_C(0x61042F300C11AC78), UINT64_C(0x35ED56A250C15D75),
- UINT64_C(0xC8D6DC14B5B04E62), UINT64_C(0x9C3FA586E960BF6F),
- UINT64_C(0xA0796652D05C76C9), UINT64_C(0xF4901FC08C8C87C4),
- UINT64_C(0x09AB957669FD94D3), UINT64_C(0x5D42ECE4352D65DE)
- }, {
- UINT64_C(0x0000000000000000), UINT64_C(0x3F0BE14A916A6DCB),
- UINT64_C(0x7E17C29522D4DB96), UINT64_C(0x411C23DFB3BEB65D),
- UINT64_C(0xFC2F852A45A9B72C), UINT64_C(0xC3246460D4C3DAE7),
- UINT64_C(0x823847BF677D6CBA), UINT64_C(0xBD33A6F5F6170171),
- UINT64_C(0x6A87A57F245D70DD), UINT64_C(0x558C4435B5371D16),
- UINT64_C(0x149067EA0689AB4B), UINT64_C(0x2B9B86A097E3C680),
- UINT64_C(0x96A8205561F4C7F1), UINT64_C(0xA9A3C11FF09EAA3A),
- UINT64_C(0xE8BFE2C043201C67), UINT64_C(0xD7B4038AD24A71AC),
- UINT64_C(0xD50F4AFE48BAE1BA), UINT64_C(0xEA04ABB4D9D08C71),
- UINT64_C(0xAB18886B6A6E3A2C), UINT64_C(0x94136921FB0457E7),
- UINT64_C(0x2920CFD40D135696), UINT64_C(0x162B2E9E9C793B5D),
- UINT64_C(0x57370D412FC78D00), UINT64_C(0x683CEC0BBEADE0CB),
- UINT64_C(0xBF88EF816CE79167), UINT64_C(0x80830ECBFD8DFCAC),
- UINT64_C(0xC19F2D144E334AF1), UINT64_C(0xFE94CC5EDF59273A),
- UINT64_C(0x43A76AAB294E264B), UINT64_C(0x7CAC8BE1B8244B80),
- UINT64_C(0x3DB0A83E0B9AFDDD), UINT64_C(0x02BB49749AF09016),
- UINT64_C(0x38C63AD73E7BDDF1), UINT64_C(0x07CDDB9DAF11B03A),
- UINT64_C(0x46D1F8421CAF0667), UINT64_C(0x79DA19088DC56BAC),
- UINT64_C(0xC4E9BFFD7BD26ADD), UINT64_C(0xFBE25EB7EAB80716),
- UINT64_C(0xBAFE7D685906B14B), UINT64_C(0x85F59C22C86CDC80),
- UINT64_C(0x52419FA81A26AD2C), UINT64_C(0x6D4A7EE28B4CC0E7),
- UINT64_C(0x2C565D3D38F276BA), UINT64_C(0x135DBC77A9981B71),
- UINT64_C(0xAE6E1A825F8F1A00), UINT64_C(0x9165FBC8CEE577CB),
- UINT64_C(0xD079D8177D5BC196), UINT64_C(0xEF72395DEC31AC5D),
- UINT64_C(0xEDC9702976C13C4B), UINT64_C(0xD2C29163E7AB5180),
- UINT64_C(0x93DEB2BC5415E7DD), UINT64_C(0xACD553F6C57F8A16),
- UINT64_C(0x11E6F50333688B67), UINT64_C(0x2EED1449A202E6AC),
- UINT64_C(0x6FF1379611BC50F1), UINT64_C(0x50FAD6DC80D63D3A),
- UINT64_C(0x874ED556529C4C96), UINT64_C(0xB845341CC3F6215D),
- UINT64_C(0xF95917C370489700), UINT64_C(0xC652F689E122FACB),
- UINT64_C(0x7B61507C1735FBBA), UINT64_C(0x446AB136865F9671),
- UINT64_C(0x057692E935E1202C), UINT64_C(0x3A7D73A3A48B4DE7),
- UINT64_C(0x718C75AE7CF7BBE2), UINT64_C(0x4E8794E4ED9DD629),
- UINT64_C(0x0F9BB73B5E236074), UINT64_C(0x30905671CF490DBF),
- UINT64_C(0x8DA3F084395E0CCE), UINT64_C(0xB2A811CEA8346105),
- UINT64_C(0xF3B432111B8AD758), UINT64_C(0xCCBFD35B8AE0BA93),
- UINT64_C(0x1B0BD0D158AACB3F), UINT64_C(0x2400319BC9C0A6F4),
- UINT64_C(0x651C12447A7E10A9), UINT64_C(0x5A17F30EEB147D62),
- UINT64_C(0xE72455FB1D037C13), UINT64_C(0xD82FB4B18C6911D8),
- UINT64_C(0x9933976E3FD7A785), UINT64_C(0xA6387624AEBDCA4E),
- UINT64_C(0xA4833F50344D5A58), UINT64_C(0x9B88DE1AA5273793),
- UINT64_C(0xDA94FDC5169981CE), UINT64_C(0xE59F1C8F87F3EC05),
- UINT64_C(0x58ACBA7A71E4ED74), UINT64_C(0x67A75B30E08E80BF),
- UINT64_C(0x26BB78EF533036E2), UINT64_C(0x19B099A5C25A5B29),
- UINT64_C(0xCE049A2F10102A85), UINT64_C(0xF10F7B65817A474E),
- UINT64_C(0xB01358BA32C4F113), UINT64_C(0x8F18B9F0A3AE9CD8),
- UINT64_C(0x322B1F0555B99DA9), UINT64_C(0x0D20FE4FC4D3F062),
- UINT64_C(0x4C3CDD90776D463F), UINT64_C(0x73373CDAE6072BF4),
- UINT64_C(0x494A4F79428C6613), UINT64_C(0x7641AE33D3E60BD8),
- UINT64_C(0x375D8DEC6058BD85), UINT64_C(0x08566CA6F132D04E),
- UINT64_C(0xB565CA530725D13F), UINT64_C(0x8A6E2B19964FBCF4),
- UINT64_C(0xCB7208C625F10AA9), UINT64_C(0xF479E98CB49B6762),
- UINT64_C(0x23CDEA0666D116CE), UINT64_C(0x1CC60B4CF7BB7B05),
- UINT64_C(0x5DDA28934405CD58), UINT64_C(0x62D1C9D9D56FA093),
- UINT64_C(0xDFE26F2C2378A1E2), UINT64_C(0xE0E98E66B212CC29),
- UINT64_C(0xA1F5ADB901AC7A74), UINT64_C(0x9EFE4CF390C617BF),
- UINT64_C(0x9C4505870A3687A9), UINT64_C(0xA34EE4CD9B5CEA62),
- UINT64_C(0xE252C71228E25C3F), UINT64_C(0xDD592658B98831F4),
- UINT64_C(0x606A80AD4F9F3085), UINT64_C(0x5F6161E7DEF55D4E),
- UINT64_C(0x1E7D42386D4BEB13), UINT64_C(0x2176A372FC2186D8),
- UINT64_C(0xF6C2A0F82E6BF774), UINT64_C(0xC9C941B2BF019ABF),
- UINT64_C(0x88D5626D0CBF2CE2), UINT64_C(0xB7DE83279DD54129),
- UINT64_C(0x0AED25D26BC24058), UINT64_C(0x35E6C498FAA82D93),
- UINT64_C(0x74FAE74749169BCE), UINT64_C(0x4BF1060DD87CF605),
- UINT64_C(0xE318EB5CF9EF77C4), UINT64_C(0xDC130A1668851A0F),
- UINT64_C(0x9D0F29C9DB3BAC52), UINT64_C(0xA204C8834A51C199),
- UINT64_C(0x1F376E76BC46C0E8), UINT64_C(0x203C8F3C2D2CAD23),
- UINT64_C(0x6120ACE39E921B7E), UINT64_C(0x5E2B4DA90FF876B5),
- UINT64_C(0x899F4E23DDB20719), UINT64_C(0xB694AF694CD86AD2),
- UINT64_C(0xF7888CB6FF66DC8F), UINT64_C(0xC8836DFC6E0CB144),
- UINT64_C(0x75B0CB09981BB035), UINT64_C(0x4ABB2A430971DDFE),
- UINT64_C(0x0BA7099CBACF6BA3), UINT64_C(0x34ACE8D62BA50668),
- UINT64_C(0x3617A1A2B155967E), UINT64_C(0x091C40E8203FFBB5),
- UINT64_C(0x4800633793814DE8), UINT64_C(0x770B827D02EB2023),
- UINT64_C(0xCA382488F4FC2152), UINT64_C(0xF533C5C265964C99),
- UINT64_C(0xB42FE61DD628FAC4), UINT64_C(0x8B2407574742970F),
- UINT64_C(0x5C9004DD9508E6A3), UINT64_C(0x639BE59704628B68),
- UINT64_C(0x2287C648B7DC3D35), UINT64_C(0x1D8C270226B650FE),
- UINT64_C(0xA0BF81F7D0A1518F), UINT64_C(0x9FB460BD41CB3C44),
- UINT64_C(0xDEA84362F2758A19), UINT64_C(0xE1A3A228631FE7D2),
- UINT64_C(0xDBDED18BC794AA35), UINT64_C(0xE4D530C156FEC7FE),
- UINT64_C(0xA5C9131EE54071A3), UINT64_C(0x9AC2F254742A1C68),
- UINT64_C(0x27F154A1823D1D19), UINT64_C(0x18FAB5EB135770D2),
- UINT64_C(0x59E69634A0E9C68F), UINT64_C(0x66ED777E3183AB44),
- UINT64_C(0xB15974F4E3C9DAE8), UINT64_C(0x8E5295BE72A3B723),
- UINT64_C(0xCF4EB661C11D017E), UINT64_C(0xF045572B50776CB5),
- UINT64_C(0x4D76F1DEA6606DC4), UINT64_C(0x727D1094370A000F),
- UINT64_C(0x3361334B84B4B652), UINT64_C(0x0C6AD20115DEDB99),
- UINT64_C(0x0ED19B758F2E4B8F), UINT64_C(0x31DA7A3F1E442644),
- UINT64_C(0x70C659E0ADFA9019), UINT64_C(0x4FCDB8AA3C90FDD2),
- UINT64_C(0xF2FE1E5FCA87FCA3), UINT64_C(0xCDF5FF155BED9168),
- UINT64_C(0x8CE9DCCAE8532735), UINT64_C(0xB3E23D8079394AFE),
- UINT64_C(0x64563E0AAB733B52), UINT64_C(0x5B5DDF403A195699),
- UINT64_C(0x1A41FC9F89A7E0C4), UINT64_C(0x254A1DD518CD8D0F),
- UINT64_C(0x9879BB20EEDA8C7E), UINT64_C(0xA7725A6A7FB0E1B5),
- UINT64_C(0xE66E79B5CC0E57E8), UINT64_C(0xD96598FF5D643A23),
- UINT64_C(0x92949EF28518CC26), UINT64_C(0xAD9F7FB81472A1ED),
- UINT64_C(0xEC835C67A7CC17B0), UINT64_C(0xD388BD2D36A67A7B),
- UINT64_C(0x6EBB1BD8C0B17B0A), UINT64_C(0x51B0FA9251DB16C1),
- UINT64_C(0x10ACD94DE265A09C), UINT64_C(0x2FA73807730FCD57),
- UINT64_C(0xF8133B8DA145BCFB), UINT64_C(0xC718DAC7302FD130),
- UINT64_C(0x8604F9188391676D), UINT64_C(0xB90F185212FB0AA6),
- UINT64_C(0x043CBEA7E4EC0BD7), UINT64_C(0x3B375FED7586661C),
- UINT64_C(0x7A2B7C32C638D041), UINT64_C(0x45209D785752BD8A),
- UINT64_C(0x479BD40CCDA22D9C), UINT64_C(0x789035465CC84057),
- UINT64_C(0x398C1699EF76F60A), UINT64_C(0x0687F7D37E1C9BC1),
- UINT64_C(0xBBB45126880B9AB0), UINT64_C(0x84BFB06C1961F77B),
- UINT64_C(0xC5A393B3AADF4126), UINT64_C(0xFAA872F93BB52CED),
- UINT64_C(0x2D1C7173E9FF5D41), UINT64_C(0x121790397895308A),
- UINT64_C(0x530BB3E6CB2B86D7), UINT64_C(0x6C0052AC5A41EB1C),
- UINT64_C(0xD133F459AC56EA6D), UINT64_C(0xEE3815133D3C87A6),
- UINT64_C(0xAF2436CC8E8231FB), UINT64_C(0x902FD7861FE85C30),
- UINT64_C(0xAA52A425BB6311D7), UINT64_C(0x9559456F2A097C1C),
- UINT64_C(0xD44566B099B7CA41), UINT64_C(0xEB4E87FA08DDA78A),
- UINT64_C(0x567D210FFECAA6FB), UINT64_C(0x6976C0456FA0CB30),
- UINT64_C(0x286AE39ADC1E7D6D), UINT64_C(0x176102D04D7410A6),
- UINT64_C(0xC0D5015A9F3E610A), UINT64_C(0xFFDEE0100E540CC1),
- UINT64_C(0xBEC2C3CFBDEABA9C), UINT64_C(0x81C922852C80D757),
- UINT64_C(0x3CFA8470DA97D626), UINT64_C(0x03F1653A4BFDBBED),
- UINT64_C(0x42ED46E5F8430DB0), UINT64_C(0x7DE6A7AF6929607B),
- UINT64_C(0x7F5DEEDBF3D9F06D), UINT64_C(0x40560F9162B39DA6),
- UINT64_C(0x014A2C4ED10D2BFB), UINT64_C(0x3E41CD0440674630),
- UINT64_C(0x83726BF1B6704741), UINT64_C(0xBC798ABB271A2A8A),
- UINT64_C(0xFD65A96494A49CD7), UINT64_C(0xC26E482E05CEF11C),
- UINT64_C(0x15DA4BA4D78480B0), UINT64_C(0x2AD1AAEE46EEED7B),
- UINT64_C(0x6BCD8931F5505B26), UINT64_C(0x54C6687B643A36ED),
- UINT64_C(0xE9F5CE8E922D379C), UINT64_C(0xD6FE2FC403475A57),
- UINT64_C(0x97E20C1BB0F9EC0A), UINT64_C(0xA8E9ED51219381C1)
- }, {
- UINT64_C(0x0000000000000000), UINT64_C(0x1DEE8A5E222CA1DC),
- UINT64_C(0x3BDD14BC445943B8), UINT64_C(0x26339EE26675E264),
- UINT64_C(0x77BA297888B28770), UINT64_C(0x6A54A326AA9E26AC),
- UINT64_C(0x4C673DC4CCEBC4C8), UINT64_C(0x5189B79AEEC76514),
- UINT64_C(0xEF7452F111650EE0), UINT64_C(0xF29AD8AF3349AF3C),
- UINT64_C(0xD4A9464D553C4D58), UINT64_C(0xC947CC137710EC84),
- UINT64_C(0x98CE7B8999D78990), UINT64_C(0x8520F1D7BBFB284C),
- UINT64_C(0xA3136F35DD8ECA28), UINT64_C(0xBEFDE56BFFA26BF4),
- UINT64_C(0x4C300AC98DC40345), UINT64_C(0x51DE8097AFE8A299),
- UINT64_C(0x77ED1E75C99D40FD), UINT64_C(0x6A03942BEBB1E121),
- UINT64_C(0x3B8A23B105768435), UINT64_C(0x2664A9EF275A25E9),
- UINT64_C(0x0057370D412FC78D), UINT64_C(0x1DB9BD5363036651),
- UINT64_C(0xA34458389CA10DA5), UINT64_C(0xBEAAD266BE8DAC79),
- UINT64_C(0x98994C84D8F84E1D), UINT64_C(0x8577C6DAFAD4EFC1),
- UINT64_C(0xD4FE714014138AD5), UINT64_C(0xC910FB1E363F2B09),
- UINT64_C(0xEF2365FC504AC96D), UINT64_C(0xF2CDEFA2726668B1),
- UINT64_C(0x986015931B88068A), UINT64_C(0x858E9FCD39A4A756),
- UINT64_C(0xA3BD012F5FD14532), UINT64_C(0xBE538B717DFDE4EE),
- UINT64_C(0xEFDA3CEB933A81FA), UINT64_C(0xF234B6B5B1162026),
- UINT64_C(0xD4072857D763C242), UINT64_C(0xC9E9A209F54F639E),
- UINT64_C(0x771447620AED086A), UINT64_C(0x6AFACD3C28C1A9B6),
- UINT64_C(0x4CC953DE4EB44BD2), UINT64_C(0x5127D9806C98EA0E),
- UINT64_C(0x00AE6E1A825F8F1A), UINT64_C(0x1D40E444A0732EC6),
- UINT64_C(0x3B737AA6C606CCA2), UINT64_C(0x269DF0F8E42A6D7E),
- UINT64_C(0xD4501F5A964C05CF), UINT64_C(0xC9BE9504B460A413),
- UINT64_C(0xEF8D0BE6D2154677), UINT64_C(0xF26381B8F039E7AB),
- UINT64_C(0xA3EA36221EFE82BF), UINT64_C(0xBE04BC7C3CD22363),
- UINT64_C(0x9837229E5AA7C107), UINT64_C(0x85D9A8C0788B60DB),
- UINT64_C(0x3B244DAB87290B2F), UINT64_C(0x26CAC7F5A505AAF3),
- UINT64_C(0x00F95917C3704897), UINT64_C(0x1D17D349E15CE94B),
- UINT64_C(0x4C9E64D30F9B8C5F), UINT64_C(0x5170EE8D2DB72D83),
- UINT64_C(0x7743706F4BC2CFE7), UINT64_C(0x6AADFA3169EE6E3B),
- UINT64_C(0xA218840D981E1391), UINT64_C(0xBFF60E53BA32B24D),
- UINT64_C(0x99C590B1DC475029), UINT64_C(0x842B1AEFFE6BF1F5),
- UINT64_C(0xD5A2AD7510AC94E1), UINT64_C(0xC84C272B3280353D),
- UINT64_C(0xEE7FB9C954F5D759), UINT64_C(0xF391339776D97685),
- UINT64_C(0x4D6CD6FC897B1D71), UINT64_C(0x50825CA2AB57BCAD),
- UINT64_C(0x76B1C240CD225EC9), UINT64_C(0x6B5F481EEF0EFF15),
- UINT64_C(0x3AD6FF8401C99A01), UINT64_C(0x273875DA23E53BDD),
- UINT64_C(0x010BEB384590D9B9), UINT64_C(0x1CE5616667BC7865),
- UINT64_C(0xEE288EC415DA10D4), UINT64_C(0xF3C6049A37F6B108),
- UINT64_C(0xD5F59A785183536C), UINT64_C(0xC81B102673AFF2B0),
- UINT64_C(0x9992A7BC9D6897A4), UINT64_C(0x847C2DE2BF443678),
- UINT64_C(0xA24FB300D931D41C), UINT64_C(0xBFA1395EFB1D75C0),
- UINT64_C(0x015CDC3504BF1E34), UINT64_C(0x1CB2566B2693BFE8),
- UINT64_C(0x3A81C88940E65D8C), UINT64_C(0x276F42D762CAFC50),
- UINT64_C(0x76E6F54D8C0D9944), UINT64_C(0x6B087F13AE213898),
- UINT64_C(0x4D3BE1F1C854DAFC), UINT64_C(0x50D56BAFEA787B20),
- UINT64_C(0x3A78919E8396151B), UINT64_C(0x27961BC0A1BAB4C7),
- UINT64_C(0x01A58522C7CF56A3), UINT64_C(0x1C4B0F7CE5E3F77F),
- UINT64_C(0x4DC2B8E60B24926B), UINT64_C(0x502C32B8290833B7),
- UINT64_C(0x761FAC5A4F7DD1D3), UINT64_C(0x6BF126046D51700F),
- UINT64_C(0xD50CC36F92F31BFB), UINT64_C(0xC8E24931B0DFBA27),
- UINT64_C(0xEED1D7D3D6AA5843), UINT64_C(0xF33F5D8DF486F99F),
- UINT64_C(0xA2B6EA171A419C8B), UINT64_C(0xBF586049386D3D57),
- UINT64_C(0x996BFEAB5E18DF33), UINT64_C(0x848574F57C347EEF),
- UINT64_C(0x76489B570E52165E), UINT64_C(0x6BA611092C7EB782),
- UINT64_C(0x4D958FEB4A0B55E6), UINT64_C(0x507B05B56827F43A),
- UINT64_C(0x01F2B22F86E0912E), UINT64_C(0x1C1C3871A4CC30F2),
- UINT64_C(0x3A2FA693C2B9D296), UINT64_C(0x27C12CCDE095734A),
- UINT64_C(0x993CC9A61F3718BE), UINT64_C(0x84D243F83D1BB962),
- UINT64_C(0xA2E1DD1A5B6E5B06), UINT64_C(0xBF0F57447942FADA),
- UINT64_C(0xEE86E0DE97859FCE), UINT64_C(0xF3686A80B5A93E12),
- UINT64_C(0xD55BF462D3DCDC76), UINT64_C(0xC8B57E3CF1F07DAA),
- UINT64_C(0xD6E9A7309F3239A7), UINT64_C(0xCB072D6EBD1E987B),
- UINT64_C(0xED34B38CDB6B7A1F), UINT64_C(0xF0DA39D2F947DBC3),
- UINT64_C(0xA1538E481780BED7), UINT64_C(0xBCBD041635AC1F0B),
- UINT64_C(0x9A8E9AF453D9FD6F), UINT64_C(0x876010AA71F55CB3),
- UINT64_C(0x399DF5C18E573747), UINT64_C(0x24737F9FAC7B969B),
- UINT64_C(0x0240E17DCA0E74FF), UINT64_C(0x1FAE6B23E822D523),
- UINT64_C(0x4E27DCB906E5B037), UINT64_C(0x53C956E724C911EB),
- UINT64_C(0x75FAC80542BCF38F), UINT64_C(0x6814425B60905253),
- UINT64_C(0x9AD9ADF912F63AE2), UINT64_C(0x873727A730DA9B3E),
- UINT64_C(0xA104B94556AF795A), UINT64_C(0xBCEA331B7483D886),
- UINT64_C(0xED6384819A44BD92), UINT64_C(0xF08D0EDFB8681C4E),
- UINT64_C(0xD6BE903DDE1DFE2A), UINT64_C(0xCB501A63FC315FF6),
- UINT64_C(0x75ADFF0803933402), UINT64_C(0x6843755621BF95DE),
- UINT64_C(0x4E70EBB447CA77BA), UINT64_C(0x539E61EA65E6D666),
- UINT64_C(0x0217D6708B21B372), UINT64_C(0x1FF95C2EA90D12AE),
- UINT64_C(0x39CAC2CCCF78F0CA), UINT64_C(0x24244892ED545116),
- UINT64_C(0x4E89B2A384BA3F2D), UINT64_C(0x536738FDA6969EF1),
- UINT64_C(0x7554A61FC0E37C95), UINT64_C(0x68BA2C41E2CFDD49),
- UINT64_C(0x39339BDB0C08B85D), UINT64_C(0x24DD11852E241981),
- UINT64_C(0x02EE8F674851FBE5), UINT64_C(0x1F0005396A7D5A39),
- UINT64_C(0xA1FDE05295DF31CD), UINT64_C(0xBC136A0CB7F39011),
- UINT64_C(0x9A20F4EED1867275), UINT64_C(0x87CE7EB0F3AAD3A9),
- UINT64_C(0xD647C92A1D6DB6BD), UINT64_C(0xCBA943743F411761),
- UINT64_C(0xED9ADD965934F505), UINT64_C(0xF07457C87B1854D9),
- UINT64_C(0x02B9B86A097E3C68), UINT64_C(0x1F5732342B529DB4),
- UINT64_C(0x3964ACD64D277FD0), UINT64_C(0x248A26886F0BDE0C),
- UINT64_C(0x7503911281CCBB18), UINT64_C(0x68ED1B4CA3E01AC4),
- UINT64_C(0x4EDE85AEC595F8A0), UINT64_C(0x53300FF0E7B9597C),
- UINT64_C(0xEDCDEA9B181B3288), UINT64_C(0xF02360C53A379354),
- UINT64_C(0xD610FE275C427130), UINT64_C(0xCBFE74797E6ED0EC),
- UINT64_C(0x9A77C3E390A9B5F8), UINT64_C(0x879949BDB2851424),
- UINT64_C(0xA1AAD75FD4F0F640), UINT64_C(0xBC445D01F6DC579C),
- UINT64_C(0x74F1233D072C2A36), UINT64_C(0x691FA96325008BEA),
- UINT64_C(0x4F2C37814375698E), UINT64_C(0x52C2BDDF6159C852),
- UINT64_C(0x034B0A458F9EAD46), UINT64_C(0x1EA5801BADB20C9A),
- UINT64_C(0x38961EF9CBC7EEFE), UINT64_C(0x257894A7E9EB4F22),
- UINT64_C(0x9B8571CC164924D6), UINT64_C(0x866BFB923465850A),
- UINT64_C(0xA05865705210676E), UINT64_C(0xBDB6EF2E703CC6B2),
- UINT64_C(0xEC3F58B49EFBA3A6), UINT64_C(0xF1D1D2EABCD7027A),
- UINT64_C(0xD7E24C08DAA2E01E), UINT64_C(0xCA0CC656F88E41C2),
- UINT64_C(0x38C129F48AE82973), UINT64_C(0x252FA3AAA8C488AF),
- UINT64_C(0x031C3D48CEB16ACB), UINT64_C(0x1EF2B716EC9DCB17),
- UINT64_C(0x4F7B008C025AAE03), UINT64_C(0x52958AD220760FDF),
- UINT64_C(0x74A614304603EDBB), UINT64_C(0x69489E6E642F4C67),
- UINT64_C(0xD7B57B059B8D2793), UINT64_C(0xCA5BF15BB9A1864F),
- UINT64_C(0xEC686FB9DFD4642B), UINT64_C(0xF186E5E7FDF8C5F7),
- UINT64_C(0xA00F527D133FA0E3), UINT64_C(0xBDE1D8233113013F),
- UINT64_C(0x9BD246C15766E35B), UINT64_C(0x863CCC9F754A4287),
- UINT64_C(0xEC9136AE1CA42CBC), UINT64_C(0xF17FBCF03E888D60),
- UINT64_C(0xD74C221258FD6F04), UINT64_C(0xCAA2A84C7AD1CED8),
- UINT64_C(0x9B2B1FD69416ABCC), UINT64_C(0x86C59588B63A0A10),
- UINT64_C(0xA0F60B6AD04FE874), UINT64_C(0xBD188134F26349A8),
- UINT64_C(0x03E5645F0DC1225C), UINT64_C(0x1E0BEE012FED8380),
- UINT64_C(0x383870E3499861E4), UINT64_C(0x25D6FABD6BB4C038),
- UINT64_C(0x745F4D278573A52C), UINT64_C(0x69B1C779A75F04F0),
- UINT64_C(0x4F82599BC12AE694), UINT64_C(0x526CD3C5E3064748),
- UINT64_C(0xA0A13C6791602FF9), UINT64_C(0xBD4FB639B34C8E25),
- UINT64_C(0x9B7C28DBD5396C41), UINT64_C(0x8692A285F715CD9D),
- UINT64_C(0xD71B151F19D2A889), UINT64_C(0xCAF59F413BFE0955),
- UINT64_C(0xECC601A35D8BEB31), UINT64_C(0xF1288BFD7FA74AED),
- UINT64_C(0x4FD56E9680052119), UINT64_C(0x523BE4C8A22980C5),
- UINT64_C(0x74087A2AC45C62A1), UINT64_C(0x69E6F074E670C37D),
- UINT64_C(0x386F47EE08B7A669), UINT64_C(0x2581CDB02A9B07B5),
- UINT64_C(0x03B253524CEEE5D1), UINT64_C(0x1E5CD90C6EC2440D)
- }
-};
diff -Nru r-base-3.2.3/src/extra/xz/check/crc64_x86.S r-base-3.3.1/src/extra/xz/check/crc64_x86.S
--- r-base-3.2.3/src/extra/xz/check/crc64_x86.S 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc64_x86.S 1970-01-01 00:00:00.000000000 +0000
@@ -1,287 +0,0 @@
-/*
- * Speed-optimized CRC64 using slicing-by-four algorithm
- *
- * This uses only i386 instructions, but it is optimized for i686 and later
- * (including e.g. Pentium II/III/IV, Athlon XP, and Core 2).
- *
- * Authors: Igor Pavlov (original CRC32 assembly code)
- * Lasse Collin (CRC64 adaptation of the modified CRC32 code)
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * This code needs lzma_crc64_table, which can be created using the
- * following C code:
-
-uint64_t lzma_crc64_table[4][256];
-
-void
-init_table(void)
-{
- // ECMA-182
- static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42);
-
- for (size_t s = 0; s < 4; ++s) {
- for (size_t b = 0; b < 256; ++b) {
- uint64_t r = s == 0 ? b : lzma_crc64_table[s - 1][b];
-
- for (size_t i = 0; i < 8; ++i) {
- if (r & 1)
- r = (r >> 1) ^ poly64;
- else
- r >>= 1;
- }
-
- lzma_crc64_table[s][b] = r;
- }
- }
-}
-
- * The prototype of the CRC64 function:
- * extern uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc);
- */
-
-/*
- * On some systems, the functions need to be prefixed. The prefix is
- * usually an underscore.
- */
-#ifndef __USER_LABEL_PREFIX__
-# define __USER_LABEL_PREFIX__
-#endif
-#define MAKE_SYM_CAT(prefix, sym) prefix ## sym
-#define MAKE_SYM(prefix, sym) MAKE_SYM_CAT(prefix, sym)
-#define LZMA_CRC64 MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc64)
-#define LZMA_CRC64_TABLE MAKE_SYM(__USER_LABEL_PREFIX__, lzma_crc64_table)
-
-/*
- * Solaris assembler doesn't have .p2align, and Darwin uses .align
- * differently than GNU/Linux and Solaris.
- */
-#if defined(__APPLE__) || defined(__MSDOS__)
-# define ALIGN(pow2, abs) .align pow2
-#else
-# define ALIGN(pow2, abs) .align abs
-#endif
-
- .text
- .globl LZMA_CRC64
-
-#if !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) \
- && !defined(__MSDOS__)
- .type LZMA_CRC64, @function
-#endif
-
- ALIGN(4, 16)
-LZMA_CRC64:
- /*
- * Register usage:
- * %eax crc LSB
- * %edx crc MSB
- * %esi buf
- * %edi size or buf + size
- * %ebx lzma_crc64_table
- * %ebp Table index
- * %ecx Temporary
- */
- pushl %ebx
- pushl %esi
- pushl %edi
- pushl %ebp
- movl 0x14(%esp), %esi /* buf */
- movl 0x18(%esp), %edi /* size */
- movl 0x1C(%esp), %eax /* crc LSB */
- movl 0x20(%esp), %edx /* crc MSB */
-
- /*
- * Store the address of lzma_crc64_table to %ebx. This is needed to
- * get position-independent code (PIC).
- *
- * The PIC macro is defined by libtool, while __PIC__ is defined
- * by GCC but only on some systems. Testing for both makes it simpler
- * to test this code without libtool, and keeps the code working also
- * when built with libtool but using something else than GCC.
- *
- * I understood that libtool may define PIC on Windows even though
- * the code in Windows DLLs is not PIC in sense that it is in ELF
- * binaries, so we need a separate check to always use the non-PIC
- * code on Windows.
- */
-#if (!defined(PIC) && !defined(__PIC__)) \
- || (defined(_WIN32) || defined(__CYGWIN__))
- /* Not PIC */
- movl $ LZMA_CRC64_TABLE, %ebx
-#elif defined(__APPLE__)
- /* Mach-O */
- call .L_get_pc
-.L_pic:
- leal .L_lzma_crc64_table$non_lazy_ptr-.L_pic(%ebx), %ebx
- movl (%ebx), %ebx
-#else
- /* ELF */
- call .L_get_pc
- addl $_GLOBAL_OFFSET_TABLE_, %ebx
- movl LZMA_CRC64_TABLE@GOT(%ebx), %ebx
-#endif
-
- /* Complement the initial value. */
- notl %eax
- notl %edx
-
-.L_align:
- /*
- * Check if there is enough input to use slicing-by-four.
- * We need eight bytes, because the loop pre-reads four bytes.
- */
- cmpl $8, %edi
- jb .L_rest
-
- /* Check if we have reached alignment of four bytes. */
- testl $3, %esi
- jz .L_slice
-
- /* Calculate CRC of the next input byte. */
- movzbl (%esi), %ebp
- incl %esi
- movzbl %al, %ecx
- xorl %ecx, %ebp
- shrdl $8, %edx, %eax
- xorl (%ebx, %ebp, 8), %eax
- shrl $8, %edx
- xorl 4(%ebx, %ebp, 8), %edx
- decl %edi
- jmp .L_align
-
-.L_slice:
- /*
- * If we get here, there's at least eight bytes of aligned input
- * available. Make %edi multiple of four bytes. Store the possible
- * remainder over the "size" variable in the argument stack.
- */
- movl %edi, 0x18(%esp)
- andl $-4, %edi
- subl %edi, 0x18(%esp)
-
- /*
- * Let %edi be buf + size - 4 while running the main loop. This way
- * we can compare for equality to determine when exit the loop.
- */
- addl %esi, %edi
- subl $4, %edi
-
- /* Read in the first four aligned bytes. */
- movl (%esi), %ecx
-
-.L_loop:
- xorl %eax, %ecx
- movzbl %cl, %ebp
- movl 0x1800(%ebx, %ebp, 8), %eax
- xorl %edx, %eax
- movl 0x1804(%ebx, %ebp, 8), %edx
- movzbl %ch, %ebp
- xorl 0x1000(%ebx, %ebp, 8), %eax
- xorl 0x1004(%ebx, %ebp, 8), %edx
- shrl $16, %ecx
- movzbl %cl, %ebp
- xorl 0x0800(%ebx, %ebp, 8), %eax
- xorl 0x0804(%ebx, %ebp, 8), %edx
- movzbl %ch, %ebp
- addl $4, %esi
- xorl (%ebx, %ebp, 8), %eax
- xorl 4(%ebx, %ebp, 8), %edx
-
- /* Check for end of aligned input. */
- cmpl %edi, %esi
-
- /*
- * Copy the next input byte to %ecx. It is slightly faster to
- * read it here than at the top of the loop.
- */
- movl (%esi), %ecx
- jb .L_loop
-
- /*
- * Process the remaining four bytes, which we have already
- * copied to %ecx.
- */
- xorl %eax, %ecx
- movzbl %cl, %ebp
- movl 0x1800(%ebx, %ebp, 8), %eax
- xorl %edx, %eax
- movl 0x1804(%ebx, %ebp, 8), %edx
- movzbl %ch, %ebp
- xorl 0x1000(%ebx, %ebp, 8), %eax
- xorl 0x1004(%ebx, %ebp, 8), %edx
- shrl $16, %ecx
- movzbl %cl, %ebp
- xorl 0x0800(%ebx, %ebp, 8), %eax
- xorl 0x0804(%ebx, %ebp, 8), %edx
- movzbl %ch, %ebp
- addl $4, %esi
- xorl (%ebx, %ebp, 8), %eax
- xorl 4(%ebx, %ebp, 8), %edx
-
- /* Copy the number of remaining bytes to %edi. */
- movl 0x18(%esp), %edi
-
-.L_rest:
- /* Check for end of input. */
- testl %edi, %edi
- jz .L_return
-
- /* Calculate CRC of the next input byte. */
- movzbl (%esi), %ebp
- incl %esi
- movzbl %al, %ecx
- xorl %ecx, %ebp
- shrdl $8, %edx, %eax
- xorl (%ebx, %ebp, 8), %eax
- shrl $8, %edx
- xorl 4(%ebx, %ebp, 8), %edx
- decl %edi
- jmp .L_rest
-
-.L_return:
- /* Complement the final value. */
- notl %eax
- notl %edx
-
- popl %ebp
- popl %edi
- popl %esi
- popl %ebx
- ret
-
-#if defined(PIC) || defined(__PIC__)
- ALIGN(4, 16)
-.L_get_pc:
- movl (%esp), %ebx
- ret
-#endif
-
-#if defined(__APPLE__) && (defined(PIC) || defined(__PIC__))
- /* Mach-O PIC */
- .section __IMPORT,__pointers,non_lazy_symbol_pointers
-.L_lzma_crc64_table$non_lazy_ptr:
- .indirect_symbol LZMA_CRC64_TABLE
- .long 0
-
-#elif defined(_WIN32) || defined(__CYGWIN__)
-# ifdef DLL_EXPORT
- /* This is equivalent of __declspec(dllexport). */
- .section .drectve
- .ascii " -export:lzma_crc64"
-# endif
-
-#elif !defined(__MSDOS__)
- /* ELF */
- .size LZMA_CRC64, .-LZMA_CRC64
-#endif
-
-/*
- * This is needed to support non-executable stack. It's ugly to
- * use __linux__ here, but I don't know a way to detect when
- * we are using GNU assembler.
- */
-#if defined(__ELF__) && defined(__linux__)
- .section .note.GNU-stack,"",@progbits
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/check/crc_macros.h r-base-3.3.1/src/extra/xz/check/crc_macros.h
--- r-base-3.2.3/src/extra/xz/check/crc_macros.h 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/crc_macros.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,32 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file crc_macros.h
-/// \brief Some endian-dependent macros for CRC32 and CRC64
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifdef WORDS_BIGENDIAN
-# include "bswap.h"
-
-# define A(x) ((x) >> 24)
-# define B(x) (((x) >> 16) & 0xFF)
-# define C(x) (((x) >> 8) & 0xFF)
-# define D(x) ((x) & 0xFF)
-
-# define S8(x) ((x) << 8)
-# define S32(x) ((x) << 32)
-
-#else
-# define A(x) ((x) & 0xFF)
-# define B(x) (((x) >> 8) & 0xFF)
-# define C(x) (((x) >> 16) & 0xFF)
-# define D(x) ((x) >> 24)
-
-# define S8(x) ((x) >> 8)
-# define S32(x) ((x) >> 32)
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/check/sha256.c r-base-3.3.1/src/extra/xz/check/sha256.c
--- r-base-3.2.3/src/extra/xz/check/sha256.c 2015-03-18 23:02:08.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/check/sha256.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,200 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file sha256.c
-/// \brief SHA-256
-///
-/// \todo Crypto++ has x86 ASM optimizations. They use SSE so if they
-/// are imported to liblzma, SSE instructions need to be used
-/// conditionally to keep the code working on older boxes.
-//
-// This code is based on the code found from 7-Zip, which has a modified
-// version of the SHA-256 found from Crypto++ .
-// The code was modified a little to fit into liblzma.
-//
-// Authors: Kevin Springle
-// Wei Dai
-// Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-// Avoid bogus warnings in transform().
-#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) || __GNUC__ > 4
-# pragma GCC diagnostic ignored "-Wuninitialized"
-#endif
-
-#include "check.h"
-
-// At least on x86, GCC is able to optimize this to a rotate instruction.
-#define rotr_32(num, amount) ((num) >> (amount) | (num) << (32 - (amount)))
-
-#define blk0(i) (W[i] = data[i])
-#define blk2(i) (W[i & 15] += s1(W[(i - 2) & 15]) + W[(i - 7) & 15] \
- + s0(W[(i - 15) & 15]))
-
-#define Ch(x, y, z) (z ^ (x & (y ^ z)))
-#define Maj(x, y, z) ((x & y) | (z & (x | y)))
-
-#define a(i) T[(0 - i) & 7]
-#define b(i) T[(1 - i) & 7]
-#define c(i) T[(2 - i) & 7]
-#define d(i) T[(3 - i) & 7]
-#define e(i) T[(4 - i) & 7]
-#define f(i) T[(5 - i) & 7]
-#define g(i) T[(6 - i) & 7]
-#define h(i) T[(7 - i) & 7]
-
-#define R(i) \
- h(i) += S1(e(i)) + Ch(e(i), f(i), g(i)) + SHA256_K[i + j] \
- + (j ? blk2(i) : blk0(i)); \
- d(i) += h(i); \
- h(i) += S0(a(i)) + Maj(a(i), b(i), c(i))
-
-#define S0(x) (rotr_32(x, 2) ^ rotr_32(x, 13) ^ rotr_32(x, 22))
-#define S1(x) (rotr_32(x, 6) ^ rotr_32(x, 11) ^ rotr_32(x, 25))
-#define s0(x) (rotr_32(x, 7) ^ rotr_32(x, 18) ^ (x >> 3))
-#define s1(x) (rotr_32(x, 17) ^ rotr_32(x, 19) ^ (x >> 10))
-
-
-static const uint32_t SHA256_K[64] = {
- 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,
- 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,
- 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,
- 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,
- 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,
- 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,
- 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,
- 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,
- 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,
- 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,
- 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,
- 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,
- 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,
- 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,
- 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,
- 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2,
-};
-
-
-static void
-transform(uint32_t state[8], const uint32_t data[16])
-{
- uint32_t W[16];
- uint32_t T[8];
-
- // Copy state[] to working vars.
- memcpy(T, state, sizeof(T));
-
- // 64 operations, partially loop unrolled
- for (unsigned int j = 0; j < 64; j += 16) {
- R( 0); R( 1); R( 2); R( 3);
- R( 4); R( 5); R( 6); R( 7);
- R( 8); R( 9); R(10); R(11);
- R(12); R(13); R(14); R(15);
- }
-
- // Add the working vars back into state[].
- state[0] += a(0);
- state[1] += b(0);
- state[2] += c(0);
- state[3] += d(0);
- state[4] += e(0);
- state[5] += f(0);
- state[6] += g(0);
- state[7] += h(0);
-}
-
-
-static void
-process(lzma_check_state *check)
-{
-#ifdef WORDS_BIGENDIAN
- transform(check->state.sha256.state, check->buffer.u32);
-
-#else
- uint32_t data[16];
-
- for (size_t i = 0; i < 16; ++i)
- data[i] = bswap32(check->buffer.u32[i]);
-
- transform(check->state.sha256.state, data);
-#endif
-
- return;
-}
-
-
-extern void
-lzma_sha256_init(lzma_check_state *check)
-{
- static const uint32_t s[8] = {
- 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,
- 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19,
- };
-
- memcpy(check->state.sha256.state, s, sizeof(s));
- check->state.sha256.size = 0;
-
- return;
-}
-
-
-extern void
-lzma_sha256_update(const uint8_t *buf, size_t size, lzma_check_state *check)
-{
- // Copy the input data into a properly aligned temporary buffer.
- // This way we can be called with arbitrarily sized buffers
- // (no need to be multiple of 64 bytes), and the code works also
- // on architectures that don't allow unaligned memory access.
- while (size > 0) {
- const size_t copy_start = check->state.sha256.size & 0x3F;
- size_t copy_size = 64 - copy_start;
- if (copy_size > size)
- copy_size = size;
-
- memcpy(check->buffer.u8 + copy_start, buf, copy_size);
-
- buf += copy_size;
- size -= copy_size;
- check->state.sha256.size += copy_size;
-
- if ((check->state.sha256.size & 0x3F) == 0)
- process(check);
- }
-
- return;
-}
-
-
-extern void
-lzma_sha256_finish(lzma_check_state *check)
-{
- // Add padding as described in RFC 3174 (it describes SHA-1 but
- // the same padding style is used for SHA-256 too).
- size_t pos = check->state.sha256.size & 0x3F;
- check->buffer.u8[pos++] = 0x80;
-
- while (pos != 64 - 8) {
- if (pos == 64) {
- process(check);
- pos = 0;
- }
-
- check->buffer.u8[pos++] = 0x00;
- }
-
- // Convert the message size from bytes to bits.
- check->state.sha256.size *= 8;
-
- check->buffer.u64[(64 - 8) / 8] = conv64be(check->state.sha256.size);
-
- process(check);
-
- for (size_t i = 0; i < 8; ++i)
- check->buffer.u32[i] = conv32be(check->state.sha256.state[i]);
-
- return;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/alone_decoder.c r-base-3.3.1/src/extra/xz/common/alone_decoder.c
--- r-base-3.2.3/src/extra/xz/common/alone_decoder.c 2013-07-09 22:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/alone_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,238 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file alone_decoder.c
-/// \brief Decoder for LZMA_Alone files
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "alone_decoder.h"
-#include "lzma_decoder.h"
-#include "lz_decoder.h"
-
-
-struct lzma_coder_s {
- lzma_next_coder next;
-
- enum {
- SEQ_PROPERTIES,
- SEQ_DICTIONARY_SIZE,
- SEQ_UNCOMPRESSED_SIZE,
- SEQ_CODER_INIT,
- SEQ_CODE,
- } sequence;
-
- /// If true, reject files that are unlikely to be .lzma files.
- /// If false, more non-.lzma files get accepted and will give
- /// LZMA_DATA_ERROR either immediately or after a few output bytes.
- bool picky;
-
- /// Position in the header fields
- size_t pos;
-
- /// Uncompressed size decoded from the header
- lzma_vli uncompressed_size;
-
- /// Memory usage limit
- uint64_t memlimit;
-
- /// Amount of memory actually needed (only an estimate)
- uint64_t memusage;
-
- /// Options decoded from the header needed to initialize
- /// the LZMA decoder
- lzma_options_lzma options;
-};
-
-
-static lzma_ret
-alone_decode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((__unused__)),
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size,
- lzma_action action)
-{
- while (*out_pos < out_size
- && (coder->sequence == SEQ_CODE || *in_pos < in_size))
- switch (coder->sequence) {
- case SEQ_PROPERTIES:
- if (lzma_lzma_lclppb_decode(&coder->options, in[*in_pos]))
- return LZMA_FORMAT_ERROR;
-
- coder->sequence = SEQ_DICTIONARY_SIZE;
- ++*in_pos;
- break;
-
- case SEQ_DICTIONARY_SIZE:
- coder->options.dict_size
- |= (size_t)(in[*in_pos]) << (coder->pos * 8);
-
- if (++coder->pos == 4) {
- if (coder->picky && coder->options.dict_size
- != UINT32_MAX) {
- // A hack to ditch tons of false positives:
- // We allow only dictionary sizes that are
- // 2^n or 2^n + 2^(n-1). LZMA_Alone created
- // only files with 2^n, but accepts any
- // dictionary size.
- uint32_t d = coder->options.dict_size - 1;
- d |= d >> 2;
- d |= d >> 3;
- d |= d >> 4;
- d |= d >> 8;
- d |= d >> 16;
- ++d;
-
- if (d != coder->options.dict_size)
- return LZMA_FORMAT_ERROR;
- }
-
- coder->pos = 0;
- coder->sequence = SEQ_UNCOMPRESSED_SIZE;
- }
-
- ++*in_pos;
- break;
-
- case SEQ_UNCOMPRESSED_SIZE:
- coder->uncompressed_size
- |= (lzma_vli)(in[*in_pos]) << (coder->pos * 8);
- ++*in_pos;
- if (++coder->pos < 8)
- break;
-
- // Another hack to ditch false positives: Assume that
- // if the uncompressed size is known, it must be less
- // than 256 GiB.
- if (coder->picky
- && coder->uncompressed_size != LZMA_VLI_UNKNOWN
- && coder->uncompressed_size
- >= (LZMA_VLI_C(1) << 38))
- return LZMA_FORMAT_ERROR;
-
- // Calculate the memory usage so that it is ready
- // for SEQ_CODER_INIT.
- coder->memusage = lzma_lzma_decoder_memusage(&coder->options)
- + LZMA_MEMUSAGE_BASE;
-
- coder->pos = 0;
- coder->sequence = SEQ_CODER_INIT;
-
- // Fall through
-
- case SEQ_CODER_INIT: {
- if (coder->memusage > coder->memlimit)
- return LZMA_MEMLIMIT_ERROR;
-
- lzma_filter_info filters[2] = {
- {
- .init = &lzma_lzma_decoder_init,
- .options = &coder->options,
- }, {
- .init = NULL,
- }
- };
-
- const lzma_ret ret = lzma_next_filter_init(&coder->next,
- allocator, filters);
- if (ret != LZMA_OK)
- return ret;
-
- // Use a hack to set the uncompressed size.
- lzma_lz_decoder_uncompressed(coder->next.coder,
- coder->uncompressed_size);
-
- coder->sequence = SEQ_CODE;
- break;
- }
-
- case SEQ_CODE: {
- return coder->next.code(coder->next.coder,
- allocator, in, in_pos, in_size,
- out, out_pos, out_size, action);
- }
-
- default:
- return LZMA_PROG_ERROR;
- }
-
- return LZMA_OK;
-}
-
-
-static void
-alone_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->next, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-static lzma_ret
-alone_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
- uint64_t *old_memlimit, uint64_t new_memlimit)
-{
- *memusage = coder->memusage;
- *old_memlimit = coder->memlimit;
-
- if (new_memlimit != 0) {
- if (new_memlimit < coder->memusage)
- return LZMA_MEMLIMIT_ERROR;
-
- coder->memlimit = new_memlimit;
- }
-
- return LZMA_OK;
-}
-
-
-extern lzma_ret
-lzma_alone_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- uint64_t memlimit, bool picky)
-{
- lzma_next_coder_init(&lzma_alone_decoder_init, next, allocator);
-
- if (memlimit == 0)
- return LZMA_PROG_ERROR;
-
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &alone_decode;
- next->end = &alone_decoder_end;
- next->memconfig = &alone_decoder_memconfig;
- next->coder->next = LZMA_NEXT_CODER_INIT;
- }
-
- next->coder->sequence = SEQ_PROPERTIES;
- next->coder->picky = picky;
- next->coder->pos = 0;
- next->coder->options.dict_size = 0;
- next->coder->options.preset_dict = NULL;
- next->coder->options.preset_dict_size = 0;
- next->coder->uncompressed_size = 0;
- next->coder->memlimit = memlimit;
- next->coder->memusage = LZMA_MEMUSAGE_BASE;
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_alone_decoder(lzma_stream *strm, uint64_t memlimit)
-{
- lzma_next_strm_init(lzma_alone_decoder_init, strm, memlimit, false);
-
- strm->internal->supported_actions[LZMA_RUN] = true;
- strm->internal->supported_actions[LZMA_FINISH] = true;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/alone_decoder.h r-base-3.3.1/src/extra/xz/common/alone_decoder.h
--- r-base-3.2.3/src/extra/xz/common/alone_decoder.h 2013-07-09 22:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/alone_decoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file alone_decoder.h
-/// \brief Decoder for LZMA_Alone files
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_ALONE_DECODER_H
-#define LZMA_ALONE_DECODER_H
-
-#include "common.h"
-
-
-extern lzma_ret lzma_alone_decoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
- uint64_t memlimit, bool picky);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/alone_encoder.c r-base-3.3.1/src/extra/xz/common/alone_encoder.c
--- r-base-3.2.3/src/extra/xz/common/alone_encoder.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/alone_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,157 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file alone_decoder.c
-/// \brief Decoder for LZMA_Alone files
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-#include "lzma_encoder.h"
-
-
-#define ALONE_HEADER_SIZE (1 + 4 + 8)
-
-
-struct lzma_coder_s {
- lzma_next_coder next;
-
- enum {
- SEQ_HEADER,
- SEQ_CODE,
- } sequence;
-
- size_t header_pos;
- uint8_t header[ALONE_HEADER_SIZE];
-};
-
-
-static lzma_ret
-alone_encode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((__unused__)),
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size,
- lzma_action action)
-{
- while (*out_pos < out_size)
- switch (coder->sequence) {
- case SEQ_HEADER:
- lzma_bufcpy(coder->header, &coder->header_pos,
- ALONE_HEADER_SIZE,
- out, out_pos, out_size);
- if (coder->header_pos < ALONE_HEADER_SIZE)
- return LZMA_OK;
-
- coder->sequence = SEQ_CODE;
- break;
-
- case SEQ_CODE:
- return coder->next.code(coder->next.coder,
- allocator, in, in_pos, in_size,
- out, out_pos, out_size, action);
-
- default:
- assert(0);
- return LZMA_PROG_ERROR;
- }
-
- return LZMA_OK;
-}
-
-
-static void
-alone_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->next, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-// At least for now, this is not used by any internal function.
-static lzma_ret
-alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_options_lzma *options)
-{
- lzma_next_coder_init(&alone_encoder_init, next, allocator);
-
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &alone_encode;
- next->end = &alone_encoder_end;
- next->coder->next = LZMA_NEXT_CODER_INIT;
- }
-
- // Basic initializations
- next->coder->sequence = SEQ_HEADER;
- next->coder->header_pos = 0;
-
- // Encode the header:
- // - Properties (1 byte)
- if (lzma_lzma_lclppb_encode(options, next->coder->header))
- return LZMA_OPTIONS_ERROR;
-
- // - Dictionary size (4 bytes)
- if (options->dict_size < LZMA_DICT_SIZE_MIN)
- return LZMA_OPTIONS_ERROR;
-
- // Round up to the next 2^n or 2^n + 2^(n - 1) depending on which
- // one is the next unless it is UINT32_MAX. While the header would
- // allow any 32-bit integer, we do this to keep the decoder of liblzma
- // accepting the resulting files.
- uint32_t d = options->dict_size - 1;
- d |= d >> 2;
- d |= d >> 3;
- d |= d >> 4;
- d |= d >> 8;
- d |= d >> 16;
- if (d != UINT32_MAX)
- ++d;
-
- unaligned_write32le(next->coder->header + 1, d);
-
- // - Uncompressed size (always unknown and using EOPM)
- memset(next->coder->header + 1 + 4, 0xFF, 8);
-
- // Initialize the LZMA encoder.
- const lzma_filter_info filters[2] = {
- {
- .init = &lzma_lzma_encoder_init,
- .options = (void *)(options),
- }, {
- .init = NULL,
- }
- };
-
- return lzma_next_filter_init(&next->coder->next, allocator, filters);
-}
-
-
-/*
-extern lzma_ret
-lzma_alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_options_alone *options)
-{
- lzma_next_coder_init(&alone_encoder_init, next, allocator, options);
-}
-*/
-
-
-extern LZMA_API(lzma_ret)
-lzma_alone_encoder(lzma_stream *strm, const lzma_options_lzma *options)
-{
- lzma_next_strm_init(alone_encoder_init, strm, options);
-
- strm->internal->supported_actions[LZMA_RUN] = true;
- strm->internal->supported_actions[LZMA_FINISH] = true;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/auto_decoder.c r-base-3.3.1/src/extra/xz/common/auto_decoder.c
--- r-base-3.2.3/src/extra/xz/common/auto_decoder.c 2013-07-09 22:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/auto_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,186 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file auto_decoder.c
-/// \brief Autodetect between .xz Stream and .lzma (LZMA_Alone) formats
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "stream_decoder.h"
-#include "alone_decoder.h"
-
-
-struct lzma_coder_s {
- /// Stream decoder or LZMA_Alone decoder
- lzma_next_coder next;
-
- uint64_t memlimit;
- uint32_t flags;
-
- enum {
- SEQ_INIT,
- SEQ_CODE,
- SEQ_FINISH,
- } sequence;
-};
-
-
-static lzma_ret
-auto_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- switch (coder->sequence) {
- case SEQ_INIT:
- if (*in_pos >= in_size)
- return LZMA_OK;
-
- // Update the sequence now, because we want to continue from
- // SEQ_CODE even if we return some LZMA_*_CHECK.
- coder->sequence = SEQ_CODE;
-
- // Detect the file format. For now this is simple, since if
- // it doesn't start with 0xFD (the first magic byte of the
- // new format), it has to be LZMA_Alone, or something that
- // we don't support at all.
- if (in[*in_pos] == 0xFD) {
- return_if_error(lzma_stream_decoder_init(
- &coder->next, allocator,
- coder->memlimit, coder->flags));
- } else {
- return_if_error(lzma_alone_decoder_init(&coder->next,
- allocator, coder->memlimit, true));
-
- // If the application wants to know about missing
- // integrity check or about the check in general, we
- // need to handle it here, because LZMA_Alone decoder
- // doesn't accept any flags.
- if (coder->flags & LZMA_TELL_NO_CHECK)
- return LZMA_NO_CHECK;
-
- if (coder->flags & LZMA_TELL_ANY_CHECK)
- return LZMA_GET_CHECK;
- }
-
- // Fall through
-
- case SEQ_CODE: {
- const lzma_ret ret = coder->next.code(
- coder->next.coder, allocator,
- in, in_pos, in_size,
- out, out_pos, out_size, action);
- if (ret != LZMA_STREAM_END
- || (coder->flags & LZMA_CONCATENATED) == 0)
- return ret;
-
- coder->sequence = SEQ_FINISH;
- }
-
- // Fall through
-
- case SEQ_FINISH:
- // When LZMA_DECODE_CONCATENATED was used and we were decoding
- // LZMA_Alone file, we need to check check that there is no
- // trailing garbage and wait for LZMA_FINISH.
- if (*in_pos < in_size)
- return LZMA_DATA_ERROR;
-
- return action == LZMA_FINISH ? LZMA_STREAM_END : LZMA_OK;
-
- default:
- assert(0);
- return LZMA_PROG_ERROR;
- }
-}
-
-
-static void
-auto_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->next, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-static lzma_check
-auto_decoder_get_check(const lzma_coder *coder)
-{
- // It is LZMA_Alone if get_check is NULL.
- return coder->next.get_check == NULL ? LZMA_CHECK_NONE
- : coder->next.get_check(coder->next.coder);
-}
-
-
-static lzma_ret
-auto_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
- uint64_t *old_memlimit, uint64_t new_memlimit)
-{
- lzma_ret ret;
-
- if (coder->next.memconfig != NULL) {
- ret = coder->next.memconfig(coder->next.coder,
- memusage, old_memlimit, new_memlimit);
- assert(*old_memlimit == coder->memlimit);
- } else {
- // No coder is configured yet. Use the base value as
- // the current memory usage.
- *memusage = LZMA_MEMUSAGE_BASE;
- *old_memlimit = coder->memlimit;
- ret = LZMA_OK;
- }
-
- if (ret == LZMA_OK && new_memlimit != 0)
- coder->memlimit = new_memlimit;
-
- return ret;
-}
-
-
-static lzma_ret
-auto_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- uint64_t memlimit, uint32_t flags)
-{
- lzma_next_coder_init(&auto_decoder_init, next, allocator);
-
- if (memlimit == 0)
- return LZMA_PROG_ERROR;
-
- if (flags & ~LZMA_SUPPORTED_FLAGS)
- return LZMA_OPTIONS_ERROR;
-
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &auto_decode;
- next->end = &auto_decoder_end;
- next->get_check = &auto_decoder_get_check;
- next->memconfig = &auto_decoder_memconfig;
- next->coder->next = LZMA_NEXT_CODER_INIT;
- }
-
- next->coder->memlimit = memlimit;
- next->coder->flags = flags;
- next->coder->sequence = SEQ_INIT;
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_auto_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags)
-{
- lzma_next_strm_init(auto_decoder_init, strm, memlimit, flags);
-
- strm->internal->supported_actions[LZMA_RUN] = true;
- strm->internal->supported_actions[LZMA_FINISH] = true;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/block_buffer_decoder.c r-base-3.3.1/src/extra/xz/common/block_buffer_decoder.c
--- r-base-3.2.3/src/extra/xz/common/block_buffer_decoder.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/block_buffer_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,80 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file block_buffer_decoder.c
-/// \brief Single-call .xz Block decoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "block_decoder.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_block_buffer_decode(lzma_block *block, lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
-{
- if (in_pos == NULL || (in == NULL && *in_pos != in_size)
- || *in_pos > in_size || out_pos == NULL
- || (out == NULL && *out_pos != out_size)
- || *out_pos > out_size)
- return LZMA_PROG_ERROR;
-
- // Initialize the Block decoder.
- lzma_next_coder block_decoder = LZMA_NEXT_CODER_INIT;
- lzma_ret ret = lzma_block_decoder_init(
- &block_decoder, allocator, block);
-
- if (ret == LZMA_OK) {
- // Save the positions so that we can restore them in case
- // an error occurs.
- const size_t in_start = *in_pos;
- const size_t out_start = *out_pos;
-
- // Do the actual decoding.
- ret = block_decoder.code(block_decoder.coder, allocator,
- in, in_pos, in_size, out, out_pos, out_size,
- LZMA_FINISH);
-
- if (ret == LZMA_STREAM_END) {
- ret = LZMA_OK;
- } else {
- if (ret == LZMA_OK) {
- // Either the input was truncated or the
- // output buffer was too small.
- assert(*in_pos == in_size
- || *out_pos == out_size);
-
- // If all the input was consumed, then the
- // input is truncated, even if the output
- // buffer is also full. This is because
- // processing the last byte of the Block
- // never produces output.
- //
- // NOTE: This assumption may break when new
- // filters are added, if the end marker of
- // the filter doesn't consume at least one
- // complete byte.
- if (*in_pos == in_size)
- ret = LZMA_DATA_ERROR;
- else
- ret = LZMA_BUF_ERROR;
- }
-
- // Restore the positions.
- *in_pos = in_start;
- *out_pos = out_start;
- }
- }
-
- // Free the decoder memory. This needs to be done even if
- // initialization fails, because the internal API doesn't
- // require the initialization function to free its memory on error.
- lzma_next_end(&block_decoder, allocator);
-
- return ret;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/block_buffer_encoder.c r-base-3.3.1/src/extra/xz/common/block_buffer_encoder.c
--- r-base-3.2.3/src/extra/xz/common/block_buffer_encoder.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/block_buffer_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,305 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file block_buffer_encoder.c
-/// \brief Single-call .xz Block encoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "block_encoder.h"
-#include "filter_encoder.h"
-#include "lzma2_encoder.h"
-#include "check.h"
-
-
-/// Estimate the maximum size of the Block Header and Check fields for
-/// a Block that uses LZMA2 uncompressed chunks. We could use
-/// lzma_block_header_size() but this is simpler.
-///
-/// Block Header Size + Block Flags + Compressed Size
-/// + Uncompressed Size + Filter Flags for LZMA2 + CRC32 + Check
-/// and round up to the next multiple of four to take Header Padding
-/// into account.
-#define HEADERS_BOUND ((1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 3 + 4 \
- + LZMA_CHECK_SIZE_MAX + 3) & ~3)
-
-
-static lzma_vli
-lzma2_bound(lzma_vli uncompressed_size)
-{
- // Prevent integer overflow in overhead calculation.
- if (uncompressed_size > COMPRESSED_SIZE_MAX)
- return 0;
-
- // Calculate the exact overhead of the LZMA2 headers: Round
- // uncompressed_size up to the next multiple of LZMA2_CHUNK_MAX,
- // multiply by the size of per-chunk header, and add one byte for
- // the end marker.
- const lzma_vli overhead = ((uncompressed_size + LZMA2_CHUNK_MAX - 1)
- / LZMA2_CHUNK_MAX)
- * LZMA2_HEADER_UNCOMPRESSED + 1;
-
- // Catch the possible integer overflow.
- if (COMPRESSED_SIZE_MAX - overhead < uncompressed_size)
- return 0;
-
- return uncompressed_size + overhead;
-}
-
-
-extern LZMA_API(size_t)
-lzma_block_buffer_bound(size_t uncompressed_size)
-{
- // For now, if the data doesn't compress, we always use uncompressed
- // chunks of LZMA2. In future we may use Subblock filter too, but
- // but for simplicity we probably will still use the same bound
- // calculation even though Subblock filter would have slightly less
- // overhead.
- lzma_vli lzma2_size = lzma2_bound(uncompressed_size);
- if (lzma2_size == 0)
- return 0;
-
- // Take Block Padding into account.
- lzma2_size = (lzma2_size + 3) & ~LZMA_VLI_C(3);
-
-#if SIZE_MAX < LZMA_VLI_MAX
- // Catch the possible integer overflow on 32-bit systems. There's no
- // overflow on 64-bit systems, because lzma2_bound() already takes
- // into account the size of the headers in the Block.
- if (SIZE_MAX - HEADERS_BOUND < lzma2_size)
- return 0;
-#endif
-
- return HEADERS_BOUND + lzma2_size;
-}
-
-
-static lzma_ret
-block_encode_uncompressed(lzma_block *block, const uint8_t *in, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
-{
- // TODO: Figure out if the last filter is LZMA2 or Subblock and use
- // that filter to encode the uncompressed chunks.
-
- // Use LZMA2 uncompressed chunks. We wouldn't need a dictionary at
- // all, but LZMA2 always requires a dictionary, so use the minimum
- // value to minimize memory usage of the decoder.
- lzma_options_lzma lzma2 = {
- .dict_size = LZMA_DICT_SIZE_MIN,
- };
-
- lzma_filter filters[2];
- filters[0].id = LZMA_FILTER_LZMA2;
- filters[0].options = &lzma2;
- filters[1].id = LZMA_VLI_UNKNOWN;
-
- // Set the above filter options to *block temporarily so that we can
- // encode the Block Header.
- lzma_filter *filters_orig = block->filters;
- block->filters = filters;
-
- if (lzma_block_header_size(block) != LZMA_OK) {
- block->filters = filters_orig;
- return LZMA_PROG_ERROR;
- }
-
- // Check that there's enough output space. The caller has already
- // set block->compressed_size to what lzma2_bound() has returned,
- // so we can reuse that value. We know that compressed_size is a
- // known valid VLI and header_size is a small value so their sum
- // will never overflow.
- assert(block->compressed_size == lzma2_bound(in_size));
- if (out_size - *out_pos
- < block->header_size + block->compressed_size) {
- block->filters = filters_orig;
- return LZMA_BUF_ERROR;
- }
-
- if (lzma_block_header_encode(block, out + *out_pos) != LZMA_OK) {
- block->filters = filters_orig;
- return LZMA_PROG_ERROR;
- }
-
- block->filters = filters_orig;
- *out_pos += block->header_size;
-
- // Encode the data using LZMA2 uncompressed chunks.
- size_t in_pos = 0;
- uint8_t control = 0x01; // Dictionary reset
-
- while (in_pos < in_size) {
- // Control byte: Indicate uncompressed chunk, of which
- // the first resets the dictionary.
- out[(*out_pos)++] = control;
- control = 0x02; // No dictionary reset
-
- // Size of the uncompressed chunk
- const size_t copy_size
- = my_min(in_size - in_pos, LZMA2_CHUNK_MAX);
- out[(*out_pos)++] = (copy_size - 1) >> 8;
- out[(*out_pos)++] = (copy_size - 1) & 0xFF;
-
- // The actual data
- assert(*out_pos + copy_size <= out_size);
- memcpy(out + *out_pos, in + in_pos, copy_size);
-
- in_pos += copy_size;
- *out_pos += copy_size;
- }
-
- // End marker
- out[(*out_pos)++] = 0x00;
- assert(*out_pos <= out_size);
-
- return LZMA_OK;
-}
-
-
-static lzma_ret
-block_encode_normal(lzma_block *block, lzma_allocator *allocator,
- const uint8_t *in, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
-{
- // Find out the size of the Block Header.
- block->compressed_size = lzma2_bound(in_size);
- if (block->compressed_size == 0)
- return LZMA_DATA_ERROR;
-
- block->uncompressed_size = in_size;
- return_if_error(lzma_block_header_size(block));
-
- // Reserve space for the Block Header and skip it for now.
- if (out_size - *out_pos <= block->header_size)
- return LZMA_BUF_ERROR;
-
- const size_t out_start = *out_pos;
- *out_pos += block->header_size;
-
- // Limit out_size so that we stop encoding if the output would grow
- // bigger than what uncompressed Block would be.
- if (out_size - *out_pos > block->compressed_size)
- out_size = *out_pos + block->compressed_size;
-
- // TODO: In many common cases this could be optimized to use
- // significantly less memory.
- lzma_next_coder raw_encoder = LZMA_NEXT_CODER_INIT;
- lzma_ret ret = lzma_raw_encoder_init(
- &raw_encoder, allocator, block->filters);
-
- if (ret == LZMA_OK) {
- size_t in_pos = 0;
- ret = raw_encoder.code(raw_encoder.coder, allocator,
- in, &in_pos, in_size, out, out_pos, out_size,
- LZMA_FINISH);
- }
-
- // NOTE: This needs to be run even if lzma_raw_encoder_init() failed.
- lzma_next_end(&raw_encoder, allocator);
-
- if (ret == LZMA_STREAM_END) {
- // Compression was successful. Write the Block Header.
- block->compressed_size
- = *out_pos - (out_start + block->header_size);
- ret = lzma_block_header_encode(block, out + out_start);
- if (ret != LZMA_OK)
- ret = LZMA_PROG_ERROR;
-
- } else if (ret == LZMA_OK) {
- // Output buffer became full.
- ret = LZMA_BUF_ERROR;
- }
-
- // Reset *out_pos if something went wrong.
- if (ret != LZMA_OK)
- *out_pos = out_start;
-
- return ret;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator,
- const uint8_t *in, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
-{
- // Validate the arguments.
- if (block == NULL || (in == NULL && in_size != 0) || out == NULL
- || out_pos == NULL || *out_pos > out_size)
- return LZMA_PROG_ERROR;
-
- // The contents of the structure may depend on the version so
- // check the version before validating the contents of *block.
- if (block->version != 0)
- return LZMA_OPTIONS_ERROR;
-
- if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX
- || block->filters == NULL)
- return LZMA_PROG_ERROR;
-
- if (!lzma_check_is_supported(block->check))
- return LZMA_UNSUPPORTED_CHECK;
-
- // Size of a Block has to be a multiple of four, so limit the size
- // here already. This way we don't need to check it again when adding
- // Block Padding.
- out_size -= (out_size - *out_pos) & 3;
-
- // Get the size of the Check field.
- const size_t check_size = lzma_check_size(block->check);
- assert(check_size != UINT32_MAX);
-
- // Reserve space for the Check field.
- if (out_size - *out_pos <= check_size)
- return LZMA_BUF_ERROR;
-
- out_size -= check_size;
-
- // Do the actual compression.
- const lzma_ret ret = block_encode_normal(block, allocator,
- in, in_size, out, out_pos, out_size);
- if (ret != LZMA_OK) {
- // If the error was something else than output buffer
- // becoming full, return the error now.
- if (ret != LZMA_BUF_ERROR)
- return ret;
-
- // The data was uncompressible (at least with the options
- // given to us) or the output buffer was too small. Use the
- // uncompressed chunks of LZMA2 to wrap the data into a valid
- // Block. If we haven't been given enough output space, even
- // this may fail.
- return_if_error(block_encode_uncompressed(block, in, in_size,
- out, out_pos, out_size));
- }
-
- assert(*out_pos <= out_size);
-
- // Block Padding. No buffer overflow here, because we already adjusted
- // out_size so that (out_size - out_start) is a multiple of four.
- // Thus, if the buffer is full, the loop body can never run.
- for (size_t i = (size_t)(block->compressed_size); i & 3; ++i) {
- assert(*out_pos < out_size);
- out[(*out_pos)++] = 0x00;
- }
-
- // If there's no Check field, we are done now.
- if (check_size > 0) {
- // Calculate the integrity check. We reserved space for
- // the Check field earlier so we don't need to check for
- // available output space here.
- lzma_check_state check;
- lzma_check_init(&check, block->check);
- lzma_check_update(&check, block->check, in, in_size);
- lzma_check_finish(&check, block->check);
-
- memcpy(block->raw_check, check.buffer.u8, check_size);
- memcpy(out + *out_pos, check.buffer.u8, check_size);
- *out_pos += check_size;
- }
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/block_decoder.c r-base-3.3.1/src/extra/xz/common/block_decoder.c
--- r-base-3.2.3/src/extra/xz/common/block_decoder.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/block_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,242 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file block_decoder.c
-/// \brief Decodes .xz Blocks
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "block_decoder.h"
-#include "filter_decoder.h"
-#include "check.h"
-
-
-struct lzma_coder_s {
- enum {
- SEQ_CODE,
- SEQ_PADDING,
- SEQ_CHECK,
- } sequence;
-
- /// The filters in the chain; initialized with lzma_raw_decoder_init().
- lzma_next_coder next;
-
- /// Decoding options; we also write Compressed Size and Uncompressed
- /// Size back to this structure when the decoding has been finished.
- lzma_block *block;
-
- /// Compressed Size calculated while decoding
- lzma_vli compressed_size;
-
- /// Uncompressed Size calculated while decoding
- lzma_vli uncompressed_size;
-
- /// Maximum allowed Compressed Size; this takes into account the
- /// size of the Block Header and Check fields when Compressed Size
- /// is unknown.
- lzma_vli compressed_limit;
-
- /// Position when reading the Check field
- size_t check_pos;
-
- /// Check of the uncompressed data
- lzma_check_state check;
-};
-
-
-static inline bool
-update_size(lzma_vli *size, lzma_vli add, lzma_vli limit)
-{
- if (limit > LZMA_VLI_MAX)
- limit = LZMA_VLI_MAX;
-
- if (limit < *size || limit - *size < add)
- return true;
-
- *size += add;
-
- return false;
-}
-
-
-static inline bool
-is_size_valid(lzma_vli size, lzma_vli reference)
-{
- return reference == LZMA_VLI_UNKNOWN || reference == size;
-}
-
-
-static lzma_ret
-block_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- switch (coder->sequence) {
- case SEQ_CODE: {
- const size_t in_start = *in_pos;
- const size_t out_start = *out_pos;
-
- const lzma_ret ret = coder->next.code(coder->next.coder,
- allocator, in, in_pos, in_size,
- out, out_pos, out_size, action);
-
- const size_t in_used = *in_pos - in_start;
- const size_t out_used = *out_pos - out_start;
-
- // NOTE: We compare to compressed_limit here, which prevents
- // the total size of the Block growing past LZMA_VLI_MAX.
- if (update_size(&coder->compressed_size, in_used,
- coder->compressed_limit)
- || update_size(&coder->uncompressed_size,
- out_used,
- coder->block->uncompressed_size))
- return LZMA_DATA_ERROR;
-
- lzma_check_update(&coder->check, coder->block->check,
- out + out_start, out_used);
-
- if (ret != LZMA_STREAM_END)
- return ret;
-
- // Compressed and Uncompressed Sizes are now at their final
- // values. Verify that they match the values given to us.
- if (!is_size_valid(coder->compressed_size,
- coder->block->compressed_size)
- || !is_size_valid(coder->uncompressed_size,
- coder->block->uncompressed_size))
- return LZMA_DATA_ERROR;
-
- // Copy the values into coder->block. The caller
- // may use this information to construct Index.
- coder->block->compressed_size = coder->compressed_size;
- coder->block->uncompressed_size = coder->uncompressed_size;
-
- coder->sequence = SEQ_PADDING;
- }
-
- // Fall through
-
- case SEQ_PADDING:
- // Compressed Data is padded to a multiple of four bytes.
- while (coder->compressed_size & 3) {
- if (*in_pos >= in_size)
- return LZMA_OK;
-
- // We use compressed_size here just get the Padding
- // right. The actual Compressed Size was stored to
- // coder->block already, and won't be modified by
- // us anymore.
- ++coder->compressed_size;
-
- if (in[(*in_pos)++] != 0x00)
- return LZMA_DATA_ERROR;
- }
-
- if (coder->block->check == LZMA_CHECK_NONE)
- return LZMA_STREAM_END;
-
- lzma_check_finish(&coder->check, coder->block->check);
- coder->sequence = SEQ_CHECK;
-
- // Fall through
-
- case SEQ_CHECK: {
- const size_t check_size = lzma_check_size(coder->block->check);
- lzma_bufcpy(in, in_pos, in_size, coder->block->raw_check,
- &coder->check_pos, check_size);
- if (coder->check_pos < check_size)
- return LZMA_OK;
-
- // Validate the Check only if we support it.
- // coder->check.buffer may be uninitialized
- // when the Check ID is not supported.
- if (lzma_check_is_supported(coder->block->check)
- && memcmp(coder->block->raw_check,
- coder->check.buffer.u8,
- check_size) != 0)
- return LZMA_DATA_ERROR;
-
- return LZMA_STREAM_END;
- }
- }
-
- return LZMA_PROG_ERROR;
-}
-
-
-static void
-block_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->next, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-extern lzma_ret
-lzma_block_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- lzma_block *block)
-{
- lzma_next_coder_init(&lzma_block_decoder_init, next, allocator);
-
- // Validate the options. lzma_block_unpadded_size() does that for us
- // except for Uncompressed Size and filters. Filters are validated
- // by the raw decoder.
- if (lzma_block_unpadded_size(block) == 0
- || !lzma_vli_is_valid(block->uncompressed_size))
- return LZMA_PROG_ERROR;
-
- // Allocate and initialize *next->coder if needed.
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &block_decode;
- next->end = &block_decoder_end;
- next->coder->next = LZMA_NEXT_CODER_INIT;
- }
-
- // Basic initializations
- next->coder->sequence = SEQ_CODE;
- next->coder->block = block;
- next->coder->compressed_size = 0;
- next->coder->uncompressed_size = 0;
-
- // If Compressed Size is not known, we calculate the maximum allowed
- // value so that encoded size of the Block (including Block Padding)
- // is still a valid VLI and a multiple of four.
- next->coder->compressed_limit
- = block->compressed_size == LZMA_VLI_UNKNOWN
- ? (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
- - block->header_size
- - lzma_check_size(block->check)
- : block->compressed_size;
-
- // Initialize the check. It's caller's problem if the Check ID is not
- // supported, and the Block decoder cannot verify the Check field.
- // Caller can test lzma_check_is_supported(block->check).
- next->coder->check_pos = 0;
- lzma_check_init(&next->coder->check, block->check);
-
- // Initialize the filter chain.
- return lzma_raw_decoder_init(&next->coder->next, allocator,
- block->filters);
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_block_decoder(lzma_stream *strm, lzma_block *block)
-{
- lzma_next_strm_init(lzma_block_decoder_init, strm, block);
-
- strm->internal->supported_actions[LZMA_RUN] = true;
- strm->internal->supported_actions[LZMA_FINISH] = true;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/block_decoder.h r-base-3.3.1/src/extra/xz/common/block_decoder.h
--- r-base-3.2.3/src/extra/xz/common/block_decoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/block_decoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,22 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file block_decoder.h
-/// \brief Decodes .xz Blocks
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_BLOCK_DECODER_H
-#define LZMA_BLOCK_DECODER_H
-
-#include "common.h"
-
-
-extern lzma_ret lzma_block_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, lzma_block *block);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/block_encoder.c r-base-3.3.1/src/extra/xz/common/block_encoder.c
--- r-base-3.2.3/src/extra/xz/common/block_encoder.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/block_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,217 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file block_encoder.c
-/// \brief Encodes .xz Blocks
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "block_encoder.h"
-#include "filter_encoder.h"
-#include "check.h"
-
-
-struct lzma_coder_s {
- /// The filters in the chain; initialized with lzma_raw_decoder_init().
- lzma_next_coder next;
-
- /// Encoding options; we also write Unpadded Size, Compressed Size,
- /// and Uncompressed Size back to this structure when the encoding
- /// has been finished.
- lzma_block *block;
-
- enum {
- SEQ_CODE,
- SEQ_PADDING,
- SEQ_CHECK,
- } sequence;
-
- /// Compressed Size calculated while encoding
- lzma_vli compressed_size;
-
- /// Uncompressed Size calculated while encoding
- lzma_vli uncompressed_size;
-
- /// Position in the Check field
- size_t pos;
-
- /// Check of the uncompressed data
- lzma_check_state check;
-};
-
-
-static lzma_ret
-block_encode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- // Check that our amount of input stays in proper limits.
- if (LZMA_VLI_MAX - coder->uncompressed_size < in_size - *in_pos)
- return LZMA_DATA_ERROR;
-
- switch (coder->sequence) {
- case SEQ_CODE: {
- const size_t in_start = *in_pos;
- const size_t out_start = *out_pos;
-
- const lzma_ret ret = coder->next.code(coder->next.coder,
- allocator, in, in_pos, in_size,
- out, out_pos, out_size, action);
-
- const size_t in_used = *in_pos - in_start;
- const size_t out_used = *out_pos - out_start;
-
- if (COMPRESSED_SIZE_MAX - coder->compressed_size < out_used)
- return LZMA_DATA_ERROR;
-
- coder->compressed_size += out_used;
-
- // No need to check for overflow because we have already
- // checked it at the beginning of this function.
- coder->uncompressed_size += in_used;
-
- lzma_check_update(&coder->check, coder->block->check,
- in + in_start, in_used);
-
- if (ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH)
- return ret;
-
- assert(*in_pos == in_size);
- assert(action == LZMA_FINISH);
-
- // Copy the values into coder->block. The caller
- // may use this information to construct Index.
- coder->block->compressed_size = coder->compressed_size;
- coder->block->uncompressed_size = coder->uncompressed_size;
-
- coder->sequence = SEQ_PADDING;
- }
-
- // Fall through
-
- case SEQ_PADDING:
- // Pad Compressed Data to a multiple of four bytes. We can
- // use coder->compressed_size for this since we don't need
- // it for anything else anymore.
- while (coder->compressed_size & 3) {
- if (*out_pos >= out_size)
- return LZMA_OK;
-
- out[*out_pos] = 0x00;
- ++*out_pos;
- ++coder->compressed_size;
- }
-
- if (coder->block->check == LZMA_CHECK_NONE)
- return LZMA_STREAM_END;
-
- lzma_check_finish(&coder->check, coder->block->check);
-
- coder->sequence = SEQ_CHECK;
-
- // Fall through
-
- case SEQ_CHECK: {
- const size_t check_size = lzma_check_size(coder->block->check);
- lzma_bufcpy(coder->check.buffer.u8, &coder->pos, check_size,
- out, out_pos, out_size);
- if (coder->pos < check_size)
- return LZMA_OK;
-
- memcpy(coder->block->raw_check, coder->check.buffer.u8,
- check_size);
- return LZMA_STREAM_END;
- }
- }
-
- return LZMA_PROG_ERROR;
-}
-
-
-static void
-block_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->next, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-static lzma_ret
-block_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
- const lzma_filter *filters lzma_attribute((__unused__)),
- const lzma_filter *reversed_filters)
-{
- if (coder->sequence != SEQ_CODE)
- return LZMA_PROG_ERROR;
-
- return lzma_next_filter_update(
- &coder->next, allocator, reversed_filters);
-}
-
-
-extern lzma_ret
-lzma_block_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- lzma_block *block)
-{
- lzma_next_coder_init(&lzma_block_encoder_init, next, allocator);
-
- if (block == NULL)
- return LZMA_PROG_ERROR;
-
- // The contents of the structure may depend on the version so
- // check the version first.
- if (block->version != 0)
- return LZMA_OPTIONS_ERROR;
-
- // If the Check ID is not supported, we cannot calculate the check and
- // thus not create a proper Block.
- if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX)
- return LZMA_PROG_ERROR;
-
- if (!lzma_check_is_supported(block->check))
- return LZMA_UNSUPPORTED_CHECK;
-
- // Allocate and initialize *next->coder if needed.
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &block_encode;
- next->end = &block_encoder_end;
- next->update = &block_encoder_update;
- next->coder->next = LZMA_NEXT_CODER_INIT;
- }
-
- // Basic initializations
- next->coder->sequence = SEQ_CODE;
- next->coder->block = block;
- next->coder->compressed_size = 0;
- next->coder->uncompressed_size = 0;
- next->coder->pos = 0;
-
- // Initialize the check
- lzma_check_init(&next->coder->check, block->check);
-
- // Initialize the requested filters.
- return lzma_raw_encoder_init(&next->coder->next, allocator,
- block->filters);
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_block_encoder(lzma_stream *strm, lzma_block *block)
-{
- lzma_next_strm_init(lzma_block_encoder_init, strm, block);
-
- strm->internal->supported_actions[LZMA_RUN] = true;
- strm->internal->supported_actions[LZMA_FINISH] = true;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/block_encoder.h r-base-3.3.1/src/extra/xz/common/block_encoder.h
--- r-base-3.2.3/src/extra/xz/common/block_encoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/block_encoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,47 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file block_encoder.h
-/// \brief Encodes .xz Blocks
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_BLOCK_ENCODER_H
-#define LZMA_BLOCK_ENCODER_H
-
-#include "common.h"
-
-
-/// \brief Biggest Compressed Size value that the Block encoder supports
-///
-/// The maximum size of a single Block is limited by the maximum size of
-/// a Stream, which in theory is 2^63 - 3 bytes (i.e. LZMA_VLI_MAX - 3).
-/// While the size is really big and no one should hit it in practice, we
-/// take it into account in some places anyway to catch some errors e.g. if
-/// application passes insanely big value to some function.
-///
-/// We could take into account the headers etc. to determine the exact
-/// maximum size of the Compressed Data field, but the complexity would give
-/// us nothing useful. Instead, limit the size of Compressed Data so that
-/// even with biggest possible Block Header and Check fields the total
-/// encoded size of the Block stays as a valid VLI. This doesn't guarantee
-/// that the size of the Stream doesn't grow too big, but that problem is
-/// taken care outside the Block handling code.
-///
-/// ~LZMA_VLI_C(3) is to guarantee that if we need padding at the end of
-/// the Compressed Data field, it will still stay in the proper limit.
-///
-/// This constant is in this file because it is needed in both
-/// block_encoder.c and block_buffer_encoder.c.
-#define COMPRESSED_SIZE_MAX ((LZMA_VLI_MAX - LZMA_BLOCK_HEADER_SIZE_MAX \
- - LZMA_CHECK_SIZE_MAX) & ~LZMA_VLI_C(3))
-
-
-extern lzma_ret lzma_block_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, lzma_block *block);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/block_header_decoder.c r-base-3.3.1/src/extra/xz/common/block_header_decoder.c
--- r-base-3.2.3/src/extra/xz/common/block_header_decoder.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/block_header_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,116 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file block_header_decoder.c
-/// \brief Decodes Block Header from .xz files
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-#include "check.h"
-
-
-static void
-free_properties(lzma_block *block, lzma_allocator *allocator)
-{
- // Free allocated filter options. The last array member is not
- // touched after the initialization in the beginning of
- // lzma_block_header_decode(), so we don't need to touch that here.
- for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i) {
- lzma_free(block->filters[i].options, allocator);
- block->filters[i].id = LZMA_VLI_UNKNOWN;
- block->filters[i].options = NULL;
- }
-
- return;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_block_header_decode(lzma_block *block,
- lzma_allocator *allocator, const uint8_t *in)
-{
- // NOTE: We consider the header to be corrupt not only when the
- // CRC32 doesn't match, but also when variable-length integers
- // are invalid or over 63 bits, or if the header is too small
- // to contain the claimed information.
-
- // Initialize the filter options array. This way the caller can
- // safely free() the options even if an error occurs in this function.
- for (size_t i = 0; i <= LZMA_FILTERS_MAX; ++i) {
- block->filters[i].id = LZMA_VLI_UNKNOWN;
- block->filters[i].options = NULL;
- }
-
- // Always zero for now.
- block->version = 0;
-
- // Validate Block Header Size and Check type. The caller must have
- // already set these, so it is a programming error if this test fails.
- if (lzma_block_header_size_decode(in[0]) != block->header_size
- || (unsigned int)(block->check) > LZMA_CHECK_ID_MAX)
- return LZMA_PROG_ERROR;
-
- // Exclude the CRC32 field.
- const size_t in_size = block->header_size - 4;
-
- // Verify CRC32
- if (lzma_crc32(in, in_size, 0) != unaligned_read32le(in + in_size))
- return LZMA_DATA_ERROR;
-
- // Check for unsupported flags.
- if (in[1] & 0x3C)
- return LZMA_OPTIONS_ERROR;
-
- // Start after the Block Header Size and Block Flags fields.
- size_t in_pos = 2;
-
- // Compressed Size
- if (in[1] & 0x40) {
- return_if_error(lzma_vli_decode(&block->compressed_size,
- NULL, in, &in_pos, in_size));
-
- // Validate Compressed Size. This checks that it isn't zero
- // and that the total size of the Block is a valid VLI.
- if (lzma_block_unpadded_size(block) == 0)
- return LZMA_DATA_ERROR;
- } else {
- block->compressed_size = LZMA_VLI_UNKNOWN;
- }
-
- // Uncompressed Size
- if (in[1] & 0x80)
- return_if_error(lzma_vli_decode(&block->uncompressed_size,
- NULL, in, &in_pos, in_size));
- else
- block->uncompressed_size = LZMA_VLI_UNKNOWN;
-
- // Filter Flags
- const size_t filter_count = (in[1] & 3) + 1;
- for (size_t i = 0; i < filter_count; ++i) {
- const lzma_ret ret = lzma_filter_flags_decode(
- &block->filters[i], allocator,
- in, &in_pos, in_size);
- if (ret != LZMA_OK) {
- free_properties(block, allocator);
- return ret;
- }
- }
-
- // Padding
- while (in_pos < in_size) {
- if (in[in_pos++] != 0x00) {
- free_properties(block, allocator);
-
- // Possibly some new field present so use
- // LZMA_OPTIONS_ERROR instead of LZMA_DATA_ERROR.
- return LZMA_OPTIONS_ERROR;
- }
- }
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/block_header_encoder.c r-base-3.3.1/src/extra/xz/common/block_header_encoder.c
--- r-base-3.2.3/src/extra/xz/common/block_header_encoder.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/block_header_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,132 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file block_header_encoder.c
-/// \brief Encodes Block Header for .xz files
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-#include "check.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_block_header_size(lzma_block *block)
-{
- if (block->version != 0)
- return LZMA_OPTIONS_ERROR;
-
- // Block Header Size + Block Flags + CRC32.
- uint32_t size = 1 + 1 + 4;
-
- // Compressed Size
- if (block->compressed_size != LZMA_VLI_UNKNOWN) {
- const uint32_t add = lzma_vli_size(block->compressed_size);
- if (add == 0 || block->compressed_size == 0)
- return LZMA_PROG_ERROR;
-
- size += add;
- }
-
- // Uncompressed Size
- if (block->uncompressed_size != LZMA_VLI_UNKNOWN) {
- const uint32_t add = lzma_vli_size(block->uncompressed_size);
- if (add == 0)
- return LZMA_PROG_ERROR;
-
- size += add;
- }
-
- // List of Filter Flags
- if (block->filters == NULL || block->filters[0].id == LZMA_VLI_UNKNOWN)
- return LZMA_PROG_ERROR;
-
- for (size_t i = 0; block->filters[i].id != LZMA_VLI_UNKNOWN; ++i) {
- // Don't allow too many filters.
- if (i == LZMA_FILTERS_MAX)
- return LZMA_PROG_ERROR;
-
- uint32_t add;
- return_if_error(lzma_filter_flags_size(&add,
- block->filters + i));
-
- size += add;
- }
-
- // Pad to a multiple of four bytes.
- block->header_size = (size + 3) & ~UINT32_C(3);
-
- // NOTE: We don't verify that the encoded size of the Block stays
- // within limits. This is because it is possible that we are called
- // with exaggerated Compressed Size (e.g. LZMA_VLI_MAX) to reserve
- // space for Block Header, and later called again with lower,
- // real values.
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_block_header_encode(const lzma_block *block, uint8_t *out)
-{
- // Validate everything but filters.
- if (lzma_block_unpadded_size(block) == 0
- || !lzma_vli_is_valid(block->uncompressed_size))
- return LZMA_PROG_ERROR;
-
- // Indicate the size of the buffer _excluding_ the CRC32 field.
- const size_t out_size = block->header_size - 4;
-
- // Store the Block Header Size.
- out[0] = out_size / 4;
-
- // We write Block Flags in pieces.
- out[1] = 0x00;
- size_t out_pos = 2;
-
- // Compressed Size
- if (block->compressed_size != LZMA_VLI_UNKNOWN) {
- return_if_error(lzma_vli_encode(block->compressed_size, NULL,
- out, &out_pos, out_size));
-
- out[1] |= 0x40;
- }
-
- // Uncompressed Size
- if (block->uncompressed_size != LZMA_VLI_UNKNOWN) {
- return_if_error(lzma_vli_encode(block->uncompressed_size, NULL,
- out, &out_pos, out_size));
-
- out[1] |= 0x80;
- }
-
- // Filter Flags
- if (block->filters == NULL || block->filters[0].id == LZMA_VLI_UNKNOWN)
- return LZMA_PROG_ERROR;
-
- size_t filter_count = 0;
- do {
- // There can be a maximum of four filters.
- if (filter_count == LZMA_FILTERS_MAX)
- return LZMA_PROG_ERROR;
-
- return_if_error(lzma_filter_flags_encode(
- block->filters + filter_count,
- out, &out_pos, out_size));
-
- } while (block->filters[++filter_count].id != LZMA_VLI_UNKNOWN);
-
- out[1] |= filter_count - 1;
-
- // Padding
- memzero(out + out_pos, out_size - out_pos);
-
- // CRC32
- unaligned_write32le(out + out_size, lzma_crc32(out, out_size, 0));
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/block_util.c r-base-3.3.1/src/extra/xz/common/block_util.c
--- r-base-3.2.3/src/extra/xz/common/block_util.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/block_util.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,90 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file block_header.c
-/// \brief Utility functions to handle lzma_block
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-#include "index.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_block_compressed_size(lzma_block *block, lzma_vli unpadded_size)
-{
- // Validate everything but Uncompressed Size and filters.
- if (lzma_block_unpadded_size(block) == 0)
- return LZMA_PROG_ERROR;
-
- const uint32_t container_size = block->header_size
- + lzma_check_size(block->check);
-
- // Validate that Compressed Size will be greater than zero.
- if (unpadded_size <= container_size)
- return LZMA_DATA_ERROR;
-
- // Calculate what Compressed Size is supposed to be.
- // If Compressed Size was present in Block Header,
- // compare that the new value matches it.
- const lzma_vli compressed_size = unpadded_size - container_size;
- if (block->compressed_size != LZMA_VLI_UNKNOWN
- && block->compressed_size != compressed_size)
- return LZMA_DATA_ERROR;
-
- block->compressed_size = compressed_size;
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_vli)
-lzma_block_unpadded_size(const lzma_block *block)
-{
- // Validate the values that we are interested in i.e. all but
- // Uncompressed Size and the filters.
- //
- // NOTE: This function is used for validation too, so it is
- // essential that these checks are always done even if
- // Compressed Size is unknown.
- if (block == NULL || block->version != 0
- || block->header_size < LZMA_BLOCK_HEADER_SIZE_MIN
- || block->header_size > LZMA_BLOCK_HEADER_SIZE_MAX
- || (block->header_size & 3)
- || !lzma_vli_is_valid(block->compressed_size)
- || block->compressed_size == 0
- || (unsigned int)(block->check) > LZMA_CHECK_ID_MAX)
- return 0;
-
- // If Compressed Size is unknown, return that we cannot know
- // size of the Block either.
- if (block->compressed_size == LZMA_VLI_UNKNOWN)
- return LZMA_VLI_UNKNOWN;
-
- // Calculate Unpadded Size and validate it.
- const lzma_vli unpadded_size = block->compressed_size
- + block->header_size
- + lzma_check_size(block->check);
-
- assert(unpadded_size >= UNPADDED_SIZE_MIN);
- if (unpadded_size > UNPADDED_SIZE_MAX)
- return 0;
-
- return unpadded_size;
-}
-
-
-extern LZMA_API(lzma_vli)
-lzma_block_total_size(const lzma_block *block)
-{
- lzma_vli unpadded_size = lzma_block_unpadded_size(block);
-
- if (unpadded_size != LZMA_VLI_UNKNOWN)
- unpadded_size = vli_ceil4(unpadded_size);
-
- return unpadded_size;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/bsr.h r-base-3.3.1/src/extra/xz/common/bsr.h
--- r-base-3.2.3/src/extra/xz/common/bsr.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/bsr.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,60 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file bsr.h
-/// \brief Bit scan reverse
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_BSR_H
-#define LZMA_BSR_H
-
-// NOTE: Both input and output variables for lzma_bsr must be uint32_t.
-
-#if defined(__GNUC__) && (defined (HAVE_ASM_X86) || defined(HAVE_ASM_X86_64))
-# define lzma_bsr(dest, n) \
- __asm__("bsrl %1, %0" : "=r" (dest) : "rm" (n))
-
-#else
-# define lzma_bsr(dest, n) dest = lzma_bsr_helper(n)
-
-static inline uint32_t
-lzma_bsr_helper(uint32_t n)
-{
- assert(n != 0);
-
- uint32_t i = 31;
-
- if ((n & UINT32_C(0xFFFF0000)) == 0) {
- n <<= 16;
- i = 15;
- }
-
- if ((n & UINT32_C(0xFF000000)) == 0) {
- n <<= 8;
- i -= 8;
- }
-
- if ((n & UINT32_C(0xF0000000)) == 0) {
- n <<= 4;
- i -= 4;
- }
-
- if ((n & UINT32_C(0xC0000000)) == 0) {
- n <<= 2;
- i -= 2;
- }
-
- if ((n & UINT32_C(0x80000000)) == 0)
- --i;
-
- return i;
-}
-
-#endif
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/bswap.h r-base-3.3.1/src/extra/xz/common/bswap.h
--- r-base-3.2.3/src/extra/xz/common/bswap.h 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/bswap.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,52 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file bswap.h
-/// \brief Byte swapping
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_BSWAP_H
-#define LZMA_BSWAP_H
-
-// NOTE: We assume that config.h is already #included.
-
-// At least glibc has byteswap.h which contains inline assembly code for
-// byteswapping. Some systems have byteswap.h but lack one or more of the
-// bswap_xx macros/functions, which is why we check them separately even
-// if byteswap.h is available.
-
-#ifdef HAVE_BYTESWAP_H
-# include
-#endif
-
-#ifndef HAVE_BSWAP_16
-# define bswap_16(num) \
- (((num) << 8) | ((num) >> 8))
-#endif
-
-#ifndef HAVE_BSWAP_32
-# define bswap_32(num) \
- ( (((num) << 24) ) \
- | (((num) << 8) & UINT32_C(0x00FF0000)) \
- | (((num) >> 8) & UINT32_C(0x0000FF00)) \
- | (((num) >> 24) ) )
-#endif
-
-#ifndef HAVE_BSWAP_64
-# define bswap_64(num) \
- ( (((num) << 56) ) \
- | (((num) << 40) & UINT64_C(0x00FF000000000000)) \
- | (((num) << 24) & UINT64_C(0x0000FF0000000000)) \
- | (((num) << 8) & UINT64_C(0x000000FF00000000)) \
- | (((num) >> 8) & UINT64_C(0x00000000FF000000)) \
- | (((num) >> 24) & UINT64_C(0x0000000000FF0000)) \
- | (((num) >> 40) & UINT64_C(0x000000000000FF00)) \
- | (((num) >> 56) ) )
-#endif
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/common.c r-base-3.3.1/src/extra/xz/common/common.c
--- r-base-3.2.3/src/extra/xz/common/common.c 2015-03-18 23:02:07.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/common.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,388 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file common.h
-/// \brief Common functions needed in many places in liblzma
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-
-
-/////////////
-// Version //
-/////////////
-
-extern LZMA_API(uint32_t)
-lzma_version_number(void)
-{
- return LZMA_VERSION;
-}
-
-
-extern LZMA_API(const char *)
-lzma_version_string(void)
-{
- return LZMA_VERSION_STRING;
-}
-
-
-///////////////////////
-// Memory allocation //
-///////////////////////
-
-extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
-lzma_alloc(size_t size, lzma_allocator *allocator)
-{
- // Some malloc() variants return NULL if called with size == 0.
- if (size == 0)
- size = 1;
-
- void *ptr;
-
- if (allocator != NULL && allocator->alloc != NULL)
- ptr = allocator->alloc(allocator->opaque, 1, size);
- else
- ptr = malloc(size);
-
- return ptr;
-}
-
-
-extern void
-lzma_free(void *ptr, lzma_allocator *allocator)
-{
- if (allocator != NULL && allocator->free != NULL)
- allocator->free(allocator->opaque, ptr);
- else
- free(ptr);
-
- return;
-}
-
-
-//////////
-// Misc //
-//////////
-
-extern size_t
-lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size)
-{
- const size_t in_avail = in_size - *in_pos;
- const size_t out_avail = out_size - *out_pos;
- const size_t copy_size = my_min(in_avail, out_avail);
-
- memcpy(out + *out_pos, in + *in_pos, copy_size);
-
- *in_pos += copy_size;
- *out_pos += copy_size;
-
- return copy_size;
-}
-
-
-extern lzma_ret
-lzma_next_filter_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- lzma_next_coder_init(filters[0].init, next, allocator);
- next->id = filters[0].id;
- return filters[0].init == NULL
- ? LZMA_OK : filters[0].init(next, allocator, filters);
-}
-
-
-extern lzma_ret
-lzma_next_filter_update(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter *reversed_filters)
-{
- // Check that the application isn't trying to change the Filter ID.
- // End of filters is indicated with LZMA_VLI_UNKNOWN in both
- // reversed_filters[0].id and next->id.
- if (reversed_filters[0].id != next->id)
- return LZMA_PROG_ERROR;
-
- if (reversed_filters[0].id == LZMA_VLI_UNKNOWN)
- return LZMA_OK;
-
- assert(next->update != NULL);
- return next->update(next->coder, allocator, NULL, reversed_filters);
-}
-
-
-extern void
-lzma_next_end(lzma_next_coder *next, lzma_allocator *allocator)
-{
- if (next->init != (uintptr_t)(NULL)) {
- // To avoid tiny end functions that simply call
- // lzma_free(coder, allocator), we allow leaving next->end
- // NULL and call lzma_free() here.
- if (next->end != NULL)
- next->end(next->coder, allocator);
- else
- lzma_free(next->coder, allocator);
-
- // Reset the variables so the we don't accidentally think
- // that it is an already initialized coder.
- *next = LZMA_NEXT_CODER_INIT;
- }
-
- return;
-}
-
-
-//////////////////////////////////////
-// External to internal API wrapper //
-//////////////////////////////////////
-
-extern lzma_ret
-lzma_strm_init(lzma_stream *strm)
-{
- if (strm == NULL)
- return LZMA_PROG_ERROR;
-
- if (strm->internal == NULL) {
- strm->internal = lzma_alloc(sizeof(lzma_internal),
- strm->allocator);
- if (strm->internal == NULL)
- return LZMA_MEM_ERROR;
-
- strm->internal->next = LZMA_NEXT_CODER_INIT;
- }
-
- strm->internal->supported_actions[LZMA_RUN] = false;
- strm->internal->supported_actions[LZMA_SYNC_FLUSH] = false;
- strm->internal->supported_actions[LZMA_FULL_FLUSH] = false;
- strm->internal->supported_actions[LZMA_FINISH] = false;
- strm->internal->sequence = ISEQ_RUN;
- strm->internal->allow_buf_error = false;
-
- strm->total_in = 0;
- strm->total_out = 0;
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_code(lzma_stream *strm, lzma_action action)
-{
- // Sanity checks
- if ((strm->next_in == NULL && strm->avail_in != 0)
- || (strm->next_out == NULL && strm->avail_out != 0)
- || strm->internal == NULL
- || strm->internal->next.code == NULL
- || (unsigned int)(action) > LZMA_FINISH
- || !strm->internal->supported_actions[action])
- return LZMA_PROG_ERROR;
-
- // Check if unsupported members have been set to non-zero or non-NULL,
- // which would indicate that some new feature is wanted.
- if (strm->reserved_ptr1 != NULL
- || strm->reserved_ptr2 != NULL
- || strm->reserved_ptr3 != NULL
- || strm->reserved_ptr4 != NULL
- || strm->reserved_int1 != 0
- || strm->reserved_int2 != 0
- || strm->reserved_int3 != 0
- || strm->reserved_int4 != 0
- || strm->reserved_enum1 != LZMA_RESERVED_ENUM
- || strm->reserved_enum2 != LZMA_RESERVED_ENUM)
- return LZMA_OPTIONS_ERROR;
-
- switch (strm->internal->sequence) {
- case ISEQ_RUN:
- switch (action) {
- case LZMA_RUN:
- break;
-
- case LZMA_SYNC_FLUSH:
- strm->internal->sequence = ISEQ_SYNC_FLUSH;
- break;
-
- case LZMA_FULL_FLUSH:
- strm->internal->sequence = ISEQ_FULL_FLUSH;
- break;
-
- case LZMA_FINISH:
- strm->internal->sequence = ISEQ_FINISH;
- break;
- }
-
- break;
-
- case ISEQ_SYNC_FLUSH:
- // The same action must be used until we return
- // LZMA_STREAM_END, and the amount of input must not change.
- if (action != LZMA_SYNC_FLUSH
- || strm->internal->avail_in != strm->avail_in)
- return LZMA_PROG_ERROR;
-
- break;
-
- case ISEQ_FULL_FLUSH:
- if (action != LZMA_FULL_FLUSH
- || strm->internal->avail_in != strm->avail_in)
- return LZMA_PROG_ERROR;
-
- break;
-
- case ISEQ_FINISH:
- if (action != LZMA_FINISH
- || strm->internal->avail_in != strm->avail_in)
- return LZMA_PROG_ERROR;
-
- break;
-
- case ISEQ_END:
- return LZMA_STREAM_END;
-
- case ISEQ_ERROR:
- default:
- return LZMA_PROG_ERROR;
- }
-
- size_t in_pos = 0;
- size_t out_pos = 0;
- lzma_ret ret = strm->internal->next.code(
- strm->internal->next.coder, strm->allocator,
- strm->next_in, &in_pos, strm->avail_in,
- strm->next_out, &out_pos, strm->avail_out, action);
-
- strm->next_in += in_pos;
- strm->avail_in -= in_pos;
- strm->total_in += in_pos;
-
- strm->next_out += out_pos;
- strm->avail_out -= out_pos;
- strm->total_out += out_pos;
-
- strm->internal->avail_in = strm->avail_in;
-
- switch (ret) {
- case LZMA_OK:
- // Don't return LZMA_BUF_ERROR when it happens the first time.
- // This is to avoid returning LZMA_BUF_ERROR when avail_out
- // was zero but still there was no more data left to written
- // to next_out.
- if (out_pos == 0 && in_pos == 0) {
- if (strm->internal->allow_buf_error)
- ret = LZMA_BUF_ERROR;
- else
- strm->internal->allow_buf_error = true;
- } else {
- strm->internal->allow_buf_error = false;
- }
- break;
-
- case LZMA_STREAM_END:
- if (strm->internal->sequence == ISEQ_SYNC_FLUSH
- || strm->internal->sequence == ISEQ_FULL_FLUSH)
- strm->internal->sequence = ISEQ_RUN;
- else
- strm->internal->sequence = ISEQ_END;
-
- // Fall through
-
- case LZMA_NO_CHECK:
- case LZMA_UNSUPPORTED_CHECK:
- case LZMA_GET_CHECK:
- case LZMA_MEMLIMIT_ERROR:
- // Something else than LZMA_OK, but not a fatal error,
- // that is, coding may be continued (except if ISEQ_END).
- strm->internal->allow_buf_error = false;
- break;
-
- default:
- // All the other errors are fatal; coding cannot be continued.
- assert(ret != LZMA_BUF_ERROR);
- strm->internal->sequence = ISEQ_ERROR;
- break;
- }
-
- return ret;
-}
-
-
-extern LZMA_API(void)
-lzma_end(lzma_stream *strm)
-{
- if (strm != NULL && strm->internal != NULL) {
- lzma_next_end(&strm->internal->next, strm->allocator);
- lzma_free(strm->internal, strm->allocator);
- strm->internal = NULL;
- }
-
- return;
-}
-
-
-extern LZMA_API(lzma_check)
-lzma_get_check(const lzma_stream *strm)
-{
- // Return LZMA_CHECK_NONE if we cannot know the check type.
- // It's a bug in the application if this happens.
- if (strm->internal->next.get_check == NULL)
- return LZMA_CHECK_NONE;
-
- return strm->internal->next.get_check(strm->internal->next.coder);
-}
-
-
-extern LZMA_API(uint64_t)
-lzma_memusage(const lzma_stream *strm)
-{
- uint64_t memusage;
- uint64_t old_memlimit;
-
- if (strm == NULL || strm->internal == NULL
- || strm->internal->next.memconfig == NULL
- || strm->internal->next.memconfig(
- strm->internal->next.coder,
- &memusage, &old_memlimit, 0) != LZMA_OK)
- return 0;
-
- return memusage;
-}
-
-
-extern LZMA_API(uint64_t)
-lzma_memlimit_get(const lzma_stream *strm)
-{
- uint64_t old_memlimit;
- uint64_t memusage;
-
- if (strm == NULL || strm->internal == NULL
- || strm->internal->next.memconfig == NULL
- || strm->internal->next.memconfig(
- strm->internal->next.coder,
- &memusage, &old_memlimit, 0) != LZMA_OK)
- return 0;
-
- return old_memlimit;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_memlimit_set(lzma_stream *strm, uint64_t new_memlimit)
-{
- // Dummy variables to simplify memconfig functions
- uint64_t old_memlimit;
- uint64_t memusage;
-
- if (strm == NULL || strm->internal == NULL
- || strm->internal->next.memconfig == NULL)
- return LZMA_PROG_ERROR;
-
- if (new_memlimit != 0 && new_memlimit < LZMA_MEMUSAGE_BASE)
- return LZMA_MEMLIMIT_ERROR;
-
- return strm->internal->next.memconfig(strm->internal->next.coder,
- &memusage, &old_memlimit, new_memlimit);
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/common.h r-base-3.3.1/src/extra/xz/common/common.h
--- r-base-3.2.3/src/extra/xz/common/common.h 2015-03-18 23:02:07.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/common.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,282 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file common.h
-/// \brief Definitions common to the whole liblzma library
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_COMMON_H
-#define LZMA_COMMON_H
-
-#include "sysdefs.h"
-#include "mythread.h"
-#include "tuklib_integer.h"
-
-#if defined(_WIN32) || defined(__CYGWIN__)
-# ifdef DLL_EXPORT
-# define LZMA_API_EXPORT __declspec(dllexport)
-# else
-# define LZMA_API_EXPORT
-# endif
-// R change: we do not want all symbols visible
-#else
-# define LZMA_API_EXPORT
-#endif
-
-#define LZMA_API(type) LZMA_API_EXPORT type LZMA_API_CALL
-
-#include "lzma.h"
-
-// These allow helping the compiler in some often-executed branches, whose
-// result is almost always the same.
-#ifdef __GNUC__
-# define likely(expr) __builtin_expect(expr, true)
-# define unlikely(expr) __builtin_expect(expr, false)
-#else
-# define likely(expr) (expr)
-# define unlikely(expr) (expr)
-#endif
-
-
-/// Size of temporary buffers needed in some filters
-#define LZMA_BUFFER_SIZE 4096
-
-
-/// Starting value for memory usage estimates. Instead of calculating size
-/// of _every_ structure and taking into account malloc() overhead etc., we
-/// add a base size to all memory usage estimates. It's not very accurate
-/// but should be easily good enough.
-#define LZMA_MEMUSAGE_BASE (UINT64_C(1) << 15)
-
-/// Start of internal Filter ID space. These IDs must never be used
-/// in Streams.
-#define LZMA_FILTER_RESERVED_START (LZMA_VLI_C(1) << 62)
-
-
-/// Supported flags that can be passed to lzma_stream_decoder()
-/// or lzma_auto_decoder().
-#define LZMA_SUPPORTED_FLAGS \
- ( LZMA_TELL_NO_CHECK \
- | LZMA_TELL_UNSUPPORTED_CHECK \
- | LZMA_TELL_ANY_CHECK \
- | LZMA_CONCATENATED )
-
-
-/// Type of encoder/decoder specific data; the actual structure is defined
-/// differently in different coders.
-typedef struct lzma_coder_s lzma_coder;
-
-typedef struct lzma_next_coder_s lzma_next_coder;
-
-typedef struct lzma_filter_info_s lzma_filter_info;
-
-
-/// Type of a function used to initialize a filter encoder or decoder
-typedef lzma_ret (*lzma_init_function)(
- lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters);
-
-/// Type of a function to do some kind of coding work (filters, Stream,
-/// Block encoders/decoders etc.). Some special coders use don't use both
-/// input and output buffers, but for simplicity they still use this same
-/// function prototype.
-typedef lzma_ret (*lzma_code_function)(
- lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size,
- lzma_action action);
-
-/// Type of a function to free the memory allocated for the coder
-typedef void (*lzma_end_function)(
- lzma_coder *coder, lzma_allocator *allocator);
-
-
-/// Raw coder validates and converts an array of lzma_filter structures to
-/// an array of lzma_filter_info structures. This array is used with
-/// lzma_next_filter_init to initialize the filter chain.
-struct lzma_filter_info_s {
- /// Filter ID. This is used only by the encoder
- /// with lzma_filters_update().
- lzma_vli id;
-
- /// Pointer to function used to initialize the filter.
- /// This is NULL to indicate end of array.
- lzma_init_function init;
-
- /// Pointer to filter's options structure
- void *options;
-};
-
-
-/// Hold data and function pointers of the next filter in the chain.
-struct lzma_next_coder_s {
- /// Pointer to coder-specific data
- lzma_coder *coder;
-
- /// Filter ID. This is LZMA_VLI_UNKNOWN when this structure doesn't
- /// point to a filter coder.
- lzma_vli id;
-
- /// "Pointer" to init function. This is never called here.
- /// We need only to detect if we are initializing a coder
- /// that was allocated earlier. See lzma_next_coder_init and
- /// lzma_next_strm_init macros in this file.
- uintptr_t init;
-
- /// Pointer to function to do the actual coding
- lzma_code_function code;
-
- /// Pointer to function to free lzma_next_coder.coder. This can
- /// be NULL; in that case, lzma_free is called to free
- /// lzma_next_coder.coder.
- lzma_end_function end;
-
- /// Pointer to function to return the type of the integrity check.
- /// Most coders won't support this.
- lzma_check (*get_check)(const lzma_coder *coder);
-
- /// Pointer to function to get and/or change the memory usage limit.
- /// If new_memlimit == 0, the limit is not changed.
- lzma_ret (*memconfig)(lzma_coder *coder, uint64_t *memusage,
- uint64_t *old_memlimit, uint64_t new_memlimit);
-
- /// Update the filter-specific options or the whole filter chain
- /// in the encoder.
- lzma_ret (*update)(lzma_coder *coder, lzma_allocator *allocator,
- const lzma_filter *filters,
- const lzma_filter *reversed_filters);
-};
-
-
-/// Macro to initialize lzma_next_coder structure
-#define LZMA_NEXT_CODER_INIT \
- (lzma_next_coder){ \
- .coder = NULL, \
- .init = (uintptr_t)(NULL), \
- .id = LZMA_VLI_UNKNOWN, \
- .code = NULL, \
- .end = NULL, \
- .get_check = NULL, \
- .memconfig = NULL, \
- .update = NULL, \
- }
-
-
-/// Internal data for lzma_strm_init, lzma_code, and lzma_end. A pointer to
-/// this is stored in lzma_stream.
-struct lzma_internal_s {
- /// The actual coder that should do something useful
- lzma_next_coder next;
-
- /// Track the state of the coder. This is used to validate arguments
- /// so that the actual coders can rely on e.g. that LZMA_SYNC_FLUSH
- /// is used on every call to lzma_code until next.code has returned
- /// LZMA_STREAM_END.
- enum {
- ISEQ_RUN,
- ISEQ_SYNC_FLUSH,
- ISEQ_FULL_FLUSH,
- ISEQ_FINISH,
- ISEQ_END,
- ISEQ_ERROR,
- } sequence;
-
- /// A copy of lzma_stream avail_in. This is used to verify that the
- /// amount of input doesn't change once e.g. LZMA_FINISH has been
- /// used.
- size_t avail_in;
-
- /// Indicates which lzma_action values are allowed by next.code.
- bool supported_actions[4];
-
- /// If true, lzma_code will return LZMA_BUF_ERROR if no progress was
- /// made (no input consumed and no output produced by next.code).
- bool allow_buf_error;
-};
-
-
-/// Allocates memory
-extern void *lzma_alloc(size_t size, lzma_allocator *allocator)
- lzma_attribute((__malloc__)) lzma_attr_alloc_size(1);
-
-/// Frees memory
-extern void lzma_free(void *ptr, lzma_allocator *allocator);
-
-
-/// Allocates strm->internal if it is NULL, and initializes *strm and
-/// strm->internal. This function is only called via lzma_next_strm_init macro.
-extern lzma_ret lzma_strm_init(lzma_stream *strm);
-
-/// Initializes the next filter in the chain, if any. This takes care of
-/// freeing the memory of previously initialized filter if it is different
-/// than the filter being initialized now. This way the actual filter
-/// initialization functions don't need to use lzma_next_coder_init macro.
-extern lzma_ret lzma_next_filter_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-/// Update the next filter in the chain, if any. This checks that
-/// the application is not trying to change the Filter IDs.
-extern lzma_ret lzma_next_filter_update(
- lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter *reversed_filters);
-
-/// Frees the memory allocated for next->coder either using next->end or,
-/// if next->end is NULL, using lzma_free.
-extern void lzma_next_end(lzma_next_coder *next, lzma_allocator *allocator);
-
-
-/// Copy as much data as possible from in[] to out[] and update *in_pos
-/// and *out_pos accordingly. Returns the number of bytes copied.
-extern size_t lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size);
-
-
-/// \brief Return if expression doesn't evaluate to LZMA_OK
-///
-/// There are several situations where we want to return immediately
-/// with the value of expr if it isn't LZMA_OK. This macro shortens
-/// the code a little.
-#define return_if_error(expr) \
-do { \
- const lzma_ret ret_ = (expr); \
- if (ret_ != LZMA_OK) \
- return ret_; \
-} while (0)
-
-
-/// If next isn't already initialized, free the previous coder. Then mark
-/// that next is _possibly_ initialized for the coder using this macro.
-/// "Possibly" means that if e.g. allocation of next->coder fails, the
-/// structure isn't actually initialized for this coder, but leaving
-/// next->init to func is still OK.
-#define lzma_next_coder_init(func, next, allocator) \
-do { \
- if ((uintptr_t)(func) != (next)->init) \
- lzma_next_end(next, allocator); \
- (next)->init = (uintptr_t)(func); \
-} while (0)
-
-
-/// Initializes lzma_strm and calls func() to initialize strm->internal->next.
-/// (The function being called will use lzma_next_coder_init()). If
-/// initialization fails, memory that wasn't freed by func() is freed
-/// along strm->internal.
-#define lzma_next_strm_init(func, strm, ...) \
-do { \
- return_if_error(lzma_strm_init(strm)); \
- const lzma_ret ret_ = func(&(strm)->internal->next, \
- (strm)->allocator, __VA_ARGS__); \
- if (ret_ != LZMA_OK) { \
- lzma_end(strm); \
- return ret_; \
- } \
-} while (0)
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/easy_buffer_encoder.c r-base-3.3.1/src/extra/xz/common/easy_buffer_encoder.c
--- r-base-3.2.3/src/extra/xz/common/easy_buffer_encoder.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/easy_buffer_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,27 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file easy_buffer_encoder.c
-/// \brief Easy single-call .xz Stream encoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "easy_preset.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_easy_buffer_encode(uint32_t preset, lzma_check check,
- lzma_allocator *allocator, const uint8_t *in, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
-{
- lzma_options_easy opt_easy;
- if (lzma_easy_preset(&opt_easy, preset))
- return LZMA_OPTIONS_ERROR;
-
- return lzma_stream_buffer_encode(opt_easy.filters, check,
- allocator, in, in_size, out, out_pos, out_size);
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/easy_decoder_memusage.c r-base-3.3.1/src/extra/xz/common/easy_decoder_memusage.c
--- r-base-3.2.3/src/extra/xz/common/easy_decoder_memusage.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/easy_decoder_memusage.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,24 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file easy_decoder_memusage.c
-/// \brief Decoder memory usage calculation to match easy encoder presets
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "easy_preset.h"
-
-
-extern LZMA_API(uint64_t)
-lzma_easy_decoder_memusage(uint32_t preset)
-{
- lzma_options_easy opt_easy;
- if (lzma_easy_preset(&opt_easy, preset))
- return UINT32_MAX;
-
- return lzma_raw_decoder_memusage(opt_easy.filters);
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/easy_encoder.c r-base-3.3.1/src/extra/xz/common/easy_encoder.c
--- r-base-3.2.3/src/extra/xz/common/easy_encoder.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/easy_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,25 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file easy_encoder.c
-/// \brief Easy .xz Stream encoder initialization
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "easy_preset.h"
-#include "stream_encoder.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_easy_encoder(lzma_stream *strm, uint32_t preset, lzma_check check)
-{
- lzma_options_easy opt_easy;
- if (lzma_easy_preset(&opt_easy, preset))
- return LZMA_OPTIONS_ERROR;
-
- return lzma_stream_encoder(strm, opt_easy.filters, check);
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/easy_encoder_memusage.c r-base-3.3.1/src/extra/xz/common/easy_encoder_memusage.c
--- r-base-3.2.3/src/extra/xz/common/easy_encoder_memusage.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/easy_encoder_memusage.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,24 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file easy_encoder_memusage.c
-/// \brief Easy .xz Stream encoder memory usage calculation
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "easy_preset.h"
-
-
-extern LZMA_API(uint64_t)
-lzma_easy_encoder_memusage(uint32_t preset)
-{
- lzma_options_easy opt_easy;
- if (lzma_easy_preset(&opt_easy, preset))
- return UINT32_MAX;
-
- return lzma_raw_encoder_memusage(opt_easy.filters);
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/easy_preset.c r-base-3.3.1/src/extra/xz/common/easy_preset.c
--- r-base-3.2.3/src/extra/xz/common/easy_preset.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/easy_preset.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,27 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file easy_preset.c
-/// \brief Preset handling for easy encoder and decoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "easy_preset.h"
-
-
-extern bool
-lzma_easy_preset(lzma_options_easy *opt_easy, uint32_t preset)
-{
- if (lzma_lzma_preset(&opt_easy->opt_lzma, preset))
- return true;
-
- opt_easy->filters[0].id = LZMA_FILTER_LZMA2;
- opt_easy->filters[0].options = &opt_easy->opt_lzma;
- opt_easy->filters[1].id = LZMA_VLI_UNKNOWN;
-
- return false;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/easy_preset.h r-base-3.3.1/src/extra/xz/common/easy_preset.h
--- r-base-3.2.3/src/extra/xz/common/easy_preset.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/easy_preset.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,32 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file easy_preset.h
-/// \brief Preset handling for easy encoder and decoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-
-
-typedef struct {
- /// We need to keep the filters array available in case
- /// LZMA_FULL_FLUSH is used.
- lzma_filter filters[LZMA_FILTERS_MAX + 1];
-
- /// Options for LZMA2
- lzma_options_lzma opt_lzma;
-
- // Options for more filters can be added later, so this struct
- // is not ready to be put into the public API.
-
-} lzma_options_easy;
-
-
-/// Set *easy to the settings given by the preset. Returns true on error,
-/// false on success.
-extern bool lzma_easy_preset(lzma_options_easy *easy, uint32_t preset);
diff -Nru r-base-3.2.3/src/extra/xz/common/filter_buffer_decoder.c r-base-3.3.1/src/extra/xz/common/filter_buffer_decoder.c
--- r-base-3.2.3/src/extra/xz/common/filter_buffer_decoder.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/filter_buffer_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,87 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file filter_buffer_decoder.c
-/// \brief Single-call raw decoding
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "filter_decoder.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_raw_buffer_decode(const lzma_filter *filters, lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
-{
- // Validate what isn't validated later in filter_common.c.
- if (in == NULL || in_pos == NULL || *in_pos > in_size || out == NULL
- || out_pos == NULL || *out_pos > out_size)
- return LZMA_PROG_ERROR;
-
- // Initialize the decoer.
- lzma_next_coder next = LZMA_NEXT_CODER_INIT;
- return_if_error(lzma_raw_decoder_init(&next, allocator, filters));
-
- // Store the positions so that we can restore them if something
- // goes wrong.
- const size_t in_start = *in_pos;
- const size_t out_start = *out_pos;
-
- // Do the actual decoding and free decoder's memory.
- lzma_ret ret = next.code(next.coder, allocator, in, in_pos, in_size,
- out, out_pos, out_size, LZMA_FINISH);
-
- if (ret == LZMA_STREAM_END) {
- ret = LZMA_OK;
- } else {
- if (ret == LZMA_OK) {
- // Either the input was truncated or the
- // output buffer was too small.
- assert(*in_pos == in_size || *out_pos == out_size);
-
- if (*in_pos != in_size) {
- // Since input wasn't consumed completely,
- // the output buffer became full and is
- // too small.
- ret = LZMA_BUF_ERROR;
-
- } else if (*out_pos != out_size) {
- // Since output didn't became full, the input
- // has to be truncated.
- ret = LZMA_DATA_ERROR;
-
- } else {
- // All the input was consumed and output
- // buffer is full. Now we don't immediately
- // know the reason for the error. Try
- // decoding one more byte. If it succeeds,
- // then the output buffer was too small. If
- // we cannot get a new output byte, the input
- // is truncated.
- uint8_t tmp[1];
- size_t tmp_pos = 0;
- (void)next.code(next.coder, allocator,
- in, in_pos, in_size,
- tmp, &tmp_pos, 1, LZMA_FINISH);
-
- if (tmp_pos == 1)
- ret = LZMA_BUF_ERROR;
- else
- ret = LZMA_DATA_ERROR;
- }
- }
-
- // Restore the positions.
- *in_pos = in_start;
- *out_pos = out_start;
- }
-
- lzma_next_end(&next, allocator);
-
- return ret;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/filter_buffer_encoder.c r-base-3.3.1/src/extra/xz/common/filter_buffer_encoder.c
--- r-base-3.2.3/src/extra/xz/common/filter_buffer_encoder.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/filter_buffer_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,54 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file filter_buffer_encoder.c
-/// \brief Single-call raw encoding
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "filter_encoder.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_raw_buffer_encode(const lzma_filter *filters, lzma_allocator *allocator,
- const uint8_t *in, size_t in_size, uint8_t *out,
- size_t *out_pos, size_t out_size)
-{
- // Validate what isn't validated later in filter_common.c.
- if ((in == NULL && in_size != 0) || out == NULL
- || out_pos == NULL || *out_pos > out_size)
- return LZMA_PROG_ERROR;
-
- // Initialize the encoder
- lzma_next_coder next = LZMA_NEXT_CODER_INIT;
- return_if_error(lzma_raw_encoder_init(&next, allocator, filters));
-
- // Store the output position so that we can restore it if
- // something goes wrong.
- const size_t out_start = *out_pos;
-
- // Do the actual encoding and free coder's memory.
- size_t in_pos = 0;
- lzma_ret ret = next.code(next.coder, allocator, in, &in_pos, in_size,
- out, out_pos, out_size, LZMA_FINISH);
- lzma_next_end(&next, allocator);
-
- if (ret == LZMA_STREAM_END) {
- ret = LZMA_OK;
- } else {
- if (ret == LZMA_OK) {
- // Output buffer was too small.
- assert(*out_pos == out_size);
- ret = LZMA_BUF_ERROR;
- }
-
- // Restore the output position.
- *out_pos = out_start;
- }
-
- return ret;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/filter_common.c r-base-3.3.1/src/extra/xz/common/filter_common.c
--- r-base-3.2.3/src/extra/xz/common/filter_common.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/filter_common.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,337 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file filter_common.c
-/// \brief Filter-specific stuff common for both encoder and decoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "filter_common.h"
-
-
-static const struct {
- /// Filter ID
- lzma_vli id;
-
- /// Size of the filter-specific options structure
- size_t options_size;
-
- /// True if it is OK to use this filter as non-last filter in
- /// the chain.
- bool non_last_ok;
-
- /// True if it is OK to use this filter as the last filter in
- /// the chain.
- bool last_ok;
-
- /// True if the filter may change the size of the data (that is, the
- /// amount of encoded output can be different than the amount of
- /// uncompressed input).
- bool changes_size;
-
-} features[] = {
-#if defined (HAVE_ENCODER_LZMA1) || defined(HAVE_DECODER_LZMA1)
- {
- .id = LZMA_FILTER_LZMA1,
- .options_size = sizeof(lzma_options_lzma),
- .non_last_ok = false,
- .last_ok = true,
- .changes_size = true,
- },
-#endif
-#if defined(HAVE_ENCODER_LZMA2) || defined(HAVE_DECODER_LZMA2)
- {
- .id = LZMA_FILTER_LZMA2,
- .options_size = sizeof(lzma_options_lzma),
- .non_last_ok = false,
- .last_ok = true,
- .changes_size = true,
- },
-#endif
-#if defined(HAVE_ENCODER_X86) || defined(HAVE_DECODER_X86)
- {
- .id = LZMA_FILTER_X86,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
- },
-#endif
-#if defined(HAVE_ENCODER_POWERPC) || defined(HAVE_DECODER_POWERPC)
- {
- .id = LZMA_FILTER_POWERPC,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
- },
-#endif
-#if defined(HAVE_ENCODER_IA64) || defined(HAVE_DECODER_IA64)
- {
- .id = LZMA_FILTER_IA64,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
- },
-#endif
-#if defined(HAVE_ENCODER_ARM) || defined(HAVE_DECODER_ARM)
- {
- .id = LZMA_FILTER_ARM,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
- },
-#endif
-#if defined(HAVE_ENCODER_ARMTHUMB) || defined(HAVE_DECODER_ARMTHUMB)
- {
- .id = LZMA_FILTER_ARMTHUMB,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
- },
-#endif
-#if defined(HAVE_ENCODER_SPARC) || defined(HAVE_DECODER_SPARC)
- {
- .id = LZMA_FILTER_SPARC,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
- },
-#endif
-#if defined(HAVE_ENCODER_DELTA) || defined(HAVE_DECODER_DELTA)
- {
- .id = LZMA_FILTER_DELTA,
- .options_size = sizeof(lzma_options_delta),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
- },
-#endif
- {
- .id = LZMA_VLI_UNKNOWN
- }
-};
-
-
-extern LZMA_API(lzma_ret)
-lzma_filters_copy(const lzma_filter *src, lzma_filter *dest,
- lzma_allocator *allocator)
-{
- if (src == NULL || dest == NULL)
- return LZMA_PROG_ERROR;
-
- lzma_ret ret;
- size_t i;
- for (i = 0; src[i].id != LZMA_VLI_UNKNOWN; ++i) {
- // There must be a maximum of four filters plus
- // the array terminator.
- if (i == LZMA_FILTERS_MAX) {
- ret = LZMA_OPTIONS_ERROR;
- goto error;
- }
-
- dest[i].id = src[i].id;
-
- if (src[i].options == NULL) {
- dest[i].options = NULL;
- } else {
- // See if the filter is supported only when the
- // options is not NULL. This might be convenient
- // sometimes if the app is actually copying only
- // a partial filter chain with a place holder ID.
- //
- // When options is not NULL, the Filter ID must be
- // supported by us, because otherwise we don't know
- // how big the options are.
- size_t j;
- for (j = 0; src[i].id != features[j].id; ++j) {
- if (features[j].id == LZMA_VLI_UNKNOWN) {
- ret = LZMA_OPTIONS_ERROR;
- goto error;
- }
- }
-
- // Allocate and copy the options.
- dest[i].options = lzma_alloc(features[j].options_size,
- allocator);
- if (dest[i].options == NULL) {
- ret = LZMA_MEM_ERROR;
- goto error;
- }
-
- memcpy(dest[i].options, src[i].options,
- features[j].options_size);
- }
- }
-
- // Terminate the filter array.
- assert(i <= LZMA_FILTERS_MAX + 1);
- dest[i].id = LZMA_VLI_UNKNOWN;
- dest[i].options = NULL;
-
- return LZMA_OK;
-
-error:
- // Free the options which we have already allocated.
- while (i-- > 0) {
- lzma_free(dest[i].options, allocator);
- dest[i].options = NULL;
- }
-
- return ret;
-}
-
-
-static lzma_ret
-validate_chain(const lzma_filter *filters, size_t *count)
-{
- // There must be at least one filter.
- if (filters == NULL || filters[0].id == LZMA_VLI_UNKNOWN)
- return LZMA_PROG_ERROR;
-
- // Number of non-last filters that may change the size of the data
- // significantly (that is, more than 1-2 % or so).
- size_t changes_size_count = 0;
-
- // True if it is OK to add a new filter after the current filter.
- bool non_last_ok = true;
-
- // True if the last filter in the given chain is actually usable as
- // the last filter. Only filters that support embedding End of Payload
- // Marker can be used as the last filter in the chain.
- bool last_ok = false;
-
- size_t i = 0;
- do {
- size_t j;
- for (j = 0; filters[i].id != features[j].id; ++j)
- if (features[j].id == LZMA_VLI_UNKNOWN)
- return LZMA_OPTIONS_ERROR;
-
- // If the previous filter in the chain cannot be a non-last
- // filter, the chain is invalid.
- if (!non_last_ok)
- return LZMA_OPTIONS_ERROR;
-
- non_last_ok = features[j].non_last_ok;
- last_ok = features[j].last_ok;
- changes_size_count += features[j].changes_size;
-
- } while (filters[++i].id != LZMA_VLI_UNKNOWN);
-
- // There must be 1-4 filters. The last filter must be usable as
- // the last filter in the chain. A maximum of three filters are
- // allowed to change the size of the data.
- if (i > LZMA_FILTERS_MAX || !last_ok || changes_size_count > 3)
- return LZMA_OPTIONS_ERROR;
-
- *count = i;
- return LZMA_OK;
-}
-
-
-extern lzma_ret
-lzma_raw_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter *options,
- lzma_filter_find coder_find, bool is_encoder)
-{
- // Do some basic validation and get the number of filters.
- size_t count;
- return_if_error(validate_chain(options, &count));
-
- // Set the filter functions and copy the options pointer.
- lzma_filter_info filters[LZMA_FILTERS_MAX + 1];
- if (is_encoder) {
- for (size_t i = 0; i < count; ++i) {
- // The order of the filters is reversed in the
- // encoder. It allows more efficient handling
- // of the uncompressed data.
- const size_t j = count - i - 1;
-
- const lzma_filter_coder *const fc
- = coder_find(options[i].id);
- if (fc == NULL || fc->init == NULL)
- return LZMA_OPTIONS_ERROR;
-
- filters[j].id = options[i].id;
- filters[j].init = fc->init;
- filters[j].options = options[i].options;
- }
- } else {
- for (size_t i = 0; i < count; ++i) {
- const lzma_filter_coder *const fc
- = coder_find(options[i].id);
- if (fc == NULL || fc->init == NULL)
- return LZMA_OPTIONS_ERROR;
-
- filters[i].id = options[i].id;
- filters[i].init = fc->init;
- filters[i].options = options[i].options;
- }
- }
-
- // Terminate the array.
- filters[count].id = LZMA_VLI_UNKNOWN;
- filters[count].init = NULL;
-
- // Initialize the filters.
- const lzma_ret ret = lzma_next_filter_init(next, allocator, filters);
- if (ret != LZMA_OK)
- lzma_next_end(next, allocator);
-
- return ret;
-}
-
-
-extern uint64_t
-lzma_raw_coder_memusage(lzma_filter_find coder_find,
- const lzma_filter *filters)
-{
- // The chain has to have at least one filter.
- {
- size_t tmp;
- if (validate_chain(filters, &tmp) != LZMA_OK)
- return UINT64_MAX;
- }
-
- uint64_t total = 0;
- size_t i = 0;
-
- do {
- const lzma_filter_coder *const fc
- = coder_find(filters[i].id);
- if (fc == NULL)
- return UINT64_MAX; // Unsupported Filter ID
-
- if (fc->memusage == NULL) {
- // This filter doesn't have a function to calculate
- // the memory usage and validate the options. Such
- // filters need only little memory, so we use 1 KiB
- // as a good estimate. They also accept all possible
- // options, so there's no need to worry about lack
- // of validation.
- total += 1024;
- } else {
- // Call the filter-specific memory usage calculation
- // function.
- const uint64_t usage
- = fc->memusage(filters[i].options);
- if (usage == UINT64_MAX)
- return UINT64_MAX; // Invalid options
-
- total += usage;
- }
- } while (filters[++i].id != LZMA_VLI_UNKNOWN);
-
- // Add some fixed amount of extra. It's to compensate memory usage
- // of Stream, Block etc. coders, malloc() overhead, stack etc.
- return total + LZMA_MEMUSAGE_BASE;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/filter_common.h r-base-3.3.1/src/extra/xz/common/filter_common.h
--- r-base-3.2.3/src/extra/xz/common/filter_common.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/filter_common.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,48 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file filter_common.c
-/// \brief Filter-specific stuff common for both encoder and decoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_FILTER_COMMON_H
-#define LZMA_FILTER_COMMON_H
-
-#include "common.h"
-
-
-/// Both lzma_filter_encoder and lzma_filter_decoder begin with these members.
-typedef struct {
- /// Filter ID
- lzma_vli id;
-
- /// Initializes the filter encoder and calls lzma_next_filter_init()
- /// for filters + 1.
- lzma_init_function init;
-
- /// Calculates memory usage of the encoder. If the options are
- /// invalid, UINT64_MAX is returned.
- uint64_t (*memusage)(const void *options);
-
-} lzma_filter_coder;
-
-
-typedef const lzma_filter_coder *(*lzma_filter_find)(lzma_vli id);
-
-
-extern lzma_ret lzma_raw_coder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter *filters,
- lzma_filter_find coder_find, bool is_encoder);
-
-
-extern uint64_t lzma_raw_coder_memusage(lzma_filter_find coder_find,
- const lzma_filter *filters);
-
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/filter_decoder.c r-base-3.3.1/src/extra/xz/common/filter_decoder.c
--- r-base-3.2.3/src/extra/xz/common/filter_decoder.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/filter_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,183 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file filter_decoder.c
-/// \brief Filter ID mapping to filter-specific functions
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "filter_decoder.h"
-#include "filter_common.h"
-#include "lzma_decoder.h"
-#include "lzma2_decoder.h"
-#include "simple_decoder.h"
-#include "delta_decoder.h"
-
-
-typedef struct {
- /// Filter ID
- lzma_vli id;
-
- /// Initializes the filter encoder and calls lzma_next_filter_init()
- /// for filters + 1.
- lzma_init_function init;
-
- /// Calculates memory usage of the encoder. If the options are
- /// invalid, UINT64_MAX is returned.
- uint64_t (*memusage)(const void *options);
-
- /// Decodes Filter Properties.
- ///
- /// \return - LZMA_OK: Properties decoded successfully.
- /// - LZMA_OPTIONS_ERROR: Unsupported properties
- /// - LZMA_MEM_ERROR: Memory allocation failed.
- lzma_ret (*props_decode)(void **options, lzma_allocator *allocator,
- const uint8_t *props, size_t props_size);
-
-} lzma_filter_decoder;
-
-
-static const lzma_filter_decoder decoders[] = {
-#ifdef HAVE_DECODER_LZMA1
- {
- .id = LZMA_FILTER_LZMA1,
- .init = &lzma_lzma_decoder_init,
- .memusage = &lzma_lzma_decoder_memusage,
- .props_decode = &lzma_lzma_props_decode,
- },
-#endif
-#ifdef HAVE_DECODER_LZMA2
- {
- .id = LZMA_FILTER_LZMA2,
- .init = &lzma_lzma2_decoder_init,
- .memusage = &lzma_lzma2_decoder_memusage,
- .props_decode = &lzma_lzma2_props_decode,
- },
-#endif
-#ifdef HAVE_DECODER_X86
- {
- .id = LZMA_FILTER_X86,
- .init = &lzma_simple_x86_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
- },
-#endif
-#ifdef HAVE_DECODER_POWERPC
- {
- .id = LZMA_FILTER_POWERPC,
- .init = &lzma_simple_powerpc_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
- },
-#endif
-#ifdef HAVE_DECODER_IA64
- {
- .id = LZMA_FILTER_IA64,
- .init = &lzma_simple_ia64_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
- },
-#endif
-#ifdef HAVE_DECODER_ARM
- {
- .id = LZMA_FILTER_ARM,
- .init = &lzma_simple_arm_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
- },
-#endif
-#ifdef HAVE_DECODER_ARMTHUMB
- {
- .id = LZMA_FILTER_ARMTHUMB,
- .init = &lzma_simple_armthumb_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
- },
-#endif
-#ifdef HAVE_DECODER_SPARC
- {
- .id = LZMA_FILTER_SPARC,
- .init = &lzma_simple_sparc_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
- },
-#endif
-#ifdef HAVE_DECODER_DELTA
- {
- .id = LZMA_FILTER_DELTA,
- .init = &lzma_delta_decoder_init,
- .memusage = &lzma_delta_coder_memusage,
- .props_decode = &lzma_delta_props_decode,
- },
-#endif
-};
-
-
-static const lzma_filter_decoder *
-decoder_find(lzma_vli id)
-{
- for (size_t i = 0; i < ARRAY_SIZE(decoders); ++i)
- if (decoders[i].id == id)
- return decoders + i;
-
- return NULL;
-}
-
-
-extern LZMA_API(lzma_bool)
-lzma_filter_decoder_is_supported(lzma_vli id)
-{
- return decoder_find(id) != NULL;
-}
-
-
-extern lzma_ret
-lzma_raw_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter *options)
-{
- return lzma_raw_coder_init(next, allocator,
- options, (lzma_filter_find)(&decoder_find), false);
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_raw_decoder(lzma_stream *strm, const lzma_filter *options)
-{
- lzma_next_strm_init(lzma_raw_decoder_init, strm, options);
-
- strm->internal->supported_actions[LZMA_RUN] = true;
- strm->internal->supported_actions[LZMA_FINISH] = true;
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(uint64_t)
-lzma_raw_decoder_memusage(const lzma_filter *filters)
-{
- return lzma_raw_coder_memusage(
- (lzma_filter_find)(&decoder_find), filters);
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_properties_decode(lzma_filter *filter, lzma_allocator *allocator,
- const uint8_t *props, size_t props_size)
-{
- // Make it always NULL so that the caller can always safely free() it.
- filter->options = NULL;
-
- const lzma_filter_decoder *const fd = decoder_find(filter->id);
- if (fd == NULL)
- return LZMA_OPTIONS_ERROR;
-
- if (fd->props_decode == NULL)
- return props_size == 0 ? LZMA_OK : LZMA_OPTIONS_ERROR;
-
- return fd->props_decode(
- &filter->options, allocator, props, props_size);
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/filter_decoder.h r-base-3.3.1/src/extra/xz/common/filter_decoder.h
--- r-base-3.2.3/src/extra/xz/common/filter_decoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/filter_decoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file filter_decoder.c
-/// \brief Filter ID mapping to filter-specific functions
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_FILTER_DECODER_H
-#define LZMA_FILTER_DECODER_H
-
-#include "common.h"
-
-
-extern lzma_ret lzma_raw_decoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter *options);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/filter_encoder.c r-base-3.3.1/src/extra/xz/common/filter_encoder.c
--- r-base-3.2.3/src/extra/xz/common/filter_encoder.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/filter_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,288 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file filter_decoder.c
-/// \brief Filter ID mapping to filter-specific functions
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "filter_encoder.h"
-#include "filter_common.h"
-#include "lzma_encoder.h"
-#include "lzma2_encoder.h"
-#include "simple_encoder.h"
-#include "delta_encoder.h"
-
-
-typedef struct {
- /// Filter ID
- lzma_vli id;
-
- /// Initializes the filter encoder and calls lzma_next_filter_init()
- /// for filters + 1.
- lzma_init_function init;
-
- /// Calculates memory usage of the encoder. If the options are
- /// invalid, UINT64_MAX is returned.
- uint64_t (*memusage)(const void *options);
-
- /// Calculates the minimum sane size for Blocks (or other types of
- /// chunks) to which the input data can be split to make
- /// multithreaded encoding possible. If this is NULL, it is assumed
- /// that the encoder is fast enough with single thread.
- lzma_vli (*chunk_size)(const void *options);
-
- /// Tells the size of the Filter Properties field. If options are
- /// invalid, UINT32_MAX is returned. If this is NULL, props_size_fixed
- /// is used.
- lzma_ret (*props_size_get)(uint32_t *size, const void *options);
- uint32_t props_size_fixed;
-
- /// Encodes Filter Properties.
- ///
- /// \return - LZMA_OK: Properties encoded successfully.
- /// - LZMA_OPTIONS_ERROR: Unsupported options
- /// - LZMA_PROG_ERROR: Invalid options or not enough
- /// output space
- lzma_ret (*props_encode)(const void *options, uint8_t *out);
-
-} lzma_filter_encoder;
-
-
-static const lzma_filter_encoder encoders[] = {
-#ifdef HAVE_ENCODER_LZMA1
- {
- .id = LZMA_FILTER_LZMA1,
- .init = &lzma_lzma_encoder_init,
- .memusage = &lzma_lzma_encoder_memusage,
- .chunk_size = NULL, // FIXME
- .props_size_get = NULL,
- .props_size_fixed = 5,
- .props_encode = &lzma_lzma_props_encode,
- },
-#endif
-#ifdef HAVE_ENCODER_LZMA2
- {
- .id = LZMA_FILTER_LZMA2,
- .init = &lzma_lzma2_encoder_init,
- .memusage = &lzma_lzma2_encoder_memusage,
- .chunk_size = NULL, // FIXME
- .props_size_get = NULL,
- .props_size_fixed = 1,
- .props_encode = &lzma_lzma2_props_encode,
- },
-#endif
-#ifdef HAVE_ENCODER_X86
- {
- .id = LZMA_FILTER_X86,
- .init = &lzma_simple_x86_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
- },
-#endif
-#ifdef HAVE_ENCODER_POWERPC
- {
- .id = LZMA_FILTER_POWERPC,
- .init = &lzma_simple_powerpc_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
- },
-#endif
-#ifdef HAVE_ENCODER_IA64
- {
- .id = LZMA_FILTER_IA64,
- .init = &lzma_simple_ia64_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
- },
-#endif
-#ifdef HAVE_ENCODER_ARM
- {
- .id = LZMA_FILTER_ARM,
- .init = &lzma_simple_arm_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
- },
-#endif
-#ifdef HAVE_ENCODER_ARMTHUMB
- {
- .id = LZMA_FILTER_ARMTHUMB,
- .init = &lzma_simple_armthumb_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
- },
-#endif
-#ifdef HAVE_ENCODER_SPARC
- {
- .id = LZMA_FILTER_SPARC,
- .init = &lzma_simple_sparc_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
- },
-#endif
-#ifdef HAVE_ENCODER_DELTA
- {
- .id = LZMA_FILTER_DELTA,
- .init = &lzma_delta_encoder_init,
- .memusage = &lzma_delta_coder_memusage,
- .chunk_size = NULL,
- .props_size_get = NULL,
- .props_size_fixed = 1,
- .props_encode = &lzma_delta_props_encode,
- },
-#endif
-};
-
-
-static const lzma_filter_encoder *
-encoder_find(lzma_vli id)
-{
- for (size_t i = 0; i < ARRAY_SIZE(encoders); ++i)
- if (encoders[i].id == id)
- return encoders + i;
-
- return NULL;
-}
-
-
-extern LZMA_API(lzma_bool)
-lzma_filter_encoder_is_supported(lzma_vli id)
-{
- return encoder_find(id) != NULL;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_filters_update(lzma_stream *strm, const lzma_filter *filters)
-{
- if (strm->internal->next.update == NULL)
- return LZMA_PROG_ERROR;
-
- // Validate the filter chain.
- if (lzma_raw_encoder_memusage(filters) == UINT64_MAX)
- return LZMA_OPTIONS_ERROR;
-
- // The actual filter chain in the encoder is reversed. Some things
- // still want the normal order chain, so we provide both.
- size_t count = 1;
- while (filters[count].id != LZMA_VLI_UNKNOWN)
- ++count;
-
- lzma_filter reversed_filters[LZMA_FILTERS_MAX + 1];
- for (size_t i = 0; i < count; ++i)
- reversed_filters[count - i - 1] = filters[i];
-
- reversed_filters[count].id = LZMA_VLI_UNKNOWN;
-
- return strm->internal->next.update(strm->internal->next.coder,
- strm->allocator, filters, reversed_filters);
-}
-
-
-extern lzma_ret
-lzma_raw_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter *options)
-{
- return lzma_raw_coder_init(next, allocator,
- options, (lzma_filter_find)(&encoder_find), true);
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_raw_encoder(lzma_stream *strm, const lzma_filter *options)
-{
- lzma_next_strm_init(lzma_raw_coder_init, strm, options,
- (lzma_filter_find)(&encoder_find), true);
-
- strm->internal->supported_actions[LZMA_RUN] = true;
- strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
- strm->internal->supported_actions[LZMA_FINISH] = true;
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(uint64_t)
-lzma_raw_encoder_memusage(const lzma_filter *filters)
-{
- return lzma_raw_coder_memusage(
- (lzma_filter_find)(&encoder_find), filters);
-}
-
-
-/*
-extern LZMA_API(lzma_vli)
-lzma_chunk_size(const lzma_filter *filters)
-{
- lzma_vli max = 0;
-
- for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i) {
- const lzma_filter_encoder *const fe
- = encoder_find(filters[i].id);
- if (fe->chunk_size != NULL) {
- const lzma_vli size
- = fe->chunk_size(filters[i].options);
- if (size == LZMA_VLI_UNKNOWN)
- return LZMA_VLI_UNKNOWN;
-
- if (size > max)
- max = size;
- }
- }
-
- return max;
-}
-*/
-
-
-extern LZMA_API(lzma_ret)
-lzma_properties_size(uint32_t *size, const lzma_filter *filter)
-{
- const lzma_filter_encoder *const fe = encoder_find(filter->id);
- if (fe == NULL) {
- // Unknown filter - if the Filter ID is a proper VLI,
- // return LZMA_OPTIONS_ERROR instead of LZMA_PROG_ERROR,
- // because it's possible that we just don't have support
- // compiled in for the requested filter.
- return filter->id <= LZMA_VLI_MAX
- ? LZMA_OPTIONS_ERROR : LZMA_PROG_ERROR;
- }
-
- if (fe->props_size_get == NULL) {
- // No props_size_get() function, use props_size_fixed.
- *size = fe->props_size_fixed;
- return LZMA_OK;
- }
-
- return fe->props_size_get(size, filter->options);
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_properties_encode(const lzma_filter *filter, uint8_t *props)
-{
- const lzma_filter_encoder *const fe = encoder_find(filter->id);
- if (fe == NULL)
- return LZMA_PROG_ERROR;
-
- if (fe->props_encode == NULL)
- return LZMA_OK;
-
- return fe->props_encode(filter->options, props);
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/filter_encoder.h r-base-3.3.1/src/extra/xz/common/filter_encoder.h
--- r-base-3.2.3/src/extra/xz/common/filter_encoder.h 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/filter_encoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,27 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file filter_encoder.c
-/// \brief Filter ID mapping to filter-specific functions
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_FILTER_ENCODER_H
-#define LZMA_FILTER_ENCODER_H
-
-#include "common.h"
-
-
-// FIXME: Might become a part of the public API once finished.
-// extern lzma_vli lzma_chunk_size(const lzma_filter *filters);
-
-
-extern lzma_ret lzma_raw_encoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter *filters);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/filter_flags_decoder.c r-base-3.3.1/src/extra/xz/common/filter_flags_decoder.c
--- r-base-3.2.3/src/extra/xz/common/filter_flags_decoder.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/filter_flags_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,46 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file filter_flags_decoder.c
-/// \brief Decodes a Filter Flags field
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "filter_decoder.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_filter_flags_decode(
- lzma_filter *filter, lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos, size_t in_size)
-{
- // Set the pointer to NULL so the caller can always safely free it.
- filter->options = NULL;
-
- // Filter ID
- return_if_error(lzma_vli_decode(&filter->id, NULL,
- in, in_pos, in_size));
-
- if (filter->id >= LZMA_FILTER_RESERVED_START)
- return LZMA_DATA_ERROR;
-
- // Size of Properties
- lzma_vli props_size;
- return_if_error(lzma_vli_decode(&props_size, NULL,
- in, in_pos, in_size));
-
- // Filter Properties
- if (in_size - *in_pos < props_size)
- return LZMA_DATA_ERROR;
-
- const lzma_ret ret = lzma_properties_decode(
- filter, allocator, in + *in_pos, props_size);
-
- *in_pos += props_size;
-
- return ret;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/filter_flags_encoder.c r-base-3.3.1/src/extra/xz/common/filter_flags_encoder.c
--- r-base-3.2.3/src/extra/xz/common/filter_flags_encoder.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/filter_flags_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,56 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file filter_flags_encoder.c
-/// \brief Decodes a Filter Flags field
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "filter_encoder.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_filter_flags_size(uint32_t *size, const lzma_filter *filter)
-{
- if (filter->id >= LZMA_FILTER_RESERVED_START)
- return LZMA_PROG_ERROR;
-
- return_if_error(lzma_properties_size(size, filter));
-
- *size += lzma_vli_size(filter->id) + lzma_vli_size(*size);
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_filter_flags_encode(const lzma_filter *filter,
- uint8_t *out, size_t *out_pos, size_t out_size)
-{
- // Filter ID
- if (filter->id >= LZMA_FILTER_RESERVED_START)
- return LZMA_PROG_ERROR;
-
- return_if_error(lzma_vli_encode(filter->id, NULL,
- out, out_pos, out_size));
-
- // Size of Properties
- uint32_t props_size;
- return_if_error(lzma_properties_size(&props_size, filter));
- return_if_error(lzma_vli_encode(props_size, NULL,
- out, out_pos, out_size));
-
- // Filter Properties
- if (out_size - *out_pos < props_size)
- return LZMA_PROG_ERROR;
-
- return_if_error(lzma_properties_encode(filter, out + *out_pos));
-
- *out_pos += props_size;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/index.c r-base-3.3.1/src/extra/xz/common/index.c
--- r-base-3.2.3/src/extra/xz/common/index.c 2012-07-27 22:05:01.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/index.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,1244 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file index.c
-/// \brief Handling of .xz Indexes and some other Stream information
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "index.h"
-#include "stream_flags_common.h"
-
-
-/// \brief How many Records to allocate at once
-///
-/// This should be big enough to avoid making lots of tiny allocations
-/// but small enough to avoid too much unused memory at once.
-#define INDEX_GROUP_SIZE 512
-
-
-/// \brief How many Records can be allocated at once at maximum
-#define PREALLOC_MAX ((SIZE_MAX - sizeof(index_group)) / sizeof(index_record))
-
-
-/// \brief Base structure for index_stream and index_group structures
-typedef struct index_tree_node_s index_tree_node;
-struct index_tree_node_s {
- /// Uncompressed start offset of this Stream (relative to the
- /// beginning of the file) or Block (relative to the beginning
- /// of the Stream)
- lzma_vli uncompressed_base;
-
- /// Compressed start offset of this Stream or Block
- lzma_vli compressed_base;
-
- index_tree_node *parent;
- index_tree_node *left;
- index_tree_node *right;
-};
-
-
-/// \brief AVL tree to hold index_stream or index_group structures
-typedef struct {
- /// Root node
- index_tree_node *root;
-
- /// Leftmost node. Since the tree will be filled sequentially,
- /// this won't change after the first node has been added to
- /// the tree.
- index_tree_node *leftmost;
-
- /// The rightmost node in the tree. Since the tree is filled
- /// sequentially, this is always the node where to add the new data.
- index_tree_node *rightmost;
-
- /// Number of nodes in the tree
- uint32_t count;
-
-} index_tree;
-
-
-typedef struct {
- lzma_vli uncompressed_sum;
- lzma_vli unpadded_sum;
-} index_record;
-
-
-typedef struct {
- /// Every Record group is part of index_stream.groups tree.
- index_tree_node node;
-
- /// Number of Blocks in this Stream before this group.
- lzma_vli number_base;
-
- /// Number of Records that can be put in records[].
- size_t allocated;
-
- /// Index of the last Record in use.
- size_t last;
-
- /// The sizes in this array are stored as cumulative sums relative
- /// to the beginning of the Stream. This makes it possible to
- /// use binary search in lzma_index_locate().
- ///
- /// Note that the cumulative summing is done specially for
- /// unpadded_sum: The previous value is rounded up to the next
- /// multiple of four before adding the Unpadded Size of the new
- /// Block. The total encoded size of the Blocks in the Stream
- /// is records[last].unpadded_sum in the last Record group of
- /// the Stream.
- ///
- /// For example, if the Unpadded Sizes are 39, 57, and 81, the
- /// stored values are 39, 97 (40 + 57), and 181 (100 + 181).
- /// The total encoded size of these Blocks is 184.
- ///
- /// This is a flexible array, because it makes easy to optimize
- /// memory usage in case someone concatenates many Streams that
- /// have only one or few Blocks.
- index_record records[];
-
-} index_group;
-
-
-typedef struct {
- /// Every index_stream is a node in the tree of Sreams.
- index_tree_node node;
-
- /// Number of this Stream (first one is 1)
- uint32_t number;
-
- /// Total number of Blocks before this Stream
- lzma_vli block_number_base;
-
- /// Record groups of this Stream are stored in a tree.
- /// It's a T-tree with AVL-tree balancing. There are
- /// INDEX_GROUP_SIZE Records per node by default.
- /// This keeps the number of memory allocations reasonable
- /// and finding a Record is fast.
- index_tree groups;
-
- /// Number of Records in this Stream
- lzma_vli record_count;
-
- /// Size of the List of Records field in this Stream. This is used
- /// together with record_count to calculate the size of the Index
- /// field and thus the total size of the Stream.
- lzma_vli index_list_size;
-
- /// Stream Flags of this Stream. This is meaningful only if
- /// the Stream Flags have been told us with lzma_index_stream_flags().
- /// Initially stream_flags.version is set to UINT32_MAX to indicate
- /// that the Stream Flags are unknown.
- lzma_stream_flags stream_flags;
-
- /// Amount of Stream Padding after this Stream. This defaults to
- /// zero and can be set with lzma_index_stream_padding().
- lzma_vli stream_padding;
-
-} index_stream;
-
-
-struct lzma_index_s {
- /// AVL-tree containing the Stream(s). Often there is just one
- /// Stream, but using a tree keeps lookups fast even when there
- /// are many concatenated Streams.
- index_tree streams;
-
- /// Uncompressed size of all the Blocks in the Stream(s)
- lzma_vli uncompressed_size;
-
- /// Total size of all the Blocks in the Stream(s)
- lzma_vli total_size;
-
- /// Total number of Records in all Streams in this lzma_index
- lzma_vli record_count;
-
- /// Size of the List of Records field if all the Streams in this
- /// lzma_index were packed into a single Stream (makes it simpler to
- /// take many .xz files and combine them into a single Stream).
- ///
- /// This value together with record_count is needed to calculate
- /// Backward Size that is stored into Stream Footer.
- lzma_vli index_list_size;
-
- /// How many Records to allocate at once in lzma_index_append().
- /// This defaults to INDEX_GROUP_SIZE but can be overriden with
- /// lzma_index_prealloc().
- size_t prealloc;
-
- /// Bitmask indicating what integrity check types have been used
- /// as set by lzma_index_stream_flags(). The bit of the last Stream
- /// is not included here, since it is possible to change it by
- /// calling lzma_index_stream_flags() again.
- uint32_t checks;
-};
-
-
-static void
-index_tree_init(index_tree *tree)
-{
- tree->root = NULL;
- tree->leftmost = NULL;
- tree->rightmost = NULL;
- tree->count = 0;
- return;
-}
-
-
-/// Helper for index_tree_end()
-static void
-index_tree_node_end(index_tree_node *node, lzma_allocator *allocator,
- void (*free_func)(void *node, lzma_allocator *allocator))
-{
- // The tree won't ever be very huge, so recursion should be fine.
- // 20 levels in the tree is likely quite a lot already in practice.
- if (node->left != NULL)
- index_tree_node_end(node->left, allocator, free_func);
-
- if (node->right != NULL)
- index_tree_node_end(node->right, allocator, free_func);
-
- if (free_func != NULL)
- free_func(node, allocator);
-
- lzma_free(node, allocator);
- return;
-}
-
-
-/// Free the meory allocated for a tree. If free_func is not NULL,
-/// it is called on each node before freeing the node. This is used
-/// to free the Record groups from each index_stream before freeing
-/// the index_stream itself.
-static void
-index_tree_end(index_tree *tree, lzma_allocator *allocator,
- void (*free_func)(void *node, lzma_allocator *allocator))
-{
- if (tree->root != NULL)
- index_tree_node_end(tree->root, allocator, free_func);
-
- return;
-}
-
-
-/// Add a new node to the tree. node->uncompressed_base and
-/// node->compressed_base must have been set by the caller already.
-static void
-index_tree_append(index_tree *tree, index_tree_node *node)
-{
- node->parent = tree->rightmost;
- node->left = NULL;
- node->right = NULL;
-
- ++tree->count;
-
- // Handle the special case of adding the first node.
- if (tree->root == NULL) {
- tree->root = node;
- tree->leftmost = node;
- tree->rightmost = node;
- return;
- }
-
- // The tree is always filled sequentially.
- assert(tree->rightmost->uncompressed_base <= node->uncompressed_base);
- assert(tree->rightmost->compressed_base < node->compressed_base);
-
- // Add the new node after the rightmost node. It's the correct
- // place due to the reason above.
- tree->rightmost->right = node;
- tree->rightmost = node;
-
- // Balance the AVL-tree if needed. We don't need to keep the balance
- // factors in nodes, because we always fill the tree sequentially,
- // and thus know the state of the tree just by looking at the node
- // count. From the node count we can calculate how many steps to go
- // up in the tree to find the rotation root.
- uint32_t up = tree->count ^ (UINT32_C(1) << bsr32(tree->count));
- if (up != 0) {
- // Locate the root node for the rotation.
- up = ctz32(tree->count) + 2;
- do {
- node = node->parent;
- } while (--up > 0);
-
- // Rotate left using node as the rotation root.
- index_tree_node *pivot = node->right;
-
- if (node->parent == NULL) {
- tree->root = pivot;
- } else {
- assert(node->parent->right == node);
- node->parent->right = pivot;
- }
-
- pivot->parent = node->parent;
-
- node->right = pivot->left;
- if (node->right != NULL)
- node->right->parent = node;
-
- pivot->left = node;
- node->parent = pivot;
- }
-
- return;
-}
-
-
-/// Get the next node in the tree. Return NULL if there are no more nodes.
-static void *
-index_tree_next(const index_tree_node *node)
-{
- if (node->right != NULL) {
- node = node->right;
- while (node->left != NULL)
- node = node->left;
-
- return (void *)(node);
- }
-
- while (node->parent != NULL && node->parent->right == node)
- node = node->parent;
-
- return (void *)(node->parent);
-}
-
-
-/// Locate a node that contains the given uncompressed offset. It is
-/// caller's job to check that target is not bigger than the uncompressed
-/// size of the tree (the last node would be returned in that case still).
-static void *
-index_tree_locate(const index_tree *tree, lzma_vli target)
-{
- const index_tree_node *result = NULL;
- const index_tree_node *node = tree->root;
-
- assert(tree->leftmost == NULL
- || tree->leftmost->uncompressed_base == 0);
-
- // Consecutive nodes may have the same uncompressed_base.
- // We must pick the rightmost one.
- while (node != NULL) {
- if (node->uncompressed_base > target) {
- node = node->left;
- } else {
- result = node;
- node = node->right;
- }
- }
-
- return (void *)(result);
-}
-
-
-/// Allocate and initialize a new Stream using the given base offsets.
-static index_stream *
-index_stream_init(lzma_vli compressed_base, lzma_vli uncompressed_base,
- lzma_vli stream_number, lzma_vli block_number_base,
- lzma_allocator *allocator)
-{
- index_stream *s = lzma_alloc(sizeof(index_stream), allocator);
- if (s == NULL)
- return NULL;
-
- s->node.uncompressed_base = uncompressed_base;
- s->node.compressed_base = compressed_base;
- s->node.parent = NULL;
- s->node.left = NULL;
- s->node.right = NULL;
-
- s->number = stream_number;
- s->block_number_base = block_number_base;
-
- index_tree_init(&s->groups);
-
- s->record_count = 0;
- s->index_list_size = 0;
- s->stream_flags.version = UINT32_MAX;
- s->stream_padding = 0;
-
- return s;
-}
-
-
-/// Free the memory allocated for a Stream and its Record groups.
-static void
-index_stream_end(void *node, lzma_allocator *allocator)
-{
- index_stream *s = node;
- index_tree_end(&s->groups, allocator, NULL);
- return;
-}
-
-
-static lzma_index *
-index_init_plain(lzma_allocator *allocator)
-{
- lzma_index *i = lzma_alloc(sizeof(lzma_index), allocator);
- if (i != NULL) {
- index_tree_init(&i->streams);
- i->uncompressed_size = 0;
- i->total_size = 0;
- i->record_count = 0;
- i->index_list_size = 0;
- i->prealloc = INDEX_GROUP_SIZE;
- i->checks = 0;
- }
-
- return i;
-}
-
-
-extern LZMA_API(lzma_index *)
-lzma_index_init(lzma_allocator *allocator)
-{
- lzma_index *i = index_init_plain(allocator);
- if (i == NULL)
- return NULL;
-
- index_stream *s = index_stream_init(0, 0, 1, 0, allocator);
- if (s == NULL) {
- lzma_free(i, allocator);
- return NULL;
- }
-
- index_tree_append(&i->streams, &s->node);
-
- return i;
-}
-
-
-extern LZMA_API(void)
-lzma_index_end(lzma_index *i, lzma_allocator *allocator)
-{
- // NOTE: If you modify this function, check also the bottom
- // of lzma_index_cat().
- if (i != NULL) {
- index_tree_end(&i->streams, allocator, &index_stream_end);
- lzma_free(i, allocator);
- }
-
- return;
-}
-
-
-extern void
-lzma_index_prealloc(lzma_index *i, lzma_vli records)
-{
- if (records > PREALLOC_MAX)
- records = PREALLOC_MAX;
-
- i->prealloc = (size_t)(records);
- return;
-}
-
-
-extern LZMA_API(uint64_t)
-lzma_index_memusage(lzma_vli streams, lzma_vli blocks)
-{
- // This calculates an upper bound that is only a little bit
- // bigger than the exact maximum memory usage with the given
- // parameters.
-
- // Typical malloc() overhead is 2 * sizeof(void *) but we take
- // a little bit extra just in case. Using LZMA_MEMUSAGE_BASE
- // instead would give too inaccurate estimate.
- const size_t alloc_overhead = 4 * sizeof(void *);
-
- // Amount of memory needed for each Stream base structures.
- // We assume that every Stream has at least one Block and
- // thus at least one group.
- const size_t stream_base = sizeof(index_stream)
- + sizeof(index_group) + 2 * alloc_overhead;
-
- // Amount of memory needed per group.
- const size_t group_base = sizeof(index_group)
- + INDEX_GROUP_SIZE * sizeof(index_record)
- + alloc_overhead;
-
- // Number of groups. There may actually be more, but that overhead
- // has been taken into account in stream_base already.
- const lzma_vli groups
- = (blocks + INDEX_GROUP_SIZE - 1) / INDEX_GROUP_SIZE;
-
- // Memory used by index_stream and index_group structures.
- const uint64_t streams_mem = streams * stream_base;
- const uint64_t groups_mem = groups * group_base;
-
- // Memory used by the base structure.
- const uint64_t index_base = sizeof(lzma_index) + alloc_overhead;
-
- // Validate the arguments and catch integer overflows.
- // Maximum number of Streams is "only" UINT32_MAX, because
- // that limit is used by the tree containing the Streams.
- const uint64_t limit = UINT64_MAX - index_base;
- if (streams == 0 || streams > UINT32_MAX || blocks > LZMA_VLI_MAX
- || streams > limit / stream_base
- || groups > limit / group_base
- || limit - streams_mem < groups_mem)
- return UINT64_MAX;
-
- return index_base + streams_mem + groups_mem;
-}
-
-
-extern LZMA_API(uint64_t)
-lzma_index_memused(const lzma_index *i)
-{
- return lzma_index_memusage(i->streams.count, i->record_count);
-}
-
-
-extern LZMA_API(lzma_vli)
-lzma_index_block_count(const lzma_index *i)
-{
- return i->record_count;
-}
-
-
-extern LZMA_API(lzma_vli)
-lzma_index_stream_count(const lzma_index *i)
-{
- return i->streams.count;
-}
-
-
-extern LZMA_API(lzma_vli)
-lzma_index_size(const lzma_index *i)
-{
- return index_size(i->record_count, i->index_list_size);
-}
-
-
-extern LZMA_API(lzma_vli)
-lzma_index_total_size(const lzma_index *i)
-{
- return i->total_size;
-}
-
-
-extern LZMA_API(lzma_vli)
-lzma_index_stream_size(const lzma_index *i)
-{
- // Stream Header + Blocks + Index + Stream Footer
- return LZMA_STREAM_HEADER_SIZE + i->total_size
- + index_size(i->record_count, i->index_list_size)
- + LZMA_STREAM_HEADER_SIZE;
-}
-
-
-static lzma_vli
-index_file_size(lzma_vli compressed_base, lzma_vli unpadded_sum,
- lzma_vli record_count, lzma_vli index_list_size,
- lzma_vli stream_padding)
-{
- // Earlier Streams and Stream Paddings + Stream Header
- // + Blocks + Index + Stream Footer + Stream Padding
- //
- // This might go over LZMA_VLI_MAX due to too big unpadded_sum
- // when this function is used in lzma_index_append().
- lzma_vli file_size = compressed_base + 2 * LZMA_STREAM_HEADER_SIZE
- + stream_padding + vli_ceil4(unpadded_sum);
- if (file_size > LZMA_VLI_MAX)
- return LZMA_VLI_UNKNOWN;
-
- // The same applies here.
- file_size += index_size(record_count, index_list_size);
- if (file_size > LZMA_VLI_MAX)
- return LZMA_VLI_UNKNOWN;
-
- return file_size;
-}
-
-
-extern LZMA_API(lzma_vli)
-lzma_index_file_size(const lzma_index *i)
-{
- const index_stream *s = (const index_stream *)(i->streams.rightmost);
- const index_group *g = (const index_group *)(s->groups.rightmost);
- return index_file_size(s->node.compressed_base,
- g == NULL ? 0 : g->records[g->last].unpadded_sum,
- s->record_count, s->index_list_size,
- s->stream_padding);
-}
-
-
-extern LZMA_API(lzma_vli)
-lzma_index_uncompressed_size(const lzma_index *i)
-{
- return i->uncompressed_size;
-}
-
-
-extern LZMA_API(uint32_t)
-lzma_index_checks(const lzma_index *i)
-{
- uint32_t checks = i->checks;
-
- // Get the type of the Check of the last Stream too.
- const index_stream *s = (const index_stream *)(i->streams.rightmost);
- if (s->stream_flags.version != UINT32_MAX)
- checks |= UINT32_C(1) << s->stream_flags.check;
-
- return checks;
-}
-
-
-extern uint32_t
-lzma_index_padding_size(const lzma_index *i)
-{
- return (LZMA_VLI_C(4) - index_size_unpadded(
- i->record_count, i->index_list_size)) & 3;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_index_stream_flags(lzma_index *i, const lzma_stream_flags *stream_flags)
-{
- if (i == NULL || stream_flags == NULL)
- return LZMA_PROG_ERROR;
-
- // Validate the Stream Flags.
- return_if_error(lzma_stream_flags_compare(
- stream_flags, stream_flags));
-
- index_stream *s = (index_stream *)(i->streams.rightmost);
- s->stream_flags = *stream_flags;
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_index_stream_padding(lzma_index *i, lzma_vli stream_padding)
-{
- if (i == NULL || stream_padding > LZMA_VLI_MAX
- || (stream_padding & 3) != 0)
- return LZMA_PROG_ERROR;
-
- index_stream *s = (index_stream *)(i->streams.rightmost);
-
- // Check that the new value won't make the file grow too big.
- const lzma_vli old_stream_padding = s->stream_padding;
- s->stream_padding = 0;
- if (lzma_index_file_size(i) + stream_padding > LZMA_VLI_MAX) {
- s->stream_padding = old_stream_padding;
- return LZMA_DATA_ERROR;
- }
-
- s->stream_padding = stream_padding;
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_index_append(lzma_index *i, lzma_allocator *allocator,
- lzma_vli unpadded_size, lzma_vli uncompressed_size)
-{
- // Validate.
- if (i == NULL || unpadded_size < UNPADDED_SIZE_MIN
- || unpadded_size > UNPADDED_SIZE_MAX
- || uncompressed_size > LZMA_VLI_MAX)
- return LZMA_PROG_ERROR;
-
- index_stream *s = (index_stream *)(i->streams.rightmost);
- index_group *g = (index_group *)(s->groups.rightmost);
-
- const lzma_vli compressed_base = g == NULL ? 0
- : vli_ceil4(g->records[g->last].unpadded_sum);
- const lzma_vli uncompressed_base = g == NULL ? 0
- : g->records[g->last].uncompressed_sum;
- const uint32_t index_list_size_add = lzma_vli_size(unpadded_size)
- + lzma_vli_size(uncompressed_size);
-
- // Check that the file size will stay within limits.
- if (index_file_size(s->node.compressed_base,
- compressed_base + unpadded_size, s->record_count + 1,
- s->index_list_size + index_list_size_add,
- s->stream_padding) == LZMA_VLI_UNKNOWN)
- return LZMA_DATA_ERROR;
-
- // The size of the Index field must not exceed the maximum value
- // that can be stored in the Backward Size field.
- if (index_size(i->record_count + 1,
- i->index_list_size + index_list_size_add)
- > LZMA_BACKWARD_SIZE_MAX)
- return LZMA_DATA_ERROR;
-
- if (g != NULL && g->last + 1 < g->allocated) {
- // There is space in the last group at least for one Record.
- ++g->last;
- } else {
- // We need to allocate a new group.
- g = lzma_alloc(sizeof(index_group)
- + i->prealloc * sizeof(index_record),
- allocator);
- if (g == NULL)
- return LZMA_MEM_ERROR;
-
- g->last = 0;
- g->allocated = i->prealloc;
-
- // Reset prealloc so that if the application happens to
- // add new Records, the allocation size will be sane.
- i->prealloc = INDEX_GROUP_SIZE;
-
- // Set the start offsets of this group.
- g->node.uncompressed_base = uncompressed_base;
- g->node.compressed_base = compressed_base;
- g->number_base = s->record_count + 1;
-
- // Add the new group to the Stream.
- index_tree_append(&s->groups, &g->node);
- }
-
- // Add the new Record to the group.
- g->records[g->last].uncompressed_sum
- = uncompressed_base + uncompressed_size;
- g->records[g->last].unpadded_sum
- = compressed_base + unpadded_size;
-
- // Update the totals.
- ++s->record_count;
- s->index_list_size += index_list_size_add;
-
- i->total_size += vli_ceil4(unpadded_size);
- i->uncompressed_size += uncompressed_size;
- ++i->record_count;
- i->index_list_size += index_list_size_add;
-
- return LZMA_OK;
-}
-
-
-/// Structure to pass info to index_cat_helper()
-typedef struct {
- /// Uncompressed size of the destination
- lzma_vli uncompressed_size;
-
- /// Compressed file size of the destination
- lzma_vli file_size;
-
- /// Same as above but for Block numbers
- lzma_vli block_number_add;
-
- /// Number of Streams that were in the destination index before we
- /// started appending new Streams from the source index. This is
- /// used to fix the Stream numbering.
- uint32_t stream_number_add;
-
- /// Destination index' Stream tree
- index_tree *streams;
-
-} index_cat_info;
-
-
-/// Add the Stream nodes from the source index to dest using recursion.
-/// Simplest iterative traversal of the source tree wouldn't work, because
-/// we update the pointers in nodes when moving them to the destination tree.
-static void
-index_cat_helper(const index_cat_info *info, index_stream *this)
-{
- index_stream *left = (index_stream *)(this->node.left);
- index_stream *right = (index_stream *)(this->node.right);
-
- if (left != NULL)
- index_cat_helper(info, left);
-
- this->node.uncompressed_base += info->uncompressed_size;
- this->node.compressed_base += info->file_size;
- this->number += info->stream_number_add;
- this->block_number_base += info->block_number_add;
- index_tree_append(info->streams, &this->node);
-
- if (right != NULL)
- index_cat_helper(info, right);
-
- return;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_index_cat(lzma_index *restrict dest, lzma_index *restrict src,
- lzma_allocator *allocator)
-{
- const lzma_vli dest_file_size = lzma_index_file_size(dest);
-
- // Check that we don't exceed the file size limits.
- if (dest_file_size + lzma_index_file_size(src) > LZMA_VLI_MAX
- || dest->uncompressed_size + src->uncompressed_size
- > LZMA_VLI_MAX)
- return LZMA_DATA_ERROR;
-
- // Check that the encoded size of the combined lzma_indexes stays
- // within limits. In theory, this should be done only if we know
- // that the user plans to actually combine the Streams and thus
- // construct a single Index (probably rare). However, exceeding
- // this limit is quite theoretical, so we do this check always
- // to simplify things elsewhere.
- {
- const lzma_vli dest_size = index_size_unpadded(
- dest->record_count, dest->index_list_size);
- const lzma_vli src_size = index_size_unpadded(
- src->record_count, src->index_list_size);
- if (vli_ceil4(dest_size + src_size) > LZMA_BACKWARD_SIZE_MAX)
- return LZMA_DATA_ERROR;
- }
-
- // Optimize the last group to minimize memory usage. Allocation has
- // to be done before modifying dest or src.
- {
- index_stream *s = (index_stream *)(dest->streams.rightmost);
- index_group *g = (index_group *)(s->groups.rightmost);
- if (g != NULL && g->last + 1 < g->allocated) {
- assert(g->node.left == NULL);
- assert(g->node.right == NULL);
-
- index_group *newg = lzma_alloc(sizeof(index_group)
- + (g->last + 1)
- * sizeof(index_record),
- allocator);
- if (newg == NULL)
- return LZMA_MEM_ERROR;
-
- newg->node = g->node;
- newg->allocated = g->last + 1;
- newg->last = g->last;
- newg->number_base = g->number_base;
-
- memcpy(newg->records, g->records, newg->allocated
- * sizeof(index_record));
-
- if (g->node.parent != NULL) {
- assert(g->node.parent->right == &g->node);
- g->node.parent->right = &newg->node;
- }
-
- if (s->groups.leftmost == &g->node) {
- assert(s->groups.root == &g->node);
- s->groups.leftmost = &newg->node;
- s->groups.root = &newg->node;
- }
-
- if (s->groups.rightmost == &g->node)
- s->groups.rightmost = &newg->node;
-
- lzma_free(g, allocator);
- }
- }
-
- // Add all the Streams from src to dest. Update the base offsets
- // of each Stream from src.
- const index_cat_info info = {
- .uncompressed_size = dest->uncompressed_size,
- .file_size = dest_file_size,
- .stream_number_add = dest->streams.count,
- .block_number_add = dest->record_count,
- .streams = &dest->streams,
- };
- index_cat_helper(&info, (index_stream *)(src->streams.root));
-
- // Update info about all the combined Streams.
- dest->uncompressed_size += src->uncompressed_size;
- dest->total_size += src->total_size;
- dest->record_count += src->record_count;
- dest->index_list_size += src->index_list_size;
- dest->checks = lzma_index_checks(dest) | src->checks;
-
- // There's nothing else left in src than the base structure.
- lzma_free(src, allocator);
-
- return LZMA_OK;
-}
-
-
-/// Duplicate an index_stream.
-static index_stream *
-index_dup_stream(const index_stream *src, lzma_allocator *allocator)
-{
- // Catch a somewhat theoretical integer overflow.
- if (src->record_count > PREALLOC_MAX)
- return NULL;
-
- // Allocate and initialize a new Stream.
- index_stream *dest = index_stream_init(src->node.compressed_base,
- src->node.uncompressed_base, src->number,
- src->block_number_base, allocator);
-
- // Return immediately if allocation failed or if there are
- // no groups to duplicate.
- if (dest == NULL || src->groups.leftmost == NULL)
- return dest;
-
- // Copy the overall information.
- dest->record_count = src->record_count;
- dest->index_list_size = src->index_list_size;
- dest->stream_flags = src->stream_flags;
- dest->stream_padding = src->stream_padding;
-
- // Allocate memory for the Records. We put all the Records into
- // a single group. It's simplest and also tends to make
- // lzma_index_locate() a little bit faster with very big Indexes.
- index_group *destg = lzma_alloc(sizeof(index_group)
- + src->record_count * sizeof(index_record),
- allocator);
- if (destg == NULL) {
- index_stream_end(dest, allocator);
- return NULL;
- }
-
- // Initialize destg.
- destg->node.uncompressed_base = 0;
- destg->node.compressed_base = 0;
- destg->number_base = 1;
- destg->allocated = src->record_count;
- destg->last = src->record_count - 1;
-
- // Go through all the groups in src and copy the Records into destg.
- const index_group *srcg = (const index_group *)(src->groups.leftmost);
- size_t i = 0;
- do {
- memcpy(destg->records + i, srcg->records,
- (srcg->last + 1) * sizeof(index_record));
- i += srcg->last + 1;
- srcg = index_tree_next(&srcg->node);
- } while (srcg != NULL);
-
- assert(i == destg->allocated);
-
- // Add the group to the new Stream.
- index_tree_append(&dest->groups, &destg->node);
-
- return dest;
-}
-
-
-extern LZMA_API(lzma_index *)
-lzma_index_dup(const lzma_index *src, lzma_allocator *allocator)
-{
- // Allocate the base structure (no initial Stream).
- lzma_index *dest = index_init_plain(allocator);
- if (dest == NULL)
- return NULL;
-
- // Copy the totals.
- dest->uncompressed_size = src->uncompressed_size;
- dest->total_size = src->total_size;
- dest->record_count = src->record_count;
- dest->index_list_size = src->index_list_size;
-
- // Copy the Streams and the groups in them.
- const index_stream *srcstream
- = (const index_stream *)(src->streams.leftmost);
- do {
- index_stream *deststream = index_dup_stream(
- srcstream, allocator);
- if (deststream == NULL) {
- lzma_index_end(dest, allocator);
- return NULL;
- }
-
- index_tree_append(&dest->streams, &deststream->node);
-
- srcstream = index_tree_next(&srcstream->node);
- } while (srcstream != NULL);
-
- return dest;
-}
-
-
-/// Indexing for lzma_index_iter.internal[]
-enum {
- ITER_INDEX,
- ITER_STREAM,
- ITER_GROUP,
- ITER_RECORD,
- ITER_METHOD,
-};
-
-
-/// Values for lzma_index_iter.internal[ITER_METHOD].s
-enum {
- ITER_METHOD_NORMAL,
- ITER_METHOD_NEXT,
- ITER_METHOD_LEFTMOST,
-};
-
-
-static void
-iter_set_info(lzma_index_iter *iter)
-{
- const lzma_index *i = iter->internal[ITER_INDEX].p;
- const index_stream *stream = iter->internal[ITER_STREAM].p;
- const index_group *group = iter->internal[ITER_GROUP].p;
- const size_t record = iter->internal[ITER_RECORD].s;
-
- // lzma_index_iter.internal must not contain a pointer to the last
- // group in the index, because that may be reallocated by
- // lzma_index_cat().
- if (group == NULL) {
- // There are no groups.
- assert(stream->groups.root == NULL);
- iter->internal[ITER_METHOD].s = ITER_METHOD_LEFTMOST;
-
- } else if (i->streams.rightmost != &stream->node
- || stream->groups.rightmost != &group->node) {
- // The group is not not the last group in the index.
- iter->internal[ITER_METHOD].s = ITER_METHOD_NORMAL;
-
- } else if (stream->groups.leftmost != &group->node) {
- // The group isn't the only group in the Stream, thus we
- // know that it must have a parent group i.e. it's not
- // the root node.
- assert(stream->groups.root != &group->node);
- assert(group->node.parent->right == &group->node);
- iter->internal[ITER_METHOD].s = ITER_METHOD_NEXT;
- iter->internal[ITER_GROUP].p = group->node.parent;
-
- } else {
- // The Stream has only one group.
- assert(stream->groups.root == &group->node);
- assert(group->node.parent == NULL);
- iter->internal[ITER_METHOD].s = ITER_METHOD_LEFTMOST;
- iter->internal[ITER_GROUP].p = NULL;
- }
-
- iter->stream.number = stream->number;
- iter->stream.block_count = stream->record_count;
- iter->stream.compressed_offset = stream->node.compressed_base;
- iter->stream.uncompressed_offset = stream->node.uncompressed_base;
-
- // iter->stream.flags will be NULL if the Stream Flags haven't been
- // set with lzma_index_stream_flags().
- iter->stream.flags = stream->stream_flags.version == UINT32_MAX
- ? NULL : &stream->stream_flags;
- iter->stream.padding = stream->stream_padding;
-
- if (stream->groups.rightmost == NULL) {
- // Stream has no Blocks.
- iter->stream.compressed_size = index_size(0, 0)
- + 2 * LZMA_STREAM_HEADER_SIZE;
- iter->stream.uncompressed_size = 0;
- } else {
- const index_group *g = (const index_group *)(
- stream->groups.rightmost);
-
- // Stream Header + Stream Footer + Index + Blocks
- iter->stream.compressed_size = 2 * LZMA_STREAM_HEADER_SIZE
- + index_size(stream->record_count,
- stream->index_list_size)
- + vli_ceil4(g->records[g->last].unpadded_sum);
- iter->stream.uncompressed_size
- = g->records[g->last].uncompressed_sum;
- }
-
- if (group != NULL) {
- iter->block.number_in_stream = group->number_base + record;
- iter->block.number_in_file = iter->block.number_in_stream
- + stream->block_number_base;
-
- iter->block.compressed_stream_offset
- = record == 0 ? group->node.compressed_base
- : vli_ceil4(group->records[
- record - 1].unpadded_sum);
- iter->block.uncompressed_stream_offset
- = record == 0 ? group->node.uncompressed_base
- : group->records[record - 1].uncompressed_sum;
-
- iter->block.uncompressed_size
- = group->records[record].uncompressed_sum
- - iter->block.uncompressed_stream_offset;
- iter->block.unpadded_size
- = group->records[record].unpadded_sum
- - iter->block.compressed_stream_offset;
- iter->block.total_size = vli_ceil4(iter->block.unpadded_size);
-
- iter->block.compressed_stream_offset
- += LZMA_STREAM_HEADER_SIZE;
-
- iter->block.compressed_file_offset
- = iter->block.compressed_stream_offset
- + iter->stream.compressed_offset;
- iter->block.uncompressed_file_offset
- = iter->block.uncompressed_stream_offset
- + iter->stream.uncompressed_offset;
- }
-
- return;
-}
-
-
-extern LZMA_API(void)
-lzma_index_iter_init(lzma_index_iter *iter, const lzma_index *i)
-{
- iter->internal[ITER_INDEX].p = i;
- lzma_index_iter_rewind(iter);
- return;
-}
-
-
-extern LZMA_API(void)
-lzma_index_iter_rewind(lzma_index_iter *iter)
-{
- iter->internal[ITER_STREAM].p = NULL;
- iter->internal[ITER_GROUP].p = NULL;
- iter->internal[ITER_RECORD].s = 0;
- iter->internal[ITER_METHOD].s = ITER_METHOD_NORMAL;
- return;
-}
-
-
-extern LZMA_API(lzma_bool)
-lzma_index_iter_next(lzma_index_iter *iter, lzma_index_iter_mode mode)
-{
- // Catch unsupported mode values.
- if ((unsigned int)(mode) > LZMA_INDEX_ITER_NONEMPTY_BLOCK)
- return true;
-
- const lzma_index *i = iter->internal[ITER_INDEX].p;
- const index_stream *stream = iter->internal[ITER_STREAM].p;
- const index_group *group = NULL;
- size_t record = iter->internal[ITER_RECORD].s;
-
- // If we are being asked for the next Stream, leave group to NULL
- // so that the rest of the this function thinks that this Stream
- // has no groups and will thus go to the next Stream.
- if (mode != LZMA_INDEX_ITER_STREAM) {
- // Get the pointer to the current group. See iter_set_inf()
- // for explanation.
- switch (iter->internal[ITER_METHOD].s) {
- case ITER_METHOD_NORMAL:
- group = iter->internal[ITER_GROUP].p;
- break;
-
- case ITER_METHOD_NEXT:
- group = index_tree_next(iter->internal[ITER_GROUP].p);
- break;
-
- case ITER_METHOD_LEFTMOST:
- group = (const index_group *)(
- stream->groups.leftmost);
- break;
- }
- }
-
-again:
- if (stream == NULL) {
- // We at the beginning of the lzma_index.
- // Locate the first Stream.
- stream = (const index_stream *)(i->streams.leftmost);
- if (mode >= LZMA_INDEX_ITER_BLOCK) {
- // Since we are being asked to return information
- // about the first a Block, skip Streams that have
- // no Blocks.
- while (stream->groups.leftmost == NULL) {
- stream = index_tree_next(&stream->node);
- if (stream == NULL)
- return true;
- }
- }
-
- // Start from the first Record in the Stream.
- group = (const index_group *)(stream->groups.leftmost);
- record = 0;
-
- } else if (group != NULL && record < group->last) {
- // The next Record is in the same group.
- ++record;
-
- } else {
- // This group has no more Records or this Stream has
- // no Blocks at all.
- record = 0;
-
- // If group is not NULL, this Stream has at least one Block
- // and thus at least one group. Find the next group.
- if (group != NULL)
- group = index_tree_next(&group->node);
-
- if (group == NULL) {
- // This Stream has no more Records. Find the next
- // Stream. If we are being asked to return information
- // about a Block, we skip empty Streams.
- do {
- stream = index_tree_next(&stream->node);
- if (stream == NULL)
- return true;
- } while (mode >= LZMA_INDEX_ITER_BLOCK
- && stream->groups.leftmost == NULL);
-
- group = (const index_group *)(
- stream->groups.leftmost);
- }
- }
-
- if (mode == LZMA_INDEX_ITER_NONEMPTY_BLOCK) {
- // We need to look for the next Block again if this Block
- // is empty.
- if (record == 0) {
- if (group->node.uncompressed_base
- == group->records[0].uncompressed_sum)
- goto again;
- } else if (group->records[record - 1].uncompressed_sum
- == group->records[record].uncompressed_sum) {
- goto again;
- }
- }
-
- iter->internal[ITER_STREAM].p = stream;
- iter->internal[ITER_GROUP].p = group;
- iter->internal[ITER_RECORD].s = record;
-
- iter_set_info(iter);
-
- return false;
-}
-
-
-extern LZMA_API(lzma_bool)
-lzma_index_iter_locate(lzma_index_iter *iter, lzma_vli target)
-{
- const lzma_index *i = iter->internal[ITER_INDEX].p;
-
- // If the target is past the end of the file, return immediately.
- if (i->uncompressed_size <= target)
- return true;
-
- // Locate the Stream containing the target offset.
- const index_stream *stream = index_tree_locate(&i->streams, target);
- assert(stream != NULL);
- target -= stream->node.uncompressed_base;
-
- // Locate the group containing the target offset.
- const index_group *group = index_tree_locate(&stream->groups, target);
- assert(group != NULL);
-
- // Use binary search to locate the exact Record. It is the first
- // Record whose uncompressed_sum is greater than target.
- // This is because we want the rightmost Record that fullfills the
- // search criterion. It is possible that there are empty Blocks;
- // we don't want to return them.
- size_t left = 0;
- size_t right = group->last;
-
- while (left < right) {
- const size_t pos = left + (right - left) / 2;
- if (group->records[pos].uncompressed_sum <= target)
- left = pos + 1;
- else
- right = pos;
- }
-
- iter->internal[ITER_STREAM].p = stream;
- iter->internal[ITER_GROUP].p = group;
- iter->internal[ITER_RECORD].s = left;
-
- iter_set_info(iter);
-
- return false;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/index_decoder.c r-base-3.3.1/src/extra/xz/common/index_decoder.c
--- r-base-3.2.3/src/extra/xz/common/index_decoder.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/index_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,345 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file index_decoder.c
-/// \brief Decodes the Index field
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "index.h"
-#include "check.h"
-
-
-struct lzma_coder_s {
- enum {
- SEQ_INDICATOR,
- SEQ_COUNT,
- SEQ_MEMUSAGE,
- SEQ_UNPADDED,
- SEQ_UNCOMPRESSED,
- SEQ_PADDING_INIT,
- SEQ_PADDING,
- SEQ_CRC32,
- } sequence;
-
- /// Memory usage limit
- uint64_t memlimit;
-
- /// Target Index
- lzma_index *index;
-
- /// Pointer give by the application, which is set after
- /// successful decoding.
- lzma_index **index_ptr;
-
- /// Number of Records left to decode.
- lzma_vli count;
-
- /// The most recent Unpadded Size field
- lzma_vli unpadded_size;
-
- /// The most recent Uncompressed Size field
- lzma_vli uncompressed_size;
-
- /// Position in integers
- size_t pos;
-
- /// CRC32 of the List of Records field
- uint32_t crc32;
-};
-
-
-static lzma_ret
-index_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size,
- uint8_t *restrict out lzma_attribute((__unused__)),
- size_t *restrict out_pos lzma_attribute((__unused__)),
- size_t out_size lzma_attribute((__unused__)),
- lzma_action action lzma_attribute((__unused__)))
-{
- // Similar optimization as in index_encoder.c
- const size_t in_start = *in_pos;
- lzma_ret ret = LZMA_OK;
-
- while (*in_pos < in_size)
- switch (coder->sequence) {
- case SEQ_INDICATOR:
- // Return LZMA_DATA_ERROR instead of e.g. LZMA_PROG_ERROR or
- // LZMA_FORMAT_ERROR, because a typical usage case for Index
- // decoder is when parsing the Stream backwards. If seeking
- // backward from the Stream Footer gives us something that
- // doesn't begin with Index Indicator, the file is considered
- // corrupt, not "programming error" or "unrecognized file
- // format". One could argue that the application should
- // verify the Index Indicator before trying to decode the
- // Index, but well, I suppose it is simpler this way.
- if (in[(*in_pos)++] != 0x00)
- return LZMA_DATA_ERROR;
-
- coder->sequence = SEQ_COUNT;
- break;
-
- case SEQ_COUNT:
- ret = lzma_vli_decode(&coder->count, &coder->pos,
- in, in_pos, in_size);
- if (ret != LZMA_STREAM_END)
- goto out;
-
- coder->pos = 0;
- coder->sequence = SEQ_MEMUSAGE;
-
- // Fall through
-
- case SEQ_MEMUSAGE:
- if (lzma_index_memusage(1, coder->count) > coder->memlimit) {
- ret = LZMA_MEMLIMIT_ERROR;
- goto out;
- }
-
- // Tell the Index handling code how many Records this
- // Index has to allow it to allocate memory more efficiently.
- lzma_index_prealloc(coder->index, coder->count);
-
- ret = LZMA_OK;
- coder->sequence = coder->count == 0
- ? SEQ_PADDING_INIT : SEQ_UNPADDED;
- break;
-
- case SEQ_UNPADDED:
- case SEQ_UNCOMPRESSED: {
- lzma_vli *size = coder->sequence == SEQ_UNPADDED
- ? &coder->unpadded_size
- : &coder->uncompressed_size;
-
- ret = lzma_vli_decode(size, &coder->pos,
- in, in_pos, in_size);
- if (ret != LZMA_STREAM_END)
- goto out;
-
- ret = LZMA_OK;
- coder->pos = 0;
-
- if (coder->sequence == SEQ_UNPADDED) {
- // Validate that encoded Unpadded Size isn't too small
- // or too big.
- if (coder->unpadded_size < UNPADDED_SIZE_MIN
- || coder->unpadded_size
- > UNPADDED_SIZE_MAX)
- return LZMA_DATA_ERROR;
-
- coder->sequence = SEQ_UNCOMPRESSED;
- } else {
- // Add the decoded Record to the Index.
- return_if_error(lzma_index_append(
- coder->index, allocator,
- coder->unpadded_size,
- coder->uncompressed_size));
-
- // Check if this was the last Record.
- coder->sequence = --coder->count == 0
- ? SEQ_PADDING_INIT
- : SEQ_UNPADDED;
- }
-
- break;
- }
-
- case SEQ_PADDING_INIT:
- coder->pos = lzma_index_padding_size(coder->index);
- coder->sequence = SEQ_PADDING;
-
- // Fall through
-
- case SEQ_PADDING:
- if (coder->pos > 0) {
- --coder->pos;
- if (in[(*in_pos)++] != 0x00)
- return LZMA_DATA_ERROR;
-
- break;
- }
-
- // Finish the CRC32 calculation.
- coder->crc32 = lzma_crc32(in + in_start,
- *in_pos - in_start, coder->crc32);
-
- coder->sequence = SEQ_CRC32;
-
- // Fall through
-
- case SEQ_CRC32:
- do {
- if (*in_pos == in_size)
- return LZMA_OK;
-
- if (((coder->crc32 >> (coder->pos * 8)) & 0xFF)
- != in[(*in_pos)++])
- return LZMA_DATA_ERROR;
-
- } while (++coder->pos < 4);
-
- // Decoding was successful, now we can let the application
- // see the decoded Index.
- *coder->index_ptr = coder->index;
-
- // Make index NULL so we don't free it unintentionally.
- coder->index = NULL;
-
- return LZMA_STREAM_END;
-
- default:
- assert(0);
- return LZMA_PROG_ERROR;
- }
-
-out:
- // Update the CRC32,
- coder->crc32 = lzma_crc32(in + in_start,
- *in_pos - in_start, coder->crc32);
-
- return ret;
-}
-
-
-static void
-index_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_index_end(coder->index, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-static lzma_ret
-index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
- uint64_t *old_memlimit, uint64_t new_memlimit)
-{
- *memusage = lzma_index_memusage(1, coder->count);
- *old_memlimit = coder->memlimit;
-
- if (new_memlimit != 0) {
- if (new_memlimit < *memusage)
- return LZMA_MEMLIMIT_ERROR;
-
- coder->memlimit = new_memlimit;
- }
-
- return LZMA_OK;
-}
-
-
-static lzma_ret
-index_decoder_reset(lzma_coder *coder, lzma_allocator *allocator,
- lzma_index **i, uint64_t memlimit)
-{
- // Remember the pointer given by the application. We will set it
- // to point to the decoded Index only if decoding is successful.
- // Before that, keep it NULL so that applications can always safely
- // pass it to lzma_index_end() no matter did decoding succeed or not.
- coder->index_ptr = i;
- *i = NULL;
-
- // We always allocate a new lzma_index.
- coder->index = lzma_index_init(allocator);
- if (coder->index == NULL)
- return LZMA_MEM_ERROR;
-
- // Initialize the rest.
- coder->sequence = SEQ_INDICATOR;
- coder->memlimit = memlimit;
- coder->count = 0; // Needs to be initialized due to _memconfig().
- coder->pos = 0;
- coder->crc32 = 0;
-
- return LZMA_OK;
-}
-
-
-static lzma_ret
-index_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- lzma_index **i, uint64_t memlimit)
-{
- lzma_next_coder_init(&index_decoder_init, next, allocator);
-
- if (i == NULL || memlimit == 0)
- return LZMA_PROG_ERROR;
-
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &index_decode;
- next->end = &index_decoder_end;
- next->memconfig = &index_decoder_memconfig;
- next->coder->index = NULL;
- } else {
- lzma_index_end(next->coder->index, allocator);
- }
-
- return index_decoder_reset(next->coder, allocator, i, memlimit);
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_index_decoder(lzma_stream *strm, lzma_index **i, uint64_t memlimit)
-{
- lzma_next_strm_init(index_decoder_init, strm, i, memlimit);
-
- strm->internal->supported_actions[LZMA_RUN] = true;
- strm->internal->supported_actions[LZMA_FINISH] = true;
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_index_buffer_decode(
- lzma_index **i, uint64_t *memlimit, lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos, size_t in_size)
-{
- // Sanity checks
- if (i == NULL || memlimit == NULL
- || in == NULL || in_pos == NULL || *in_pos > in_size)
- return LZMA_PROG_ERROR;
-
- // Initialize the decoder.
- lzma_coder coder;
- return_if_error(index_decoder_reset(&coder, allocator, i, *memlimit));
-
- // Store the input start position so that we can restore it in case
- // of an error.
- const size_t in_start = *in_pos;
-
- // Do the actual decoding.
- lzma_ret ret = index_decode(&coder, allocator, in, in_pos, in_size,
- NULL, NULL, 0, LZMA_RUN);
-
- if (ret == LZMA_STREAM_END) {
- ret = LZMA_OK;
- } else {
- // Something went wrong, free the Index structure and restore
- // the input position.
- lzma_index_end(coder.index, allocator);
- *in_pos = in_start;
-
- if (ret == LZMA_OK) {
- // The input is truncated or otherwise corrupt.
- // Use LZMA_DATA_ERROR instead of LZMA_BUF_ERROR
- // like lzma_vli_decode() does in single-call mode.
- ret = LZMA_DATA_ERROR;
-
- } else if (ret == LZMA_MEMLIMIT_ERROR) {
- // Tell the caller how much memory would have
- // been needed.
- *memlimit = lzma_index_memusage(1, coder.count);
- }
- }
-
- return ret;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/index_encoder.c r-base-3.3.1/src/extra/xz/common/index_encoder.c
--- r-base-3.2.3/src/extra/xz/common/index_encoder.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/index_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,254 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file index_encoder.c
-/// \brief Encodes the Index field
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "index_encoder.h"
-#include "index.h"
-#include "check.h"
-
-
-struct lzma_coder_s {
- enum {
- SEQ_INDICATOR,
- SEQ_COUNT,
- SEQ_UNPADDED,
- SEQ_UNCOMPRESSED,
- SEQ_NEXT,
- SEQ_PADDING,
- SEQ_CRC32,
- } sequence;
-
- /// Index being encoded
- const lzma_index *index;
-
- /// Iterator for the Index being encoded
- lzma_index_iter iter;
-
- /// Position in integers
- size_t pos;
-
- /// CRC32 of the List of Records field
- uint32_t crc32;
-};
-
-
-static lzma_ret
-index_encode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((__unused__)),
- const uint8_t *restrict in lzma_attribute((__unused__)),
- size_t *restrict in_pos lzma_attribute((__unused__)),
- size_t in_size lzma_attribute((__unused__)),
- uint8_t *restrict out, size_t *restrict out_pos,
- size_t out_size,
- lzma_action action lzma_attribute((__unused__)))
-{
- // Position where to start calculating CRC32. The idea is that we
- // need to call lzma_crc32() only once per call to index_encode().
- const size_t out_start = *out_pos;
-
- // Return value to use if we return at the end of this function.
- // We use "goto out" to jump out of the while-switch construct
- // instead of returning directly, because that way we don't need
- // to copypaste the lzma_crc32() call to many places.
- lzma_ret ret = LZMA_OK;
-
- while (*out_pos < out_size)
- switch (coder->sequence) {
- case SEQ_INDICATOR:
- out[*out_pos] = 0x00;
- ++*out_pos;
- coder->sequence = SEQ_COUNT;
- break;
-
- case SEQ_COUNT: {
- const lzma_vli count = lzma_index_block_count(coder->index);
- ret = lzma_vli_encode(count, &coder->pos,
- out, out_pos, out_size);
- if (ret != LZMA_STREAM_END)
- goto out;
-
- ret = LZMA_OK;
- coder->pos = 0;
- coder->sequence = SEQ_NEXT;
- break;
- }
-
- case SEQ_NEXT:
- if (lzma_index_iter_next(
- &coder->iter, LZMA_INDEX_ITER_BLOCK)) {
- // Get the size of the Index Padding field.
- coder->pos = lzma_index_padding_size(coder->index);
- assert(coder->pos <= 3);
- coder->sequence = SEQ_PADDING;
- break;
- }
-
- coder->sequence = SEQ_UNPADDED;
-
- // Fall through
-
- case SEQ_UNPADDED:
- case SEQ_UNCOMPRESSED: {
- const lzma_vli size = coder->sequence == SEQ_UNPADDED
- ? coder->iter.block.unpadded_size
- : coder->iter.block.uncompressed_size;
-
- ret = lzma_vli_encode(size, &coder->pos,
- out, out_pos, out_size);
- if (ret != LZMA_STREAM_END)
- goto out;
-
- ret = LZMA_OK;
- coder->pos = 0;
-
- // Advance to SEQ_UNCOMPRESSED or SEQ_NEXT.
- ++coder->sequence;
- break;
- }
-
- case SEQ_PADDING:
- if (coder->pos > 0) {
- --coder->pos;
- out[(*out_pos)++] = 0x00;
- break;
- }
-
- // Finish the CRC32 calculation.
- coder->crc32 = lzma_crc32(out + out_start,
- *out_pos - out_start, coder->crc32);
-
- coder->sequence = SEQ_CRC32;
-
- // Fall through
-
- case SEQ_CRC32:
- // We don't use the main loop, because we don't want
- // coder->crc32 to be touched anymore.
- do {
- if (*out_pos == out_size)
- return LZMA_OK;
-
- out[*out_pos] = (coder->crc32 >> (coder->pos * 8))
- & 0xFF;
- ++*out_pos;
-
- } while (++coder->pos < 4);
-
- return LZMA_STREAM_END;
-
- default:
- assert(0);
- return LZMA_PROG_ERROR;
- }
-
-out:
- // Update the CRC32.
- coder->crc32 = lzma_crc32(out + out_start,
- *out_pos - out_start, coder->crc32);
-
- return ret;
-}
-
-
-static void
-index_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_free(coder, allocator);
- return;
-}
-
-
-static void
-index_encoder_reset(lzma_coder *coder, const lzma_index *i)
-{
- lzma_index_iter_init(&coder->iter, i);
-
- coder->sequence = SEQ_INDICATOR;
- coder->index = i;
- coder->pos = 0;
- coder->crc32 = 0;
-
- return;
-}
-
-
-extern lzma_ret
-lzma_index_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_index *i)
-{
- lzma_next_coder_init(&lzma_index_encoder_init, next, allocator);
-
- if (i == NULL)
- return LZMA_PROG_ERROR;
-
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &index_encode;
- next->end = &index_encoder_end;
- }
-
- index_encoder_reset(next->coder, i);
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_index_encoder(lzma_stream *strm, const lzma_index *i)
-{
- lzma_next_strm_init(lzma_index_encoder_init, strm, i);
-
- strm->internal->supported_actions[LZMA_RUN] = true;
- strm->internal->supported_actions[LZMA_FINISH] = true;
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_index_buffer_encode(const lzma_index *i,
- uint8_t *out, size_t *out_pos, size_t out_size)
-{
- // Validate the arguments.
- if (i == NULL || out == NULL || out_pos == NULL || *out_pos > out_size)
- return LZMA_PROG_ERROR;
-
- // Don't try to encode if there's not enough output space.
- if (out_size - *out_pos < lzma_index_size(i))
- return LZMA_BUF_ERROR;
-
- // The Index encoder needs just one small data structure so we can
- // allocate it on stack.
- lzma_coder coder;
- index_encoder_reset(&coder, i);
-
- // Do the actual encoding. This should never fail, but store
- // the original *out_pos just in case.
- const size_t out_start = *out_pos;
- lzma_ret ret = index_encode(&coder, NULL, NULL, NULL, 0,
- out, out_pos, out_size, LZMA_RUN);
-
- if (ret == LZMA_STREAM_END) {
- ret = LZMA_OK;
- } else {
- // We should never get here, but just in case, restore the
- // output position and set the error accordingly if something
- // goes wrong and debugging isn't enabled.
- assert(0);
- *out_pos = out_start;
- ret = LZMA_PROG_ERROR;
- }
-
- return ret;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/index_encoder.h r-base-3.3.1/src/extra/xz/common/index_encoder.h
--- r-base-3.2.3/src/extra/xz/common/index_encoder.h 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/index_encoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file index_encoder.h
-/// \brief Encodes the Index field
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_INDEX_ENCODER_H
-#define LZMA_INDEX_ENCODER_H
-
-#include "common.h"
-
-
-extern lzma_ret lzma_index_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_index *i);
-
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/index.h r-base-3.3.1/src/extra/xz/common/index.h
--- r-base-3.2.3/src/extra/xz/common/index.h 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/index.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,73 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file index.h
-/// \brief Handling of Index
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_INDEX_H
-#define LZMA_INDEX_H
-
-#include "common.h"
-
-
-/// Minimum Unpadded Size
-#define UNPADDED_SIZE_MIN LZMA_VLI_C(5)
-
-/// Maximum Unpadded Size
-#define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
-
-
-/// Get the size of the Index Padding field. This is needed by Index encoder
-/// and decoder, but applications should have no use for this.
-extern uint32_t lzma_index_padding_size(const lzma_index *i);
-
-
-/// Set for how many Records to allocate memory the next time
-/// lzma_index_append() needs to allocate space for a new Record.
-/// This is used only by the Index decoder.
-extern void lzma_index_prealloc(lzma_index *i, lzma_vli records);
-
-
-/// Round the variable-length integer to the next multiple of four.
-static inline lzma_vli
-vli_ceil4(lzma_vli vli)
-{
- assert(vli <= LZMA_VLI_MAX);
- return (vli + 3) & ~LZMA_VLI_C(3);
-}
-
-
-/// Calculate the size of the Index field excluding Index Padding
-static inline lzma_vli
-index_size_unpadded(lzma_vli count, lzma_vli index_list_size)
-{
- // Index Indicator + Number of Records + List of Records + CRC32
- return 1 + lzma_vli_size(count) + index_list_size + 4;
-}
-
-
-/// Calculate the size of the Index field including Index Padding
-static inline lzma_vli
-index_size(lzma_vli count, lzma_vli index_list_size)
-{
- return vli_ceil4(index_size_unpadded(count, index_list_size));
-}
-
-
-/// Calculate the total size of the Stream
-static inline lzma_vli
-index_stream_size(lzma_vli blocks_size,
- lzma_vli count, lzma_vli index_list_size)
-{
- return LZMA_STREAM_HEADER_SIZE + blocks_size
- + index_size(count, index_list_size)
- + LZMA_STREAM_HEADER_SIZE;
-}
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/index_hash.c r-base-3.3.1/src/extra/xz/common/index_hash.c
--- r-base-3.2.3/src/extra/xz/common/index_hash.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/index_hash.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,332 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file index_hash.c
-/// \brief Validates Index by using a hash function
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-#include "index.h"
-#include "check.h"
-
-
-typedef struct {
- /// Sum of the Block sizes (including Block Padding)
- lzma_vli blocks_size;
-
- /// Sum of the Uncompressed Size fields
- lzma_vli uncompressed_size;
-
- /// Number of Records
- lzma_vli count;
-
- /// Size of the List of Index Records as bytes
- lzma_vli index_list_size;
-
- /// Check calculated from Unpadded Sizes and Uncompressed Sizes.
- lzma_check_state check;
-
-} lzma_index_hash_info;
-
-
-struct lzma_index_hash_s {
- enum {
- SEQ_BLOCK,
- SEQ_COUNT,
- SEQ_UNPADDED,
- SEQ_UNCOMPRESSED,
- SEQ_PADDING_INIT,
- SEQ_PADDING,
- SEQ_CRC32,
- } sequence;
-
- /// Information collected while decoding the actual Blocks.
- lzma_index_hash_info blocks;
-
- /// Information collected from the Index field.
- lzma_index_hash_info records;
-
- /// Number of Records not fully decoded
- lzma_vli remaining;
-
- /// Unpadded Size currently being read from an Index Record.
- lzma_vli unpadded_size;
-
- /// Uncompressed Size currently being read from an Index Record.
- lzma_vli uncompressed_size;
-
- /// Position in variable-length integers when decoding them from
- /// the List of Records.
- size_t pos;
-
- /// CRC32 of the Index
- uint32_t crc32;
-};
-
-
-extern LZMA_API(lzma_index_hash *)
-lzma_index_hash_init(lzma_index_hash *index_hash, lzma_allocator *allocator)
-{
- if (index_hash == NULL) {
- index_hash = lzma_alloc(sizeof(lzma_index_hash), allocator);
- if (index_hash == NULL)
- return NULL;
- }
-
- index_hash->sequence = SEQ_BLOCK;
- index_hash->blocks.blocks_size = 0;
- index_hash->blocks.uncompressed_size = 0;
- index_hash->blocks.count = 0;
- index_hash->blocks.index_list_size = 0;
- index_hash->records.blocks_size = 0;
- index_hash->records.uncompressed_size = 0;
- index_hash->records.count = 0;
- index_hash->records.index_list_size = 0;
- index_hash->unpadded_size = 0;
- index_hash->uncompressed_size = 0;
- index_hash->pos = 0;
- index_hash->crc32 = 0;
-
- // These cannot fail because LZMA_CHECK_BEST is known to be supported.
- (void)lzma_check_init(&index_hash->blocks.check, LZMA_CHECK_BEST);
- (void)lzma_check_init(&index_hash->records.check, LZMA_CHECK_BEST);
-
- return index_hash;
-}
-
-
-extern LZMA_API(void)
-lzma_index_hash_end(lzma_index_hash *index_hash, lzma_allocator *allocator)
-{
- lzma_free(index_hash, allocator);
- return;
-}
-
-
-extern LZMA_API(lzma_vli)
-lzma_index_hash_size(const lzma_index_hash *index_hash)
-{
- // Get the size of the Index from ->blocks instead of ->records for
- // cases where application wants to know the Index Size before
- // decoding the Index.
- return index_size(index_hash->blocks.count,
- index_hash->blocks.index_list_size);
-}
-
-
-/// Updates the sizes and the hash without any validation.
-static lzma_ret
-hash_append(lzma_index_hash_info *info, lzma_vli unpadded_size,
- lzma_vli uncompressed_size)
-{
- info->blocks_size += vli_ceil4(unpadded_size);
- info->uncompressed_size += uncompressed_size;
- info->index_list_size += lzma_vli_size(unpadded_size)
- + lzma_vli_size(uncompressed_size);
- ++info->count;
-
- const lzma_vli sizes[2] = { unpadded_size, uncompressed_size };
- lzma_check_update(&info->check, LZMA_CHECK_BEST,
- (const uint8_t *)(sizes), sizeof(sizes));
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_index_hash_append(lzma_index_hash *index_hash, lzma_vli unpadded_size,
- lzma_vli uncompressed_size)
-{
- // Validate the arguments.
- if (index_hash->sequence != SEQ_BLOCK
- || unpadded_size < UNPADDED_SIZE_MIN
- || unpadded_size > UNPADDED_SIZE_MAX
- || uncompressed_size > LZMA_VLI_MAX)
- return LZMA_PROG_ERROR;
-
- // Update the hash.
- return_if_error(hash_append(&index_hash->blocks,
- unpadded_size, uncompressed_size));
-
- // Validate the properties of *info are still in allowed limits.
- if (index_hash->blocks.blocks_size > LZMA_VLI_MAX
- || index_hash->blocks.uncompressed_size > LZMA_VLI_MAX
- || index_size(index_hash->blocks.count,
- index_hash->blocks.index_list_size)
- > LZMA_BACKWARD_SIZE_MAX
- || index_stream_size(index_hash->blocks.blocks_size,
- index_hash->blocks.count,
- index_hash->blocks.index_list_size)
- > LZMA_VLI_MAX)
- return LZMA_DATA_ERROR;
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in,
- size_t *in_pos, size_t in_size)
-{
- // Catch zero input buffer here, because in contrast to Index encoder
- // and decoder functions, applications call this function directly
- // instead of via lzma_code(), which does the buffer checking.
- if (*in_pos >= in_size)
- return LZMA_BUF_ERROR;
-
- // NOTE: This function has many similarities to index_encode() and
- // index_decode() functions found from index_encoder.c and
- // index_decoder.c. See the comments especially in index_encoder.c.
- const size_t in_start = *in_pos;
- lzma_ret ret = LZMA_OK;
-
- while (*in_pos < in_size)
- switch (index_hash->sequence) {
- case SEQ_BLOCK:
- // Check the Index Indicator is present.
- if (in[(*in_pos)++] != 0x00)
- return LZMA_DATA_ERROR;
-
- index_hash->sequence = SEQ_COUNT;
- break;
-
- case SEQ_COUNT: {
- ret = lzma_vli_decode(&index_hash->remaining,
- &index_hash->pos, in, in_pos, in_size);
- if (ret != LZMA_STREAM_END)
- goto out;
-
- // The count must match the count of the Blocks decoded.
- if (index_hash->remaining != index_hash->blocks.count)
- return LZMA_DATA_ERROR;
-
- ret = LZMA_OK;
- index_hash->pos = 0;
-
- // Handle the special case when there are no Blocks.
- index_hash->sequence = index_hash->remaining == 0
- ? SEQ_PADDING_INIT : SEQ_UNPADDED;
- break;
- }
-
- case SEQ_UNPADDED:
- case SEQ_UNCOMPRESSED: {
- lzma_vli *size = index_hash->sequence == SEQ_UNPADDED
- ? &index_hash->unpadded_size
- : &index_hash->uncompressed_size;
-
- ret = lzma_vli_decode(size, &index_hash->pos,
- in, in_pos, in_size);
- if (ret != LZMA_STREAM_END)
- goto out;
-
- ret = LZMA_OK;
- index_hash->pos = 0;
-
- if (index_hash->sequence == SEQ_UNPADDED) {
- if (index_hash->unpadded_size < UNPADDED_SIZE_MIN
- || index_hash->unpadded_size
- > UNPADDED_SIZE_MAX)
- return LZMA_DATA_ERROR;
-
- index_hash->sequence = SEQ_UNCOMPRESSED;
- } else {
- // Update the hash.
- return_if_error(hash_append(&index_hash->records,
- index_hash->unpadded_size,
- index_hash->uncompressed_size));
-
- // Verify that we don't go over the known sizes. Note
- // that this validation is simpler than the one used
- // in lzma_index_hash_append(), because here we know
- // that values in index_hash->blocks are already
- // validated and we are fine as long as we don't
- // exceed them in index_hash->records.
- if (index_hash->blocks.blocks_size
- < index_hash->records.blocks_size
- || index_hash->blocks.uncompressed_size
- < index_hash->records.uncompressed_size
- || index_hash->blocks.index_list_size
- < index_hash->records.index_list_size)
- return LZMA_DATA_ERROR;
-
- // Check if this was the last Record.
- index_hash->sequence = --index_hash->remaining == 0
- ? SEQ_PADDING_INIT : SEQ_UNPADDED;
- }
-
- break;
- }
-
- case SEQ_PADDING_INIT:
- index_hash->pos = (LZMA_VLI_C(4) - index_size_unpadded(
- index_hash->records.count,
- index_hash->records.index_list_size)) & 3;
- index_hash->sequence = SEQ_PADDING;
-
- // Fall through
-
- case SEQ_PADDING:
- if (index_hash->pos > 0) {
- --index_hash->pos;
- if (in[(*in_pos)++] != 0x00)
- return LZMA_DATA_ERROR;
-
- break;
- }
-
- // Compare the sizes.
- if (index_hash->blocks.blocks_size
- != index_hash->records.blocks_size
- || index_hash->blocks.uncompressed_size
- != index_hash->records.uncompressed_size
- || index_hash->blocks.index_list_size
- != index_hash->records.index_list_size)
- return LZMA_DATA_ERROR;
-
- // Finish the hashes and compare them.
- lzma_check_finish(&index_hash->blocks.check, LZMA_CHECK_BEST);
- lzma_check_finish(&index_hash->records.check, LZMA_CHECK_BEST);
- if (memcmp(index_hash->blocks.check.buffer.u8,
- index_hash->records.check.buffer.u8,
- lzma_check_size(LZMA_CHECK_BEST)) != 0)
- return LZMA_DATA_ERROR;
-
- // Finish the CRC32 calculation.
- index_hash->crc32 = lzma_crc32(in + in_start,
- *in_pos - in_start, index_hash->crc32);
-
- index_hash->sequence = SEQ_CRC32;
-
- // Fall through
-
- case SEQ_CRC32:
- do {
- if (*in_pos == in_size)
- return LZMA_OK;
-
- if (((index_hash->crc32 >> (index_hash->pos * 8))
- & 0xFF) != in[(*in_pos)++])
- return LZMA_DATA_ERROR;
-
- } while (++index_hash->pos < 4);
-
- return LZMA_STREAM_END;
-
- default:
- assert(0);
- return LZMA_PROG_ERROR;
- }
-
-out:
- // Update the CRC32,
- index_hash->crc32 = lzma_crc32(in + in_start,
- *in_pos - in_start, index_hash->crc32);
-
- return ret;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/local.h r-base-3.3.1/src/extra/xz/common/local.h
--- r-base-3.2.3/src/extra/xz/common/local.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/local.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,123 +0,0 @@
-/* Define to 1 if crc32 integrity check is enabled. */
-#define HAVE_CHECK_CRC32 1
-
-/* Define to 1 if crc64 integrity check is enabled. */
-#define HAVE_CHECK_CRC64 1
-
-/* Define to 1 if sha256 integrity check is enabled. */
-#define HAVE_CHECK_SHA256 1
-
-/* Define to 1 if decoder components are enabled. */
-#define HAVE_DECODER 1
-
-/* Define to 1 if arm decoder is enabled. */
-#define HAVE_DECODER_ARM 1
-
-/* Define to 1 if armthumb decoder is enabled. */
-#define HAVE_DECODER_ARMTHUMB 1
-
-/* Define to 1 if delta decoder is enabled. */
-#define HAVE_DECODER_DELTA 1
-
-/* Define to 1 if ia64 decoder is enabled. */
-#define HAVE_DECODER_IA64 1
-
-/* Define to 1 if lzma1 decoder is enabled. */
-#define HAVE_DECODER_LZMA1 1
-
-/* Define to 1 if lzma2 decoder is enabled. */
-#define HAVE_DECODER_LZMA2 1
-
-/* Define to 1 if powerpc decoder is enabled. */
-#define HAVE_DECODER_POWERPC 1
-
-/* Define to 1 if sparc decoder is enabled. */
-#define HAVE_DECODER_SPARC 1
-
-/* Define to 1 if subblock decoder is enabled. */
-#define HAVE_DECODER_SUBBLOCK 1
-
-/* Define to 1 if x86 decoder is enabled. */
-#define HAVE_DECODER_X86 1
-
-/* Define to 1 if you have the header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define to 1 if encoder components are enabled. */
-#define HAVE_ENCODER 1
-
-/* Define to 1 if arm encoder is enabled. */
-#define HAVE_ENCODER_ARM 1
-
-/* Define to 1 if armthumb encoder is enabled. */
-#define HAVE_ENCODER_ARMTHUMB 1
-
-/* Define to 1 if delta encoder is enabled. */
-#define HAVE_ENCODER_DELTA 1
-
-/* Define to 1 if ia64 encoder is enabled. */
-#define HAVE_ENCODER_IA64 1
-
-/* Define to 1 if lzma1 encoder is enabled. */
-#define HAVE_ENCODER_LZMA1 1
-
-/* Define to 1 if lzma2 encoder is enabled. */
-#define HAVE_ENCODER_LZMA2 1
-
-/* Define to 1 if powerpc encoder is enabled. */
-#define HAVE_ENCODER_POWERPC 1
-
-/* Define to 1 if sparc encoder is enabled. */
-#define HAVE_ENCODER_SPARC 1
-
-/* Define to 1 if subblock encoder is enabled. */
-/* #undef HAVE_ENCODER_SUBBLOCK */
-
-/* Define to 1 if x86 encoder is enabled. */
-#define HAVE_ENCODER_X86 1
-
-/* Define to 1 to enable bt2 match finder. */
-#define HAVE_MF_BT2 1
-
-/* Define to 1 to enable bt3 match finder. */
-#define HAVE_MF_BT3 1
-
-/* Define to 1 to enable bt4 match finder. */
-#define HAVE_MF_BT4 1
-
-/* Define to 1 to enable hc3 match finder. */
-#define HAVE_MF_HC3 1
-
-/* Define to 1 to enable hc4 match finder. */
-#define HAVE_MF_HC4 1
-
-/* Things that might be defined on a per-platform basis: */
-
-/* Define to 1 if using x86 assembler optimizations. */
-/* #define HAVE_ASM_X86 1 */
-
-/* Define to 1 if using x86_64 assembler optimizations. */
-/* #undef HAVE_ASM_X86_64 */
-
-/* Define to 1 if bswap_16 is available. */
-/* #undef HAVE_BSWAP_16 */
-
-/* Define to 1 if bswap_32 is available. */
-/* #undef HAVE_BSWAP_32 */
-
-/* Define to 1 if bswap_64 is available. */
-/* #undef HAVE_BSWAP_64 */
-
-/* Define to 1 if you have the header file. */
-/* #undef HAVE_BYTESWAP_H */
-
-/* Define to 1 if the system supports fast unaligned memory access. */
-/* #define HAVE_FAST_UNALIGNED_ACCESS 1 */
-
-/* Define to 1 if the system has the type `_Bool'. */
-/* #define HAVE__BOOL 1 */
-
-#ifdef WIN32
-#define HAVE_ASM_X86 1
-#define HAVE_FAST_UNALIGNED_ACCESS 1
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/mythread.h r-base-3.3.1/src/extra/xz/common/mythread.h
--- r-base-3.2.3/src/extra/xz/common/mythread.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/mythread.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,42 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file mythread.h
-/// \brief Wrappers for threads
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "sysdefs.h"
-
-
-#ifdef HAVE_PTHREAD
-# include
-
-# define mythread_once(func) \
- do { \
- static pthread_once_t once_ = PTHREAD_ONCE_INIT; \
- pthread_once(&once_, &func); \
- } while (0)
-
-# define mythread_sigmask(how, set, oset) \
- pthread_sigmask(how, set, oset)
-
-#else
-
-# define mythread_once(func) \
- do { \
- static bool once_ = false; \
- if (!once_) { \
- func(); \
- once_ = true; \
- } \
- } while (0)
-
-# define mythread_sigmask(how, set, oset) \
- sigprocmask(how, set, oset)
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/stream_buffer_decoder.c r-base-3.3.1/src/extra/xz/common/stream_buffer_decoder.c
--- r-base-3.2.3/src/extra/xz/common/stream_buffer_decoder.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/stream_buffer_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,91 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file stream_buffer_decoder.c
-/// \brief Single-call .xz Stream decoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "stream_decoder.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_stream_buffer_decode(uint64_t *memlimit, uint32_t flags,
- lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos, size_t in_size,
- uint8_t *out, size_t *out_pos, size_t out_size)
-{
- // Sanity checks
- if (in_pos == NULL || (in == NULL && *in_pos != in_size)
- || *in_pos > in_size || out_pos == NULL
- || (out == NULL && *out_pos != out_size)
- || *out_pos > out_size)
- return LZMA_PROG_ERROR;
-
- // Catch flags that are not allowed in buffer-to-buffer decoding.
- if (flags & LZMA_TELL_ANY_CHECK)
- return LZMA_PROG_ERROR;
-
- // Initialize the Stream decoder.
- // TODO: We need something to tell the decoder that it can use the
- // output buffer as workspace, and thus save significant amount of RAM.
- lzma_next_coder stream_decoder = LZMA_NEXT_CODER_INIT;
- lzma_ret ret = lzma_stream_decoder_init(
- &stream_decoder, allocator, *memlimit, flags);
-
- if (ret == LZMA_OK) {
- // Save the positions so that we can restore them in case
- // an error occurs.
- const size_t in_start = *in_pos;
- const size_t out_start = *out_pos;
-
- // Do the actual decoding.
- ret = stream_decoder.code(stream_decoder.coder, allocator,
- in, in_pos, in_size, out, out_pos, out_size,
- LZMA_FINISH);
-
- if (ret == LZMA_STREAM_END) {
- ret = LZMA_OK;
- } else {
- // Something went wrong, restore the positions.
- *in_pos = in_start;
- *out_pos = out_start;
-
- if (ret == LZMA_OK) {
- // Either the input was truncated or the
- // output buffer was too small.
- assert(*in_pos == in_size
- || *out_pos == out_size);
-
- // If all the input was consumed, then the
- // input is truncated, even if the output
- // buffer is also full. This is because
- // processing the last byte of the Stream
- // never produces output.
- if (*in_pos == in_size)
- ret = LZMA_DATA_ERROR;
- else
- ret = LZMA_BUF_ERROR;
-
- } else if (ret == LZMA_MEMLIMIT_ERROR) {
- // Let the caller know how much memory would
- // have been needed.
- uint64_t memusage;
- (void)stream_decoder.memconfig(
- stream_decoder.coder,
- memlimit, &memusage, 0);
- }
- }
- }
-
- // Free the decoder memory. This needs to be done even if
- // initialization fails, because the internal API doesn't
- // require the initialization function to free its memory on error.
- lzma_next_end(&stream_decoder, allocator);
-
- return ret;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/stream_buffer_encoder.c r-base-3.3.1/src/extra/xz/common/stream_buffer_encoder.c
--- r-base-3.2.3/src/extra/xz/common/stream_buffer_encoder.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/stream_buffer_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,140 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file stream_buffer_encoder.c
-/// \brief Single-call .xz Stream encoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "index.h"
-
-
-/// Maximum size of Index that has exactly one Record.
-/// Index Indicator + Number of Records + Record + CRC32 rounded up to
-/// the next multiple of four.
-#define INDEX_BOUND ((1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3) & ~3)
-
-/// Stream Header, Stream Footer, and Index
-#define HEADERS_BOUND (2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND)
-
-
-extern LZMA_API(size_t)
-lzma_stream_buffer_bound(size_t uncompressed_size)
-{
- // Get the maximum possible size of a Block.
- const size_t block_bound = lzma_block_buffer_bound(uncompressed_size);
- if (block_bound == 0)
- return 0;
-
- // Catch the possible integer overflow and also prevent the size of
- // the Stream exceeding LZMA_VLI_MAX (theoretically possible on
- // 64-bit systems).
- if (my_min(SIZE_MAX, LZMA_VLI_MAX) - block_bound < HEADERS_BOUND)
- return 0;
-
- return block_bound + HEADERS_BOUND;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check,
- lzma_allocator *allocator, const uint8_t *in, size_t in_size,
- uint8_t *out, size_t *out_pos_ptr, size_t out_size)
-{
- // Sanity checks
- if (filters == NULL || (unsigned int)(check) > LZMA_CHECK_ID_MAX
- || (in == NULL && in_size != 0) || out == NULL
- || out_pos_ptr == NULL || *out_pos_ptr > out_size)
- return LZMA_PROG_ERROR;
-
- if (!lzma_check_is_supported(check))
- return LZMA_UNSUPPORTED_CHECK;
-
- // Note for the paranoids: Index encoder prevents the Stream from
- // getting too big and still being accepted with LZMA_OK, and Block
- // encoder catches if the input is too big. So we don't need to
- // separately check if the buffers are too big.
-
- // Use a local copy. We update *out_pos_ptr only if everything
- // succeeds.
- size_t out_pos = *out_pos_ptr;
-
- // Check that there's enough space for both Stream Header and
- // Stream Footer.
- if (out_size - out_pos <= 2 * LZMA_STREAM_HEADER_SIZE)
- return LZMA_BUF_ERROR;
-
- // Reserve space for Stream Footer so we don't need to check for
- // available space again before encoding Stream Footer.
- out_size -= LZMA_STREAM_HEADER_SIZE;
-
- // Encode the Stream Header.
- lzma_stream_flags stream_flags = {
- .version = 0,
- .check = check,
- };
-
- if (lzma_stream_header_encode(&stream_flags, out + out_pos)
- != LZMA_OK)
- return LZMA_PROG_ERROR;
-
- out_pos += LZMA_STREAM_HEADER_SIZE;
-
- // Encode a Block but only if there is at least one byte of input.
- lzma_block block = {
- .version = 0,
- .check = check,
- .filters = filters,
- };
-
- if (in_size > 0)
- return_if_error(lzma_block_buffer_encode(&block, allocator,
- in, in_size, out, &out_pos, out_size));
-
- // Index
- {
- // Create an Index. It will have one Record if there was
- // at least one byte of input to encode. Otherwise the
- // Index will be empty.
- lzma_index *i = lzma_index_init(allocator);
- if (i == NULL)
- return LZMA_MEM_ERROR;
-
- lzma_ret ret = LZMA_OK;
-
- if (in_size > 0)
- ret = lzma_index_append(i, allocator,
- lzma_block_unpadded_size(&block),
- block.uncompressed_size);
-
- // If adding the Record was successful, encode the Index
- // and get its size which will be stored into Stream Footer.
- if (ret == LZMA_OK) {
- ret = lzma_index_buffer_encode(
- i, out, &out_pos, out_size);
-
- stream_flags.backward_size = lzma_index_size(i);
- }
-
- lzma_index_end(i, allocator);
-
- if (ret != LZMA_OK)
- return ret;
- }
-
- // Stream Footer. We have already reserved space for this.
- if (lzma_stream_footer_encode(&stream_flags, out + out_pos)
- != LZMA_OK)
- return LZMA_PROG_ERROR;
-
- out_pos += LZMA_STREAM_HEADER_SIZE;
-
- // Everything went fine, make the new output position available
- // to the application.
- *out_pos_ptr = out_pos;
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/stream_decoder.c r-base-3.3.1/src/extra/xz/common/stream_decoder.c
--- r-base-3.2.3/src/extra/xz/common/stream_decoder.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/stream_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,451 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file stream_decoder.c
-/// \brief Decodes .xz Streams
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "stream_decoder.h"
-#include "block_decoder.h"
-
-
-struct lzma_coder_s {
- enum {
- SEQ_STREAM_HEADER,
- SEQ_BLOCK_HEADER,
- SEQ_BLOCK,
- SEQ_INDEX,
- SEQ_STREAM_FOOTER,
- SEQ_STREAM_PADDING,
- } sequence;
-
- /// Block or Metadata decoder. This takes little memory and the same
- /// data structure can be used to decode every Block Header, so it's
- /// a good idea to have a separate lzma_next_coder structure for it.
- lzma_next_coder block_decoder;
-
- /// Block options decoded by the Block Header decoder and used by
- /// the Block decoder.
- lzma_block block_options;
-
- /// Stream Flags from Stream Header
- lzma_stream_flags stream_flags;
-
- /// Index is hashed so that it can be compared to the sizes of Blocks
- /// with O(1) memory usage.
- lzma_index_hash *index_hash;
-
- /// Memory usage limit
- uint64_t memlimit;
-
- /// Amount of memory actually needed (only an estimate)
- uint64_t memusage;
-
- /// If true, LZMA_NO_CHECK is returned if the Stream has
- /// no integrity check.
- bool tell_no_check;
-
- /// If true, LZMA_UNSUPPORTED_CHECK is returned if the Stream has
- /// an integrity check that isn't supported by this liblzma build.
- bool tell_unsupported_check;
-
- /// If true, LZMA_GET_CHECK is returned after decoding Stream Header.
- bool tell_any_check;
-
- /// If true, we will decode concatenated Streams that possibly have
- /// Stream Padding between or after them. LZMA_STREAM_END is returned
- /// once the application isn't giving us any new input, and we aren't
- /// in the middle of a Stream, and possible Stream Padding is a
- /// multiple of four bytes.
- bool concatenated;
-
- /// When decoding concatenated Streams, this is true as long as we
- /// are decoding the first Stream. This is needed to avoid misleading
- /// LZMA_FORMAT_ERROR in case the later Streams don't have valid magic
- /// bytes.
- bool first_stream;
-
- /// Write position in buffer[] and position in Stream Padding
- size_t pos;
-
- /// Buffer to hold Stream Header, Block Header, and Stream Footer.
- /// Block Header has biggest maximum size.
- uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX];
-};
-
-
-static lzma_ret
-stream_decoder_reset(lzma_coder *coder, lzma_allocator *allocator)
-{
- // Initialize the Index hash used to verify the Index.
- coder->index_hash = lzma_index_hash_init(coder->index_hash, allocator);
- if (coder->index_hash == NULL)
- return LZMA_MEM_ERROR;
-
- // Reset the rest of the variables.
- coder->sequence = SEQ_STREAM_HEADER;
- coder->pos = 0;
-
- return LZMA_OK;
-}
-
-
-static lzma_ret
-stream_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- // When decoding the actual Block, it may be able to produce more
- // output even if we don't give it any new input.
- while (true)
- switch (coder->sequence) {
- case SEQ_STREAM_HEADER: {
- // Copy the Stream Header to the internal buffer.
- lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,
- LZMA_STREAM_HEADER_SIZE);
-
- // Return if we didn't get the whole Stream Header yet.
- if (coder->pos < LZMA_STREAM_HEADER_SIZE)
- return LZMA_OK;
-
- coder->pos = 0;
-
- // Decode the Stream Header.
- const lzma_ret ret = lzma_stream_header_decode(
- &coder->stream_flags, coder->buffer);
- if (ret != LZMA_OK)
- return ret == LZMA_FORMAT_ERROR && !coder->first_stream
- ? LZMA_DATA_ERROR : ret;
-
- // If we are decoding concatenated Streams, and the later
- // Streams have invalid Header Magic Bytes, we give
- // LZMA_DATA_ERROR instead of LZMA_FORMAT_ERROR.
- coder->first_stream = false;
-
- // Copy the type of the Check so that Block Header and Block
- // decoders see it.
- coder->block_options.check = coder->stream_flags.check;
-
- // Even if we return LZMA_*_CHECK below, we want
- // to continue from Block Header decoding.
- coder->sequence = SEQ_BLOCK_HEADER;
-
- // Detect if there's no integrity check or if it is
- // unsupported if those were requested by the application.
- if (coder->tell_no_check && coder->stream_flags.check
- == LZMA_CHECK_NONE)
- return LZMA_NO_CHECK;
-
- if (coder->tell_unsupported_check
- && !lzma_check_is_supported(
- coder->stream_flags.check))
- return LZMA_UNSUPPORTED_CHECK;
-
- if (coder->tell_any_check)
- return LZMA_GET_CHECK;
- }
-
- // Fall through
-
- case SEQ_BLOCK_HEADER: {
- if (*in_pos >= in_size)
- return LZMA_OK;
-
- if (coder->pos == 0) {
- // Detect if it's Index.
- if (in[*in_pos] == 0x00) {
- coder->sequence = SEQ_INDEX;
- break;
- }
-
- // Calculate the size of the Block Header. Note that
- // Block Header decoder wants to see this byte too
- // so don't advance *in_pos.
- coder->block_options.header_size
- = lzma_block_header_size_decode(
- in[*in_pos]);
- }
-
- // Copy the Block Header to the internal buffer.
- lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,
- coder->block_options.header_size);
-
- // Return if we didn't get the whole Block Header yet.
- if (coder->pos < coder->block_options.header_size)
- return LZMA_OK;
-
- coder->pos = 0;
-
- // Version 0 is currently the only possible version.
- coder->block_options.version = 0;
-
- // Set up a buffer to hold the filter chain. Block Header
- // decoder will initialize all members of this array so
- // we don't need to do it here.
- lzma_filter filters[LZMA_FILTERS_MAX + 1];
- coder->block_options.filters = filters;
-
- // Decode the Block Header.
- return_if_error(lzma_block_header_decode(&coder->block_options,
- allocator, coder->buffer));
-
- // Check the memory usage limit.
- const uint64_t memusage = lzma_raw_decoder_memusage(filters);
- lzma_ret ret;
-
- if (memusage == UINT64_MAX) {
- // One or more unknown Filter IDs.
- ret = LZMA_OPTIONS_ERROR;
- } else {
- // Now we can set coder->memusage since we know that
- // the filter chain is valid. We don't want
- // lzma_memusage() to return UINT64_MAX in case of
- // invalid filter chain.
- coder->memusage = memusage;
-
- if (memusage > coder->memlimit) {
- // The chain would need too much memory.
- ret = LZMA_MEMLIMIT_ERROR;
- } else {
- // Memory usage is OK.
- // Initialize the Block decoder.
- ret = lzma_block_decoder_init(
- &coder->block_decoder,
- allocator,
- &coder->block_options);
- }
- }
-
- // Free the allocated filter options since they are needed
- // only to initialize the Block decoder.
- for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i)
- lzma_free(filters[i].options, allocator);
-
- coder->block_options.filters = NULL;
-
- // Check if memory usage calculation and Block enocoder
- // initialization succeeded.
- if (ret != LZMA_OK)
- return ret;
-
- coder->sequence = SEQ_BLOCK;
- }
-
- // Fall through
-
- case SEQ_BLOCK: {
- const lzma_ret ret = coder->block_decoder.code(
- coder->block_decoder.coder, allocator,
- in, in_pos, in_size, out, out_pos, out_size,
- action);
-
- if (ret != LZMA_STREAM_END)
- return ret;
-
- // Block decoded successfully. Add the new size pair to
- // the Index hash.
- return_if_error(lzma_index_hash_append(coder->index_hash,
- lzma_block_unpadded_size(
- &coder->block_options),
- coder->block_options.uncompressed_size));
-
- coder->sequence = SEQ_BLOCK_HEADER;
- break;
- }
-
- case SEQ_INDEX: {
- // If we don't have any input, don't call
- // lzma_index_hash_decode() since it would return
- // LZMA_BUF_ERROR, which we must not do here.
- if (*in_pos >= in_size)
- return LZMA_OK;
-
- // Decode the Index and compare it to the hash calculated
- // from the sizes of the Blocks (if any).
- const lzma_ret ret = lzma_index_hash_decode(coder->index_hash,
- in, in_pos, in_size);
- if (ret != LZMA_STREAM_END)
- return ret;
-
- coder->sequence = SEQ_STREAM_FOOTER;
- }
-
- // Fall through
-
- case SEQ_STREAM_FOOTER: {
- // Copy the Stream Footer to the internal buffer.
- lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,
- LZMA_STREAM_HEADER_SIZE);
-
- // Return if we didn't get the whole Stream Footer yet.
- if (coder->pos < LZMA_STREAM_HEADER_SIZE)
- return LZMA_OK;
-
- coder->pos = 0;
-
- // Decode the Stream Footer. The decoder gives
- // LZMA_FORMAT_ERROR if the magic bytes don't match,
- // so convert that return code to LZMA_DATA_ERROR.
- lzma_stream_flags footer_flags;
- const lzma_ret ret = lzma_stream_footer_decode(
- &footer_flags, coder->buffer);
- if (ret != LZMA_OK)
- return ret == LZMA_FORMAT_ERROR
- ? LZMA_DATA_ERROR : ret;
-
- // Check that Index Size stored in the Stream Footer matches
- // the real size of the Index field.
- if (lzma_index_hash_size(coder->index_hash)
- != footer_flags.backward_size)
- return LZMA_DATA_ERROR;
-
- // Compare that the Stream Flags fields are identical in
- // both Stream Header and Stream Footer.
- return_if_error(lzma_stream_flags_compare(
- &coder->stream_flags, &footer_flags));
-
- if (!coder->concatenated)
- return LZMA_STREAM_END;
-
- coder->sequence = SEQ_STREAM_PADDING;
- }
-
- // Fall through
-
- case SEQ_STREAM_PADDING:
- assert(coder->concatenated);
-
- // Skip over possible Stream Padding.
- while (true) {
- if (*in_pos >= in_size) {
- // Unless LZMA_FINISH was used, we cannot
- // know if there's more input coming later.
- if (action != LZMA_FINISH)
- return LZMA_OK;
-
- // Stream Padding must be a multiple of
- // four bytes.
- return coder->pos == 0
- ? LZMA_STREAM_END
- : LZMA_DATA_ERROR;
- }
-
- // If the byte is not zero, it probably indicates
- // beginning of a new Stream (or the file is corrupt).
- if (in[*in_pos] != 0x00)
- break;
-
- ++*in_pos;
- coder->pos = (coder->pos + 1) & 3;
- }
-
- // Stream Padding must be a multiple of four bytes (empty
- // Stream Padding is OK).
- if (coder->pos != 0) {
- ++*in_pos;
- return LZMA_DATA_ERROR;
- }
-
- // Prepare to decode the next Stream.
- return_if_error(stream_decoder_reset(coder, allocator));
- break;
-
- default:
- assert(0);
- return LZMA_PROG_ERROR;
- }
-
- // Never reached
-}
-
-
-static void
-stream_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->block_decoder, allocator);
- lzma_index_hash_end(coder->index_hash, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-static lzma_check
-stream_decoder_get_check(const lzma_coder *coder)
-{
- return coder->stream_flags.check;
-}
-
-
-static lzma_ret
-stream_decoder_memconfig(lzma_coder *coder, uint64_t *memusage,
- uint64_t *old_memlimit, uint64_t new_memlimit)
-{
- *memusage = coder->memusage;
- *old_memlimit = coder->memlimit;
-
- if (new_memlimit != 0) {
- if (new_memlimit < coder->memusage)
- return LZMA_MEMLIMIT_ERROR;
-
- coder->memlimit = new_memlimit;
- }
-
- return LZMA_OK;
-}
-
-
-extern lzma_ret
-lzma_stream_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- uint64_t memlimit, uint32_t flags)
-{
- lzma_next_coder_init(&lzma_stream_decoder_init, next, allocator);
-
- if (memlimit == 0)
- return LZMA_PROG_ERROR;
-
- if (flags & ~LZMA_SUPPORTED_FLAGS)
- return LZMA_OPTIONS_ERROR;
-
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &stream_decode;
- next->end = &stream_decoder_end;
- next->get_check = &stream_decoder_get_check;
- next->memconfig = &stream_decoder_memconfig;
-
- next->coder->block_decoder = LZMA_NEXT_CODER_INIT;
- next->coder->index_hash = NULL;
- }
-
- next->coder->memlimit = memlimit;
- next->coder->memusage = LZMA_MEMUSAGE_BASE;
- next->coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0;
- next->coder->tell_unsupported_check
- = (flags & LZMA_TELL_UNSUPPORTED_CHECK) != 0;
- next->coder->tell_any_check = (flags & LZMA_TELL_ANY_CHECK) != 0;
- next->coder->concatenated = (flags & LZMA_CONCATENATED) != 0;
- next->coder->first_stream = true;
-
- return stream_decoder_reset(next->coder, allocator);
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_stream_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags)
-{
- lzma_next_strm_init(lzma_stream_decoder_init, strm, memlimit, flags);
-
- strm->internal->supported_actions[LZMA_RUN] = true;
- strm->internal->supported_actions[LZMA_FINISH] = true;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/stream_decoder.h r-base-3.3.1/src/extra/xz/common/stream_decoder.h
--- r-base-3.2.3/src/extra/xz/common/stream_decoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/stream_decoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,21 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file stream_decoder.h
-/// \brief Decodes .xz Streams
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_STREAM_DECODER_H
-#define LZMA_STREAM_DECODER_H
-
-#include "common.h"
-
-extern lzma_ret lzma_stream_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, uint64_t memlimit, uint32_t flags);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/stream_encoder.c r-base-3.3.1/src/extra/xz/common/stream_encoder.c
--- r-base-3.2.3/src/extra/xz/common/stream_encoder.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/stream_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,331 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file stream_encoder.c
-/// \brief Encodes .xz Streams
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "stream_encoder.h"
-#include "block_encoder.h"
-#include "index_encoder.h"
-
-
-struct lzma_coder_s {
- enum {
- SEQ_STREAM_HEADER,
- SEQ_BLOCK_INIT,
- SEQ_BLOCK_HEADER,
- SEQ_BLOCK_ENCODE,
- SEQ_INDEX_ENCODE,
- SEQ_STREAM_FOOTER,
- } sequence;
-
- /// True if Block encoder has been initialized by
- /// lzma_stream_encoder_init() or stream_encoder_update()
- /// and thus doesn't need to be initialized in stream_encode().
- bool block_encoder_is_initialized;
-
- /// Block
- lzma_next_coder block_encoder;
-
- /// Options for the Block encoder
- lzma_block block_options;
-
- /// The filter chain currently in use
- lzma_filter filters[LZMA_FILTERS_MAX + 1];
-
- /// Index encoder. This is separate from Block encoder, because this
- /// doesn't take much memory, and when encoding multiple Streams
- /// with the same encoding options we avoid reallocating memory.
- lzma_next_coder index_encoder;
-
- /// Index to hold sizes of the Blocks
- lzma_index *index;
-
- /// Read position in buffer[]
- size_t buffer_pos;
-
- /// Total number of bytes in buffer[]
- size_t buffer_size;
-
- /// Buffer to hold Stream Header, Block Header, and Stream Footer.
- /// Block Header has biggest maximum size.
- uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX];
-};
-
-
-static lzma_ret
-block_encoder_init(lzma_coder *coder, lzma_allocator *allocator)
-{
- // Prepare the Block options. Even though Block encoder doesn't need
- // compressed_size, uncompressed_size, and header_size to be
- // initialized, it is a good idea to do it here, because this way
- // we catch if someone gave us Filter ID that cannot be used in
- // Blocks/Streams.
- coder->block_options.compressed_size = LZMA_VLI_UNKNOWN;
- coder->block_options.uncompressed_size = LZMA_VLI_UNKNOWN;
-
- return_if_error(lzma_block_header_size(&coder->block_options));
-
- // Initialize the actual Block encoder.
- return lzma_block_encoder_init(&coder->block_encoder, allocator,
- &coder->block_options);
-}
-
-
-static lzma_ret
-stream_encode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- // Main loop
- while (*out_pos < out_size)
- switch (coder->sequence) {
- case SEQ_STREAM_HEADER:
- case SEQ_BLOCK_HEADER:
- case SEQ_STREAM_FOOTER:
- lzma_bufcpy(coder->buffer, &coder->buffer_pos,
- coder->buffer_size, out, out_pos, out_size);
- if (coder->buffer_pos < coder->buffer_size)
- return LZMA_OK;
-
- if (coder->sequence == SEQ_STREAM_FOOTER)
- return LZMA_STREAM_END;
-
- coder->buffer_pos = 0;
- ++coder->sequence;
- break;
-
- case SEQ_BLOCK_INIT: {
- if (*in_pos == in_size) {
- // If we are requested to flush or finish the current
- // Block, return LZMA_STREAM_END immediately since
- // there's nothing to do.
- if (action != LZMA_FINISH)
- return action == LZMA_RUN
- ? LZMA_OK : LZMA_STREAM_END;
-
- // The application had used LZMA_FULL_FLUSH to finish
- // the previous Block, but now wants to finish without
- // encoding new data, or it is simply creating an
- // empty Stream with no Blocks.
- //
- // Initialize the Index encoder, and continue to
- // actually encoding the Index.
- return_if_error(lzma_index_encoder_init(
- &coder->index_encoder, allocator,
- coder->index));
- coder->sequence = SEQ_INDEX_ENCODE;
- break;
- }
-
- // Initialize the Block encoder unless it was already
- // initialized by lzma_stream_encoder_init() or
- // stream_encoder_update().
- if (!coder->block_encoder_is_initialized)
- return_if_error(block_encoder_init(coder, allocator));
-
- // Make it false so that we don't skip the initialization
- // with the next Block.
- coder->block_encoder_is_initialized = false;
-
- // Encode the Block Header. This shouldn't fail since we have
- // already initialized the Block encoder.
- if (lzma_block_header_encode(&coder->block_options,
- coder->buffer) != LZMA_OK)
- return LZMA_PROG_ERROR;
-
- coder->buffer_size = coder->block_options.header_size;
- coder->sequence = SEQ_BLOCK_HEADER;
- break;
- }
-
- case SEQ_BLOCK_ENCODE: {
- static const lzma_action convert[4] = {
- LZMA_RUN,
- LZMA_SYNC_FLUSH,
- LZMA_FINISH,
- LZMA_FINISH,
- };
-
- const lzma_ret ret = coder->block_encoder.code(
- coder->block_encoder.coder, allocator,
- in, in_pos, in_size,
- out, out_pos, out_size, convert[action]);
- if (ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH)
- return ret;
-
- // Add a new Index Record.
- const lzma_vli unpadded_size = lzma_block_unpadded_size(
- &coder->block_options);
- assert(unpadded_size != 0);
- return_if_error(lzma_index_append(coder->index, allocator,
- unpadded_size,
- coder->block_options.uncompressed_size));
-
- coder->sequence = SEQ_BLOCK_INIT;
- break;
- }
-
- case SEQ_INDEX_ENCODE: {
- // Call the Index encoder. It doesn't take any input, so
- // those pointers can be NULL.
- const lzma_ret ret = coder->index_encoder.code(
- coder->index_encoder.coder, allocator,
- NULL, NULL, 0,
- out, out_pos, out_size, LZMA_RUN);
- if (ret != LZMA_STREAM_END)
- return ret;
-
- // Encode the Stream Footer into coder->buffer.
- const lzma_stream_flags stream_flags = {
- .version = 0,
- .backward_size = lzma_index_size(coder->index),
- .check = coder->block_options.check,
- };
-
- if (lzma_stream_footer_encode(&stream_flags, coder->buffer)
- != LZMA_OK)
- return LZMA_PROG_ERROR;
-
- coder->buffer_size = LZMA_STREAM_HEADER_SIZE;
- coder->sequence = SEQ_STREAM_FOOTER;
- break;
- }
-
- default:
- assert(0);
- return LZMA_PROG_ERROR;
- }
-
- return LZMA_OK;
-}
-
-
-static void
-stream_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->block_encoder, allocator);
- lzma_next_end(&coder->index_encoder, allocator);
- lzma_index_end(coder->index, allocator);
-
- for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
- lzma_free(coder->filters[i].options, allocator);
-
- lzma_free(coder, allocator);
- return;
-}
-
-
-static lzma_ret
-stream_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
- const lzma_filter *filters,
- const lzma_filter *reversed_filters)
-{
- if (coder->sequence <= SEQ_BLOCK_INIT) {
- // There is no incomplete Block waiting to be finished,
- // thus we can change the whole filter chain. Start by
- // trying to initialize the Block encoder with the new
- // chain. This way we detect if the chain is valid.
- coder->block_encoder_is_initialized = false;
- coder->block_options.filters = (lzma_filter *)(filters);
- const lzma_ret ret = block_encoder_init(coder, allocator);
- coder->block_options.filters = coder->filters;
- if (ret != LZMA_OK)
- return ret;
-
- coder->block_encoder_is_initialized = true;
-
- } else if (coder->sequence <= SEQ_BLOCK_ENCODE) {
- // We are in the middle of a Block. Try to update only
- // the filter-specific options.
- return_if_error(coder->block_encoder.update(
- coder->block_encoder.coder, allocator,
- filters, reversed_filters));
- } else {
- // Trying to update the filter chain when we are already
- // encoding Index or Stream Footer.
- return LZMA_PROG_ERROR;
- }
-
- // Free the copy of the old chain and make a copy of the new chain.
- for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
- lzma_free(coder->filters[i].options, allocator);
-
- return lzma_filters_copy(filters, coder->filters, allocator);
-}
-
-
-extern lzma_ret
-lzma_stream_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter *filters, lzma_check check)
-{
- lzma_next_coder_init(&lzma_stream_encoder_init, next, allocator);
-
- if (filters == NULL)
- return LZMA_PROG_ERROR;
-
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &stream_encode;
- next->end = &stream_encoder_end;
- next->update = &stream_encoder_update;
-
- next->coder->filters[0].id = LZMA_VLI_UNKNOWN;
- next->coder->block_encoder = LZMA_NEXT_CODER_INIT;
- next->coder->index_encoder = LZMA_NEXT_CODER_INIT;
- next->coder->index = NULL;
- }
-
- // Basic initializations
- next->coder->sequence = SEQ_STREAM_HEADER;
- next->coder->block_options.version = 0;
- next->coder->block_options.check = check;
-
- // Initialize the Index
- lzma_index_end(next->coder->index, allocator);
- next->coder->index = lzma_index_init(allocator);
- if (next->coder->index == NULL)
- return LZMA_MEM_ERROR;
-
- // Encode the Stream Header
- lzma_stream_flags stream_flags = {
- .version = 0,
- .check = check,
- };
- return_if_error(lzma_stream_header_encode(
- &stream_flags, next->coder->buffer));
-
- next->coder->buffer_pos = 0;
- next->coder->buffer_size = LZMA_STREAM_HEADER_SIZE;
-
- // Initialize the Block encoder. This way we detect unsupported
- // filter chains when initializing the Stream encoder instead of
- // giving an error after Stream Header has already written out.
- return stream_encoder_update(
- next->coder, allocator, filters, NULL);
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_stream_encoder(lzma_stream *strm,
- const lzma_filter *filters, lzma_check check)
-{
- lzma_next_strm_init(lzma_stream_encoder_init, strm, filters, check);
-
- strm->internal->supported_actions[LZMA_RUN] = true;
- strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
- strm->internal->supported_actions[LZMA_FULL_FLUSH] = true;
- strm->internal->supported_actions[LZMA_FINISH] = true;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/stream_encoder.h r-base-3.3.1/src/extra/xz/common/stream_encoder.h
--- r-base-3.2.3/src/extra/xz/common/stream_encoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/stream_encoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file stream_encoder.h
-/// \brief Encodes .xz Streams
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_STREAM_ENCODER_H
-#define LZMA_STREAM_ENCODER_H
-
-#include "common.h"
-
-
-extern lzma_ret lzma_stream_encoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter *filters, lzma_check check);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/stream_flags_common.c r-base-3.3.1/src/extra/xz/common/stream_flags_common.c
--- r-base-3.2.3/src/extra/xz/common/stream_flags_common.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/stream_flags_common.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,47 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file stream_flags_common.c
-/// \brief Common stuff for Stream flags coders
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "stream_flags_common.h"
-
-
-const uint8_t lzma_header_magic[6] = { 0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00 };
-const uint8_t lzma_footer_magic[2] = { 0x59, 0x5A };
-
-
-extern LZMA_API(lzma_ret)
-lzma_stream_flags_compare(
- const lzma_stream_flags *a, const lzma_stream_flags *b)
-{
- // We can compare only version 0 structures.
- if (a->version != 0 || b->version != 0)
- return LZMA_OPTIONS_ERROR;
-
- // Check type
- if ((unsigned int)(a->check) > LZMA_CHECK_ID_MAX
- || (unsigned int)(b->check) > LZMA_CHECK_ID_MAX)
- return LZMA_PROG_ERROR;
-
- if (a->check != b->check)
- return LZMA_DATA_ERROR;
-
- // Backward Sizes are compared only if they are known in both.
- if (a->backward_size != LZMA_VLI_UNKNOWN
- && b->backward_size != LZMA_VLI_UNKNOWN) {
- if (!is_backward_size_valid(a) || !is_backward_size_valid(b))
- return LZMA_PROG_ERROR;
-
- if (a->backward_size != b->backward_size)
- return LZMA_DATA_ERROR;
- }
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/stream_flags_common.h r-base-3.3.1/src/extra/xz/common/stream_flags_common.h
--- r-base-3.2.3/src/extra/xz/common/stream_flags_common.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/stream_flags_common.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,33 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file stream_flags_common.h
-/// \brief Common stuff for Stream flags coders
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_STREAM_FLAGS_COMMON_H
-#define LZMA_STREAM_FLAGS_COMMON_H
-
-#include "common.h"
-
-/// Size of the Stream Flags field
-#define LZMA_STREAM_FLAGS_SIZE 2
-
-extern const uint8_t lzma_header_magic[6];
-extern const uint8_t lzma_footer_magic[2];
-
-
-static inline bool
-is_backward_size_valid(const lzma_stream_flags *options)
-{
- return options->backward_size >= LZMA_BACKWARD_SIZE_MIN
- && options->backward_size <= LZMA_BACKWARD_SIZE_MAX
- && (options->backward_size & 3) == 0;
-}
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/stream_flags_decoder.c r-base-3.3.1/src/extra/xz/common/stream_flags_decoder.c
--- r-base-3.2.3/src/extra/xz/common/stream_flags_decoder.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/stream_flags_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,82 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file stream_flags_decoder.c
-/// \brief Decodes Stream Header and Stream Footer from .xz files
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "stream_flags_common.h"
-
-
-static bool
-stream_flags_decode(lzma_stream_flags *options, const uint8_t *in)
-{
- // Reserved bits must be unset.
- if (in[0] != 0x00 || (in[1] & 0xF0))
- return true;
-
- options->version = 0;
- options->check = in[1] & 0x0F;
-
- return false;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_stream_header_decode(lzma_stream_flags *options, const uint8_t *in)
-{
- // Magic
- if (memcmp(in, lzma_header_magic, sizeof(lzma_header_magic)) != 0)
- return LZMA_FORMAT_ERROR;
-
- // Verify the CRC32 so we can distinguish between corrupt
- // and unsupported files.
- const uint32_t crc = lzma_crc32(in + sizeof(lzma_header_magic),
- LZMA_STREAM_FLAGS_SIZE, 0);
- if (crc != unaligned_read32le(in + sizeof(lzma_header_magic)
- + LZMA_STREAM_FLAGS_SIZE))
- return LZMA_DATA_ERROR;
-
- // Stream Flags
- if (stream_flags_decode(options, in + sizeof(lzma_header_magic)))
- return LZMA_OPTIONS_ERROR;
-
- // Set Backward Size to indicate unknown value. That way
- // lzma_stream_flags_compare() can be used to compare Stream Header
- // and Stream Footer while keeping it useful also for comparing
- // two Stream Footers.
- options->backward_size = LZMA_VLI_UNKNOWN;
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_stream_footer_decode(lzma_stream_flags *options, const uint8_t *in)
-{
- // Magic
- if (memcmp(in + sizeof(uint32_t) * 2 + LZMA_STREAM_FLAGS_SIZE,
- lzma_footer_magic, sizeof(lzma_footer_magic)) != 0)
- return LZMA_FORMAT_ERROR;
-
- // CRC32
- const uint32_t crc = lzma_crc32(in + sizeof(uint32_t),
- sizeof(uint32_t) + LZMA_STREAM_FLAGS_SIZE, 0);
- if (crc != unaligned_read32le(in))
- return LZMA_DATA_ERROR;
-
- // Stream Flags
- if (stream_flags_decode(options, in + sizeof(uint32_t) * 2))
- return LZMA_OPTIONS_ERROR;
-
- // Backward Size
- options->backward_size = unaligned_read32le(in + sizeof(uint32_t));
- options->backward_size = (options->backward_size + 1) * 4;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/stream_flags_encoder.c r-base-3.3.1/src/extra/xz/common/stream_flags_encoder.c
--- r-base-3.2.3/src/extra/xz/common/stream_flags_encoder.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/stream_flags_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,86 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file stream_flags_encoder.c
-/// \brief Encodes Stream Header and Stream Footer for .xz files
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "stream_flags_common.h"
-
-
-static bool
-stream_flags_encode(const lzma_stream_flags *options, uint8_t *out)
-{
- if ((unsigned int)(options->check) > LZMA_CHECK_ID_MAX)
- return true;
-
- out[0] = 0x00;
- out[1] = options->check;
-
- return false;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_stream_header_encode(const lzma_stream_flags *options, uint8_t *out)
-{
- assert(sizeof(lzma_header_magic) + LZMA_STREAM_FLAGS_SIZE
- + 4 == LZMA_STREAM_HEADER_SIZE);
-
- if (options->version != 0)
- return LZMA_OPTIONS_ERROR;
-
- // Magic
- memcpy(out, lzma_header_magic, sizeof(lzma_header_magic));
-
- // Stream Flags
- if (stream_flags_encode(options, out + sizeof(lzma_header_magic)))
- return LZMA_PROG_ERROR;
-
- // CRC32 of the Stream Header
- const uint32_t crc = lzma_crc32(out + sizeof(lzma_header_magic),
- LZMA_STREAM_FLAGS_SIZE, 0);
-
- unaligned_write32le(out + sizeof(lzma_header_magic)
- + LZMA_STREAM_FLAGS_SIZE, crc);
-
- return LZMA_OK;
-}
-
-
-extern LZMA_API(lzma_ret)
-lzma_stream_footer_encode(const lzma_stream_flags *options, uint8_t *out)
-{
- assert(2 * 4 + LZMA_STREAM_FLAGS_SIZE + sizeof(lzma_footer_magic)
- == LZMA_STREAM_HEADER_SIZE);
-
- if (options->version != 0)
- return LZMA_OPTIONS_ERROR;
-
- // Backward Size
- if (!is_backward_size_valid(options))
- return LZMA_PROG_ERROR;
-
- unaligned_write32le(out + 4, options->backward_size / 4 - 1);
-
- // Stream Flags
- if (stream_flags_encode(options, out + 2 * 4))
- return LZMA_PROG_ERROR;
-
- // CRC32
- const uint32_t crc = lzma_crc32(
- out + 4, 4 + LZMA_STREAM_FLAGS_SIZE, 0);
-
- unaligned_write32le(out, crc);
-
- // Magic
- memcpy(out + 2 * 4 + LZMA_STREAM_FLAGS_SIZE,
- lzma_footer_magic, sizeof(lzma_footer_magic));
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/sysdefs.h r-base-3.3.1/src/extra/xz/common/sysdefs.h
--- r-base-3.2.3/src/extra/xz/common/sysdefs.h 2015-03-18 23:02:07.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/sysdefs.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,195 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file sysdefs.h
-/// \brief Common includes, definitions, system-specific things etc.
-///
-/// This file is used also by the lzma command line tool, that's why this
-/// file is separate from common.h.
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_SYSDEFS_H
-#define LZMA_SYSDEFS_H
-
-//////////////
-// Includes //
-//////////////
-
-#ifdef HAVE_CONFIG_H
-# include
-#endif
-
-// R change
-#include "local.h"
-// Get standard-compliant stdio functions under MinGW and MinGW-w64.
-//#ifdef __MINGW32__
-//# define __USE_MINGW_ANSI_STDIO 1
-//#endif
-
-// size_t and NULL
-#include
-
-#ifdef HAVE_INTTYPES_H
-# include
-#endif
-
-// C99 says that inttypes.h always includes stdint.h, but some systems
-// don't do that, and require including stdint.h separately.
-#ifdef HAVE_STDINT_H
-# include
-#endif
-
-// Some pre-C99 systems have SIZE_MAX in limits.h instead of stdint.h. The
-// limits are also used to figure out some macros missing from pre-C99 systems.
-#ifdef HAVE_LIMITS_H
-# include
-#endif
-
-// Be more compatible with systems that have non-conforming inttypes.h.
-// We assume that int is 32-bit and that long is either 32-bit or 64-bit.
-// Full Autoconf test could be more correct, but this should work well enough.
-// Note that this duplicates some code from lzma.h, but this is better since
-// we can work without inttypes.h thanks to Autoconf tests.
-#ifndef UINT32_C
-# if UINT_MAX != 4294967295U
-# error UINT32_C is not defined and unsigned int is not 32-bit.
-# endif
-# define UINT32_C(n) n ## U
-#endif
-#ifndef UINT32_MAX
-# define UINT32_MAX UINT32_C(4294967295)
-#endif
-#ifndef PRIu32
-# define PRIu32 "u"
-#endif
-#ifndef PRIx32
-# define PRIx32 "x"
-#endif
-#ifndef PRIX32
-# define PRIX32 "X"
-#endif
-
-#if ULONG_MAX == 4294967295UL
-# ifndef UINT64_C
-# define UINT64_C(n) n ## ULL
-# endif
-# ifndef PRIu64
-# define PRIu64 "llu"
-# endif
-# ifndef PRIx64
-# define PRIx64 "llx"
-# endif
-# ifndef PRIX64
-# define PRIX64 "llX"
-# endif
-#else
-# ifndef UINT64_C
-# define UINT64_C(n) n ## UL
-# endif
-# ifndef PRIu64
-# define PRIu64 "lu"
-# endif
-# ifndef PRIx64
-# define PRIx64 "lx"
-# endif
-# ifndef PRIX64
-# define PRIX64 "lX"
-# endif
-#endif
-#ifndef UINT64_MAX
-# define UINT64_MAX UINT64_C(18446744073709551615)
-#endif
-
-// Incorrect(?) SIZE_MAX:
-// - Interix headers typedef size_t to unsigned long,
-// but a few lines later define SIZE_MAX to INT32_MAX.
-// - SCO OpenServer (x86) headers typedef size_t to unsigned int
-// but define SIZE_MAX to INT32_MAX.
-#if defined(__INTERIX) || defined(_SCO_DS)
-# undef SIZE_MAX
-#endif
-
-// The code currently assumes that size_t is either 32-bit or 64-bit.
-#ifndef SIZE_MAX
-# if SIZEOF_SIZE_T == 4
-# define SIZE_MAX UINT32_MAX
-# elif SIZEOF_SIZE_T == 8
-# define SIZE_MAX UINT64_MAX
-# else
-# error size_t is not 32-bit or 64-bit
-# endif
-#endif
-#if SIZE_MAX != UINT32_MAX && SIZE_MAX != UINT64_MAX
-# error size_t is not 32-bit or 64-bit
-#endif
-
-#include
-#include
-
-// Pre-C99 systems lack stdbool.h. All the code in LZMA Utils must be written
-// so that it works with fake bool type, for example:
-//
-// bool foo = (flags & 0x100) != 0;
-// bool bar = !!(flags & 0x100);
-//
-// This works with the real C99 bool but breaks with fake bool:
-//
-// bool baz = (flags & 0x100);
-//
-#ifdef HAVE_STDBOOL_H
-# include
-#else
-# if ! HAVE__BOOL
-/* _Bool gave problems on one Solaris system */
-typedef unsigned char _Bool8;
-# endif
-# define bool _Bool8
-# define false 0
-# define true 1
-# define __bool_true_false_are_defined 1
-#endif
-
-// string.h should be enough but let's include strings.h and memory.h too if
-// they exists, since that shouldn't do any harm, but may improve portability.
-#ifdef HAVE_STRING_H
-# include
-#endif
-
-#ifdef HAVE_STRINGS_H
-# include
-#endif
-
-#ifdef HAVE_MEMORY_H
-# include
-#endif
-
-
-////////////
-// Macros //
-////////////
-
-#undef memzero
-#define memzero(s, n) memset(s, 0, n)
-
-// NOTE: Avoid using MIN() and MAX(), because even conditionally defining
-// those macros can cause some portability trouble, since on some systems
-// the system headers insist defining their own versions.
-#define my_min(x, y) ((x) < (y) ? (x) : (y))
-#define my_max(x, y) ((x) > (y) ? (x) : (y))
-
-#ifndef ARRAY_SIZE
-# define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
-#endif
-
-#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
-# define lzma_attr_alloc_size(x) __attribute__((__alloc_size__(x)))
-#else
-# define lzma_attr_alloc_size(x)
-#endif
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/tuklib_common.h r-base-3.3.1/src/extra/xz/common/tuklib_common.h
--- r-base-3.2.3/src/extra/xz/common/tuklib_common.h 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/tuklib_common.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,71 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file tuklib_common.h
-/// \brief Common definitions for tuklib modules
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef TUKLIB_COMMON_H
-#define TUKLIB_COMMON_H
-
-// The config file may be replaced by a package-specific file.
-// It should include at least stddef.h, inttypes.h, and limits.h.
-#include "tuklib_config.h"
-
-// TUKLIB_SYMBOL_PREFIX is prefixed to all symbols exported by
-// the tuklib modules. If you use a tuklib module in a library,
-// you should use TUKLIB_SYMBOL_PREFIX to make sure that there
-// are no symbol conflicts in case someone links your library
-// into application that also uses the same tuklib module.
-#ifndef TUKLIB_SYMBOL_PREFIX
-# define TUKLIB_SYMBOL_PREFIX
-#endif
-
-#define TUKLIB_CAT_X(a, b) a ## b
-#define TUKLIB_CAT(a, b) TUKLIB_CAT_X(a, b)
-
-#ifndef TUKLIB_SYMBOL
-# define TUKLIB_SYMBOL(sym) TUKLIB_CAT(TUKLIB_SYMBOL_PREFIX, sym)
-#endif
-
-#ifndef TUKLIB_DECLS_BEGIN
-# ifdef __cplusplus
-# define TUKLIB_DECLS_BEGIN extern "C" {
-# else
-# define TUKLIB_DECLS_BEGIN
-# endif
-#endif
-
-#ifndef TUKLIB_DECLS_END
-# ifdef __cplusplus
-# define TUKLIB_DECLS_END }
-# else
-# define TUKLIB_DECLS_END
-# endif
-#endif
-
-#if defined(__GNUC__) && defined(__GNUC_MINOR__)
-# define TUKLIB_GNUC_REQ(major, minor) \
- ((__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)) \
- || __GNUC__ > (major))
-#else
-# define TUKLIB_GNUC_REQ(major, minor) 0
-#endif
-
-#if TUKLIB_GNUC_REQ(2, 5)
-# define tuklib_attr_noreturn __attribute__((__noreturn__))
-#else
-# define tuklib_attr_noreturn
-#endif
-
-#if (defined(_WIN32) && !defined(__CYGWIN__)) \
- || defined(__OS2__) || defined(__MSDOS__)
-# define TUKLIB_DOSLIKE 1
-#endif
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/tuklib_config.h r-base-3.3.1/src/extra/xz/common/tuklib_config.h
--- r-base-3.2.3/src/extra/xz/common/tuklib_config.h 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/tuklib_config.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,7 +0,0 @@
-#ifdef HAVE_CONFIG_H
-# include "sysdefs.h"
-#else
-# include
-# include
-# include
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/tuklib_integer.h r-base-3.3.1/src/extra/xz/common/tuklib_integer.h
--- r-base-3.2.3/src/extra/xz/common/tuklib_integer.h 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/tuklib_integer.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,523 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file tuklib_integer.h
-/// \brief Various integer and bit operations
-///
-/// This file provides macros or functions to do some basic integer and bit
-/// operations.
-///
-/// Endianness related integer operations (XX = 16, 32, or 64; Y = b or l):
-/// - Byte swapping: bswapXX(num)
-/// - Byte order conversions to/from native: convXXYe(num)
-/// - Aligned reads: readXXYe(ptr)
-/// - Aligned writes: writeXXYe(ptr, num)
-/// - Unaligned reads (16/32-bit only): unaligned_readXXYe(ptr)
-/// - Unaligned writes (16/32-bit only): unaligned_writeXXYe(ptr, num)
-///
-/// Since they can macros, the arguments should have no side effects since
-/// they may be evaluated more than once.
-///
-/// \todo PowerPC and possibly some other architectures support
-/// byte swapping load and store instructions. This file
-/// doesn't take advantage of those instructions.
-///
-/// Bit scan operations for non-zero 32-bit integers:
-/// - Bit scan reverse (find highest non-zero bit): bsr32(num)
-/// - Count leading zeros: clz32(num)
-/// - Count trailing zeros: ctz32(num)
-/// - Bit scan forward (simply an alias for ctz32()): bsf32(num)
-///
-/// The above bit scan operations return 0-31. If num is zero,
-/// the result is undefined.
-//
-// Authors: Lasse Collin
-// Joachim Henke
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef TUKLIB_INTEGER_H
-#define TUKLIB_INTEGER_H
-
-#include "tuklib_common.h"
-
-
-////////////////////////////////////////
-// Operating system specific features //
-////////////////////////////////////////
-
-#if defined(HAVE_BYTESWAP_H)
- // glibc, uClibc, dietlibc
-# include
-# ifdef HAVE_BSWAP_16
-# define bswap16(num) bswap_16(num)
-# endif
-# ifdef HAVE_BSWAP_32
-# define bswap32(num) bswap_32(num)
-# endif
-# ifdef HAVE_BSWAP_64
-# define bswap64(num) bswap_64(num)
-# endif
-
-#elif defined(HAVE_SYS_ENDIAN_H)
- // *BSDs and Darwin
-# include
-
-#elif defined(HAVE_SYS_BYTEORDER_H)
- // Solaris
-# include
-# ifdef BSWAP_16
-# define bswap16(num) BSWAP_16(num)
-# endif
-# ifdef BSWAP_32
-# define bswap32(num) BSWAP_32(num)
-# endif
-# ifdef BSWAP_64
-# define bswap64(num) BSWAP_64(num)
-# endif
-# ifdef BE_16
-# define conv16be(num) BE_16(num)
-# endif
-# ifdef BE_32
-# define conv32be(num) BE_32(num)
-# endif
-# ifdef BE_64
-# define conv64be(num) BE_64(num)
-# endif
-# ifdef LE_16
-# define conv16le(num) LE_16(num)
-# endif
-# ifdef LE_32
-# define conv32le(num) LE_32(num)
-# endif
-# ifdef LE_64
-# define conv64le(num) LE_64(num)
-# endif
-#endif
-
-
-///////////////////
-// Byte swapping //
-///////////////////
-
-#ifndef bswap16
-# define bswap16(num) \
- (((uint16_t)(num) << 8) | ((uint16_t)(num) >> 8))
-#endif
-
-#ifndef bswap32
-# define bswap32(num) \
- ( (((uint32_t)(num) << 24) ) \
- | (((uint32_t)(num) << 8) & UINT32_C(0x00FF0000)) \
- | (((uint32_t)(num) >> 8) & UINT32_C(0x0000FF00)) \
- | (((uint32_t)(num) >> 24) ) )
-#endif
-
-#ifndef bswap64
-# define bswap64(num) \
- ( (((uint64_t)(num) << 56) ) \
- | (((uint64_t)(num) << 40) & UINT64_C(0x00FF000000000000)) \
- | (((uint64_t)(num) << 24) & UINT64_C(0x0000FF0000000000)) \
- | (((uint64_t)(num) << 8) & UINT64_C(0x000000FF00000000)) \
- | (((uint64_t)(num) >> 8) & UINT64_C(0x00000000FF000000)) \
- | (((uint64_t)(num) >> 24) & UINT64_C(0x0000000000FF0000)) \
- | (((uint64_t)(num) >> 40) & UINT64_C(0x000000000000FF00)) \
- | (((uint64_t)(num) >> 56) ) )
-#endif
-
-// Define conversion macros using the basic byte swapping macros.
-#ifdef WORDS_BIGENDIAN
-# ifndef conv16be
-# define conv16be(num) ((uint16_t)(num))
-# endif
-# ifndef conv32be
-# define conv32be(num) ((uint32_t)(num))
-# endif
-# ifndef conv64be
-# define conv64be(num) ((uint64_t)(num))
-# endif
-# ifndef conv16le
-# define conv16le(num) bswap16(num)
-# endif
-# ifndef conv32le
-# define conv32le(num) bswap32(num)
-# endif
-# ifndef conv64le
-# define conv64le(num) bswap64(num)
-# endif
-#else
-# ifndef conv16be
-# define conv16be(num) bswap16(num)
-# endif
-# ifndef conv32be
-# define conv32be(num) bswap32(num)
-# endif
-# ifndef conv64be
-# define conv64be(num) bswap64(num)
-# endif
-# ifndef conv16le
-# define conv16le(num) ((uint16_t)(num))
-# endif
-# ifndef conv32le
-# define conv32le(num) ((uint32_t)(num))
-# endif
-# ifndef conv64le
-# define conv64le(num) ((uint64_t)(num))
-# endif
-#endif
-
-
-//////////////////////////////
-// Aligned reads and writes //
-//////////////////////////////
-
-static inline uint16_t
-read16be(const uint8_t *buf)
-{
- uint16_t num = *(const uint16_t *)buf;
- return conv16be(num);
-}
-
-
-static inline uint16_t
-read16le(const uint8_t *buf)
-{
- uint16_t num = *(const uint16_t *)buf;
- return conv16le(num);
-}
-
-
-static inline uint32_t
-read32be(const uint8_t *buf)
-{
- uint32_t num = *(const uint32_t *)buf;
- return conv32be(num);
-}
-
-
-static inline uint32_t
-read32le(const uint8_t *buf)
-{
- uint32_t num = *(const uint32_t *)buf;
- return conv32le(num);
-}
-
-
-static inline uint64_t
-read64be(const uint8_t *buf)
-{
- uint64_t num = *(const uint64_t *)buf;
- return conv64be(num);
-}
-
-
-static inline uint64_t
-read64le(const uint8_t *buf)
-{
- uint64_t num = *(const uint64_t *)buf;
- return conv64le(num);
-}
-
-
-// NOTE: Possible byte swapping must be done in a macro to allow GCC
-// to optimize byte swapping of constants when using glibc's or *BSD's
-// byte swapping macros. The actual write is done in an inline function
-// to make type checking of the buf pointer possible similarly to readXXYe()
-// functions.
-
-#define write16be(buf, num) write16ne((buf), conv16be(num))
-#define write16le(buf, num) write16ne((buf), conv16le(num))
-#define write32be(buf, num) write32ne((buf), conv32be(num))
-#define write32le(buf, num) write32ne((buf), conv32le(num))
-#define write64be(buf, num) write64ne((buf), conv64be(num))
-#define write64le(buf, num) write64ne((buf), conv64le(num))
-
-
-static inline void
-write16ne(uint8_t *buf, uint16_t num)
-{
- *(uint16_t *)buf = num;
- return;
-}
-
-
-static inline void
-write32ne(uint8_t *buf, uint32_t num)
-{
- *(uint32_t *)buf = num;
- return;
-}
-
-
-static inline void
-write64ne(uint8_t *buf, uint64_t num)
-{
- *(uint64_t *)buf = num;
- return;
-}
-
-
-////////////////////////////////
-// Unaligned reads and writes //
-////////////////////////////////
-
-// NOTE: TUKLIB_FAST_UNALIGNED_ACCESS indicates only support for 16-bit and
-// 32-bit unaligned integer loads and stores. It's possible that 64-bit
-// unaligned access doesn't work or is slower than byte-by-byte access.
-// Since unaligned 64-bit is probably not needed as often as 16-bit or
-// 32-bit, we simply don't support 64-bit unaligned access for now.
-#ifdef TUKLIB_FAST_UNALIGNED_ACCESS
-# define unaligned_read16be read16be
-# define unaligned_read16le read16le
-# define unaligned_read32be read32be
-# define unaligned_read32le read32le
-# define unaligned_write16be write16be
-# define unaligned_write16le write16le
-# define unaligned_write32be write32be
-# define unaligned_write32le write32le
-
-#else
-
-static inline uint16_t
-unaligned_read16be(const uint8_t *buf)
-{
- uint16_t num = ((uint16_t)buf[0] << 8) | (uint16_t)buf[1];
- return num;
-}
-
-
-static inline uint16_t
-unaligned_read16le(const uint8_t *buf)
-{
- uint16_t num = ((uint16_t)buf[0]) | ((uint16_t)buf[1] << 8);
- return num;
-}
-
-
-static inline uint32_t
-unaligned_read32be(const uint8_t *buf)
-{
- uint32_t num = (uint32_t)buf[0] << 24;
- num |= (uint32_t)buf[1] << 16;
- num |= (uint32_t)buf[2] << 8;
- num |= (uint32_t)buf[3];
- return num;
-}
-
-
-static inline uint32_t
-unaligned_read32le(const uint8_t *buf)
-{
- uint32_t num = (uint32_t)buf[0];
- num |= (uint32_t)buf[1] << 8;
- num |= (uint32_t)buf[2] << 16;
- num |= (uint32_t)buf[3] << 24;
- return num;
-}
-
-
-static inline void
-unaligned_write16be(uint8_t *buf, uint16_t num)
-{
- buf[0] = num >> 8;
- buf[1] = num;
- return;
-}
-
-
-static inline void
-unaligned_write16le(uint8_t *buf, uint16_t num)
-{
- buf[0] = num;
- buf[1] = num >> 8;
- return;
-}
-
-
-static inline void
-unaligned_write32be(uint8_t *buf, uint32_t num)
-{
- buf[0] = num >> 24;
- buf[1] = num >> 16;
- buf[2] = num >> 8;
- buf[3] = num;
- return;
-}
-
-
-static inline void
-unaligned_write32le(uint8_t *buf, uint32_t num)
-{
- buf[0] = num;
- buf[1] = num >> 8;
- buf[2] = num >> 16;
- buf[3] = num >> 24;
- return;
-}
-
-#endif
-
-
-static inline uint32_t
-bsr32(uint32_t n)
-{
- // Check for ICC first, since it tends to define __GNUC__ too.
-#if defined(__INTEL_COMPILER)
- return _bit_scan_reverse(n);
-
-#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX == UINT32_MAX
- // GCC >= 3.4 has __builtin_clz(), which gives good results on
- // multiple architectures. On x86, __builtin_clz() ^ 31U becomes
- // either plain BSR (so the XOR gets optimized away) or LZCNT and
- // XOR (if -march indicates that SSE4a instructions are supported).
- return __builtin_clz(n) ^ 31U;
-
-#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
- uint32_t i;
- __asm__("bsrl %1, %0" : "=r" (i) : "rm" (n));
- return i;
-
-#elif defined(_MSC_VER) && _MSC_VER >= 1400
- // MSVC isn't supported by tuklib, but since this code exists,
- // it doesn't hurt to have it here anyway.
- uint32_t i;
- _BitScanReverse((DWORD *)&i, n);
- return i;
-
-#else
- uint32_t i = 31;
-
- if ((n & UINT32_C(0xFFFF0000)) == 0) {
- n <<= 16;
- i = 15;
- }
-
- if ((n & UINT32_C(0xFF000000)) == 0) {
- n <<= 8;
- i -= 8;
- }
-
- if ((n & UINT32_C(0xF0000000)) == 0) {
- n <<= 4;
- i -= 4;
- }
-
- if ((n & UINT32_C(0xC0000000)) == 0) {
- n <<= 2;
- i -= 2;
- }
-
- if ((n & UINT32_C(0x80000000)) == 0)
- --i;
-
- return i;
-#endif
-}
-
-
-static inline uint32_t
-clz32(uint32_t n)
-{
-#if defined(__INTEL_COMPILER)
- return _bit_scan_reverse(n) ^ 31U;
-
-#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX == UINT32_MAX
- return __builtin_clz(n);
-
-#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
- uint32_t i;
- __asm__("bsrl %1, %0\n\t"
- "xorl $31, %0"
- : "=r" (i) : "rm" (n));
- return i;
-
-#elif defined(_MSC_VER) && _MSC_VER >= 1400
- uint32_t i;
- _BitScanReverse((DWORD *)&i, n);
- return i ^ 31U;
-
-#else
- uint32_t i = 0;
-
- if ((n & UINT32_C(0xFFFF0000)) == 0) {
- n <<= 16;
- i = 16;
- }
-
- if ((n & UINT32_C(0xFF000000)) == 0) {
- n <<= 8;
- i += 8;
- }
-
- if ((n & UINT32_C(0xF0000000)) == 0) {
- n <<= 4;
- i += 4;
- }
-
- if ((n & UINT32_C(0xC0000000)) == 0) {
- n <<= 2;
- i += 2;
- }
-
- if ((n & UINT32_C(0x80000000)) == 0)
- ++i;
-
- return i;
-#endif
-}
-
-
-static inline uint32_t
-ctz32(uint32_t n)
-{
-#if defined(__INTEL_COMPILER)
- return _bit_scan_forward(n);
-
-#elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX >= UINT32_MAX
- return __builtin_ctz(n);
-
-#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
- uint32_t i;
- __asm__("bsfl %1, %0" : "=r" (i) : "rm" (n));
- return i;
-
-#elif defined(_MSC_VER) && _MSC_VER >= 1400
- uint32_t i;
- _BitScanForward((DWORD *)&i, n);
- return i;
-
-#else
- uint32_t i = 0;
-
- if ((n & UINT32_C(0x0000FFFF)) == 0) {
- n >>= 16;
- i = 16;
- }
-
- if ((n & UINT32_C(0x000000FF)) == 0) {
- n >>= 8;
- i += 8;
- }
-
- if ((n & UINT32_C(0x0000000F)) == 0) {
- n >>= 4;
- i += 4;
- }
-
- if ((n & UINT32_C(0x00000003)) == 0) {
- n >>= 2;
- i += 2;
- }
-
- if ((n & UINT32_C(0x00000001)) == 0)
- ++i;
-
- return i;
-#endif
-}
-
-#define bsf32 ctz32
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/common/vli_decoder.c r-base-3.3.1/src/extra/xz/common/vli_decoder.c
--- r-base-3.2.3/src/extra/xz/common/vli_decoder.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/vli_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,86 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file vli_decoder.c
-/// \brief Decodes variable-length integers
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_vli_decode(lzma_vli *restrict vli, size_t *vli_pos,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size)
-{
- // If we haven't been given vli_pos, work in single-call mode.
- size_t vli_pos_internal = 0;
- if (vli_pos == NULL) {
- vli_pos = &vli_pos_internal;
- *vli = 0;
-
- // If there's no input, use LZMA_DATA_ERROR. This way it is
- // easy to decode VLIs from buffers that have known size,
- // and get the correct error code in case the buffer is
- // too short.
- if (*in_pos >= in_size)
- return LZMA_DATA_ERROR;
-
- } else {
- // Initialize *vli when starting to decode a new integer.
- if (*vli_pos == 0)
- *vli = 0;
-
- // Validate the arguments.
- if (*vli_pos >= LZMA_VLI_BYTES_MAX
- || (*vli >> (*vli_pos * 7)) != 0)
- return LZMA_PROG_ERROR;;
-
- if (*in_pos >= in_size)
- return LZMA_BUF_ERROR;
- }
-
- do {
- // Read the next byte. Use a temporary variable so that we
- // can update *in_pos immediately.
- const uint8_t byte = in[*in_pos];
- ++*in_pos;
-
- // Add the newly read byte to *vli.
- *vli += (lzma_vli)(byte & 0x7F) << (*vli_pos * 7);
- ++*vli_pos;
-
- // Check if this is the last byte of a multibyte integer.
- if ((byte & 0x80) == 0) {
- // We don't allow using variable-length integers as
- // padding i.e. the encoding must use the most the
- // compact form.
- if (byte == 0x00 && *vli_pos > 1)
- return LZMA_DATA_ERROR;
-
- return vli_pos == &vli_pos_internal
- ? LZMA_OK : LZMA_STREAM_END;
- }
-
- // There is at least one more byte coming. If we have already
- // read maximum number of bytes, the integer is considered
- // corrupt.
- //
- // If we need bigger integers in future, old versions liblzma
- // will confusingly indicate the file being corrupt istead of
- // unsupported. I suppose it's still better this way, because
- // in the foreseeable future (writing this in 2008) the only
- // reason why files would appear having over 63-bit integers
- // is that the files are simply corrupt.
- if (*vli_pos == LZMA_VLI_BYTES_MAX)
- return LZMA_DATA_ERROR;
-
- } while (*in_pos < in_size);
-
- return vli_pos == &vli_pos_internal ? LZMA_DATA_ERROR : LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/vli_encoder.c r-base-3.3.1/src/extra/xz/common/vli_encoder.c
--- r-base-3.2.3/src/extra/xz/common/vli_encoder.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/vli_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,69 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file vli_encoder.c
-/// \brief Encodes variable-length integers
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-
-
-extern LZMA_API(lzma_ret)
-lzma_vli_encode(lzma_vli vli, size_t *vli_pos,
- uint8_t *restrict out, size_t *restrict out_pos,
- size_t out_size)
-{
- // If we haven't been given vli_pos, work in single-call mode.
- size_t vli_pos_internal = 0;
- if (vli_pos == NULL) {
- vli_pos = &vli_pos_internal;
-
- // In single-call mode, we expect that the caller has
- // reserved enough output space.
- if (*out_pos >= out_size)
- return LZMA_PROG_ERROR;
- } else {
- // This never happens when we are called by liblzma, but
- // may happen if called directly from an application.
- if (*out_pos >= out_size)
- return LZMA_BUF_ERROR;
- }
-
- // Validate the arguments.
- if (*vli_pos >= LZMA_VLI_BYTES_MAX || vli > LZMA_VLI_MAX)
- return LZMA_PROG_ERROR;
-
- // Shift vli so that the next bits to encode are the lowest. In
- // single-call mode this never changes vli since *vli_pos is zero.
- vli >>= *vli_pos * 7;
-
- // Write the non-last bytes in a loop.
- while (vli >= 0x80) {
- // We don't need *vli_pos during this function call anymore,
- // but update it here so that it is ready if we need to
- // return before the whole integer has been decoded.
- ++*vli_pos;
- assert(*vli_pos < LZMA_VLI_BYTES_MAX);
-
- // Write the next byte.
- out[*out_pos] = (uint8_t)(vli) | 0x80;
- vli >>= 7;
-
- if (++*out_pos == out_size)
- return vli_pos == &vli_pos_internal
- ? LZMA_PROG_ERROR : LZMA_OK;
- }
-
- // Write the last byte.
- out[*out_pos] = (uint8_t)(vli);
- ++*out_pos;
- ++*vli_pos;
-
- return vli_pos == &vli_pos_internal ? LZMA_OK : LZMA_STREAM_END;
-
-}
diff -Nru r-base-3.2.3/src/extra/xz/common/vli_size.c r-base-3.3.1/src/extra/xz/common/vli_size.c
--- r-base-3.2.3/src/extra/xz/common/vli_size.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/common/vli_size.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,30 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file vli_size.c
-/// \brief Calculates the encoded size of a variable-length integer
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-
-
-extern LZMA_API(uint32_t)
-lzma_vli_size(lzma_vli vli)
-{
- if (vli > LZMA_VLI_MAX)
- return 0;
-
- uint32_t i = 0;
- do {
- vli >>= 7;
- ++i;
- } while (vli != 0);
-
- assert(i <= LZMA_VLI_BYTES_MAX);
- return i;
-}
diff -Nru r-base-3.2.3/src/extra/xz/delta/delta_common.c r-base-3.3.1/src/extra/xz/delta/delta_common.c
--- r-base-3.2.3/src/extra/xz/delta/delta_common.c 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/delta/delta_common.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,70 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file delta_common.c
-/// \brief Common stuff for Delta encoder and decoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "delta_common.h"
-#include "delta_private.h"
-
-
-static void
-delta_coder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->next, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-extern lzma_ret
-lzma_delta_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- // Allocate memory for the decoder if needed.
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- // End function is the same for encoder and decoder.
- next->end = &delta_coder_end;
- next->coder->next = LZMA_NEXT_CODER_INIT;
- }
-
- // Validate the options.
- if (lzma_delta_coder_memusage(filters[0].options) == UINT64_MAX)
- return LZMA_OPTIONS_ERROR;
-
- // Set the delta distance.
- const lzma_options_delta *opt = filters[0].options;
- next->coder->distance = opt->dist;
-
- // Initialize the rest of the variables.
- next->coder->pos = 0;
- memzero(next->coder->history, LZMA_DELTA_DIST_MAX);
-
- // Initialize the next decoder in the chain, if any.
- return lzma_next_filter_init(&next->coder->next,
- allocator, filters + 1);
-}
-
-
-extern uint64_t
-lzma_delta_coder_memusage(const void *options)
-{
- const lzma_options_delta *opt = options;
-
- if (opt == NULL || opt->type != LZMA_DELTA_TYPE_BYTE
- || opt->dist < LZMA_DELTA_DIST_MIN
- || opt->dist > LZMA_DELTA_DIST_MAX)
- return UINT64_MAX;
-
- return sizeof(lzma_coder);
-}
diff -Nru r-base-3.2.3/src/extra/xz/delta/delta_common.h r-base-3.3.1/src/extra/xz/delta/delta_common.h
--- r-base-3.2.3/src/extra/xz/delta/delta_common.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/delta/delta_common.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,20 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file delta_common.h
-/// \brief Common stuff for Delta encoder and decoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_DELTA_COMMON_H
-#define LZMA_DELTA_COMMON_H
-
-#include "common.h"
-
-extern uint64_t lzma_delta_coder_memusage(const void *options);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/delta/delta_decoder.c r-base-3.3.1/src/extra/xz/delta/delta_decoder.c
--- r-base-3.2.3/src/extra/xz/delta/delta_decoder.c 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/delta/delta_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,76 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file delta_decoder.c
-/// \brief Delta filter decoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "delta_decoder.h"
-#include "delta_private.h"
-
-
-static void
-decode_buffer(lzma_coder *coder, uint8_t *buffer, size_t size)
-{
- const size_t distance = coder->distance;
-
- for (size_t i = 0; i < size; ++i) {
- buffer[i] += coder->history[(distance + coder->pos) & 0xFF];
- coder->history[coder->pos-- & 0xFF] = buffer[i];
- }
-}
-
-
-static lzma_ret
-delta_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- assert(coder->next.code != NULL);
-
- const size_t out_start = *out_pos;
-
- const lzma_ret ret = coder->next.code(coder->next.coder, allocator,
- in, in_pos, in_size, out, out_pos, out_size,
- action);
-
- decode_buffer(coder, out + out_start, *out_pos - out_start);
-
- return ret;
-}
-
-
-extern lzma_ret
-lzma_delta_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- next->code = &delta_decode;
- return lzma_delta_coder_init(next, allocator, filters);
-}
-
-
-extern lzma_ret
-lzma_delta_props_decode(void **options, lzma_allocator *allocator,
- const uint8_t *props, size_t props_size)
-{
- if (props_size != 1)
- return LZMA_OPTIONS_ERROR;
-
- lzma_options_delta *opt
- = lzma_alloc(sizeof(lzma_options_delta), allocator);
- if (opt == NULL)
- return LZMA_MEM_ERROR;
-
- opt->type = LZMA_DELTA_TYPE_BYTE;
- opt->dist = props[0] + 1;
-
- *options = opt;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/delta/delta_decoder.h r-base-3.3.1/src/extra/xz/delta/delta_decoder.h
--- r-base-3.2.3/src/extra/xz/delta/delta_decoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/delta/delta_decoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,25 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file delta_decoder.h
-/// \brief Delta filter decoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_DELTA_DECODER_H
-#define LZMA_DELTA_DECODER_H
-
-#include "delta_common.h"
-
-extern lzma_ret lzma_delta_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-extern lzma_ret lzma_delta_props_decode(
- void **options, lzma_allocator *allocator,
- const uint8_t *props, size_t props_size);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/delta/delta_encoder.c r-base-3.3.1/src/extra/xz/delta/delta_encoder.c
--- r-base-3.2.3/src/extra/xz/delta/delta_encoder.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/delta/delta_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,121 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file delta_encoder.c
-/// \brief Delta filter encoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "delta_encoder.h"
-#include "delta_private.h"
-
-
-/// Copies and encodes the data at the same time. This is used when Delta
-/// is the first filter in the chain (and thus the last filter in the
-/// encoder's filter stack).
-static void
-copy_and_encode(lzma_coder *coder,
- const uint8_t *restrict in, uint8_t *restrict out, size_t size)
-{
- const size_t distance = coder->distance;
-
- for (size_t i = 0; i < size; ++i) {
- const uint8_t tmp = coder->history[
- (distance + coder->pos) & 0xFF];
- coder->history[coder->pos-- & 0xFF] = in[i];
- out[i] = in[i] - tmp;
- }
-}
-
-
-/// Encodes the data in place. This is used when we are the last filter
-/// in the chain (and thus non-last filter in the encoder's filter stack).
-static void
-encode_in_place(lzma_coder *coder, uint8_t *buffer, size_t size)
-{
- const size_t distance = coder->distance;
-
- for (size_t i = 0; i < size; ++i) {
- const uint8_t tmp = coder->history[
- (distance + coder->pos) & 0xFF];
- coder->history[coder->pos-- & 0xFF] = buffer[i];
- buffer[i] -= tmp;
- }
-}
-
-
-static lzma_ret
-delta_encode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- lzma_ret ret;
-
- if (coder->next.code == NULL) {
- const size_t in_avail = in_size - *in_pos;
- const size_t out_avail = out_size - *out_pos;
- const size_t size = my_min(in_avail, out_avail);
-
- copy_and_encode(coder, in + *in_pos, out + *out_pos, size);
-
- *in_pos += size;
- *out_pos += size;
-
- ret = action != LZMA_RUN && *in_pos == in_size
- ? LZMA_STREAM_END : LZMA_OK;
-
- } else {
- const size_t out_start = *out_pos;
-
- ret = coder->next.code(coder->next.coder, allocator,
- in, in_pos, in_size, out, out_pos, out_size,
- action);
-
- encode_in_place(coder, out + out_start, *out_pos - out_start);
- }
-
- return ret;
-}
-
-
-static lzma_ret
-delta_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
- const lzma_filter *filters_null lzma_attribute((__unused__)),
- const lzma_filter *reversed_filters)
-{
- // Delta doesn't and will never support changing the options in
- // the middle of encoding. If the app tries to change them, we
- // simply ignore them.
- return lzma_next_filter_update(
- &coder->next, allocator, reversed_filters + 1);
-}
-
-
-extern lzma_ret
-lzma_delta_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- next->code = &delta_encode;
- next->update = &delta_encoder_update;
- return lzma_delta_coder_init(next, allocator, filters);
-}
-
-
-extern lzma_ret
-lzma_delta_props_encode(const void *options, uint8_t *out)
-{
- // The caller must have already validated the options, so it's
- // LZMA_PROG_ERROR if they are invalid.
- if (lzma_delta_coder_memusage(options) == UINT64_MAX)
- return LZMA_PROG_ERROR;
-
- const lzma_options_delta *opt = options;
- out[0] = opt->dist - LZMA_DELTA_DIST_MIN;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/delta/delta_encoder.h r-base-3.3.1/src/extra/xz/delta/delta_encoder.h
--- r-base-3.2.3/src/extra/xz/delta/delta_encoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/delta/delta_encoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file delta_encoder.h
-/// \brief Delta filter encoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_DELTA_ENCODER_H
-#define LZMA_DELTA_ENCODER_H
-
-#include "delta_common.h"
-
-extern lzma_ret lzma_delta_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-extern lzma_ret lzma_delta_props_encode(const void *options, uint8_t *out);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/delta/delta_private.h r-base-3.3.1/src/extra/xz/delta/delta_private.h
--- r-base-3.2.3/src/extra/xz/delta/delta_private.h 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/delta/delta_private.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,37 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file delta_private.h
-/// \brief Private common stuff for Delta encoder and decoder
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_DELTA_PRIVATE_H
-#define LZMA_DELTA_PRIVATE_H
-
-#include "delta_common.h"
-
-struct lzma_coder_s {
- /// Next coder in the chain
- lzma_next_coder next;
-
- /// Delta distance
- size_t distance;
-
- /// Position in history[]
- uint8_t pos;
-
- /// Buffer to hold history of the original data
- uint8_t history[LZMA_DELTA_DIST_MAX];
-};
-
-
-extern lzma_ret lzma_delta_coder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/lz/lz_decoder.c r-base-3.3.1/src/extra/xz/lz/lz_decoder.c
--- r-base-3.2.3/src/extra/xz/lz/lz_decoder.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lz/lz_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,300 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lz_decoder.c
-/// \brief LZ out window
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-// liblzma supports multiple LZ77-based filters. The LZ part is shared
-// between these filters. The LZ code takes care of dictionary handling
-// and passing the data between filters in the chain. The filter-specific
-// part decodes from the input buffer to the dictionary.
-
-
-#include "lz_decoder.h"
-
-
-struct lzma_coder_s {
- /// Dictionary (history buffer)
- lzma_dict dict;
-
- /// The actual LZ-based decoder e.g. LZMA
- lzma_lz_decoder lz;
-
- /// Next filter in the chain, if any. Note that LZMA and LZMA2 are
- /// only allowed as the last filter, but the long-range filter in
- /// future can be in the middle of the chain.
- lzma_next_coder next;
-
- /// True if the next filter in the chain has returned LZMA_STREAM_END.
- bool next_finished;
-
- /// True if the LZ decoder (e.g. LZMA) has detected end of payload
- /// marker. This may become true before next_finished becomes true.
- bool this_finished;
-
- /// Temporary buffer needed when the LZ-based filter is not the last
- /// filter in the chain. The output of the next filter is first
- /// decoded into buffer[], which is then used as input for the actual
- /// LZ-based decoder.
- struct {
- size_t pos;
- size_t size;
- uint8_t buffer[LZMA_BUFFER_SIZE];
- } temp;
-};
-
-
-static void
-lz_decoder_reset(lzma_coder *coder)
-{
- coder->dict.pos = 0;
- coder->dict.full = 0;
- coder->dict.buf[coder->dict.size - 1] = '\0';
- coder->dict.need_reset = false;
- return;
-}
-
-
-static lzma_ret
-decode_buffer(lzma_coder *coder,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size)
-{
- while (true) {
- // Wrap the dictionary if needed.
- if (coder->dict.pos == coder->dict.size)
- coder->dict.pos = 0;
-
- // Store the current dictionary position. It is needed to know
- // where to start copying to the out[] buffer.
- const size_t dict_start = coder->dict.pos;
-
- // Calculate how much we allow coder->lz.code() to decode.
- // It must not decode past the end of the dictionary
- // buffer, and we don't want it to decode more than is
- // actually needed to fill the out[] buffer.
- coder->dict.limit = coder->dict.pos
- + my_min(out_size - *out_pos,
- coder->dict.size - coder->dict.pos);
-
- // Call the coder->lz.code() to do the actual decoding.
- const lzma_ret ret = coder->lz.code(
- coder->lz.coder, &coder->dict,
- in, in_pos, in_size);
-
- // Copy the decoded data from the dictionary to the out[]
- // buffer.
- const size_t copy_size = coder->dict.pos - dict_start;
- assert(copy_size <= out_size - *out_pos);
- memcpy(out + *out_pos, coder->dict.buf + dict_start,
- copy_size);
- *out_pos += copy_size;
-
- // Reset the dictionary if so requested by coder->lz.code().
- if (coder->dict.need_reset) {
- lz_decoder_reset(coder);
-
- // Since we reset dictionary, we don't check if
- // dictionary became full.
- if (ret != LZMA_OK || *out_pos == out_size)
- return ret;
- } else {
- // Return if everything got decoded or an error
- // occurred, or if there's no more data to decode.
- //
- // Note that detecting if there's something to decode
- // is done by looking if dictionary become full
- // instead of looking if *in_pos == in_size. This
- // is because it is possible that all the input was
- // consumed already but some data is pending to be
- // written to the dictionary.
- if (ret != LZMA_OK || *out_pos == out_size
- || coder->dict.pos < coder->dict.size)
- return ret;
- }
- }
-}
-
-
-static lzma_ret
-lz_decode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((__unused__)),
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size,
- lzma_action action)
-{
- if (coder->next.code == NULL)
- return decode_buffer(coder, in, in_pos, in_size,
- out, out_pos, out_size);
-
- // We aren't the last coder in the chain, we need to decode
- // our input to a temporary buffer.
- while (*out_pos < out_size) {
- // Fill the temporary buffer if it is empty.
- if (!coder->next_finished
- && coder->temp.pos == coder->temp.size) {
- coder->temp.pos = 0;
- coder->temp.size = 0;
-
- const lzma_ret ret = coder->next.code(
- coder->next.coder,
- allocator, in, in_pos, in_size,
- coder->temp.buffer, &coder->temp.size,
- LZMA_BUFFER_SIZE, action);
-
- if (ret == LZMA_STREAM_END)
- coder->next_finished = true;
- else if (ret != LZMA_OK || coder->temp.size == 0)
- return ret;
- }
-
- if (coder->this_finished) {
- if (coder->temp.size != 0)
- return LZMA_DATA_ERROR;
-
- if (coder->next_finished)
- return LZMA_STREAM_END;
-
- return LZMA_OK;
- }
-
- const lzma_ret ret = decode_buffer(coder, coder->temp.buffer,
- &coder->temp.pos, coder->temp.size,
- out, out_pos, out_size);
-
- if (ret == LZMA_STREAM_END)
- coder->this_finished = true;
- else if (ret != LZMA_OK)
- return ret;
- else if (coder->next_finished && *out_pos < out_size)
- return LZMA_DATA_ERROR;
- }
-
- return LZMA_OK;
-}
-
-
-static void
-lz_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->next, allocator);
- lzma_free(coder->dict.buf, allocator);
-
- if (coder->lz.end != NULL)
- coder->lz.end(coder->lz.coder, allocator);
- else
- lzma_free(coder->lz.coder, allocator);
-
- lzma_free(coder, allocator);
- return;
-}
-
-
-extern lzma_ret
-lzma_lz_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters,
- lzma_ret (*lz_init)(lzma_lz_decoder *lz,
- lzma_allocator *allocator, const void *options,
- lzma_lz_options *lz_options))
-{
- // Allocate the base structure if it isn't already allocated.
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &lz_decode;
- next->end = &lz_decoder_end;
-
- next->coder->dict.buf = NULL;
- next->coder->dict.size = 0;
- next->coder->lz = LZMA_LZ_DECODER_INIT;
- next->coder->next = LZMA_NEXT_CODER_INIT;
- }
-
- // Allocate and initialize the LZ-based decoder. It will also give
- // us the dictionary size.
- lzma_lz_options lz_options;
- return_if_error(lz_init(&next->coder->lz, allocator,
- filters[0].options, &lz_options));
-
- // If the dictionary size is very small, increase it to 4096 bytes.
- // This is to prevent constant wrapping of the dictionary, which
- // would slow things down. The downside is that since we don't check
- // separately for the real dictionary size, we may happily accept
- // corrupt files.
- if (lz_options.dict_size < 4096)
- lz_options.dict_size = 4096;
-
- // Make dictionary size a multipe of 16. Some LZ-based decoders like
- // LZMA use the lowest bits lzma_dict.pos to know the alignment of the
- // data. Aligned buffer is also good when memcpying from the
- // dictionary to the output buffer, since applications are
- // recommended to give aligned buffers to liblzma.
- //
- // Avoid integer overflow.
- if (lz_options.dict_size > SIZE_MAX - 15)
- return LZMA_MEM_ERROR;
-
- lz_options.dict_size = (lz_options.dict_size + 15) & ~((size_t)(15));
-
- // Allocate and initialize the dictionary.
- if (next->coder->dict.size != lz_options.dict_size) {
- lzma_free(next->coder->dict.buf, allocator);
- next->coder->dict.buf
- = lzma_alloc(lz_options.dict_size, allocator);
- if (next->coder->dict.buf == NULL)
- return LZMA_MEM_ERROR;
-
- next->coder->dict.size = lz_options.dict_size;
- }
-
- lz_decoder_reset(next->coder);
-
- // Use the preset dictionary if it was given to us.
- if (lz_options.preset_dict != NULL
- && lz_options.preset_dict_size > 0) {
- // If the preset dictionary is bigger than the actual
- // dictionary, copy only the tail.
- const size_t copy_size = my_min(lz_options.preset_dict_size,
- lz_options.dict_size);
- const size_t offset = lz_options.preset_dict_size - copy_size;
- memcpy(next->coder->dict.buf, lz_options.preset_dict + offset,
- copy_size);
- next->coder->dict.pos = copy_size;
- next->coder->dict.full = copy_size;
- }
-
- // Miscellaneous initializations
- next->coder->next_finished = false;
- next->coder->this_finished = false;
- next->coder->temp.pos = 0;
- next->coder->temp.size = 0;
-
- // Initialize the next filter in the chain, if any.
- return lzma_next_filter_init(&next->coder->next, allocator,
- filters + 1);
-}
-
-
-extern uint64_t
-lzma_lz_decoder_memusage(size_t dictionary_size)
-{
- return sizeof(lzma_coder) + (uint64_t)(dictionary_size);
-}
-
-
-extern void
-lzma_lz_decoder_uncompressed(lzma_coder *coder, lzma_vli uncompressed_size)
-{
- coder->lz.set_uncompressed(coder->lz.coder, uncompressed_size);
-}
diff -Nru r-base-3.2.3/src/extra/xz/lz/lz_decoder.h r-base-3.3.1/src/extra/xz/lz/lz_decoder.h
--- r-base-3.2.3/src/extra/xz/lz/lz_decoder.h 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lz/lz_decoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,234 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lz_decoder.h
-/// \brief LZ out window
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_LZ_DECODER_H
-#define LZMA_LZ_DECODER_H
-
-#include "common.h"
-
-
-typedef struct {
- /// Pointer to the dictionary buffer. It can be an allocated buffer
- /// internal to liblzma, or it can a be a buffer given by the
- /// application when in single-call mode (not implemented yet).
- uint8_t *buf;
-
- /// Write position in dictionary. The next byte will be written to
- /// buf[pos].
- size_t pos;
-
- /// Indicates how full the dictionary is. This is used by
- /// dict_is_distance_valid() to detect corrupt files that would
- /// read beyond the beginning of the dictionary.
- size_t full;
-
- /// Write limit
- size_t limit;
-
- /// Size of the dictionary
- size_t size;
-
- /// True when dictionary should be reset before decoding more data.
- bool need_reset;
-
-} lzma_dict;
-
-
-typedef struct {
- size_t dict_size;
- const uint8_t *preset_dict;
- size_t preset_dict_size;
-} lzma_lz_options;
-
-
-typedef struct {
- /// Data specific to the LZ-based decoder
- lzma_coder *coder;
-
- /// Function to decode from in[] to *dict
- lzma_ret (*code)(lzma_coder *restrict coder,
- lzma_dict *restrict dict, const uint8_t *restrict in,
- size_t *restrict in_pos, size_t in_size);
-
- void (*reset)(lzma_coder *coder, const void *options);
-
- /// Set the uncompressed size
- void (*set_uncompressed)(lzma_coder *coder,
- lzma_vli uncompressed_size);
-
- /// Free allocated resources
- void (*end)(lzma_coder *coder, lzma_allocator *allocator);
-
-} lzma_lz_decoder;
-
-
-#define LZMA_LZ_DECODER_INIT \
- (lzma_lz_decoder){ \
- .coder = NULL, \
- .code = NULL, \
- .reset = NULL, \
- .set_uncompressed = NULL, \
- .end = NULL, \
- }
-
-
-extern lzma_ret lzma_lz_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters,
- lzma_ret (*lz_init)(lzma_lz_decoder *lz,
- lzma_allocator *allocator, const void *options,
- lzma_lz_options *lz_options));
-
-extern uint64_t lzma_lz_decoder_memusage(size_t dictionary_size);
-
-extern void lzma_lz_decoder_uncompressed(
- lzma_coder *coder, lzma_vli uncompressed_size);
-
-
-//////////////////////
-// Inline functions //
-//////////////////////
-
-/// Get a byte from the history buffer.
-static inline uint8_t
-dict_get(const lzma_dict *const dict, const uint32_t distance)
-{
- return dict->buf[dict->pos - distance - 1
- + (distance < dict->pos ? 0 : dict->size)];
-}
-
-
-/// Test if dictionary is empty.
-static inline bool
-dict_is_empty(const lzma_dict *const dict)
-{
- return dict->full == 0;
-}
-
-
-/// Validate the match distance
-static inline bool
-dict_is_distance_valid(const lzma_dict *const dict, const size_t distance)
-{
- return dict->full > distance;
-}
-
-
-/// Repeat *len bytes at distance.
-static inline bool
-dict_repeat(lzma_dict *dict, uint32_t distance, uint32_t *len)
-{
- // Don't write past the end of the dictionary.
- const size_t dict_avail = dict->limit - dict->pos;
- uint32_t left = my_min(dict_avail, *len);
- *len -= left;
-
- // Repeat a block of data from the history. Because memcpy() is faster
- // than copying byte by byte in a loop, the copying process gets split
- // into three cases.
- if (distance < left) {
- // Source and target areas overlap, thus we can't use
- // memcpy() nor even memmove() safely.
- do {
- dict->buf[dict->pos] = dict_get(dict, distance);
- ++dict->pos;
- } while (--left > 0);
-
- } else if (distance < dict->pos) {
- // The easiest and fastest case
- memcpy(dict->buf + dict->pos,
- dict->buf + dict->pos - distance - 1,
- left);
- dict->pos += left;
-
- } else {
- // The bigger the dictionary, the more rare this
- // case occurs. We need to "wrap" the dict, thus
- // we might need two memcpy() to copy all the data.
- assert(dict->full == dict->size);
- const uint32_t copy_pos
- = dict->pos - distance - 1 + dict->size;
- uint32_t copy_size = dict->size - copy_pos;
-
- if (copy_size < left) {
- memmove(dict->buf + dict->pos, dict->buf + copy_pos,
- copy_size);
- dict->pos += copy_size;
- copy_size = left - copy_size;
- memcpy(dict->buf + dict->pos, dict->buf, copy_size);
- dict->pos += copy_size;
- } else {
- memmove(dict->buf + dict->pos, dict->buf + copy_pos,
- left);
- dict->pos += left;
- }
- }
-
- // Update how full the dictionary is.
- if (dict->full < dict->pos)
- dict->full = dict->pos;
-
- return unlikely(*len != 0);
-}
-
-
-/// Puts one byte into the dictionary. Returns true if the dictionary was
-/// already full and the byte couldn't be added.
-static inline bool
-dict_put(lzma_dict *dict, uint8_t byte)
-{
- if (unlikely(dict->pos == dict->limit))
- return true;
-
- dict->buf[dict->pos++] = byte;
-
- if (dict->pos > dict->full)
- dict->full = dict->pos;
-
- return false;
-}
-
-
-/// Copies arbitrary amount of data into the dictionary.
-static inline void
-dict_write(lzma_dict *restrict dict, const uint8_t *restrict in,
- size_t *restrict in_pos, size_t in_size,
- size_t *restrict left)
-{
- // NOTE: If we are being given more data than the size of the
- // dictionary, it could be possible to optimize the LZ decoder
- // so that not everything needs to go through the dictionary.
- // This shouldn't be very common thing in practice though, and
- // the slowdown of one extra memcpy() isn't bad compared to how
- // much time it would have taken if the data were compressed.
-
- if (in_size - *in_pos > *left)
- in_size = *in_pos + *left;
-
- *left -= lzma_bufcpy(in, in_pos, in_size,
- dict->buf, &dict->pos, dict->limit);
-
- if (dict->pos > dict->full)
- dict->full = dict->pos;
-
- return;
-}
-
-
-static inline void
-dict_reset(lzma_dict *dict)
-{
- dict->need_reset = true;
- return;
-}
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/lz/lz_encoder.c r-base-3.3.1/src/extra/xz/lz/lz_encoder.c
--- r-base-3.2.3/src/extra/xz/lz/lz_encoder.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lz/lz_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,583 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lz_encoder.c
-/// \brief LZ in window
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "lz_encoder.h"
-#include "lz_encoder_hash.h"
-
-// See lz_encoder_hash.h. This is a bit hackish but avoids making
-// endianness a conditional in makefiles.
-#if defined(WORDS_BIGENDIAN) && !defined(HAVE_SMALL)
-# include "lz_encoder_hash_table.h"
-#endif
-
-
-struct lzma_coder_s {
- /// LZ-based encoder e.g. LZMA
- lzma_lz_encoder lz;
-
- /// History buffer and match finder
- lzma_mf mf;
-
- /// Next coder in the chain
- lzma_next_coder next;
-};
-
-
-/// \brief Moves the data in the input window to free space for new data
-///
-/// mf->buffer is a sliding input window, which keeps mf->keep_size_before
-/// bytes of input history available all the time. Now and then we need to
-/// "slide" the buffer to make space for the new data to the end of the
-/// buffer. At the same time, data older than keep_size_before is dropped.
-///
-static void
-move_window(lzma_mf *mf)
-{
- // Align the move to a multiple of 16 bytes. Some LZ-based encoders
- // like LZMA use the lowest bits of mf->read_pos to know the
- // alignment of the uncompressed data. We also get better speed
- // for memmove() with aligned buffers.
- assert(mf->read_pos > mf->keep_size_before);
- const uint32_t move_offset
- = (mf->read_pos - mf->keep_size_before) & ~UINT32_C(15);
-
- assert(mf->write_pos > move_offset);
- const size_t move_size = mf->write_pos - move_offset;
-
- assert(move_offset + move_size <= mf->size);
-
- memmove(mf->buffer, mf->buffer + move_offset, move_size);
-
- mf->offset += move_offset;
- mf->read_pos -= move_offset;
- mf->read_limit -= move_offset;
- mf->write_pos -= move_offset;
-
- return;
-}
-
-
-/// \brief Tries to fill the input window (mf->buffer)
-///
-/// If we are the last encoder in the chain, our input data is in in[].
-/// Otherwise we call the next filter in the chain to process in[] and
-/// write its output to mf->buffer.
-///
-/// This function must not be called once it has returned LZMA_STREAM_END.
-///
-static lzma_ret
-fill_window(lzma_coder *coder, lzma_allocator *allocator, const uint8_t *in,
- size_t *in_pos, size_t in_size, lzma_action action)
-{
- assert(coder->mf.read_pos <= coder->mf.write_pos);
-
- // Move the sliding window if needed.
- if (coder->mf.read_pos >= coder->mf.size - coder->mf.keep_size_after)
- move_window(&coder->mf);
-
- // Maybe this is ugly, but lzma_mf uses uint32_t for most things
- // (which I find cleanest), but we need size_t here when filling
- // the history window.
- size_t write_pos = coder->mf.write_pos;
- lzma_ret ret;
- if (coder->next.code == NULL) {
- // Not using a filter, simply memcpy() as much as possible.
- lzma_bufcpy(in, in_pos, in_size, coder->mf.buffer,
- &write_pos, coder->mf.size);
-
- ret = action != LZMA_RUN && *in_pos == in_size
- ? LZMA_STREAM_END : LZMA_OK;
-
- } else {
- ret = coder->next.code(coder->next.coder, allocator,
- in, in_pos, in_size,
- coder->mf.buffer, &write_pos,
- coder->mf.size, action);
- }
-
- coder->mf.write_pos = write_pos;
-
- // If end of stream has been reached or flushing completed, we allow
- // the encoder to process all the input (that is, read_pos is allowed
- // to reach write_pos). Otherwise we keep keep_size_after bytes
- // available as prebuffer.
- if (ret == LZMA_STREAM_END) {
- assert(*in_pos == in_size);
- ret = LZMA_OK;
- coder->mf.action = action;
- coder->mf.read_limit = coder->mf.write_pos;
-
- } else if (coder->mf.write_pos > coder->mf.keep_size_after) {
- // This needs to be done conditionally, because if we got
- // only little new input, there may be too little input
- // to do any encoding yet.
- coder->mf.read_limit = coder->mf.write_pos
- - coder->mf.keep_size_after;
- }
-
- // Restart the match finder after finished LZMA_SYNC_FLUSH.
- if (coder->mf.pending > 0
- && coder->mf.read_pos < coder->mf.read_limit) {
- // Match finder may update coder->pending and expects it to
- // start from zero, so use a temporary variable.
- const size_t pending = coder->mf.pending;
- coder->mf.pending = 0;
-
- // Rewind read_pos so that the match finder can hash
- // the pending bytes.
- assert(coder->mf.read_pos >= pending);
- coder->mf.read_pos -= pending;
-
- // Call the skip function directly instead of using
- // mf_skip(), since we don't want to touch mf->read_ahead.
- coder->mf.skip(&coder->mf, pending);
- }
-
- return ret;
-}
-
-
-static lzma_ret
-lz_encode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size,
- uint8_t *restrict out, size_t *restrict out_pos,
- size_t out_size, lzma_action action)
-{
- while (*out_pos < out_size
- && (*in_pos < in_size || action != LZMA_RUN)) {
- // Read more data to coder->mf.buffer if needed.
- if (coder->mf.action == LZMA_RUN && coder->mf.read_pos
- >= coder->mf.read_limit)
- return_if_error(fill_window(coder, allocator,
- in, in_pos, in_size, action));
-
- // Encode
- const lzma_ret ret = coder->lz.code(coder->lz.coder,
- &coder->mf, out, out_pos, out_size);
- if (ret != LZMA_OK) {
- // Setting this to LZMA_RUN for cases when we are
- // flushing. It doesn't matter when finishing or if
- // an error occurred.
- coder->mf.action = LZMA_RUN;
- return ret;
- }
- }
-
- return LZMA_OK;
-}
-
-
-static bool
-lz_encoder_prepare(lzma_mf *mf, lzma_allocator *allocator,
- const lzma_lz_options *lz_options)
-{
- // For now, the dictionary size is limited to 1.5 GiB. This may grow
- // in the future if needed, but it needs a little more work than just
- // changing this check.
- if (lz_options->dict_size < LZMA_DICT_SIZE_MIN
- || lz_options->dict_size
- > (UINT32_C(1) << 30) + (UINT32_C(1) << 29)
- || lz_options->nice_len > lz_options->match_len_max)
- return true;
-
- mf->keep_size_before = lz_options->before_size + lz_options->dict_size;
-
- mf->keep_size_after = lz_options->after_size
- + lz_options->match_len_max;
-
- // To avoid constant memmove()s, allocate some extra space. Since
- // memmove()s become more expensive when the size of the buffer
- // increases, we reserve more space when a large dictionary is
- // used to make the memmove() calls rarer.
- //
- // This works with dictionaries up to about 3 GiB. If bigger
- // dictionary is wanted, some extra work is needed:
- // - Several variables in lzma_mf have to be changed from uint32_t
- // to size_t.
- // - Memory usage calculation needs something too, e.g. use uint64_t
- // for mf->size.
- uint32_t reserve = lz_options->dict_size / 2;
- if (reserve > (UINT32_C(1) << 30))
- reserve /= 2;
-
- reserve += (lz_options->before_size + lz_options->match_len_max
- + lz_options->after_size) / 2 + (UINT32_C(1) << 19);
-
- const uint32_t old_size = mf->size;
- mf->size = mf->keep_size_before + reserve + mf->keep_size_after;
-
- // Deallocate the old history buffer if it exists but has different
- // size than what is needed now.
- if (mf->buffer != NULL && old_size != mf->size) {
- lzma_free(mf->buffer, allocator);
- mf->buffer = NULL;
- }
-
- // Match finder options
- mf->match_len_max = lz_options->match_len_max;
- mf->nice_len = lz_options->nice_len;
-
- // cyclic_size has to stay smaller than 2 Gi. Note that this doesn't
- // mean limiting dictionary size to less than 2 GiB. With a match
- // finder that uses multibyte resolution (hashes start at e.g. every
- // fourth byte), cyclic_size would stay below 2 Gi even when
- // dictionary size is greater than 2 GiB.
- //
- // It would be possible to allow cyclic_size >= 2 Gi, but then we
- // would need to be careful to use 64-bit types in various places
- // (size_t could do since we would need bigger than 32-bit address
- // space anyway). It would also require either zeroing a multigigabyte
- // buffer at initialization (waste of time and RAM) or allow
- // normalization in lz_encoder_mf.c to access uninitialized
- // memory to keep the code simpler. The current way is simple and
- // still allows pretty big dictionaries, so I don't expect these
- // limits to change.
- mf->cyclic_size = lz_options->dict_size + 1;
-
- // Validate the match finder ID and setup the function pointers.
- switch (lz_options->match_finder) {
-#ifdef HAVE_MF_HC3
- case LZMA_MF_HC3:
- mf->find = &lzma_mf_hc3_find;
- mf->skip = &lzma_mf_hc3_skip;
- break;
-#endif
-#ifdef HAVE_MF_HC4
- case LZMA_MF_HC4:
- mf->find = &lzma_mf_hc4_find;
- mf->skip = &lzma_mf_hc4_skip;
- break;
-#endif
-#ifdef HAVE_MF_BT2
- case LZMA_MF_BT2:
- mf->find = &lzma_mf_bt2_find;
- mf->skip = &lzma_mf_bt2_skip;
- break;
-#endif
-#ifdef HAVE_MF_BT3
- case LZMA_MF_BT3:
- mf->find = &lzma_mf_bt3_find;
- mf->skip = &lzma_mf_bt3_skip;
- break;
-#endif
-#ifdef HAVE_MF_BT4
- case LZMA_MF_BT4:
- mf->find = &lzma_mf_bt4_find;
- mf->skip = &lzma_mf_bt4_skip;
- break;
-#endif
-
- default:
- return true;
- }
-
- // Calculate the sizes of mf->hash and mf->son and check that
- // nice_len is big enough for the selected match finder.
- const uint32_t hash_bytes = lz_options->match_finder & 0x0F;
- if (hash_bytes > mf->nice_len)
- return true;
-
- const bool is_bt = (lz_options->match_finder & 0x10) != 0;
- uint32_t hs;
-
- if (hash_bytes == 2) {
- hs = 0xFFFF;
- } else {
- // Round dictionary size up to the next 2^n - 1 so it can
- // be used as a hash mask.
- hs = lz_options->dict_size - 1;
- hs |= hs >> 1;
- hs |= hs >> 2;
- hs |= hs >> 4;
- hs |= hs >> 8;
- hs >>= 1;
- hs |= 0xFFFF;
-
- if (hs > (UINT32_C(1) << 24)) {
- if (hash_bytes == 3)
- hs = (UINT32_C(1) << 24) - 1;
- else
- hs >>= 1;
- }
- }
-
- mf->hash_mask = hs;
-
- ++hs;
- if (hash_bytes > 2)
- hs += HASH_2_SIZE;
- if (hash_bytes > 3)
- hs += HASH_3_SIZE;
-/*
- No match finder uses this at the moment.
- if (mf->hash_bytes > 4)
- hs += HASH_4_SIZE;
-*/
-
- // If the above code calculating hs is modified, make sure that
- // this assertion stays valid (UINT32_MAX / 5 is not strictly the
- // exact limit). If it doesn't, you need to calculate that
- // hash_size_sum + sons_count cannot overflow.
- assert(hs < UINT32_MAX / 5);
-
- const uint32_t old_count = mf->hash_size_sum + mf->sons_count;
- mf->hash_size_sum = hs;
- mf->sons_count = mf->cyclic_size;
- if (is_bt)
- mf->sons_count *= 2;
-
- const uint32_t new_count = mf->hash_size_sum + mf->sons_count;
-
- // Deallocate the old hash array if it exists and has different size
- // than what is needed now.
- if (old_count != new_count) {
- lzma_free(mf->hash, allocator);
- mf->hash = NULL;
- }
-
- // Maximum number of match finder cycles
- mf->depth = lz_options->depth;
- if (mf->depth == 0) {
- if (is_bt)
- mf->depth = 16 + mf->nice_len / 2;
- else
- mf->depth = 4 + mf->nice_len / 4;
- }
-
- return false;
-}
-
-
-static bool
-lz_encoder_init(lzma_mf *mf, lzma_allocator *allocator,
- const lzma_lz_options *lz_options)
-{
- // Allocate the history buffer.
- if (mf->buffer == NULL) {
- mf->buffer = lzma_alloc(mf->size, allocator);
- if (mf->buffer == NULL)
- return true;
- }
-
- // Use cyclic_size as initial mf->offset. This allows
- // avoiding a few branches in the match finders. The downside is
- // that match finder needs to be normalized more often, which may
- // hurt performance with huge dictionaries.
- mf->offset = mf->cyclic_size;
- mf->read_pos = 0;
- mf->read_ahead = 0;
- mf->read_limit = 0;
- mf->write_pos = 0;
- mf->pending = 0;
-
- // Allocate match finder's hash array.
- const size_t alloc_count = mf->hash_size_sum + mf->sons_count;
-
-#if UINT32_MAX >= SIZE_MAX / 4
- // Check for integer overflow. (Huge dictionaries are not
- // possible on 32-bit CPU.)
- if (alloc_count > SIZE_MAX / sizeof(uint32_t))
- return true;
-#endif
-
- if (mf->hash == NULL) {
- mf->hash = lzma_alloc(alloc_count * sizeof(uint32_t),
- allocator);
- if (mf->hash == NULL)
- return true;
- }
-
- mf->son = mf->hash + mf->hash_size_sum;
- mf->cyclic_pos = 0;
-
- // Initialize the hash table. Since EMPTY_HASH_VALUE is zero, we
- // can use memset().
-/*
- for (uint32_t i = 0; i < hash_size_sum; ++i)
- mf->hash[i] = EMPTY_HASH_VALUE;
-*/
- memzero(mf->hash, (size_t)(mf->hash_size_sum) * sizeof(uint32_t));
-
- // We don't need to initialize mf->son, but not doing that will
- // make Valgrind complain in normalization (see normalize() in
- // lz_encoder_mf.c).
- //
- // Skipping this initialization is *very* good when big dictionary is
- // used but only small amount of data gets actually compressed: most
- // of the mf->hash won't get actually allocated by the kernel, so
- // we avoid wasting RAM and improve initialization speed a lot.
- //memzero(mf->son, (size_t)(mf->sons_count) * sizeof(uint32_t));
-
- // Handle preset dictionary.
- if (lz_options->preset_dict != NULL
- && lz_options->preset_dict_size > 0) {
- // If the preset dictionary is bigger than the actual
- // dictionary, use only the tail.
- mf->write_pos = my_min(lz_options->preset_dict_size, mf->size);
- memcpy(mf->buffer, lz_options->preset_dict
- + lz_options->preset_dict_size - mf->write_pos,
- mf->write_pos);
- mf->action = LZMA_SYNC_FLUSH;
- mf->skip(mf, mf->write_pos);
- }
-
- mf->action = LZMA_RUN;
-
- return false;
-}
-
-
-extern uint64_t
-lzma_lz_encoder_memusage(const lzma_lz_options *lz_options)
-{
- // Old buffers must not exist when calling lz_encoder_prepare().
- lzma_mf mf = {
- .buffer = NULL,
- .hash = NULL,
- .hash_size_sum = 0,
- .sons_count = 0,
- };
-
- // Setup the size information into mf.
- if (lz_encoder_prepare(&mf, NULL, lz_options))
- return UINT64_MAX;
-
- // Calculate the memory usage.
- return (uint64_t)(mf.hash_size_sum + mf.sons_count)
- * sizeof(uint32_t)
- + (uint64_t)(mf.size) + sizeof(lzma_coder);
-}
-
-
-static void
-lz_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->next, allocator);
-
- lzma_free(coder->mf.hash, allocator);
- lzma_free(coder->mf.buffer, allocator);
-
- if (coder->lz.end != NULL)
- coder->lz.end(coder->lz.coder, allocator);
- else
- lzma_free(coder->lz.coder, allocator);
-
- lzma_free(coder, allocator);
- return;
-}
-
-
-static lzma_ret
-lz_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
- const lzma_filter *filters_null lzma_attribute((__unused__)),
- const lzma_filter *reversed_filters)
-{
- if (coder->lz.options_update == NULL)
- return LZMA_PROG_ERROR;
-
- return_if_error(coder->lz.options_update(
- coder->lz.coder, reversed_filters));
-
- return lzma_next_filter_update(
- &coder->next, allocator, reversed_filters + 1);
-}
-
-
-extern lzma_ret
-lzma_lz_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters,
- lzma_ret (*lz_init)(lzma_lz_encoder *lz,
- lzma_allocator *allocator, const void *options,
- lzma_lz_options *lz_options))
-{
-#ifdef HAVE_SMALL
- // We need that the CRC32 table has been initialized.
- lzma_crc32_init();
-#endif
-
- // Allocate and initialize the base data structure.
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &lz_encode;
- next->end = &lz_encoder_end;
- next->update = &lz_encoder_update;
-
- next->coder->lz.coder = NULL;
- next->coder->lz.code = NULL;
- next->coder->lz.end = NULL;
-
- next->coder->mf.buffer = NULL;
- next->coder->mf.hash = NULL;
- next->coder->mf.hash_size_sum = 0;
- next->coder->mf.sons_count = 0;
-
- next->coder->next = LZMA_NEXT_CODER_INIT;
- }
-
- // Initialize the LZ-based encoder.
- lzma_lz_options lz_options;
- return_if_error(lz_init(&next->coder->lz, allocator,
- filters[0].options, &lz_options));
-
- // Setup the size information into next->coder->mf and deallocate
- // old buffers if they have wrong size.
- if (lz_encoder_prepare(&next->coder->mf, allocator, &lz_options))
- return LZMA_OPTIONS_ERROR;
-
- // Allocate new buffers if needed, and do the rest of
- // the initialization.
- if (lz_encoder_init(&next->coder->mf, allocator, &lz_options))
- return LZMA_MEM_ERROR;
-
- // Initialize the next filter in the chain, if any.
- return lzma_next_filter_init(&next->coder->next, allocator,
- filters + 1);
-}
-
-
-extern LZMA_API(lzma_bool)
-lzma_mf_is_supported(lzma_match_finder mf)
-{
- bool ret = false;
-
-#ifdef HAVE_MF_HC3
- if (mf == LZMA_MF_HC3)
- ret = true;
-#endif
-
-#ifdef HAVE_MF_HC4
- if (mf == LZMA_MF_HC4)
- ret = true;
-#endif
-
-#ifdef HAVE_MF_BT2
- if (mf == LZMA_MF_BT2)
- ret = true;
-#endif
-
-#ifdef HAVE_MF_BT3
- if (mf == LZMA_MF_BT3)
- ret = true;
-#endif
-
-#ifdef HAVE_MF_BT4
- if (mf == LZMA_MF_BT4)
- ret = true;
-#endif
-
- return ret;
-}
diff -Nru r-base-3.2.3/src/extra/xz/lz/lz_encoder.h r-base-3.3.1/src/extra/xz/lz/lz_encoder.h
--- r-base-3.2.3/src/extra/xz/lz/lz_encoder.h 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lz/lz_encoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,328 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lz_encoder.h
-/// \brief LZ in window and match finder API
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_LZ_ENCODER_H
-#define LZMA_LZ_ENCODER_H
-
-#include "common.h"
-
-
-/// A table of these is used by the LZ-based encoder to hold
-/// the length-distance pairs found by the match finder.
-typedef struct {
- uint32_t len;
- uint32_t dist;
-} lzma_match;
-
-
-typedef struct lzma_mf_s lzma_mf;
-struct lzma_mf_s {
- ///////////////
- // In Window //
- ///////////////
-
- /// Pointer to buffer with data to be compressed
- uint8_t *buffer;
-
- /// Total size of the allocated buffer (that is, including all
- /// the extra space)
- uint32_t size;
-
- /// Number of bytes that must be kept available in our input history.
- /// That is, once keep_size_before bytes have been processed,
- /// buffer[read_pos - keep_size_before] is the oldest byte that
- /// must be available for reading.
- uint32_t keep_size_before;
-
- /// Number of bytes that must be kept in buffer after read_pos.
- /// That is, read_pos <= write_pos - keep_size_after as long as
- /// action is LZMA_RUN; when action != LZMA_RUN, read_pos is allowed
- /// to reach write_pos so that the last bytes get encoded too.
- uint32_t keep_size_after;
-
- /// Match finders store locations of matches using 32-bit integers.
- /// To avoid adjusting several megabytes of integers every time the
- /// input window is moved with move_window, we only adjust the
- /// offset of the buffer. Thus, buffer[value_in_hash_table - offset]
- /// is the byte pointed by value_in_hash_table.
- uint32_t offset;
-
- /// buffer[read_pos] is the next byte to run through the match
- /// finder. This is incremented in the match finder once the byte
- /// has been processed.
- uint32_t read_pos;
-
- /// Number of bytes that have been ran through the match finder, but
- /// which haven't been encoded by the LZ-based encoder yet.
- uint32_t read_ahead;
-
- /// As long as read_pos is less than read_limit, there is enough
- /// input available in buffer for at least one encoding loop.
- ///
- /// Because of the stateful API, read_limit may and will get greater
- /// than read_pos quite often. This is taken into account when
- /// calculating the value for keep_size_after.
- uint32_t read_limit;
-
- /// buffer[write_pos] is the first byte that doesn't contain valid
- /// uncompressed data; that is, the next input byte will be copied
- /// to buffer[write_pos].
- uint32_t write_pos;
-
- /// Number of bytes not hashed before read_pos. This is needed to
- /// restart the match finder after LZMA_SYNC_FLUSH.
- uint32_t pending;
-
- //////////////////
- // Match Finder //
- //////////////////
-
- /// Find matches. Returns the number of distance-length pairs written
- /// to the matches array. This is called only via lzma_mf_find().
- uint32_t (*find)(lzma_mf *mf, lzma_match *matches);
-
- /// Skips num bytes. This is like find() but doesn't make the
- /// distance-length pairs available, thus being a little faster.
- /// This is called only via mf_skip().
- void (*skip)(lzma_mf *mf, uint32_t num);
-
- uint32_t *hash;
- uint32_t *son;
- uint32_t cyclic_pos;
- uint32_t cyclic_size; // Must be dictionary size + 1.
- uint32_t hash_mask;
-
- /// Maximum number of loops in the match finder
- uint32_t depth;
-
- /// Maximum length of a match that the match finder will try to find.
- uint32_t nice_len;
-
- /// Maximum length of a match supported by the LZ-based encoder.
- /// If the longest match found by the match finder is nice_len,
- /// mf_find() tries to expand it up to match_len_max bytes.
- uint32_t match_len_max;
-
- /// When running out of input, binary tree match finders need to know
- /// if it is due to flushing or finishing. The action is used also
- /// by the LZ-based encoders themselves.
- lzma_action action;
-
- /// Number of elements in hash[]
- uint32_t hash_size_sum;
-
- /// Number of elements in son[]
- uint32_t sons_count;
-};
-
-
-typedef struct {
- /// Extra amount of data to keep available before the "actual"
- /// dictionary.
- size_t before_size;
-
- /// Size of the history buffer
- size_t dict_size;
-
- /// Extra amount of data to keep available after the "actual"
- /// dictionary.
- size_t after_size;
-
- /// Maximum length of a match that the LZ-based encoder can accept.
- /// This is used to extend matches of length nice_len to the
- /// maximum possible length.
- size_t match_len_max;
-
- /// Match finder will search matches up to this length.
- /// This must be less than or equal to match_len_max.
- size_t nice_len;
-
- /// Type of the match finder to use
- lzma_match_finder match_finder;
-
- /// Maximum search depth
- uint32_t depth;
-
- /// TODO: Comment
- const uint8_t *preset_dict;
-
- uint32_t preset_dict_size;
-
-} lzma_lz_options;
-
-
-// The total usable buffer space at any moment outside the match finder:
-// before_size + dict_size + after_size + match_len_max
-//
-// In reality, there's some extra space allocated to prevent the number of
-// memmove() calls reasonable. The bigger the dict_size is, the bigger
-// this extra buffer will be since with bigger dictionaries memmove() would
-// also take longer.
-//
-// A single encoder loop in the LZ-based encoder may call the match finder
-// (mf_find() or mf_skip()) at most after_size times. In other words,
-// a single encoder loop may increment lzma_mf.read_pos at most after_size
-// times. Since matches are looked up to
-// lzma_mf.buffer[lzma_mf.read_pos + match_len_max - 1], the total
-// amount of extra buffer needed after dict_size becomes
-// after_size + match_len_max.
-//
-// before_size has two uses. The first one is to keep literals available
-// in cases when the LZ-based encoder has made some read ahead.
-// TODO: Maybe this could be changed by making the LZ-based encoders to
-// store the actual literals as they do with length-distance pairs.
-//
-// Algorithms such as LZMA2 first try to compress a chunk, and then check
-// if the encoded result is smaller than the uncompressed one. If the chunk
-// was uncompressible, it is better to store it in uncompressed form in
-// the output stream. To do this, the whole uncompressed chunk has to be
-// still available in the history buffer. before_size achieves that.
-
-
-typedef struct {
- /// Data specific to the LZ-based encoder
- lzma_coder *coder;
-
- /// Function to encode from *dict to out[]
- lzma_ret (*code)(lzma_coder *restrict coder,
- lzma_mf *restrict mf, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size);
-
- /// Free allocated resources
- void (*end)(lzma_coder *coder, lzma_allocator *allocator);
-
- /// Update the options in the middle of the encoding.
- lzma_ret (*options_update)(lzma_coder *coder,
- const lzma_filter *filter);
-
-} lzma_lz_encoder;
-
-
-// Basic steps:
-// 1. Input gets copied into the dictionary.
-// 2. Data in dictionary gets run through the match finder byte by byte.
-// 3. The literals and matches are encoded using e.g. LZMA.
-//
-// The bytes that have been ran through the match finder, but not encoded yet,
-// are called `read ahead'.
-
-
-/// Get pointer to the first byte not ran through the match finder
-static inline const uint8_t *
-mf_ptr(const lzma_mf *mf)
-{
- return mf->buffer + mf->read_pos;
-}
-
-
-/// Get the number of bytes that haven't been ran through the match finder yet.
-static inline uint32_t
-mf_avail(const lzma_mf *mf)
-{
- return mf->write_pos - mf->read_pos;
-}
-
-
-/// Get the number of bytes that haven't been encoded yet (some of these
-/// bytes may have been ran through the match finder though).
-static inline uint32_t
-mf_unencoded(const lzma_mf *mf)
-{
- return mf->write_pos - mf->read_pos + mf->read_ahead;
-}
-
-
-/// Calculate the absolute offset from the beginning of the most recent
-/// dictionary reset. Only the lowest four bits are important, so there's no
-/// problem that we don't know the 64-bit size of the data encoded so far.
-///
-/// NOTE: When moving the input window, we need to do it so that the lowest
-/// bits of dict->read_pos are not modified to keep this macro working
-/// as intended.
-static inline uint32_t
-mf_position(const lzma_mf *mf)
-{
- return mf->read_pos - mf->read_ahead;
-}
-
-
-/// Since everything else begins with mf_, use it also for lzma_mf_find().
-#define mf_find lzma_mf_find
-
-
-/// Skip the given number of bytes. This is used when a good match was found.
-/// For example, if mf_find() finds a match of 200 bytes long, the first byte
-/// of that match was already consumed by mf_find(), and the rest 199 bytes
-/// have to be skipped with mf_skip(mf, 199).
-static inline void
-mf_skip(lzma_mf *mf, uint32_t amount)
-{
- if (amount != 0) {
- mf->skip(mf, amount);
- mf->read_ahead += amount;
- }
-}
-
-
-/// Copies at most *left number of bytes from the history buffer
-/// to out[]. This is needed by LZMA2 to encode uncompressed chunks.
-static inline void
-mf_read(lzma_mf *mf, uint8_t *out, size_t *out_pos, size_t out_size,
- size_t *left)
-{
- const size_t out_avail = out_size - *out_pos;
- const size_t copy_size = my_min(out_avail, *left);
-
- assert(mf->read_ahead == 0);
- assert(mf->read_pos >= *left);
-
- memcpy(out + *out_pos, mf->buffer + mf->read_pos - *left,
- copy_size);
-
- *out_pos += copy_size;
- *left -= copy_size;
- return;
-}
-
-
-extern lzma_ret lzma_lz_encoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters,
- lzma_ret (*lz_init)(lzma_lz_encoder *lz,
- lzma_allocator *allocator, const void *options,
- lzma_lz_options *lz_options));
-
-
-extern uint64_t lzma_lz_encoder_memusage(const lzma_lz_options *lz_options);
-
-
-// These are only for LZ encoder's internal use.
-extern uint32_t lzma_mf_find(
- lzma_mf *mf, uint32_t *count, lzma_match *matches);
-
-extern uint32_t lzma_mf_hc3_find(lzma_mf *dict, lzma_match *matches);
-extern void lzma_mf_hc3_skip(lzma_mf *dict, uint32_t amount);
-
-extern uint32_t lzma_mf_hc4_find(lzma_mf *dict, lzma_match *matches);
-extern void lzma_mf_hc4_skip(lzma_mf *dict, uint32_t amount);
-
-extern uint32_t lzma_mf_bt2_find(lzma_mf *dict, lzma_match *matches);
-extern void lzma_mf_bt2_skip(lzma_mf *dict, uint32_t amount);
-
-extern uint32_t lzma_mf_bt3_find(lzma_mf *dict, lzma_match *matches);
-extern void lzma_mf_bt3_skip(lzma_mf *dict, uint32_t amount);
-
-extern uint32_t lzma_mf_bt4_find(lzma_mf *dict, lzma_match *matches);
-extern void lzma_mf_bt4_skip(lzma_mf *dict, uint32_t amount);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/lz/lz_encoder_hash.h r-base-3.3.1/src/extra/xz/lz/lz_encoder_hash.h
--- r-base-3.2.3/src/extra/xz/lz/lz_encoder_hash.h 2012-07-27 22:05:01.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lz/lz_encoder_hash.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,108 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lz_encoder_hash.h
-/// \brief Hash macros for match finders
-//
-// Author: Igor Pavlov
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_LZ_ENCODER_HASH_H
-#define LZMA_LZ_ENCODER_HASH_H
-
-#if defined(WORDS_BIGENDIAN) && !defined(HAVE_SMALL)
- // This is to make liblzma produce the same output on big endian
- // systems that it does on little endian systems. lz_encoder.c
- // takes care of including the actual table.
- extern const uint32_t lzma_lz_hash_table[256];
-# define hash_table lzma_lz_hash_table
-#else
-# include "check.h"
-# define hash_table lzma_crc32_table[0]
-#endif
-
-#define HASH_2_SIZE (UINT32_C(1) << 10)
-#define HASH_3_SIZE (UINT32_C(1) << 16)
-#define HASH_4_SIZE (UINT32_C(1) << 20)
-
-#define HASH_2_MASK (HASH_2_SIZE - 1)
-#define HASH_3_MASK (HASH_3_SIZE - 1)
-#define HASH_4_MASK (HASH_4_SIZE - 1)
-
-#define FIX_3_HASH_SIZE (HASH_2_SIZE)
-#define FIX_4_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE)
-#define FIX_5_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE + HASH_4_SIZE)
-
-// Endianness doesn't matter in hash_2_calc() (no effect on the output).
-#ifdef TUKLIB_FAST_UNALIGNED_ACCESS
-# define hash_2_calc() \
- const uint32_t hash_value = *(const uint16_t *)(cur)
-#else
-# define hash_2_calc() \
- const uint32_t hash_value \
- = (uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8)
-#endif
-
-#define hash_3_calc() \
- const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
- const uint32_t hash_2_value = temp & HASH_2_MASK; \
- const uint32_t hash_value \
- = (temp ^ ((uint32_t)(cur[2]) << 8)) & mf->hash_mask
-
-#define hash_4_calc() \
- const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
- const uint32_t hash_2_value = temp & HASH_2_MASK; \
- const uint32_t hash_3_value \
- = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \
- const uint32_t hash_value = (temp ^ ((uint32_t)(cur[2]) << 8) \
- ^ (hash_table[cur[3]] << 5)) & mf->hash_mask
-
-
-// The following are not currently used.
-
-#define hash_5_calc() \
- const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
- const uint32_t hash_2_value = temp & HASH_2_MASK; \
- const uint32_t hash_3_value \
- = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \
- uint32_t hash_4_value = (temp ^ ((uint32_t)(cur[2]) << 8) ^ \
- ^ hash_table[cur[3]] << 5); \
- const uint32_t hash_value \
- = (hash_4_value ^ (hash_table[cur[4]] << 3)) \
- & mf->hash_mask; \
- hash_4_value &= HASH_4_MASK
-
-/*
-#define hash_zip_calc() \
- const uint32_t hash_value \
- = (((uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8)) \
- ^ hash_table[cur[2]]) & 0xFFFF
-*/
-
-#define hash_zip_calc() \
- const uint32_t hash_value \
- = (((uint32_t)(cur[2]) | ((uint32_t)(cur[0]) << 8)) \
- ^ hash_table[cur[1]]) & 0xFFFF
-
-#define mt_hash_2_calc() \
- const uint32_t hash_2_value \
- = (hash_table[cur[0]] ^ cur[1]) & HASH_2_MASK
-
-#define mt_hash_3_calc() \
- const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
- const uint32_t hash_2_value = temp & HASH_2_MASK; \
- const uint32_t hash_3_value \
- = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK
-
-#define mt_hash_4_calc() \
- const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \
- const uint32_t hash_2_value = temp & HASH_2_MASK; \
- const uint32_t hash_3_value \
- = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \
- const uint32_t hash_4_value = (temp ^ ((uint32_t)(cur[2]) << 8) ^ \
- (hash_table[cur[3]] << 5)) & HASH_4_MASK
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/lz/lz_encoder_hash_table.h r-base-3.3.1/src/extra/xz/lz/lz_encoder_hash_table.h
--- r-base-3.2.3/src/extra/xz/lz/lz_encoder_hash_table.h 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lz/lz_encoder_hash_table.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,68 +0,0 @@
-/* This file has been automatically generated by crc32_tablegen.c. */
-
-const uint32_t lzma_lz_hash_table[256] = {
- 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
- 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
- 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
- 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
- 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
- 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
- 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
- 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
- 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
- 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
- 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
- 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
- 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
- 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
- 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
- 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
- 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
- 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
- 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
- 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
- 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
- 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
- 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
- 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
- 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
- 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
- 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
- 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
- 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
- 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
- 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
- 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
- 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
- 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
- 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
- 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
- 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
- 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
- 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
- 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
- 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
- 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
- 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
- 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
- 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
- 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
- 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
- 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
- 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
- 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
- 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
- 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
- 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
- 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
- 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
- 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
- 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
- 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
- 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
- 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
- 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
- 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
- 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
- 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
-};
diff -Nru r-base-3.2.3/src/extra/xz/lz/lz_encoder_mf.c r-base-3.3.1/src/extra/xz/lz/lz_encoder_mf.c
--- r-base-3.2.3/src/extra/xz/lz/lz_encoder_mf.c 2010-11-08 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lz/lz_encoder_mf.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,753 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lz_encoder_mf.c
-/// \brief Match finders
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "lz_encoder.h"
-#include "lz_encoder_hash.h"
-
-
-/// \brief Find matches starting from the current byte
-///
-/// \return The length of the longest match found
-extern uint32_t
-lzma_mf_find(lzma_mf *mf, uint32_t *count_ptr, lzma_match *matches)
-{
- // Call the match finder. It returns the number of length-distance
- // pairs found.
- // FIXME: Minimum count is zero, what _exactly_ is the maximum?
- const uint32_t count = mf->find(mf, matches);
-
- // Length of the longest match; assume that no matches were found
- // and thus the maximum length is zero.
- uint32_t len_best = 0;
-
- if (count > 0) {
-#ifndef NDEBUG
- // Validate the matches.
- for (uint32_t i = 0; i < count; ++i) {
- assert(matches[i].len <= mf->nice_len);
- assert(matches[i].dist < mf->read_pos);
- assert(memcmp(mf_ptr(mf) - 1,
- mf_ptr(mf) - matches[i].dist - 2,
- matches[i].len) == 0);
- }
-#endif
-
- // The last used element in the array contains
- // the longest match.
- len_best = matches[count - 1].len;
-
- // If a match of maximum search length was found, try to
- // extend the match to maximum possible length.
- if (len_best == mf->nice_len) {
- // The limit for the match length is either the
- // maximum match length supported by the LZ-based
- // encoder or the number of bytes left in the
- // dictionary, whichever is smaller.
- uint32_t limit = mf_avail(mf) + 1;
- if (limit > mf->match_len_max)
- limit = mf->match_len_max;
-
- // Pointer to the byte we just ran through
- // the match finder.
- const uint8_t *p1 = mf_ptr(mf) - 1;
-
- // Pointer to the beginning of the match. We need -1
- // here because the match distances are zero based.
- const uint8_t *p2 = p1 - matches[count - 1].dist - 1;
-
- while (len_best < limit
- && p1[len_best] == p2[len_best])
- ++len_best;
- }
- }
-
- *count_ptr = count;
-
- // Finally update the read position to indicate that match finder was
- // run for this dictionary offset.
- ++mf->read_ahead;
-
- return len_best;
-}
-
-
-/// Hash value to indicate unused element in the hash. Since we start the
-/// positions from dict_size + 1, zero is always too far to qualify
-/// as usable match position.
-#define EMPTY_HASH_VALUE 0
-
-
-/// Normalization must be done when lzma_mf.offset + lzma_mf.read_pos
-/// reaches MUST_NORMALIZE_POS.
-#define MUST_NORMALIZE_POS UINT32_MAX
-
-
-/// \brief Normalizes hash values
-///
-/// The hash arrays store positions of match candidates. The positions are
-/// relative to an arbitrary offset that is not the same as the absolute
-/// offset in the input stream. The relative position of the current byte
-/// is lzma_mf.offset + lzma_mf.read_pos. The distances of the matches are
-/// the differences of the current read position and the position found from
-/// the hash.
-///
-/// To prevent integer overflows of the offsets stored in the hash arrays,
-/// we need to "normalize" the stored values now and then. During the
-/// normalization, we drop values that indicate distance greater than the
-/// dictionary size, thus making space for new values.
-static void
-normalize(lzma_mf *mf)
-{
- assert(mf->read_pos + mf->offset == MUST_NORMALIZE_POS);
-
- // In future we may not want to touch the lowest bits, because there
- // may be match finders that use larger resolution than one byte.
- const uint32_t subvalue
- = (MUST_NORMALIZE_POS - mf->cyclic_size);
- // & (~(UINT32_C(1) << 10) - 1);
-
- const uint32_t count = mf->hash_size_sum + mf->sons_count;
- uint32_t *hash = mf->hash;
-
- for (uint32_t i = 0; i < count; ++i) {
- // If the distance is greater than the dictionary size,
- // we can simply mark the hash element as empty.
- //
- // NOTE: Only the first mf->hash_size_sum elements are
- // initialized for sure. There may be uninitialized elements
- // in mf->son. Since we go through both mf->hash and
- // mf->son here in normalization, Valgrind may complain
- // that the "if" below depends on uninitialized value. In
- // this case it is safe to ignore the warning. See also the
- // comments in lz_encoder_init() in lz_encoder.c.
- if (hash[i] <= subvalue)
- hash[i] = EMPTY_HASH_VALUE;
- else
- hash[i] -= subvalue;
- }
-
- // Update offset to match the new locations.
- mf->offset -= subvalue;
-
- return;
-}
-
-
-/// Mark the current byte as processed from point of view of the match finder.
-static void
-move_pos(lzma_mf *mf)
-{
- if (++mf->cyclic_pos == mf->cyclic_size)
- mf->cyclic_pos = 0;
-
- ++mf->read_pos;
- assert(mf->read_pos <= mf->write_pos);
-
- if (unlikely(mf->read_pos + mf->offset == UINT32_MAX))
- normalize(mf);
-}
-
-
-/// When flushing, we cannot run the match finder unless there is nice_len
-/// bytes available in the dictionary. Instead, we skip running the match
-/// finder (indicating that no match was found), and count how many bytes we
-/// have ignored this way.
-///
-/// When new data is given after the flushing was completed, the match finder
-/// is restarted by rewinding mf->read_pos backwards by mf->pending. Then
-/// the missed bytes are added to the hash using the match finder's skip
-/// function (with small amount of input, it may start using mf->pending
-/// again if flushing).
-///
-/// Due to this rewinding, we don't touch cyclic_pos or test for
-/// normalization. It will be done when the match finder's skip function
-/// catches up after a flush.
-static void
-move_pending(lzma_mf *mf)
-{
- ++mf->read_pos;
- assert(mf->read_pos <= mf->write_pos);
- ++mf->pending;
-}
-
-
-/// Calculate len_limit and determine if there is enough input to run
-/// the actual match finder code. Sets up "cur" and "pos". This macro
-/// is used by all find functions and binary tree skip functions. Hash
-/// chain skip function doesn't need len_limit so a simpler code is used
-/// in them.
-#define header(is_bt, len_min, ret_op) \
- uint32_t len_limit = mf_avail(mf); \
- if (mf->nice_len <= len_limit) { \
- len_limit = mf->nice_len; \
- } else if (len_limit < (len_min) \
- || (is_bt && mf->action == LZMA_SYNC_FLUSH)) { \
- assert(mf->action != LZMA_RUN); \
- move_pending(mf); \
- ret_op; \
- } \
- const uint8_t *cur = mf_ptr(mf); \
- const uint32_t pos = mf->read_pos + mf->offset
-
-
-/// Header for find functions. "return 0" indicates that zero matches
-/// were found.
-#define header_find(is_bt, len_min) \
- header(is_bt, len_min, return 0); \
- uint32_t matches_count = 0
-
-
-/// Header for a loop in a skip function. "continue" tells to skip the rest
-/// of the code in the loop.
-#define header_skip(is_bt, len_min) \
- header(is_bt, len_min, continue)
-
-
-/// Calls hc_find_func() or bt_find_func() and calculates the total number
-/// of matches found. Updates the dictionary position and returns the number
-/// of matches found.
-#define call_find(func, len_best) \
-do { \
- matches_count = func(len_limit, pos, cur, cur_match, mf->depth, \
- mf->son, mf->cyclic_pos, mf->cyclic_size, \
- matches + matches_count, len_best) \
- - matches; \
- move_pos(mf); \
- return matches_count; \
-} while (0)
-
-
-////////////////
-// Hash Chain //
-////////////////
-
-#if defined(HAVE_MF_HC3) || defined(HAVE_MF_HC4)
-///
-///
-/// \param len_limit Don't look for matches longer than len_limit.
-/// \param pos lzma_mf.read_pos + lzma_mf.offset
-/// \param cur Pointer to current byte (mf_ptr(mf))
-/// \param cur_match Start position of the current match candidate
-/// \param depth Maximum length of the hash chain
-/// \param son lzma_mf.son (contains the hash chain)
-/// \param cyclic_pos
-/// \param cyclic_size
-/// \param matches Array to hold the matches.
-/// \param len_best The length of the longest match found so far.
-static lzma_match *
-hc_find_func(
- const uint32_t len_limit,
- const uint32_t pos,
- const uint8_t *const cur,
- uint32_t cur_match,
- uint32_t depth,
- uint32_t *const son,
- const uint32_t cyclic_pos,
- const uint32_t cyclic_size,
- lzma_match *matches,
- uint32_t len_best)
-{
- son[cyclic_pos] = cur_match;
-
- while (true) {
- const uint32_t delta = pos - cur_match;
- if (depth-- == 0 || delta >= cyclic_size)
- return matches;
-
- const uint8_t *const pb = cur - delta;
- cur_match = son[cyclic_pos - delta
- + (delta > cyclic_pos ? cyclic_size : 0)];
-
- if (pb[len_best] == cur[len_best] && pb[0] == cur[0]) {
- uint32_t len = 0;
- while (++len != len_limit)
- if (pb[len] != cur[len])
- break;
-
- if (len_best < len) {
- len_best = len;
- matches->len = len;
- matches->dist = delta - 1;
- ++matches;
-
- if (len == len_limit)
- return matches;
- }
- }
- }
-}
-
-
-#define hc_find(len_best) \
- call_find(hc_find_func, len_best)
-
-
-#define hc_skip() \
-do { \
- mf->son[mf->cyclic_pos] = cur_match; \
- move_pos(mf); \
-} while (0)
-
-#endif
-
-
-#ifdef HAVE_MF_HC3
-extern uint32_t
-lzma_mf_hc3_find(lzma_mf *mf, lzma_match *matches)
-{
- header_find(false, 3);
-
- hash_3_calc();
-
- const uint32_t delta2 = pos - mf->hash[hash_2_value];
- const uint32_t cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];
-
- mf->hash[hash_2_value] = pos;
- mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
-
- uint32_t len_best = 2;
-
- if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
- for ( ; len_best != len_limit; ++len_best)
- if (*(cur + len_best - delta2) != cur[len_best])
- break;
-
- matches[0].len = len_best;
- matches[0].dist = delta2 - 1;
- matches_count = 1;
-
- if (len_best == len_limit) {
- hc_skip();
- return 1; // matches_count
- }
- }
-
- hc_find(len_best);
-}
-
-
-extern void
-lzma_mf_hc3_skip(lzma_mf *mf, uint32_t amount)
-{
- do {
- if (mf_avail(mf) < 3) {
- move_pending(mf);
- continue;
- }
-
- const uint8_t *cur = mf_ptr(mf);
- const uint32_t pos = mf->read_pos + mf->offset;
-
- hash_3_calc();
-
- const uint32_t cur_match
- = mf->hash[FIX_3_HASH_SIZE + hash_value];
-
- mf->hash[hash_2_value] = pos;
- mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
-
- hc_skip();
-
- } while (--amount != 0);
-}
-#endif
-
-
-#ifdef HAVE_MF_HC4
-extern uint32_t
-lzma_mf_hc4_find(lzma_mf *mf, lzma_match *matches)
-{
- header_find(false, 4);
-
- hash_4_calc();
-
- uint32_t delta2 = pos - mf->hash[hash_2_value];
- const uint32_t delta3
- = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value];
- const uint32_t cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];
-
- mf->hash[hash_2_value ] = pos;
- mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
- mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;
-
- uint32_t len_best = 1;
-
- if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
- len_best = 2;
- matches[0].len = 2;
- matches[0].dist = delta2 - 1;
- matches_count = 1;
- }
-
- if (delta2 != delta3 && delta3 < mf->cyclic_size
- && *(cur - delta3) == *cur) {
- len_best = 3;
- matches[matches_count++].dist = delta3 - 1;
- delta2 = delta3;
- }
-
- if (matches_count != 0) {
- for ( ; len_best != len_limit; ++len_best)
- if (*(cur + len_best - delta2) != cur[len_best])
- break;
-
- matches[matches_count - 1].len = len_best;
-
- if (len_best == len_limit) {
- hc_skip();
- return matches_count;
- }
- }
-
- if (len_best < 3)
- len_best = 3;
-
- hc_find(len_best);
-}
-
-
-extern void
-lzma_mf_hc4_skip(lzma_mf *mf, uint32_t amount)
-{
- do {
- if (mf_avail(mf) < 4) {
- move_pending(mf);
- continue;
- }
-
- const uint8_t *cur = mf_ptr(mf);
- const uint32_t pos = mf->read_pos + mf->offset;
-
- hash_4_calc();
-
- const uint32_t cur_match
- = mf->hash[FIX_4_HASH_SIZE + hash_value];
-
- mf->hash[hash_2_value] = pos;
- mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
- mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;
-
- hc_skip();
-
- } while (--amount != 0);
-}
-#endif
-
-
-/////////////////
-// Binary Tree //
-/////////////////
-
-#if defined(HAVE_MF_BT2) || defined(HAVE_MF_BT3) || defined(HAVE_MF_BT4)
-static lzma_match *
-bt_find_func(
- const uint32_t len_limit,
- const uint32_t pos,
- const uint8_t *const cur,
- uint32_t cur_match,
- uint32_t depth,
- uint32_t *const son,
- const uint32_t cyclic_pos,
- const uint32_t cyclic_size,
- lzma_match *matches,
- uint32_t len_best)
-{
- uint32_t *ptr0 = son + (cyclic_pos << 1) + 1;
- uint32_t *ptr1 = son + (cyclic_pos << 1);
-
- uint32_t len0 = 0;
- uint32_t len1 = 0;
-
- while (true) {
- const uint32_t delta = pos - cur_match;
- if (depth-- == 0 || delta >= cyclic_size) {
- *ptr0 = EMPTY_HASH_VALUE;
- *ptr1 = EMPTY_HASH_VALUE;
- return matches;
- }
-
- uint32_t *const pair = son + ((cyclic_pos - delta
- + (delta > cyclic_pos ? cyclic_size : 0))
- << 1);
-
- const uint8_t *const pb = cur - delta;
- uint32_t len = my_min(len0, len1);
-
- if (pb[len] == cur[len]) {
- while (++len != len_limit)
- if (pb[len] != cur[len])
- break;
-
- if (len_best < len) {
- len_best = len;
- matches->len = len;
- matches->dist = delta - 1;
- ++matches;
-
- if (len == len_limit) {
- *ptr1 = pair[0];
- *ptr0 = pair[1];
- return matches;
- }
- }
- }
-
- if (pb[len] < cur[len]) {
- *ptr1 = cur_match;
- ptr1 = pair + 1;
- cur_match = *ptr1;
- len1 = len;
- } else {
- *ptr0 = cur_match;
- ptr0 = pair;
- cur_match = *ptr0;
- len0 = len;
- }
- }
-}
-
-
-static void
-bt_skip_func(
- const uint32_t len_limit,
- const uint32_t pos,
- const uint8_t *const cur,
- uint32_t cur_match,
- uint32_t depth,
- uint32_t *const son,
- const uint32_t cyclic_pos,
- const uint32_t cyclic_size)
-{
- uint32_t *ptr0 = son + (cyclic_pos << 1) + 1;
- uint32_t *ptr1 = son + (cyclic_pos << 1);
-
- uint32_t len0 = 0;
- uint32_t len1 = 0;
-
- while (true) {
- const uint32_t delta = pos - cur_match;
- if (depth-- == 0 || delta >= cyclic_size) {
- *ptr0 = EMPTY_HASH_VALUE;
- *ptr1 = EMPTY_HASH_VALUE;
- return;
- }
-
- uint32_t *pair = son + ((cyclic_pos - delta
- + (delta > cyclic_pos ? cyclic_size : 0))
- << 1);
- const uint8_t *pb = cur - delta;
- uint32_t len = my_min(len0, len1);
-
- if (pb[len] == cur[len]) {
- while (++len != len_limit)
- if (pb[len] != cur[len])
- break;
-
- if (len == len_limit) {
- *ptr1 = pair[0];
- *ptr0 = pair[1];
- return;
- }
- }
-
- if (pb[len] < cur[len]) {
- *ptr1 = cur_match;
- ptr1 = pair + 1;
- cur_match = *ptr1;
- len1 = len;
- } else {
- *ptr0 = cur_match;
- ptr0 = pair;
- cur_match = *ptr0;
- len0 = len;
- }
- }
-}
-
-
-#define bt_find(len_best) \
- call_find(bt_find_func, len_best)
-
-#define bt_skip() \
-do { \
- bt_skip_func(len_limit, pos, cur, cur_match, mf->depth, \
- mf->son, mf->cyclic_pos, \
- mf->cyclic_size); \
- move_pos(mf); \
-} while (0)
-
-#endif
-
-
-#ifdef HAVE_MF_BT2
-extern uint32_t
-lzma_mf_bt2_find(lzma_mf *mf, lzma_match *matches)
-{
- header_find(true, 2);
-
- hash_2_calc();
-
- const uint32_t cur_match = mf->hash[hash_value];
- mf->hash[hash_value] = pos;
-
- bt_find(1);
-}
-
-
-extern void
-lzma_mf_bt2_skip(lzma_mf *mf, uint32_t amount)
-{
- do {
- header_skip(true, 2);
-
- hash_2_calc();
-
- const uint32_t cur_match = mf->hash[hash_value];
- mf->hash[hash_value] = pos;
-
- bt_skip();
-
- } while (--amount != 0);
-}
-#endif
-
-
-#ifdef HAVE_MF_BT3
-extern uint32_t
-lzma_mf_bt3_find(lzma_mf *mf, lzma_match *matches)
-{
- header_find(true, 3);
-
- hash_3_calc();
-
- const uint32_t delta2 = pos - mf->hash[hash_2_value];
- const uint32_t cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];
-
- mf->hash[hash_2_value] = pos;
- mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
-
- uint32_t len_best = 2;
-
- if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
- for ( ; len_best != len_limit; ++len_best)
- if (*(cur + len_best - delta2) != cur[len_best])
- break;
-
- matches[0].len = len_best;
- matches[0].dist = delta2 - 1;
- matches_count = 1;
-
- if (len_best == len_limit) {
- bt_skip();
- return 1; // matches_count
- }
- }
-
- bt_find(len_best);
-}
-
-
-extern void
-lzma_mf_bt3_skip(lzma_mf *mf, uint32_t amount)
-{
- do {
- header_skip(true, 3);
-
- hash_3_calc();
-
- const uint32_t cur_match
- = mf->hash[FIX_3_HASH_SIZE + hash_value];
-
- mf->hash[hash_2_value] = pos;
- mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;
-
- bt_skip();
-
- } while (--amount != 0);
-}
-#endif
-
-
-#ifdef HAVE_MF_BT4
-extern uint32_t
-lzma_mf_bt4_find(lzma_mf *mf, lzma_match *matches)
-{
- header_find(true, 4);
-
- hash_4_calc();
-
- uint32_t delta2 = pos - mf->hash[hash_2_value];
- const uint32_t delta3
- = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value];
- const uint32_t cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];
-
- mf->hash[hash_2_value] = pos;
- mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
- mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;
-
- uint32_t len_best = 1;
-
- if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {
- len_best = 2;
- matches[0].len = 2;
- matches[0].dist = delta2 - 1;
- matches_count = 1;
- }
-
- if (delta2 != delta3 && delta3 < mf->cyclic_size
- && *(cur - delta3) == *cur) {
- len_best = 3;
- matches[matches_count++].dist = delta3 - 1;
- delta2 = delta3;
- }
-
- if (matches_count != 0) {
- for ( ; len_best != len_limit; ++len_best)
- if (*(cur + len_best - delta2) != cur[len_best])
- break;
-
- matches[matches_count - 1].len = len_best;
-
- if (len_best == len_limit) {
- bt_skip();
- return matches_count;
- }
- }
-
- if (len_best < 3)
- len_best = 3;
-
- bt_find(len_best);
-}
-
-
-extern void
-lzma_mf_bt4_skip(lzma_mf *mf, uint32_t amount)
-{
- do {
- header_skip(true, 4);
-
- hash_4_calc();
-
- const uint32_t cur_match
- = mf->hash[FIX_4_HASH_SIZE + hash_value];
-
- mf->hash[hash_2_value] = pos;
- mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;
- mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;
-
- bt_skip();
-
- } while (--amount != 0);
-}
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/lzma/fastpos.h r-base-3.3.1/src/extra/xz/lzma/fastpos.h
--- r-base-3.2.3/src/extra/xz/lzma/fastpos.h 2010-11-08 23:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/fastpos.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,140 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file fastpos.h
-/// \brief Kind of two-bit version of bit scan reverse
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_FASTPOS_H
-#define LZMA_FASTPOS_H
-
-// LZMA encodes match distances (positions) by storing the highest two
-// bits using a six-bit value [0, 63], and then the missing lower bits.
-// Dictionary size is also stored using this encoding in the new .lzma
-// file format header.
-//
-// fastpos.h provides a way to quickly find out the correct six-bit
-// values. The following table gives some examples of this encoding:
-//
-// pos return
-// 0 0
-// 1 1
-// 2 2
-// 3 3
-// 4 4
-// 5 4
-// 6 5
-// 7 5
-// 8 6
-// 11 6
-// 12 7
-// ... ...
-// 15 7
-// 16 8
-// 17 8
-// ... ...
-// 23 8
-// 24 9
-// 25 9
-// ... ...
-//
-//
-// Provided functions or macros
-// ----------------------------
-//
-// get_pos_slot(pos) is the basic version. get_pos_slot_2(pos)
-// assumes that pos >= FULL_DISTANCES, thus the result is at least
-// FULL_DISTANCES_BITS * 2. Using get_pos_slot(pos) instead of
-// get_pos_slot_2(pos) would give the same result, but get_pos_slot_2(pos)
-// should be tiny bit faster due to the assumption being made.
-//
-//
-// Size vs. speed
-// --------------
-//
-// With some CPUs that have fast BSR (bit scan reverse) instruction, the
-// size optimized version is slightly faster than the bigger table based
-// approach. Such CPUs include Intel Pentium Pro, Pentium II, Pentium III
-// and Core 2 (possibly others). AMD K7 seems to have slower BSR, but that
-// would still have speed roughly comparable to the table version. Older
-// x86 CPUs like the original Pentium have very slow BSR; on those systems
-// the table version is a lot faster.
-//
-// On some CPUs, the table version is a lot faster when using position
-// dependent code, but with position independent code the size optimized
-// version is slightly faster. This occurs at least on 32-bit SPARC (no
-// ASM optimizations).
-//
-// I'm making the table version the default, because that has good speed
-// on all systems I have tried. The size optimized version is sometimes
-// slightly faster, but sometimes it is a lot slower.
-
-#ifdef HAVE_SMALL
-# define get_pos_slot(pos) ((pos) <= 4 ? (pos) : get_pos_slot_2(pos))
-
-static inline uint32_t
-get_pos_slot_2(uint32_t pos)
-{
- const uint32_t i = bsr32(pos);
- return (i + i) + ((pos >> (i - 1)) & 1);
-}
-
-
-#else
-
-#define FASTPOS_BITS 13
-
-extern const uint8_t lzma_fastpos[1 << FASTPOS_BITS];
-
-
-#define fastpos_shift(extra, n) \
- ((extra) + (n) * (FASTPOS_BITS - 1))
-
-#define fastpos_limit(extra, n) \
- (UINT32_C(1) << (FASTPOS_BITS + fastpos_shift(extra, n)))
-
-#define fastpos_result(pos, extra, n) \
- lzma_fastpos[(pos) >> fastpos_shift(extra, n)] \
- + 2 * fastpos_shift(extra, n)
-
-
-static inline uint32_t
-get_pos_slot(uint32_t pos)
-{
- // If it is small enough, we can pick the result directly from
- // the precalculated table.
- if (pos < fastpos_limit(0, 0))
- return lzma_fastpos[pos];
-
- if (pos < fastpos_limit(0, 1))
- return fastpos_result(pos, 0, 1);
-
- return fastpos_result(pos, 0, 2);
-}
-
-
-#ifdef FULL_DISTANCES_BITS
-static inline uint32_t
-get_pos_slot_2(uint32_t pos)
-{
- assert(pos >= FULL_DISTANCES);
-
- if (pos < fastpos_limit(FULL_DISTANCES_BITS - 1, 0))
- return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 0);
-
- if (pos < fastpos_limit(FULL_DISTANCES_BITS - 1, 1))
- return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 1);
-
- return fastpos_result(pos, FULL_DISTANCES_BITS - 1, 2);
-}
-#endif
-
-#endif
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/lzma/fastpos_table.c r-base-3.3.1/src/extra/xz/lzma/fastpos_table.c
--- r-base-3.2.3/src/extra/xz/lzma/fastpos_table.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/fastpos_table.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,519 +0,0 @@
-/* This file has been automatically generated by fastpos_tablegen.c. */
-
-#include "common.h"
-#include "fastpos.h"
-
-const uint8_t lzma_fastpos[1 << FASTPOS_BITS] = {
- 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
- 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25
-};
diff -Nru r-base-3.2.3/src/extra/xz/lzma/fastpos_tablegen.c r-base-3.3.1/src/extra/xz/lzma/fastpos_tablegen.c
--- r-base-3.2.3/src/extra/xz/lzma/fastpos_tablegen.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/fastpos_tablegen.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,56 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file fastpos_tablegen.c
-/// \brief Generates the lzma_fastpos[] lookup table
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include
-#include
-#include
-#include "fastpos.h"
-
-
-int
-main(void)
-{
- uint8_t fastpos[1 << FASTPOS_BITS];
-
- const uint8_t fast_slots = 2 * FASTPOS_BITS;
- uint32_t c = 2;
-
- fastpos[0] = 0;
- fastpos[1] = 1;
-
- for (uint8_t slot_fast = 2; slot_fast < fast_slots; ++slot_fast) {
- const uint32_t k = 1 << ((slot_fast >> 1) - 1);
- for (uint32_t j = 0; j < k; ++j, ++c)
- fastpos[c] = slot_fast;
- }
-
- printf("/* This file has been automatically generated "
- "by fastpos_tablegen.c. */\n\n"
- "#include \"common.h\"\n"
- "#include \"fastpos.h\"\n\n"
- "const uint8_t lzma_fastpos[1 << FASTPOS_BITS] = {");
-
- for (size_t i = 0; i < (1 << FASTPOS_BITS); ++i) {
- if (i % 16 == 0)
- printf("\n\t");
-
- printf("%3u", (unsigned int)(fastpos[i]));
-
- if (i != (1 << FASTPOS_BITS) - 1)
- printf(",");
- }
-
- printf("\n};\n");
-
- return 0;
-}
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma2_decoder.c r-base-3.3.1/src/extra/xz/lzma/lzma2_decoder.c
--- r-base-3.2.3/src/extra/xz/lzma/lzma2_decoder.c 2011-04-23 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma2_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,304 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma2_decoder.c
-/// \brief LZMA2 decoder
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "lzma2_decoder.h"
-#include "lz_decoder.h"
-#include "lzma_decoder.h"
-
-
-struct lzma_coder_s {
- enum sequence {
- SEQ_CONTROL,
- SEQ_UNCOMPRESSED_1,
- SEQ_UNCOMPRESSED_2,
- SEQ_COMPRESSED_0,
- SEQ_COMPRESSED_1,
- SEQ_PROPERTIES,
- SEQ_LZMA,
- SEQ_COPY,
- } sequence;
-
- /// Sequence after the size fields have been decoded.
- enum sequence next_sequence;
-
- /// LZMA decoder
- lzma_lz_decoder lzma;
-
- /// Uncompressed size of LZMA chunk
- size_t uncompressed_size;
-
- /// Compressed size of the chunk (naturally equals to uncompressed
- /// size of uncompressed chunk)
- size_t compressed_size;
-
- /// True if properties are needed. This is false before the
- /// first LZMA chunk.
- bool need_properties;
-
- /// True if dictionary reset is needed. This is false before the
- /// first chunk (LZMA or uncompressed).
- bool need_dictionary_reset;
-
- lzma_options_lzma options;
-};
-
-
-static lzma_ret
-lzma2_decode(lzma_coder *restrict coder, lzma_dict *restrict dict,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size)
-{
- // With SEQ_LZMA it is possible that no new input is needed to do
- // some progress. The rest of the sequences assume that there is
- // at least one byte of input.
- while (*in_pos < in_size || coder->sequence == SEQ_LZMA)
- switch (coder->sequence) {
- case SEQ_CONTROL: {
- const uint32_t control = in[*in_pos];
- ++*in_pos;
-
- // End marker
- if (control == 0x00)
- return LZMA_STREAM_END;
-
- if (control >= 0xE0 || control == 1) {
- // Dictionary reset implies that next LZMA chunk has
- // to set new properties.
- coder->need_properties = true;
- coder->need_dictionary_reset = true;
- } else if (coder->need_dictionary_reset) {
- return LZMA_DATA_ERROR;
- }
-
- if (control >= 0x80) {
- // LZMA chunk. The highest five bits of the
- // uncompressed size are taken from the control byte.
- coder->uncompressed_size = (control & 0x1F) << 16;
- coder->sequence = SEQ_UNCOMPRESSED_1;
-
- // See if there are new properties or if we need to
- // reset the state.
- if (control >= 0xC0) {
- // When there are new properties, state reset
- // is done at SEQ_PROPERTIES.
- coder->need_properties = false;
- coder->next_sequence = SEQ_PROPERTIES;
-
- } else if (coder->need_properties) {
- return LZMA_DATA_ERROR;
-
- } else {
- coder->next_sequence = SEQ_LZMA;
-
- // If only state reset is wanted with old
- // properties, do the resetting here for
- // simplicity.
- if (control >= 0xA0)
- coder->lzma.reset(coder->lzma.coder,
- &coder->options);
- }
- } else {
- // Invalid control values
- if (control > 2)
- return LZMA_DATA_ERROR;
-
- // It's uncompressed chunk
- coder->sequence = SEQ_COMPRESSED_0;
- coder->next_sequence = SEQ_COPY;
- }
-
- if (coder->need_dictionary_reset) {
- // Finish the dictionary reset and let the caller
- // flush the dictionary to the actual output buffer.
- coder->need_dictionary_reset = false;
- dict_reset(dict);
- return LZMA_OK;
- }
-
- break;
- }
-
- case SEQ_UNCOMPRESSED_1:
- coder->uncompressed_size += (uint32_t)(in[(*in_pos)++]) << 8;
- coder->sequence = SEQ_UNCOMPRESSED_2;
- break;
-
- case SEQ_UNCOMPRESSED_2:
- coder->uncompressed_size += in[(*in_pos)++] + 1;
- coder->sequence = SEQ_COMPRESSED_0;
- coder->lzma.set_uncompressed(coder->lzma.coder,
- coder->uncompressed_size);
- break;
-
- case SEQ_COMPRESSED_0:
- coder->compressed_size = (uint32_t)(in[(*in_pos)++]) << 8;
- coder->sequence = SEQ_COMPRESSED_1;
- break;
-
- case SEQ_COMPRESSED_1:
- coder->compressed_size += in[(*in_pos)++] + 1;
- coder->sequence = coder->next_sequence;
- break;
-
- case SEQ_PROPERTIES:
- if (lzma_lzma_lclppb_decode(&coder->options, in[(*in_pos)++]))
- return LZMA_DATA_ERROR;
-
- coder->lzma.reset(coder->lzma.coder, &coder->options);
-
- coder->sequence = SEQ_LZMA;
- break;
-
- case SEQ_LZMA: {
- // Store the start offset so that we can update
- // coder->compressed_size later.
- const size_t in_start = *in_pos;
-
- // Decode from in[] to *dict.
- const lzma_ret ret = coder->lzma.code(coder->lzma.coder,
- dict, in, in_pos, in_size);
-
- // Validate and update coder->compressed_size.
- const size_t in_used = *in_pos - in_start;
- if (in_used > coder->compressed_size)
- return LZMA_DATA_ERROR;
-
- coder->compressed_size -= in_used;
-
- // Return if we didn't finish the chunk, or an error occurred.
- if (ret != LZMA_STREAM_END)
- return ret;
-
- // The LZMA decoder must have consumed the whole chunk now.
- // We don't need to worry about uncompressed size since it
- // is checked by the LZMA decoder.
- if (coder->compressed_size != 0)
- return LZMA_DATA_ERROR;
-
- coder->sequence = SEQ_CONTROL;
- break;
- }
-
- case SEQ_COPY: {
- // Copy from input to the dictionary as is.
- dict_write(dict, in, in_pos, in_size, &coder->compressed_size);
- if (coder->compressed_size != 0)
- return LZMA_OK;
-
- coder->sequence = SEQ_CONTROL;
- break;
- }
-
- default:
- assert(0);
- return LZMA_PROG_ERROR;
- }
-
- return LZMA_OK;
-}
-
-
-static void
-lzma2_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- assert(coder->lzma.end == NULL);
- lzma_free(coder->lzma.coder, allocator);
-
- lzma_free(coder, allocator);
-
- return;
-}
-
-
-static lzma_ret
-lzma2_decoder_init(lzma_lz_decoder *lz, lzma_allocator *allocator,
- const void *opt, lzma_lz_options *lz_options)
-{
- if (lz->coder == NULL) {
- lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (lz->coder == NULL)
- return LZMA_MEM_ERROR;
-
- lz->code = &lzma2_decode;
- lz->end = &lzma2_decoder_end;
-
- lz->coder->lzma = LZMA_LZ_DECODER_INIT;
- }
-
- const lzma_options_lzma *options = opt;
-
- lz->coder->sequence = SEQ_CONTROL;
- lz->coder->need_properties = true;
- lz->coder->need_dictionary_reset = options->preset_dict == NULL
- || options->preset_dict_size == 0;
-
- return lzma_lzma_decoder_create(&lz->coder->lzma,
- allocator, options, lz_options);
-}
-
-
-extern lzma_ret
-lzma_lzma2_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- // LZMA2 can only be the last filter in the chain. This is enforced
- // by the raw_decoder initialization.
- assert(filters[1].init == NULL);
-
- return lzma_lz_decoder_init(next, allocator, filters,
- &lzma2_decoder_init);
-}
-
-
-extern uint64_t
-lzma_lzma2_decoder_memusage(const void *options)
-{
- return sizeof(lzma_coder)
- + lzma_lzma_decoder_memusage_nocheck(options);
-}
-
-
-extern lzma_ret
-lzma_lzma2_props_decode(void **options, lzma_allocator *allocator,
- const uint8_t *props, size_t props_size)
-{
- if (props_size != 1)
- return LZMA_OPTIONS_ERROR;
-
- // Check that reserved bits are unset.
- if (props[0] & 0xC0)
- return LZMA_OPTIONS_ERROR;
-
- // Decode the dictionary size.
- if (props[0] > 40)
- return LZMA_OPTIONS_ERROR;
-
- lzma_options_lzma *opt = lzma_alloc(
- sizeof(lzma_options_lzma), allocator);
- if (opt == NULL)
- return LZMA_MEM_ERROR;
-
- if (props[0] == 40) {
- opt->dict_size = UINT32_MAX;
- } else {
- opt->dict_size = 2 | (props[0] & 1);
- opt->dict_size <<= props[0] / 2 + 11;
- }
-
- opt->preset_dict = NULL;
- opt->preset_dict_size = 0;
-
- *options = opt;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma2_decoder.h r-base-3.3.1/src/extra/xz/lzma/lzma2_decoder.h
--- r-base-3.2.3/src/extra/xz/lzma/lzma2_decoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma2_decoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,28 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma2_decoder.h
-/// \brief LZMA2 decoder
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_LZMA2_DECODER_H
-#define LZMA_LZMA2_DECODER_H
-
-#include "common.h"
-
-extern lzma_ret lzma_lzma2_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-extern uint64_t lzma_lzma2_decoder_memusage(const void *options);
-
-extern lzma_ret lzma_lzma2_props_decode(
- void **options, lzma_allocator *allocator,
- const uint8_t *props, size_t props_size);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma2_encoder.c r-base-3.3.1/src/extra/xz/lzma/lzma2_encoder.c
--- r-base-3.2.3/src/extra/xz/lzma/lzma2_encoder.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma2_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,393 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma2_encoder.c
-/// \brief LZMA2 encoder
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "lz_encoder.h"
-#include "lzma_encoder.h"
-#include "fastpos.h"
-#include "lzma2_encoder.h"
-
-
-struct lzma_coder_s {
- enum {
- SEQ_INIT,
- SEQ_LZMA_ENCODE,
- SEQ_LZMA_COPY,
- SEQ_UNCOMPRESSED_HEADER,
- SEQ_UNCOMPRESSED_COPY,
- } sequence;
-
- /// LZMA encoder
- lzma_coder *lzma;
-
- /// LZMA options currently in use.
- lzma_options_lzma opt_cur;
-
- bool need_properties;
- bool need_state_reset;
- bool need_dictionary_reset;
-
- /// Uncompressed size of a chunk
- size_t uncompressed_size;
-
- /// Compressed size of a chunk (excluding headers); this is also used
- /// to indicate the end of buf[] in SEQ_LZMA_COPY.
- size_t compressed_size;
-
- /// Read position in buf[]
- size_t buf_pos;
-
- /// Buffer to hold the chunk header and LZMA compressed data
- uint8_t buf[LZMA2_HEADER_MAX + LZMA2_CHUNK_MAX];
-};
-
-
-static void
-lzma2_header_lzma(lzma_coder *coder)
-{
- assert(coder->uncompressed_size > 0);
- assert(coder->uncompressed_size <= LZMA2_UNCOMPRESSED_MAX);
- assert(coder->compressed_size > 0);
- assert(coder->compressed_size <= LZMA2_CHUNK_MAX);
-
- size_t pos;
-
- if (coder->need_properties) {
- pos = 0;
-
- if (coder->need_dictionary_reset)
- coder->buf[pos] = 0x80 + (3 << 5);
- else
- coder->buf[pos] = 0x80 + (2 << 5);
- } else {
- pos = 1;
-
- if (coder->need_state_reset)
- coder->buf[pos] = 0x80 + (1 << 5);
- else
- coder->buf[pos] = 0x80;
- }
-
- // Set the start position for copying.
- coder->buf_pos = pos;
-
- // Uncompressed size
- size_t size = coder->uncompressed_size - 1;
- coder->buf[pos++] += size >> 16;
- coder->buf[pos++] = (size >> 8) & 0xFF;
- coder->buf[pos++] = size & 0xFF;
-
- // Compressed size
- size = coder->compressed_size - 1;
- coder->buf[pos++] = size >> 8;
- coder->buf[pos++] = size & 0xFF;
-
- // Properties, if needed
- if (coder->need_properties)
- lzma_lzma_lclppb_encode(&coder->opt_cur, coder->buf + pos);
-
- coder->need_properties = false;
- coder->need_state_reset = false;
- coder->need_dictionary_reset = false;
-
- // The copying code uses coder->compressed_size to indicate the end
- // of coder->buf[], so we need add the maximum size of the header here.
- coder->compressed_size += LZMA2_HEADER_MAX;
-
- return;
-}
-
-
-static void
-lzma2_header_uncompressed(lzma_coder *coder)
-{
- assert(coder->uncompressed_size > 0);
- assert(coder->uncompressed_size <= LZMA2_CHUNK_MAX);
-
- // If this is the first chunk, we need to include dictionary
- // reset indicator.
- if (coder->need_dictionary_reset)
- coder->buf[0] = 1;
- else
- coder->buf[0] = 2;
-
- coder->need_dictionary_reset = false;
-
- // "Compressed" size
- coder->buf[1] = (coder->uncompressed_size - 1) >> 8;
- coder->buf[2] = (coder->uncompressed_size - 1) & 0xFF;
-
- // Set the start position for copying.
- coder->buf_pos = 0;
- return;
-}
-
-
-static lzma_ret
-lzma2_encode(lzma_coder *restrict coder, lzma_mf *restrict mf,
- uint8_t *restrict out, size_t *restrict out_pos,
- size_t out_size)
-{
- while (*out_pos < out_size)
- switch (coder->sequence) {
- case SEQ_INIT:
- // If there's no input left and we are flushing or finishing,
- // don't start a new chunk.
- if (mf_unencoded(mf) == 0) {
- // Write end of payload marker if finishing.
- if (mf->action == LZMA_FINISH)
- out[(*out_pos)++] = 0;
-
- return mf->action == LZMA_RUN
- ? LZMA_OK : LZMA_STREAM_END;
- }
-
- if (coder->need_state_reset)
- return_if_error(lzma_lzma_encoder_reset(
- coder->lzma, &coder->opt_cur));
-
- coder->uncompressed_size = 0;
- coder->compressed_size = 0;
- coder->sequence = SEQ_LZMA_ENCODE;
-
- // Fall through
-
- case SEQ_LZMA_ENCODE: {
- // Calculate how much more uncompressed data this chunk
- // could accept.
- const uint32_t left = LZMA2_UNCOMPRESSED_MAX
- - coder->uncompressed_size;
- uint32_t limit;
-
- if (left < mf->match_len_max) {
- // Must flush immediately since the next LZMA symbol
- // could make the uncompressed size of the chunk too
- // big.
- limit = 0;
- } else {
- // Calculate maximum read_limit that is OK from point
- // of view of LZMA2 chunk size.
- limit = mf->read_pos - mf->read_ahead
- + left - mf->match_len_max;
- }
-
- // Save the start position so that we can update
- // coder->uncompressed_size.
- const uint32_t read_start = mf->read_pos - mf->read_ahead;
-
- // Call the LZMA encoder until the chunk is finished.
- const lzma_ret ret = lzma_lzma_encode(coder->lzma, mf,
- coder->buf + LZMA2_HEADER_MAX,
- &coder->compressed_size,
- LZMA2_CHUNK_MAX, limit);
-
- coder->uncompressed_size += mf->read_pos - mf->read_ahead
- - read_start;
-
- assert(coder->compressed_size <= LZMA2_CHUNK_MAX);
- assert(coder->uncompressed_size <= LZMA2_UNCOMPRESSED_MAX);
-
- if (ret != LZMA_STREAM_END)
- return LZMA_OK;
-
- // See if the chunk compressed. If it didn't, we encode it
- // as uncompressed chunk. This saves a few bytes of space
- // and makes decoding faster.
- if (coder->compressed_size >= coder->uncompressed_size) {
- coder->uncompressed_size += mf->read_ahead;
- assert(coder->uncompressed_size
- <= LZMA2_UNCOMPRESSED_MAX);
- mf->read_ahead = 0;
- lzma2_header_uncompressed(coder);
- coder->need_state_reset = true;
- coder->sequence = SEQ_UNCOMPRESSED_HEADER;
- break;
- }
-
- // The chunk did compress at least by one byte, so we store
- // the chunk as LZMA.
- lzma2_header_lzma(coder);
-
- coder->sequence = SEQ_LZMA_COPY;
- }
-
- // Fall through
-
- case SEQ_LZMA_COPY:
- // Copy the compressed chunk along its headers to the
- // output buffer.
- lzma_bufcpy(coder->buf, &coder->buf_pos,
- coder->compressed_size,
- out, out_pos, out_size);
- if (coder->buf_pos != coder->compressed_size)
- return LZMA_OK;
-
- coder->sequence = SEQ_INIT;
- break;
-
- case SEQ_UNCOMPRESSED_HEADER:
- // Copy the three-byte header to indicate uncompressed chunk.
- lzma_bufcpy(coder->buf, &coder->buf_pos,
- LZMA2_HEADER_UNCOMPRESSED,
- out, out_pos, out_size);
- if (coder->buf_pos != LZMA2_HEADER_UNCOMPRESSED)
- return LZMA_OK;
-
- coder->sequence = SEQ_UNCOMPRESSED_COPY;
-
- // Fall through
-
- case SEQ_UNCOMPRESSED_COPY:
- // Copy the uncompressed data as is from the dictionary
- // to the output buffer.
- mf_read(mf, out, out_pos, out_size, &coder->uncompressed_size);
- if (coder->uncompressed_size != 0)
- return LZMA_OK;
-
- coder->sequence = SEQ_INIT;
- break;
- }
-
- return LZMA_OK;
-}
-
-
-static void
-lzma2_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_free(coder->lzma, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-static lzma_ret
-lzma2_encoder_options_update(lzma_coder *coder, const lzma_filter *filter)
-{
- // New options can be set only when there is no incomplete chunk.
- // This is the case at the beginning of the raw stream and right
- // after LZMA_SYNC_FLUSH.
- if (filter->options == NULL || coder->sequence != SEQ_INIT)
- return LZMA_PROG_ERROR;
-
- // Look if there are new options. At least for now,
- // only lc/lp/pb can be changed.
- const lzma_options_lzma *opt = filter->options;
- if (coder->opt_cur.lc != opt->lc || coder->opt_cur.lp != opt->lp
- || coder->opt_cur.pb != opt->pb) {
- // Validate the options.
- if (opt->lc > LZMA_LCLP_MAX || opt->lp > LZMA_LCLP_MAX
- || opt->lc + opt->lp > LZMA_LCLP_MAX
- || opt->pb > LZMA_PB_MAX)
- return LZMA_OPTIONS_ERROR;
-
- // The new options will be used when the encoder starts
- // a new LZMA2 chunk.
- coder->opt_cur.lc = opt->lc;
- coder->opt_cur.lp = opt->lp;
- coder->opt_cur.pb = opt->pb;
- coder->need_properties = true;
- coder->need_state_reset = true;
- }
-
- return LZMA_OK;
-}
-
-
-static lzma_ret
-lzma2_encoder_init(lzma_lz_encoder *lz, lzma_allocator *allocator,
- const void *options, lzma_lz_options *lz_options)
-{
- if (options == NULL)
- return LZMA_PROG_ERROR;
-
- if (lz->coder == NULL) {
- lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (lz->coder == NULL)
- return LZMA_MEM_ERROR;
-
- lz->code = &lzma2_encode;
- lz->end = &lzma2_encoder_end;
- lz->options_update = &lzma2_encoder_options_update;
-
- lz->coder->lzma = NULL;
- }
-
- lz->coder->opt_cur = *(const lzma_options_lzma *)(options);
-
- lz->coder->sequence = SEQ_INIT;
- lz->coder->need_properties = true;
- lz->coder->need_state_reset = false;
- lz->coder->need_dictionary_reset
- = lz->coder->opt_cur.preset_dict == NULL
- || lz->coder->opt_cur.preset_dict_size == 0;
-
- // Initialize LZMA encoder
- return_if_error(lzma_lzma_encoder_create(&lz->coder->lzma, allocator,
- &lz->coder->opt_cur, lz_options));
-
- // Make sure that we will always have enough history available in
- // case we need to use uncompressed chunks. They are used when the
- // compressed size of a chunk is not smaller than the uncompressed
- // size, so we need to have at least LZMA2_COMPRESSED_MAX bytes
- // history available.
- if (lz_options->before_size + lz_options->dict_size < LZMA2_CHUNK_MAX)
- lz_options->before_size
- = LZMA2_CHUNK_MAX - lz_options->dict_size;
-
- return LZMA_OK;
-}
-
-
-extern lzma_ret
-lzma_lzma2_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- return lzma_lz_encoder_init(
- next, allocator, filters, &lzma2_encoder_init);
-}
-
-
-extern uint64_t
-lzma_lzma2_encoder_memusage(const void *options)
-{
- const uint64_t lzma_mem = lzma_lzma_encoder_memusage(options);
- if (lzma_mem == UINT64_MAX)
- return UINT64_MAX;
-
- return sizeof(lzma_coder) + lzma_mem;
-}
-
-
-extern lzma_ret
-lzma_lzma2_props_encode(const void *options, uint8_t *out)
-{
- const lzma_options_lzma *const opt = options;
- uint32_t d = my_max(opt->dict_size, LZMA_DICT_SIZE_MIN);
-
- // Round up to the next 2^n - 1 or 2^n + 2^(n - 1) - 1 depending
- // on which one is the next:
- --d;
- d |= d >> 2;
- d |= d >> 3;
- d |= d >> 4;
- d |= d >> 8;
- d |= d >> 16;
-
- // Get the highest two bits using the proper encoding:
- if (d == UINT32_MAX)
- out[0] = 40;
- else
- out[0] = get_pos_slot(d + 1) - 24;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma2_encoder.h r-base-3.3.1/src/extra/xz/lzma/lzma2_encoder.h
--- r-base-3.2.3/src/extra/xz/lzma/lzma2_encoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma2_encoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,41 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma2_encoder.h
-/// \brief LZMA2 encoder
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_LZMA2_ENCODER_H
-#define LZMA_LZMA2_ENCODER_H
-
-#include "common.h"
-
-
-/// Maximum number of bytes of actual data per chunk (no headers)
-#define LZMA2_CHUNK_MAX (UINT32_C(1) << 16)
-
-/// Maximum uncompressed size of LZMA chunk (no headers)
-#define LZMA2_UNCOMPRESSED_MAX (UINT32_C(1) << 21)
-
-/// Maximum size of LZMA2 headers
-#define LZMA2_HEADER_MAX 6
-
-/// Size of a header for uncompressed chunk
-#define LZMA2_HEADER_UNCOMPRESSED 3
-
-
-extern lzma_ret lzma_lzma2_encoder_init(
- lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters);
-
-extern uint64_t lzma_lzma2_encoder_memusage(const void *options);
-
-extern lzma_ret lzma_lzma2_props_encode(const void *options, uint8_t *out);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma_common.h r-base-3.3.1/src/extra/xz/lzma/lzma_common.h
--- r-base-3.2.3/src/extra/xz/lzma/lzma_common.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma_common.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,223 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma_common.h
-/// \brief Private definitions common to LZMA encoder and decoder
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_LZMA_COMMON_H
-#define LZMA_LZMA_COMMON_H
-
-#include "common.h"
-#include "range_common.h"
-
-
-///////////////////
-// Miscellaneous //
-///////////////////
-
-/// Maximum number of position states. A position state is the lowest pos bits
-/// number of bits of the current uncompressed offset. In some places there
-/// are different sets of probabilities for different pos states.
-#define POS_STATES_MAX (1 << LZMA_PB_MAX)
-
-
-/// Validates lc, lp, and pb.
-static inline bool
-is_lclppb_valid(const lzma_options_lzma *options)
-{
- return options->lc <= LZMA_LCLP_MAX && options->lp <= LZMA_LCLP_MAX
- && options->lc + options->lp <= LZMA_LCLP_MAX
- && options->pb <= LZMA_PB_MAX;
-}
-
-
-///////////
-// State //
-///////////
-
-/// This enum is used to track which events have occurred most recently and
-/// in which order. This information is used to predict the next event.
-///
-/// Events:
-/// - Literal: One 8-bit byte
-/// - Match: Repeat a chunk of data at some distance
-/// - Long repeat: Multi-byte match at a recently seen distance
-/// - Short repeat: One-byte repeat at a recently seen distance
-///
-/// The event names are in from STATE_oldest_older_previous. REP means
-/// either short or long repeated match, and NONLIT means any non-literal.
-typedef enum {
- STATE_LIT_LIT,
- STATE_MATCH_LIT_LIT,
- STATE_REP_LIT_LIT,
- STATE_SHORTREP_LIT_LIT,
- STATE_MATCH_LIT,
- STATE_REP_LIT,
- STATE_SHORTREP_LIT,
- STATE_LIT_MATCH,
- STATE_LIT_LONGREP,
- STATE_LIT_SHORTREP,
- STATE_NONLIT_MATCH,
- STATE_NONLIT_REP,
-} lzma_lzma_state;
-
-
-/// Total number of states
-#define STATES 12
-
-/// The lowest 7 states indicate that the previous state was a literal.
-#define LIT_STATES 7
-
-
-/// Indicate that the latest state was a literal.
-#define update_literal(state) \
- state = ((state) <= STATE_SHORTREP_LIT_LIT \
- ? STATE_LIT_LIT \
- : ((state) <= STATE_LIT_SHORTREP \
- ? (state) - 3 \
- : (state) - 6))
-
-/// Indicate that the latest state was a match.
-#define update_match(state) \
- state = ((state) < LIT_STATES ? STATE_LIT_MATCH : STATE_NONLIT_MATCH)
-
-/// Indicate that the latest state was a long repeated match.
-#define update_long_rep(state) \
- state = ((state) < LIT_STATES ? STATE_LIT_LONGREP : STATE_NONLIT_REP)
-
-/// Indicate that the latest state was a short match.
-#define update_short_rep(state) \
- state = ((state) < LIT_STATES ? STATE_LIT_SHORTREP : STATE_NONLIT_REP)
-
-/// Test if the previous state was a literal.
-#define is_literal_state(state) \
- ((state) < LIT_STATES)
-
-
-/////////////
-// Literal //
-/////////////
-
-/// Each literal coder is divided in three sections:
-/// - 0x001-0x0FF: Without match byte
-/// - 0x101-0x1FF: With match byte; match bit is 0
-/// - 0x201-0x2FF: With match byte; match bit is 1
-///
-/// Match byte is used when the previous LZMA symbol was something else than
-/// a literal (that is, it was some kind of match).
-#define LITERAL_CODER_SIZE 0x300
-
-/// Maximum number of literal coders
-#define LITERAL_CODERS_MAX (1 << LZMA_LCLP_MAX)
-
-/// Locate the literal coder for the next literal byte. The choice depends on
-/// - the lowest literal_pos_bits bits of the position of the current
-/// byte; and
-/// - the highest literal_context_bits bits of the previous byte.
-#define literal_subcoder(probs, lc, lp_mask, pos, prev_byte) \
- ((probs)[(((pos) & lp_mask) << lc) + ((prev_byte) >> (8 - lc))])
-
-
-static inline void
-literal_init(probability (*probs)[LITERAL_CODER_SIZE],
- uint32_t lc, uint32_t lp)
-{
- assert(lc + lp <= LZMA_LCLP_MAX);
-
- const uint32_t coders = 1U << (lc + lp);
-
- for (uint32_t i = 0; i < coders; ++i)
- for (uint32_t j = 0; j < LITERAL_CODER_SIZE; ++j)
- bit_reset(probs[i][j]);
-
- return;
-}
-
-
-//////////////////
-// Match length //
-//////////////////
-
-// Minimum length of a match is two bytes.
-#define MATCH_LEN_MIN 2
-
-// Match length is encoded with 4, 5, or 10 bits.
-//
-// Length Bits
-// 2-9 4 = Choice=0 + 3 bits
-// 10-17 5 = Choice=1 + Choice2=0 + 3 bits
-// 18-273 10 = Choice=1 + Choice2=1 + 8 bits
-#define LEN_LOW_BITS 3
-#define LEN_LOW_SYMBOLS (1 << LEN_LOW_BITS)
-#define LEN_MID_BITS 3
-#define LEN_MID_SYMBOLS (1 << LEN_MID_BITS)
-#define LEN_HIGH_BITS 8
-#define LEN_HIGH_SYMBOLS (1 << LEN_HIGH_BITS)
-#define LEN_SYMBOLS (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS)
-
-// Maximum length of a match is 273 which is a result of the encoding
-// described above.
-#define MATCH_LEN_MAX (MATCH_LEN_MIN + LEN_SYMBOLS - 1)
-
-
-////////////////////
-// Match distance //
-////////////////////
-
-// Different set of probabilities is used for match distances that have very
-// short match length: Lengths of 2, 3, and 4 bytes have a separate set of
-// probabilities for each length. The matches with longer length use a shared
-// set of probabilities.
-#define LEN_TO_POS_STATES 4
-
-// Macro to get the index of the appropriate probability array.
-#define get_len_to_pos_state(len) \
- ((len) < LEN_TO_POS_STATES + MATCH_LEN_MIN \
- ? (len) - MATCH_LEN_MIN \
- : LEN_TO_POS_STATES - 1)
-
-// The highest two bits of a match distance (pos slot) are encoded using six
-// bits. See fastpos.h for more explanation.
-#define POS_SLOT_BITS 6
-#define POS_SLOTS (1 << POS_SLOT_BITS)
-
-// Match distances up to 127 are fully encoded using probabilities. Since
-// the highest two bits (pos slot) are always encoded using six bits, the
-// distances 0-3 don't need any additional bits to encode, since the pos
-// slot itself is the same as the actual distance. START_POS_MODEL_INDEX
-// indicates the first pos slot where at least one additional bit is needed.
-#define START_POS_MODEL_INDEX 4
-
-// Match distances greater than 127 are encoded in three pieces:
-// - pos slot: the highest two bits
-// - direct bits: 2-26 bits below the highest two bits
-// - alignment bits: four lowest bits
-//
-// Direct bits don't use any probabilities.
-//
-// The pos slot value of 14 is for distances 128-191 (see the table in
-// fastpos.h to understand why).
-#define END_POS_MODEL_INDEX 14
-
-// Pos slots that indicate a distance <= 127.
-#define FULL_DISTANCES_BITS (END_POS_MODEL_INDEX / 2)
-#define FULL_DISTANCES (1 << FULL_DISTANCES_BITS)
-
-// For match distances greater than 127, only the highest two bits and the
-// lowest four bits (alignment) is encoded using probabilities.
-#define ALIGN_BITS 4
-#define ALIGN_TABLE_SIZE (1 << ALIGN_BITS)
-#define ALIGN_MASK (ALIGN_TABLE_SIZE - 1)
-
-// LZMA remembers the four most recent match distances. Reusing these distances
-// tends to take less space than re-encoding the actual distance value.
-#define REP_DISTANCES 4
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma_decoder.c r-base-3.3.1/src/extra/xz/lzma/lzma_decoder.c
--- r-base-3.2.3/src/extra/xz/lzma/lzma_decoder.c 2010-11-08 23:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,1057 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma_decoder.c
-/// \brief LZMA decoder
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "lz_decoder.h"
-#include "lzma_common.h"
-#include "lzma_decoder.h"
-#include "range_decoder.h"
-
-
-#ifdef HAVE_SMALL
-
-// Macros for (somewhat) size-optimized code.
-#define seq_4(seq) seq
-
-#define seq_6(seq) seq
-
-#define seq_8(seq) seq
-
-#define seq_len(seq) \
- seq ## _CHOICE, \
- seq ## _CHOICE2, \
- seq ## _BITTREE
-
-#define len_decode(target, ld, pos_state, seq) \
-do { \
-case seq ## _CHOICE: \
- rc_if_0(ld.choice, seq ## _CHOICE) { \
- rc_update_0(ld.choice); \
- probs = ld.low[pos_state];\
- limit = LEN_LOW_SYMBOLS; \
- target = MATCH_LEN_MIN; \
- } else { \
- rc_update_1(ld.choice); \
-case seq ## _CHOICE2: \
- rc_if_0(ld.choice2, seq ## _CHOICE2) { \
- rc_update_0(ld.choice2); \
- probs = ld.mid[pos_state]; \
- limit = LEN_MID_SYMBOLS; \
- target = MATCH_LEN_MIN + LEN_LOW_SYMBOLS; \
- } else { \
- rc_update_1(ld.choice2); \
- probs = ld.high; \
- limit = LEN_HIGH_SYMBOLS; \
- target = MATCH_LEN_MIN + LEN_LOW_SYMBOLS \
- + LEN_MID_SYMBOLS; \
- } \
- } \
- symbol = 1; \
-case seq ## _BITTREE: \
- do { \
- rc_bit(probs[symbol], , , seq ## _BITTREE); \
- } while (symbol < limit); \
- target += symbol - limit; \
-} while (0)
-
-#else // HAVE_SMALL
-
-// Unrolled versions
-#define seq_4(seq) \
- seq ## 0, \
- seq ## 1, \
- seq ## 2, \
- seq ## 3
-
-#define seq_6(seq) \
- seq ## 0, \
- seq ## 1, \
- seq ## 2, \
- seq ## 3, \
- seq ## 4, \
- seq ## 5
-
-#define seq_8(seq) \
- seq ## 0, \
- seq ## 1, \
- seq ## 2, \
- seq ## 3, \
- seq ## 4, \
- seq ## 5, \
- seq ## 6, \
- seq ## 7
-
-#define seq_len(seq) \
- seq ## _CHOICE, \
- seq ## _LOW0, \
- seq ## _LOW1, \
- seq ## _LOW2, \
- seq ## _CHOICE2, \
- seq ## _MID0, \
- seq ## _MID1, \
- seq ## _MID2, \
- seq ## _HIGH0, \
- seq ## _HIGH1, \
- seq ## _HIGH2, \
- seq ## _HIGH3, \
- seq ## _HIGH4, \
- seq ## _HIGH5, \
- seq ## _HIGH6, \
- seq ## _HIGH7
-
-#define len_decode(target, ld, pos_state, seq) \
-do { \
- symbol = 1; \
-case seq ## _CHOICE: \
- rc_if_0(ld.choice, seq ## _CHOICE) { \
- rc_update_0(ld.choice); \
- rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW0); \
- rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW1); \
- rc_bit_case(ld.low[pos_state][symbol], , , seq ## _LOW2); \
- target = symbol - LEN_LOW_SYMBOLS + MATCH_LEN_MIN; \
- } else { \
- rc_update_1(ld.choice); \
-case seq ## _CHOICE2: \
- rc_if_0(ld.choice2, seq ## _CHOICE2) { \
- rc_update_0(ld.choice2); \
- rc_bit_case(ld.mid[pos_state][symbol], , , \
- seq ## _MID0); \
- rc_bit_case(ld.mid[pos_state][symbol], , , \
- seq ## _MID1); \
- rc_bit_case(ld.mid[pos_state][symbol], , , \
- seq ## _MID2); \
- target = symbol - LEN_MID_SYMBOLS \
- + MATCH_LEN_MIN + LEN_LOW_SYMBOLS; \
- } else { \
- rc_update_1(ld.choice2); \
- rc_bit_case(ld.high[symbol], , , seq ## _HIGH0); \
- rc_bit_case(ld.high[symbol], , , seq ## _HIGH1); \
- rc_bit_case(ld.high[symbol], , , seq ## _HIGH2); \
- rc_bit_case(ld.high[symbol], , , seq ## _HIGH3); \
- rc_bit_case(ld.high[symbol], , , seq ## _HIGH4); \
- rc_bit_case(ld.high[symbol], , , seq ## _HIGH5); \
- rc_bit_case(ld.high[symbol], , , seq ## _HIGH6); \
- rc_bit_case(ld.high[symbol], , , seq ## _HIGH7); \
- target = symbol - LEN_HIGH_SYMBOLS \
- + MATCH_LEN_MIN \
- + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS; \
- } \
- } \
-} while (0)
-
-#endif // HAVE_SMALL
-
-
-/// Length decoder probabilities; see comments in lzma_common.h.
-typedef struct {
- probability choice;
- probability choice2;
- probability low[POS_STATES_MAX][LEN_LOW_SYMBOLS];
- probability mid[POS_STATES_MAX][LEN_MID_SYMBOLS];
- probability high[LEN_HIGH_SYMBOLS];
-} lzma_length_decoder;
-
-
-struct lzma_coder_s {
- ///////////////////
- // Probabilities //
- ///////////////////
-
- /// Literals; see comments in lzma_common.h.
- probability literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE];
-
- /// If 1, it's a match. Otherwise it's a single 8-bit literal.
- probability is_match[STATES][POS_STATES_MAX];
-
- /// If 1, it's a repeated match. The distance is one of rep0 .. rep3.
- probability is_rep[STATES];
-
- /// If 0, distance of a repeated match is rep0.
- /// Otherwise check is_rep1.
- probability is_rep0[STATES];
-
- /// If 0, distance of a repeated match is rep1.
- /// Otherwise check is_rep2.
- probability is_rep1[STATES];
-
- /// If 0, distance of a repeated match is rep2. Otherwise it is rep3.
- probability is_rep2[STATES];
-
- /// If 1, the repeated match has length of one byte. Otherwise
- /// the length is decoded from rep_len_decoder.
- probability is_rep0_long[STATES][POS_STATES_MAX];
-
- /// Probability tree for the highest two bits of the match distance.
- /// There is a separate probability tree for match lengths of
- /// 2 (i.e. MATCH_LEN_MIN), 3, 4, and [5, 273].
- probability pos_slot[LEN_TO_POS_STATES][POS_SLOTS];
-
- /// Probability trees for additional bits for match distance when the
- /// distance is in the range [4, 127].
- probability pos_special[FULL_DISTANCES - END_POS_MODEL_INDEX];
-
- /// Probability tree for the lowest four bits of a match distance
- /// that is equal to or greater than 128.
- probability pos_align[ALIGN_TABLE_SIZE];
-
- /// Length of a normal match
- lzma_length_decoder match_len_decoder;
-
- /// Length of a repeated match
- lzma_length_decoder rep_len_decoder;
-
- ///////////////////
- // Decoder state //
- ///////////////////
-
- // Range coder
- lzma_range_decoder rc;
-
- // Types of the most recently seen LZMA symbols
- lzma_lzma_state state;
-
- uint32_t rep0; ///< Distance of the latest match
- uint32_t rep1; ///< Distance of second latest match
- uint32_t rep2; ///< Distance of third latest match
- uint32_t rep3; ///< Distance of fourth latest match
-
- uint32_t pos_mask; // (1U << pb) - 1
- uint32_t literal_context_bits;
- uint32_t literal_pos_mask;
-
- /// Uncompressed size as bytes, or LZMA_VLI_UNKNOWN if end of
- /// payload marker is expected.
- lzma_vli uncompressed_size;
-
- ////////////////////////////////
- // State of incomplete symbol //
- ////////////////////////////////
-
- /// Position where to continue the decoder loop
- enum {
- SEQ_NORMALIZE,
- SEQ_IS_MATCH,
- seq_8(SEQ_LITERAL),
- seq_8(SEQ_LITERAL_MATCHED),
- SEQ_LITERAL_WRITE,
- SEQ_IS_REP,
- seq_len(SEQ_MATCH_LEN),
- seq_6(SEQ_POS_SLOT),
- SEQ_POS_MODEL,
- SEQ_DIRECT,
- seq_4(SEQ_ALIGN),
- SEQ_EOPM,
- SEQ_IS_REP0,
- SEQ_SHORTREP,
- SEQ_IS_REP0_LONG,
- SEQ_IS_REP1,
- SEQ_IS_REP2,
- seq_len(SEQ_REP_LEN),
- SEQ_COPY,
- } sequence;
-
- /// Base of the current probability tree
- probability *probs;
-
- /// Symbol being decoded. This is also used as an index variable in
- /// bittree decoders: probs[symbol]
- uint32_t symbol;
-
- /// Used as a loop termination condition on bittree decoders and
- /// direct bits decoder.
- uint32_t limit;
-
- /// Matched literal decoder: 0x100 or 0 to help avoiding branches.
- /// Bittree reverse decoders: Offset of the next bit: 1 << offset
- uint32_t offset;
-
- /// If decoding a literal: match byte.
- /// If decoding a match: length of the match.
- uint32_t len;
-};
-
-
-static lzma_ret
-lzma_decode(lzma_coder *restrict coder, lzma_dict *restrict dictptr,
- const uint8_t *restrict in,
- size_t *restrict in_pos, size_t in_size)
-{
- ////////////////////
- // Initialization //
- ////////////////////
-
- if (!rc_read_init(&coder->rc, in, in_pos, in_size))
- return LZMA_OK;
-
- ///////////////
- // Variables //
- ///////////////
-
- // Making local copies of often-used variables improves both
- // speed and readability.
-
- lzma_dict dict = *dictptr;
-
- const size_t dict_start = dict.pos;
-
- // Range decoder
- rc_to_local(coder->rc, *in_pos);
-
- // State
- uint32_t state = coder->state;
- uint32_t rep0 = coder->rep0;
- uint32_t rep1 = coder->rep1;
- uint32_t rep2 = coder->rep2;
- uint32_t rep3 = coder->rep3;
-
- const uint32_t pos_mask = coder->pos_mask;
-
- // These variables are actually needed only if we last time ran
- // out of input in the middle of the decoder loop.
- probability *probs = coder->probs;
- uint32_t symbol = coder->symbol;
- uint32_t limit = coder->limit;
- uint32_t offset = coder->offset;
- uint32_t len = coder->len;
-
- const uint32_t literal_pos_mask = coder->literal_pos_mask;
- const uint32_t literal_context_bits = coder->literal_context_bits;
-
- // Temporary variables
- uint32_t pos_state = dict.pos & pos_mask;
-
- lzma_ret ret = LZMA_OK;
-
- // If uncompressed size is known, there must be no end of payload
- // marker.
- const bool no_eopm = coder->uncompressed_size
- != LZMA_VLI_UNKNOWN;
- if (no_eopm && coder->uncompressed_size < dict.limit - dict.pos)
- dict.limit = dict.pos + (size_t)(coder->uncompressed_size);
-
- // The main decoder loop. The "switch" is used to restart the decoder at
- // correct location. Once restarted, the "switch" is no longer used.
- switch (coder->sequence)
- while (true) {
- // Calculate new pos_state. This is skipped on the first loop
- // since we already calculated it when setting up the local
- // variables.
- pos_state = dict.pos & pos_mask;
-
- case SEQ_NORMALIZE:
- case SEQ_IS_MATCH:
- if (unlikely(no_eopm && dict.pos == dict.limit))
- break;
-
- rc_if_0(coder->is_match[state][pos_state], SEQ_IS_MATCH) {
- rc_update_0(coder->is_match[state][pos_state]);
-
- // It's a literal i.e. a single 8-bit byte.
-
- probs = literal_subcoder(coder->literal,
- literal_context_bits, literal_pos_mask,
- dict.pos, dict_get(&dict, 0));
- symbol = 1;
-
- if (is_literal_state(state)) {
- // Decode literal without match byte.
-#ifdef HAVE_SMALL
- case SEQ_LITERAL:
- do {
- rc_bit(probs[symbol], , , SEQ_LITERAL);
- } while (symbol < (1 << 8));
-#else
- rc_bit_case(probs[symbol], , , SEQ_LITERAL0);
- rc_bit_case(probs[symbol], , , SEQ_LITERAL1);
- rc_bit_case(probs[symbol], , , SEQ_LITERAL2);
- rc_bit_case(probs[symbol], , , SEQ_LITERAL3);
- rc_bit_case(probs[symbol], , , SEQ_LITERAL4);
- rc_bit_case(probs[symbol], , , SEQ_LITERAL5);
- rc_bit_case(probs[symbol], , , SEQ_LITERAL6);
- rc_bit_case(probs[symbol], , , SEQ_LITERAL7);
-#endif
- } else {
- // Decode literal with match byte.
- //
- // We store the byte we compare against
- // ("match byte") to "len" to minimize the
- // number of variables we need to store
- // between decoder calls.
- len = dict_get(&dict, rep0) << 1;
-
- // The usage of "offset" allows omitting some
- // branches, which should give tiny speed
- // improvement on some CPUs. "offset" gets
- // set to zero if match_bit didn't match.
- offset = 0x100;
-
-#ifdef HAVE_SMALL
- case SEQ_LITERAL_MATCHED:
- do {
- const uint32_t match_bit
- = len & offset;
- const uint32_t subcoder_index
- = offset + match_bit
- + symbol;
-
- rc_bit(probs[subcoder_index],
- offset &= ~match_bit,
- offset &= match_bit,
- SEQ_LITERAL_MATCHED);
-
- // It seems to be faster to do this
- // here instead of putting it to the
- // beginning of the loop and then
- // putting the "case" in the middle
- // of the loop.
- len <<= 1;
-
- } while (symbol < (1 << 8));
-#else
- // Unroll the loop.
- uint32_t match_bit;
- uint32_t subcoder_index;
-
-# define d(seq) \
- case seq: \
- match_bit = len & offset; \
- subcoder_index = offset + match_bit + symbol; \
- rc_bit(probs[subcoder_index], \
- offset &= ~match_bit, \
- offset &= match_bit, \
- seq)
-
- d(SEQ_LITERAL_MATCHED0);
- len <<= 1;
- d(SEQ_LITERAL_MATCHED1);
- len <<= 1;
- d(SEQ_LITERAL_MATCHED2);
- len <<= 1;
- d(SEQ_LITERAL_MATCHED3);
- len <<= 1;
- d(SEQ_LITERAL_MATCHED4);
- len <<= 1;
- d(SEQ_LITERAL_MATCHED5);
- len <<= 1;
- d(SEQ_LITERAL_MATCHED6);
- len <<= 1;
- d(SEQ_LITERAL_MATCHED7);
-# undef d
-#endif
- }
-
- //update_literal(state);
- // Use a lookup table to update to literal state,
- // since compared to other state updates, this would
- // need two branches.
- static const lzma_lzma_state next_state[] = {
- STATE_LIT_LIT,
- STATE_LIT_LIT,
- STATE_LIT_LIT,
- STATE_LIT_LIT,
- STATE_MATCH_LIT_LIT,
- STATE_REP_LIT_LIT,
- STATE_SHORTREP_LIT_LIT,
- STATE_MATCH_LIT,
- STATE_REP_LIT,
- STATE_SHORTREP_LIT,
- STATE_MATCH_LIT,
- STATE_REP_LIT
- };
- state = next_state[state];
-
- case SEQ_LITERAL_WRITE:
- if (unlikely(dict_put(&dict, symbol))) {
- coder->sequence = SEQ_LITERAL_WRITE;
- goto out;
- }
-
- continue;
- }
-
- // Instead of a new byte we are going to get a byte range
- // (distance and length) which will be repeated from our
- // output history.
-
- rc_update_1(coder->is_match[state][pos_state]);
-
- case SEQ_IS_REP:
- rc_if_0(coder->is_rep[state], SEQ_IS_REP) {
- // Not a repeated match
- rc_update_0(coder->is_rep[state]);
- update_match(state);
-
- // The latest three match distances are kept in
- // memory in case there are repeated matches.
- rep3 = rep2;
- rep2 = rep1;
- rep1 = rep0;
-
- // Decode the length of the match.
- len_decode(len, coder->match_len_decoder,
- pos_state, SEQ_MATCH_LEN);
-
- // Prepare to decode the highest two bits of the
- // match distance.
- probs = coder->pos_slot[get_len_to_pos_state(len)];
- symbol = 1;
-
-#ifdef HAVE_SMALL
- case SEQ_POS_SLOT:
- do {
- rc_bit(probs[symbol], , , SEQ_POS_SLOT);
- } while (symbol < POS_SLOTS);
-#else
- rc_bit_case(probs[symbol], , , SEQ_POS_SLOT0);
- rc_bit_case(probs[symbol], , , SEQ_POS_SLOT1);
- rc_bit_case(probs[symbol], , , SEQ_POS_SLOT2);
- rc_bit_case(probs[symbol], , , SEQ_POS_SLOT3);
- rc_bit_case(probs[symbol], , , SEQ_POS_SLOT4);
- rc_bit_case(probs[symbol], , , SEQ_POS_SLOT5);
-#endif
- // Get rid of the highest bit that was needed for
- // indexing of the probability array.
- symbol -= POS_SLOTS;
- assert(symbol <= 63);
-
- if (symbol < START_POS_MODEL_INDEX) {
- // Match distances [0, 3] have only two bits.
- rep0 = symbol;
- } else {
- // Decode the lowest [1, 29] bits of
- // the match distance.
- limit = (symbol >> 1) - 1;
- assert(limit >= 1 && limit <= 30);
- rep0 = 2 + (symbol & 1);
-
- if (symbol < END_POS_MODEL_INDEX) {
- // Prepare to decode the low bits for
- // a distance of [4, 127].
- assert(limit <= 5);
- rep0 <<= limit;
- assert(rep0 <= 96);
- // -1 is fine, because we start
- // decoding at probs[1], not probs[0].
- // NOTE: This violates the C standard,
- // since we are doing pointer
- // arithmetic past the beginning of
- // the array.
- assert((int32_t)(rep0 - symbol - 1)
- >= -1);
- assert((int32_t)(rep0 - symbol - 1)
- <= 82);
- probs = coder->pos_special + rep0
- - symbol - 1;
- symbol = 1;
- offset = 0;
- case SEQ_POS_MODEL:
-#ifdef HAVE_SMALL
- do {
- rc_bit(probs[symbol], ,
- rep0 += 1 << offset,
- SEQ_POS_MODEL);
- } while (++offset < limit);
-#else
- switch (limit) {
- case 5:
- assert(offset == 0);
- rc_bit(probs[symbol], ,
- rep0 += 1,
- SEQ_POS_MODEL);
- ++offset;
- --limit;
- case 4:
- rc_bit(probs[symbol], ,
- rep0 += 1 << offset,
- SEQ_POS_MODEL);
- ++offset;
- --limit;
- case 3:
- rc_bit(probs[symbol], ,
- rep0 += 1 << offset,
- SEQ_POS_MODEL);
- ++offset;
- --limit;
- case 2:
- rc_bit(probs[symbol], ,
- rep0 += 1 << offset,
- SEQ_POS_MODEL);
- ++offset;
- --limit;
- case 1:
- // We need "symbol" only for
- // indexing the probability
- // array, thus we can use
- // rc_bit_last() here to omit
- // the unneeded updating of
- // "symbol".
- rc_bit_last(probs[symbol], ,
- rep0 += 1 << offset,
- SEQ_POS_MODEL);
- }
-#endif
- } else {
- // The distance is >= 128. Decode the
- // lower bits without probabilities
- // except the lowest four bits.
- assert(symbol >= 14);
- assert(limit >= 6);
- limit -= ALIGN_BITS;
- assert(limit >= 2);
- case SEQ_DIRECT:
- // Not worth manual unrolling
- do {
- rc_direct(rep0, SEQ_DIRECT);
- } while (--limit > 0);
-
- // Decode the lowest four bits using
- // probabilities.
- rep0 <<= ALIGN_BITS;
- symbol = 1;
-#ifdef HAVE_SMALL
- offset = 0;
- case SEQ_ALIGN:
- do {
- rc_bit(coder->pos_align[
- symbol], ,
- rep0 += 1 << offset,
- SEQ_ALIGN);
- } while (++offset < ALIGN_BITS);
-#else
- case SEQ_ALIGN0:
- rc_bit(coder->pos_align[symbol], ,
- rep0 += 1, SEQ_ALIGN0);
- case SEQ_ALIGN1:
- rc_bit(coder->pos_align[symbol], ,
- rep0 += 2, SEQ_ALIGN1);
- case SEQ_ALIGN2:
- rc_bit(coder->pos_align[symbol], ,
- rep0 += 4, SEQ_ALIGN2);
- case SEQ_ALIGN3:
- // Like in SEQ_POS_MODEL, we don't
- // need "symbol" for anything else
- // than indexing the probability array.
- rc_bit_last(coder->pos_align[symbol], ,
- rep0 += 8, SEQ_ALIGN3);
-#endif
-
- if (rep0 == UINT32_MAX) {
- // End of payload marker was
- // found. It must not be
- // present if uncompressed
- // size is known.
- if (coder->uncompressed_size
- != LZMA_VLI_UNKNOWN) {
- ret = LZMA_DATA_ERROR;
- goto out;
- }
-
- case SEQ_EOPM:
- // LZMA1 stream with
- // end-of-payload marker.
- rc_normalize(SEQ_EOPM);
- ret = LZMA_STREAM_END;
- goto out;
- }
- }
- }
-
- // Validate the distance we just decoded.
- if (unlikely(!dict_is_distance_valid(&dict, rep0))) {
- ret = LZMA_DATA_ERROR;
- goto out;
- }
-
- } else {
- rc_update_1(coder->is_rep[state]);
-
- // Repeated match
- //
- // The match distance is a value that we have had
- // earlier. The latest four match distances are
- // available as rep0, rep1, rep2 and rep3. We will
- // now decode which of them is the new distance.
- //
- // There cannot be a match if we haven't produced
- // any output, so check that first.
- if (unlikely(!dict_is_distance_valid(&dict, 0))) {
- ret = LZMA_DATA_ERROR;
- goto out;
- }
-
- case SEQ_IS_REP0:
- rc_if_0(coder->is_rep0[state], SEQ_IS_REP0) {
- rc_update_0(coder->is_rep0[state]);
- // The distance is rep0.
-
- case SEQ_IS_REP0_LONG:
- rc_if_0(coder->is_rep0_long[state][pos_state],
- SEQ_IS_REP0_LONG) {
- rc_update_0(coder->is_rep0_long[
- state][pos_state]);
-
- update_short_rep(state);
-
- case SEQ_SHORTREP:
- if (unlikely(dict_put(&dict, dict_get(
- &dict, rep0)))) {
- coder->sequence = SEQ_SHORTREP;
- goto out;
- }
-
- continue;
- }
-
- // Repeating more than one byte at
- // distance of rep0.
- rc_update_1(coder->is_rep0_long[
- state][pos_state]);
-
- } else {
- rc_update_1(coder->is_rep0[state]);
-
- case SEQ_IS_REP1:
- // The distance is rep1, rep2 or rep3. Once
- // we find out which one of these three, it
- // is stored to rep0 and rep1, rep2 and rep3
- // are updated accordingly.
- rc_if_0(coder->is_rep1[state], SEQ_IS_REP1) {
- rc_update_0(coder->is_rep1[state]);
-
- const uint32_t distance = rep1;
- rep1 = rep0;
- rep0 = distance;
-
- } else {
- rc_update_1(coder->is_rep1[state]);
- case SEQ_IS_REP2:
- rc_if_0(coder->is_rep2[state],
- SEQ_IS_REP2) {
- rc_update_0(coder->is_rep2[
- state]);
-
- const uint32_t distance = rep2;
- rep2 = rep1;
- rep1 = rep0;
- rep0 = distance;
-
- } else {
- rc_update_1(coder->is_rep2[
- state]);
-
- const uint32_t distance = rep3;
- rep3 = rep2;
- rep2 = rep1;
- rep1 = rep0;
- rep0 = distance;
- }
- }
- }
-
- update_long_rep(state);
-
- // Decode the length of the repeated match.
- len_decode(len, coder->rep_len_decoder,
- pos_state, SEQ_REP_LEN);
- }
-
- /////////////////////////////////
- // Repeat from history buffer. //
- /////////////////////////////////
-
- // The length is always between these limits. There is no way
- // to trigger the algorithm to set len outside this range.
- assert(len >= MATCH_LEN_MIN);
- assert(len <= MATCH_LEN_MAX);
-
- case SEQ_COPY:
- // Repeat len bytes from distance of rep0.
- if (unlikely(dict_repeat(&dict, rep0, &len))) {
- coder->sequence = SEQ_COPY;
- goto out;
- }
- }
-
- rc_normalize(SEQ_NORMALIZE);
- coder->sequence = SEQ_IS_MATCH;
-
-out:
- // Save state
-
- // NOTE: Must not copy dict.limit.
- dictptr->pos = dict.pos;
- dictptr->full = dict.full;
-
- rc_from_local(coder->rc, *in_pos);
-
- coder->state = state;
- coder->rep0 = rep0;
- coder->rep1 = rep1;
- coder->rep2 = rep2;
- coder->rep3 = rep3;
-
- coder->probs = probs;
- coder->symbol = symbol;
- coder->limit = limit;
- coder->offset = offset;
- coder->len = len;
-
- // Update the remaining amount of uncompressed data if uncompressed
- // size was known.
- if (coder->uncompressed_size != LZMA_VLI_UNKNOWN) {
- coder->uncompressed_size -= dict.pos - dict_start;
-
- // Since there cannot be end of payload marker if the
- // uncompressed size was known, we check here if we
- // finished decoding.
- if (coder->uncompressed_size == 0 && ret == LZMA_OK
- && coder->sequence != SEQ_NORMALIZE)
- ret = coder->sequence == SEQ_IS_MATCH
- ? LZMA_STREAM_END : LZMA_DATA_ERROR;
- }
-
- // We can do an additional check in the range decoder to catch some
- // corrupted files.
- if (ret == LZMA_STREAM_END) {
- if (!rc_is_finished(coder->rc))
- ret = LZMA_DATA_ERROR;
-
- // Reset the range decoder so that it is ready to reinitialize
- // for a new LZMA2 chunk.
- rc_reset(coder->rc);
- }
-
- return ret;
-}
-
-
-
-static void
-lzma_decoder_uncompressed(lzma_coder *coder, lzma_vli uncompressed_size)
-{
- coder->uncompressed_size = uncompressed_size;
-}
-
-/*
-extern void
-lzma_lzma_decoder_uncompressed(void *coder_ptr, lzma_vli uncompressed_size)
-{
- // This is hack.
- (*(lzma_coder **)(coder))->uncompressed_size = uncompressed_size;
-}
-*/
-
-static void
-lzma_decoder_reset(lzma_coder *coder, const void *opt)
-{
- const lzma_options_lzma *options = opt;
-
- // NOTE: We assume that lc/lp/pb are valid since they were
- // successfully decoded with lzma_lzma_decode_properties().
-
- // Calculate pos_mask. We don't need pos_bits as is for anything.
- coder->pos_mask = (1U << options->pb) - 1;
-
- // Initialize the literal decoder.
- literal_init(coder->literal, options->lc, options->lp);
-
- coder->literal_context_bits = options->lc;
- coder->literal_pos_mask = (1U << options->lp) - 1;
-
- // State
- coder->state = STATE_LIT_LIT;
- coder->rep0 = 0;
- coder->rep1 = 0;
- coder->rep2 = 0;
- coder->rep3 = 0;
- coder->pos_mask = (1U << options->pb) - 1;
-
- // Range decoder
- rc_reset(coder->rc);
-
- // Bit and bittree decoders
- for (uint32_t i = 0; i < STATES; ++i) {
- for (uint32_t j = 0; j <= coder->pos_mask; ++j) {
- bit_reset(coder->is_match[i][j]);
- bit_reset(coder->is_rep0_long[i][j]);
- }
-
- bit_reset(coder->is_rep[i]);
- bit_reset(coder->is_rep0[i]);
- bit_reset(coder->is_rep1[i]);
- bit_reset(coder->is_rep2[i]);
- }
-
- for (uint32_t i = 0; i < LEN_TO_POS_STATES; ++i)
- bittree_reset(coder->pos_slot[i], POS_SLOT_BITS);
-
- for (uint32_t i = 0; i < FULL_DISTANCES - END_POS_MODEL_INDEX; ++i)
- bit_reset(coder->pos_special[i]);
-
- bittree_reset(coder->pos_align, ALIGN_BITS);
-
- // Len decoders (also bit/bittree)
- const uint32_t num_pos_states = 1U << options->pb;
- bit_reset(coder->match_len_decoder.choice);
- bit_reset(coder->match_len_decoder.choice2);
- bit_reset(coder->rep_len_decoder.choice);
- bit_reset(coder->rep_len_decoder.choice2);
-
- for (uint32_t pos_state = 0; pos_state < num_pos_states; ++pos_state) {
- bittree_reset(coder->match_len_decoder.low[pos_state],
- LEN_LOW_BITS);
- bittree_reset(coder->match_len_decoder.mid[pos_state],
- LEN_MID_BITS);
-
- bittree_reset(coder->rep_len_decoder.low[pos_state],
- LEN_LOW_BITS);
- bittree_reset(coder->rep_len_decoder.mid[pos_state],
- LEN_MID_BITS);
- }
-
- bittree_reset(coder->match_len_decoder.high, LEN_HIGH_BITS);
- bittree_reset(coder->rep_len_decoder.high, LEN_HIGH_BITS);
-
- coder->sequence = SEQ_IS_MATCH;
- coder->probs = NULL;
- coder->symbol = 0;
- coder->limit = 0;
- coder->offset = 0;
- coder->len = 0;
-
- return;
-}
-
-
-extern lzma_ret
-lzma_lzma_decoder_create(lzma_lz_decoder *lz, lzma_allocator *allocator,
- const void *opt, lzma_lz_options *lz_options)
-{
- if (lz->coder == NULL) {
- lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (lz->coder == NULL)
- return LZMA_MEM_ERROR;
-
- lz->code = &lzma_decode;
- lz->reset = &lzma_decoder_reset;
- lz->set_uncompressed = &lzma_decoder_uncompressed;
- }
-
- // All dictionary sizes are OK here. LZ decoder will take care of
- // the special cases.
- const lzma_options_lzma *options = opt;
- lz_options->dict_size = options->dict_size;
- lz_options->preset_dict = options->preset_dict;
- lz_options->preset_dict_size = options->preset_dict_size;
-
- return LZMA_OK;
-}
-
-
-/// Allocate and initialize LZMA decoder. This is used only via LZ
-/// initialization (lzma_lzma_decoder_init() passes function pointer to
-/// the LZ initialization).
-static lzma_ret
-lzma_decoder_init(lzma_lz_decoder *lz, lzma_allocator *allocator,
- const void *options, lzma_lz_options *lz_options)
-{
- if (!is_lclppb_valid(options))
- return LZMA_PROG_ERROR;
-
- return_if_error(lzma_lzma_decoder_create(
- lz, allocator, options, lz_options));
-
- lzma_decoder_reset(lz->coder, options);
- lzma_decoder_uncompressed(lz->coder, LZMA_VLI_UNKNOWN);
-
- return LZMA_OK;
-}
-
-
-extern lzma_ret
-lzma_lzma_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- // LZMA can only be the last filter in the chain. This is enforced
- // by the raw_decoder initialization.
- assert(filters[1].init == NULL);
-
- return lzma_lz_decoder_init(next, allocator, filters,
- &lzma_decoder_init);
-}
-
-
-extern bool
-lzma_lzma_lclppb_decode(lzma_options_lzma *options, uint8_t byte)
-{
- if (byte > (4 * 5 + 4) * 9 + 8)
- return true;
-
- // See the file format specification to understand this.
- options->pb = byte / (9 * 5);
- byte -= options->pb * 9 * 5;
- options->lp = byte / 9;
- options->lc = byte - options->lp * 9;
-
- return options->lc + options->lp > LZMA_LCLP_MAX;
-}
-
-
-extern uint64_t
-lzma_lzma_decoder_memusage_nocheck(const void *options)
-{
- const lzma_options_lzma *const opt = options;
- return sizeof(lzma_coder) + lzma_lz_decoder_memusage(opt->dict_size);
-}
-
-
-extern uint64_t
-lzma_lzma_decoder_memusage(const void *options)
-{
- if (!is_lclppb_valid(options))
- return UINT64_MAX;
-
- return lzma_lzma_decoder_memusage_nocheck(options);
-}
-
-
-extern lzma_ret
-lzma_lzma_props_decode(void **options, lzma_allocator *allocator,
- const uint8_t *props, size_t props_size)
-{
- if (props_size != 5)
- return LZMA_OPTIONS_ERROR;
-
- lzma_options_lzma *opt
- = lzma_alloc(sizeof(lzma_options_lzma), allocator);
- if (opt == NULL)
- return LZMA_MEM_ERROR;
-
- if (lzma_lzma_lclppb_decode(opt, props[0]))
- goto error;
-
- // All dictionary sizes are accepted, including zero. LZ decoder
- // will automatically use a dictionary at least a few KiB even if
- // a smaller dictionary is requested.
- opt->dict_size = unaligned_read32le(props + 1);
-
- opt->preset_dict = NULL;
- opt->preset_dict_size = 0;
-
- *options = opt;
-
- return LZMA_OK;
-
-error:
- lzma_free(opt, allocator);
- return LZMA_OPTIONS_ERROR;
-}
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma_decoder.h r-base-3.3.1/src/extra/xz/lzma/lzma_decoder.h
--- r-base-3.2.3/src/extra/xz/lzma/lzma_decoder.h 2010-11-08 23:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma_decoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,52 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma_decoder.h
-/// \brief LZMA decoder API
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_LZMA_DECODER_H
-#define LZMA_LZMA_DECODER_H
-
-#include "common.h"
-
-
-/// Allocates and initializes LZMA decoder
-extern lzma_ret lzma_lzma_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-extern uint64_t lzma_lzma_decoder_memusage(const void *options);
-
-extern lzma_ret lzma_lzma_props_decode(
- void **options, lzma_allocator *allocator,
- const uint8_t *props, size_t props_size);
-
-
-/// \brief Decodes the LZMA Properties byte (lc/lp/pb)
-///
-/// \return true if error occurred, false on success
-///
-extern bool lzma_lzma_lclppb_decode(
- lzma_options_lzma *options, uint8_t byte);
-
-
-#ifdef LZMA_LZ_DECODER_H
-/// Allocate and setup function pointers only. This is used by LZMA1 and
-/// LZMA2 decoders.
-extern lzma_ret lzma_lzma_decoder_create(
- lzma_lz_decoder *lz, lzma_allocator *allocator,
- const void *opt, lzma_lz_options *lz_options);
-
-/// Gets memory usage without validating lc/lp/pb. This is used by LZMA2
-/// decoder, because raw LZMA2 decoding doesn't need lc/lp/pb.
-extern uint64_t lzma_lzma_decoder_memusage_nocheck(const void *options);
-
-#endif
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma_encoder.c r-base-3.3.1/src/extra/xz/lzma/lzma_encoder.c
--- r-base-3.2.3/src/extra/xz/lzma/lzma_encoder.c 2010-11-08 23:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,675 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma_encoder.c
-/// \brief LZMA encoder
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "lzma2_encoder.h"
-#include "lzma_encoder_private.h"
-#include "fastpos.h"
-
-
-/////////////
-// Literal //
-/////////////
-
-static inline void
-literal_matched(lzma_range_encoder *rc, probability *subcoder,
- uint32_t match_byte, uint32_t symbol)
-{
- uint32_t offset = 0x100;
- symbol += UINT32_C(1) << 8;
-
- do {
- match_byte <<= 1;
- const uint32_t match_bit = match_byte & offset;
- const uint32_t subcoder_index
- = offset + match_bit + (symbol >> 8);
- const uint32_t bit = (symbol >> 7) & 1;
- rc_bit(rc, &subcoder[subcoder_index], bit);
-
- symbol <<= 1;
- offset &= ~(match_byte ^ symbol);
-
- } while (symbol < (UINT32_C(1) << 16));
-}
-
-
-static inline void
-literal(lzma_coder *coder, lzma_mf *mf, uint32_t position)
-{
- // Locate the literal byte to be encoded and the subcoder.
- const uint8_t cur_byte = mf->buffer[
- mf->read_pos - mf->read_ahead];
- probability *subcoder = literal_subcoder(coder->literal,
- coder->literal_context_bits, coder->literal_pos_mask,
- position, mf->buffer[mf->read_pos - mf->read_ahead - 1]);
-
- if (is_literal_state(coder->state)) {
- // Previous LZMA-symbol was a literal. Encode a normal
- // literal without a match byte.
- rc_bittree(&coder->rc, subcoder, 8, cur_byte);
- } else {
- // Previous LZMA-symbol was a match. Use the last byte of
- // the match as a "match byte". That is, compare the bits
- // of the current literal and the match byte.
- const uint8_t match_byte = mf->buffer[
- mf->read_pos - coder->reps[0] - 1
- - mf->read_ahead];
- literal_matched(&coder->rc, subcoder, match_byte, cur_byte);
- }
-
- update_literal(coder->state);
-}
-
-
-//////////////////
-// Match length //
-//////////////////
-
-static void
-length_update_prices(lzma_length_encoder *lc, const uint32_t pos_state)
-{
- const uint32_t table_size = lc->table_size;
- lc->counters[pos_state] = table_size;
-
- const uint32_t a0 = rc_bit_0_price(lc->choice);
- const uint32_t a1 = rc_bit_1_price(lc->choice);
- const uint32_t b0 = a1 + rc_bit_0_price(lc->choice2);
- const uint32_t b1 = a1 + rc_bit_1_price(lc->choice2);
- uint32_t *const prices = lc->prices[pos_state];
-
- uint32_t i;
- for (i = 0; i < table_size && i < LEN_LOW_SYMBOLS; ++i)
- prices[i] = a0 + rc_bittree_price(lc->low[pos_state],
- LEN_LOW_BITS, i);
-
- for (; i < table_size && i < LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS; ++i)
- prices[i] = b0 + rc_bittree_price(lc->mid[pos_state],
- LEN_MID_BITS, i - LEN_LOW_SYMBOLS);
-
- for (; i < table_size; ++i)
- prices[i] = b1 + rc_bittree_price(lc->high, LEN_HIGH_BITS,
- i - LEN_LOW_SYMBOLS - LEN_MID_SYMBOLS);
-
- return;
-}
-
-
-static inline void
-length(lzma_range_encoder *rc, lzma_length_encoder *lc,
- const uint32_t pos_state, uint32_t len, const bool fast_mode)
-{
- assert(len <= MATCH_LEN_MAX);
- len -= MATCH_LEN_MIN;
-
- if (len < LEN_LOW_SYMBOLS) {
- rc_bit(rc, &lc->choice, 0);
- rc_bittree(rc, lc->low[pos_state], LEN_LOW_BITS, len);
- } else {
- rc_bit(rc, &lc->choice, 1);
- len -= LEN_LOW_SYMBOLS;
-
- if (len < LEN_MID_SYMBOLS) {
- rc_bit(rc, &lc->choice2, 0);
- rc_bittree(rc, lc->mid[pos_state], LEN_MID_BITS, len);
- } else {
- rc_bit(rc, &lc->choice2, 1);
- len -= LEN_MID_SYMBOLS;
- rc_bittree(rc, lc->high, LEN_HIGH_BITS, len);
- }
- }
-
- // Only getoptimum uses the prices so don't update the table when
- // in fast mode.
- if (!fast_mode)
- if (--lc->counters[pos_state] == 0)
- length_update_prices(lc, pos_state);
-}
-
-
-///////////
-// Match //
-///////////
-
-static inline void
-match(lzma_coder *coder, const uint32_t pos_state,
- const uint32_t distance, const uint32_t len)
-{
- update_match(coder->state);
-
- length(&coder->rc, &coder->match_len_encoder, pos_state, len,
- coder->fast_mode);
-
- const uint32_t pos_slot = get_pos_slot(distance);
- const uint32_t len_to_pos_state = get_len_to_pos_state(len);
- rc_bittree(&coder->rc, coder->pos_slot[len_to_pos_state],
- POS_SLOT_BITS, pos_slot);
-
- if (pos_slot >= START_POS_MODEL_INDEX) {
- const uint32_t footer_bits = (pos_slot >> 1) - 1;
- const uint32_t base = (2 | (pos_slot & 1)) << footer_bits;
- const uint32_t pos_reduced = distance - base;
-
- if (pos_slot < END_POS_MODEL_INDEX) {
- // Careful here: base - pos_slot - 1 can be -1, but
- // rc_bittree_reverse starts at probs[1], not probs[0].
- rc_bittree_reverse(&coder->rc,
- coder->pos_special + base - pos_slot - 1,
- footer_bits, pos_reduced);
- } else {
- rc_direct(&coder->rc, pos_reduced >> ALIGN_BITS,
- footer_bits - ALIGN_BITS);
- rc_bittree_reverse(
- &coder->rc, coder->pos_align,
- ALIGN_BITS, pos_reduced & ALIGN_MASK);
- ++coder->align_price_count;
- }
- }
-
- coder->reps[3] = coder->reps[2];
- coder->reps[2] = coder->reps[1];
- coder->reps[1] = coder->reps[0];
- coder->reps[0] = distance;
- ++coder->match_price_count;
-}
-
-
-////////////////////
-// Repeated match //
-////////////////////
-
-static inline void
-rep_match(lzma_coder *coder, const uint32_t pos_state,
- const uint32_t rep, const uint32_t len)
-{
- if (rep == 0) {
- rc_bit(&coder->rc, &coder->is_rep0[coder->state], 0);
- rc_bit(&coder->rc,
- &coder->is_rep0_long[coder->state][pos_state],
- len != 1);
- } else {
- const uint32_t distance = coder->reps[rep];
- rc_bit(&coder->rc, &coder->is_rep0[coder->state], 1);
-
- if (rep == 1) {
- rc_bit(&coder->rc, &coder->is_rep1[coder->state], 0);
- } else {
- rc_bit(&coder->rc, &coder->is_rep1[coder->state], 1);
- rc_bit(&coder->rc, &coder->is_rep2[coder->state],
- rep - 2);
-
- if (rep == 3)
- coder->reps[3] = coder->reps[2];
-
- coder->reps[2] = coder->reps[1];
- }
-
- coder->reps[1] = coder->reps[0];
- coder->reps[0] = distance;
- }
-
- if (len == 1) {
- update_short_rep(coder->state);
- } else {
- length(&coder->rc, &coder->rep_len_encoder, pos_state, len,
- coder->fast_mode);
- update_long_rep(coder->state);
- }
-}
-
-
-//////////
-// Main //
-//////////
-
-static void
-encode_symbol(lzma_coder *coder, lzma_mf *mf,
- uint32_t back, uint32_t len, uint32_t position)
-{
- const uint32_t pos_state = position & coder->pos_mask;
-
- if (back == UINT32_MAX) {
- // Literal i.e. eight-bit byte
- assert(len == 1);
- rc_bit(&coder->rc,
- &coder->is_match[coder->state][pos_state], 0);
- literal(coder, mf, position);
- } else {
- // Some type of match
- rc_bit(&coder->rc,
- &coder->is_match[coder->state][pos_state], 1);
-
- if (back < REP_DISTANCES) {
- // It's a repeated match i.e. the same distance
- // has been used earlier.
- rc_bit(&coder->rc, &coder->is_rep[coder->state], 1);
- rep_match(coder, pos_state, back, len);
- } else {
- // Normal match
- rc_bit(&coder->rc, &coder->is_rep[coder->state], 0);
- match(coder, pos_state, back - REP_DISTANCES, len);
- }
- }
-
- assert(mf->read_ahead >= len);
- mf->read_ahead -= len;
-}
-
-
-static bool
-encode_init(lzma_coder *coder, lzma_mf *mf)
-{
- assert(mf_position(mf) == 0);
-
- if (mf->read_pos == mf->read_limit) {
- if (mf->action == LZMA_RUN)
- return false; // We cannot do anything.
-
- // We are finishing (we cannot get here when flushing).
- assert(mf->write_pos == mf->read_pos);
- assert(mf->action == LZMA_FINISH);
- } else {
- // Do the actual initialization. The first LZMA symbol must
- // always be a literal.
- mf_skip(mf, 1);
- mf->read_ahead = 0;
- rc_bit(&coder->rc, &coder->is_match[0][0], 0);
- rc_bittree(&coder->rc, coder->literal[0], 8, mf->buffer[0]);
- }
-
- // Initialization is done (except if empty file).
- coder->is_initialized = true;
-
- return true;
-}
-
-
-static void
-encode_eopm(lzma_coder *coder, uint32_t position)
-{
- const uint32_t pos_state = position & coder->pos_mask;
- rc_bit(&coder->rc, &coder->is_match[coder->state][pos_state], 1);
- rc_bit(&coder->rc, &coder->is_rep[coder->state], 0);
- match(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN);
-}
-
-
-/// Number of bytes that a single encoding loop in lzma_lzma_encode() can
-/// consume from the dictionary. This limit comes from lzma_lzma_optimum()
-/// and may need to be updated if that function is significantly modified.
-#define LOOP_INPUT_MAX (OPTS + 1)
-
-
-extern lzma_ret
-lzma_lzma_encode(lzma_coder *restrict coder, lzma_mf *restrict mf,
- uint8_t *restrict out, size_t *restrict out_pos,
- size_t out_size, uint32_t limit)
-{
- // Initialize the stream if no data has been encoded yet.
- if (!coder->is_initialized && !encode_init(coder, mf))
- return LZMA_OK;
-
- // Get the lowest bits of the uncompressed offset from the LZ layer.
- uint32_t position = mf_position(mf);
-
- while (true) {
- // Encode pending bits, if any. Calling this before encoding
- // the next symbol is needed only with plain LZMA, since
- // LZMA2 always provides big enough buffer to flush
- // everything out from the range encoder. For the same reason,
- // rc_encode() never returns true when this function is used
- // as part of LZMA2 encoder.
- if (rc_encode(&coder->rc, out, out_pos, out_size)) {
- assert(limit == UINT32_MAX);
- return LZMA_OK;
- }
-
- // With LZMA2 we need to take care that compressed size of
- // a chunk doesn't get too big.
- // FIXME? Check if this could be improved.
- if (limit != UINT32_MAX
- && (mf->read_pos - mf->read_ahead >= limit
- || *out_pos + rc_pending(&coder->rc)
- >= LZMA2_CHUNK_MAX
- - LOOP_INPUT_MAX))
- break;
-
- // Check that there is some input to process.
- if (mf->read_pos >= mf->read_limit) {
- if (mf->action == LZMA_RUN)
- return LZMA_OK;
-
- if (mf->read_ahead == 0)
- break;
- }
-
- // Get optimal match (repeat position and length).
- // Value ranges for pos:
- // - [0, REP_DISTANCES): repeated match
- // - [REP_DISTANCES, UINT32_MAX):
- // match at (pos - REP_DISTANCES)
- // - UINT32_MAX: not a match but a literal
- // Value ranges for len:
- // - [MATCH_LEN_MIN, MATCH_LEN_MAX]
- uint32_t len;
- uint32_t back;
-
- if (coder->fast_mode)
- lzma_lzma_optimum_fast(coder, mf, &back, &len);
- else
- lzma_lzma_optimum_normal(
- coder, mf, &back, &len, position);
-
- encode_symbol(coder, mf, back, len, position);
-
- position += len;
- }
-
- if (!coder->is_flushed) {
- coder->is_flushed = true;
-
- // We don't support encoding plain LZMA streams without EOPM,
- // and LZMA2 doesn't use EOPM at LZMA level.
- if (limit == UINT32_MAX)
- encode_eopm(coder, position);
-
- // Flush the remaining bytes from the range encoder.
- rc_flush(&coder->rc);
-
- // Copy the remaining bytes to the output buffer. If there
- // isn't enough output space, we will copy out the remaining
- // bytes on the next call to this function by using
- // the rc_encode() call in the encoding loop above.
- if (rc_encode(&coder->rc, out, out_pos, out_size)) {
- assert(limit == UINT32_MAX);
- return LZMA_OK;
- }
- }
-
- // Make it ready for the next LZMA2 chunk.
- coder->is_flushed = false;
-
- return LZMA_STREAM_END;
-}
-
-
-static lzma_ret
-lzma_encode(lzma_coder *restrict coder, lzma_mf *restrict mf,
- uint8_t *restrict out, size_t *restrict out_pos,
- size_t out_size)
-{
- // Plain LZMA has no support for sync-flushing.
- if (unlikely(mf->action == LZMA_SYNC_FLUSH))
- return LZMA_OPTIONS_ERROR;
-
- return lzma_lzma_encode(coder, mf, out, out_pos, out_size, UINT32_MAX);
-}
-
-
-////////////////////
-// Initialization //
-////////////////////
-
-static bool
-is_options_valid(const lzma_options_lzma *options)
-{
- // Validate some of the options. LZ encoder validates nice_len too
- // but we need a valid value here earlier.
- return is_lclppb_valid(options)
- && options->nice_len >= MATCH_LEN_MIN
- && options->nice_len <= MATCH_LEN_MAX
- && (options->mode == LZMA_MODE_FAST
- || options->mode == LZMA_MODE_NORMAL);
-}
-
-
-static void
-set_lz_options(lzma_lz_options *lz_options, const lzma_options_lzma *options)
-{
- // LZ encoder initialization does the validation for these so we
- // don't need to validate here.
- lz_options->before_size = OPTS;
- lz_options->dict_size = options->dict_size;
- lz_options->after_size = LOOP_INPUT_MAX;
- lz_options->match_len_max = MATCH_LEN_MAX;
- lz_options->nice_len = options->nice_len;
- lz_options->match_finder = options->mf;
- lz_options->depth = options->depth;
- lz_options->preset_dict = options->preset_dict;
- lz_options->preset_dict_size = options->preset_dict_size;
- return;
-}
-
-
-static void
-length_encoder_reset(lzma_length_encoder *lencoder,
- const uint32_t num_pos_states, const bool fast_mode)
-{
- bit_reset(lencoder->choice);
- bit_reset(lencoder->choice2);
-
- for (size_t pos_state = 0; pos_state < num_pos_states; ++pos_state) {
- bittree_reset(lencoder->low[pos_state], LEN_LOW_BITS);
- bittree_reset(lencoder->mid[pos_state], LEN_MID_BITS);
- }
-
- bittree_reset(lencoder->high, LEN_HIGH_BITS);
-
- if (!fast_mode)
- for (size_t pos_state = 0; pos_state < num_pos_states;
- ++pos_state)
- length_update_prices(lencoder, pos_state);
-
- return;
-}
-
-
-extern lzma_ret
-lzma_lzma_encoder_reset(lzma_coder *coder, const lzma_options_lzma *options)
-{
- if (!is_options_valid(options))
- return LZMA_OPTIONS_ERROR;
-
- coder->pos_mask = (1U << options->pb) - 1;
- coder->literal_context_bits = options->lc;
- coder->literal_pos_mask = (1U << options->lp) - 1;
-
- // Range coder
- rc_reset(&coder->rc);
-
- // State
- coder->state = STATE_LIT_LIT;
- for (size_t i = 0; i < REP_DISTANCES; ++i)
- coder->reps[i] = 0;
-
- literal_init(coder->literal, options->lc, options->lp);
-
- // Bit encoders
- for (size_t i = 0; i < STATES; ++i) {
- for (size_t j = 0; j <= coder->pos_mask; ++j) {
- bit_reset(coder->is_match[i][j]);
- bit_reset(coder->is_rep0_long[i][j]);
- }
-
- bit_reset(coder->is_rep[i]);
- bit_reset(coder->is_rep0[i]);
- bit_reset(coder->is_rep1[i]);
- bit_reset(coder->is_rep2[i]);
- }
-
- for (size_t i = 0; i < FULL_DISTANCES - END_POS_MODEL_INDEX; ++i)
- bit_reset(coder->pos_special[i]);
-
- // Bit tree encoders
- for (size_t i = 0; i < LEN_TO_POS_STATES; ++i)
- bittree_reset(coder->pos_slot[i], POS_SLOT_BITS);
-
- bittree_reset(coder->pos_align, ALIGN_BITS);
-
- // Length encoders
- length_encoder_reset(&coder->match_len_encoder,
- 1U << options->pb, coder->fast_mode);
-
- length_encoder_reset(&coder->rep_len_encoder,
- 1U << options->pb, coder->fast_mode);
-
- // Price counts are incremented every time appropriate probabilities
- // are changed. price counts are set to zero when the price tables
- // are updated, which is done when the appropriate price counts have
- // big enough value, and lzma_mf.read_ahead == 0 which happens at
- // least every OPTS (a few thousand) possible price count increments.
- //
- // By resetting price counts to UINT32_MAX / 2, we make sure that the
- // price tables will be initialized before they will be used (since
- // the value is definitely big enough), and that it is OK to increment
- // price counts without risk of integer overflow (since UINT32_MAX / 2
- // is small enough). The current code doesn't increment price counts
- // before initializing price tables, but it maybe done in future if
- // we add support for saving the state between LZMA2 chunks.
- coder->match_price_count = UINT32_MAX / 2;
- coder->align_price_count = UINT32_MAX / 2;
-
- coder->opts_end_index = 0;
- coder->opts_current_index = 0;
-
- return LZMA_OK;
-}
-
-
-extern lzma_ret
-lzma_lzma_encoder_create(lzma_coder **coder_ptr, lzma_allocator *allocator,
- const lzma_options_lzma *options, lzma_lz_options *lz_options)
-{
- // Allocate lzma_coder if it wasn't already allocated.
- if (*coder_ptr == NULL) {
- *coder_ptr = lzma_alloc(sizeof(lzma_coder), allocator);
- if (*coder_ptr == NULL)
- return LZMA_MEM_ERROR;
- }
-
- lzma_coder *coder = *coder_ptr;
-
- // Set compression mode. We haven't validates the options yet,
- // but it's OK here, since nothing bad happens with invalid
- // options in the code below, and they will get rejected by
- // lzma_lzma_encoder_reset() call at the end of this function.
- switch (options->mode) {
- case LZMA_MODE_FAST:
- coder->fast_mode = true;
- break;
-
- case LZMA_MODE_NORMAL: {
- coder->fast_mode = false;
-
- // Set dist_table_size.
- // Round the dictionary size up to next 2^n.
- uint32_t log_size = 0;
- while ((UINT32_C(1) << log_size) < options->dict_size)
- ++log_size;
-
- coder->dist_table_size = log_size * 2;
-
- // Length encoders' price table size
- coder->match_len_encoder.table_size
- = options->nice_len + 1 - MATCH_LEN_MIN;
- coder->rep_len_encoder.table_size
- = options->nice_len + 1 - MATCH_LEN_MIN;
- break;
- }
-
- default:
- return LZMA_OPTIONS_ERROR;
- }
-
- // We don't need to write the first byte as literal if there is
- // a non-empty preset dictionary. encode_init() wouldn't even work
- // if there is a non-empty preset dictionary, because encode_init()
- // assumes that position is zero and previous byte is also zero.
- coder->is_initialized = options->preset_dict != NULL
- && options->preset_dict_size > 0;
- coder->is_flushed = false;
-
- set_lz_options(lz_options, options);
-
- return lzma_lzma_encoder_reset(coder, options);
-}
-
-
-static lzma_ret
-lzma_encoder_init(lzma_lz_encoder *lz, lzma_allocator *allocator,
- const void *options, lzma_lz_options *lz_options)
-{
- lz->code = &lzma_encode;
- return lzma_lzma_encoder_create(
- &lz->coder, allocator, options, lz_options);
-}
-
-
-extern lzma_ret
-lzma_lzma_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- return lzma_lz_encoder_init(
- next, allocator, filters, &lzma_encoder_init);
-}
-
-
-extern uint64_t
-lzma_lzma_encoder_memusage(const void *options)
-{
- if (!is_options_valid(options))
- return UINT64_MAX;
-
- lzma_lz_options lz_options;
- set_lz_options(&lz_options, options);
-
- const uint64_t lz_memusage = lzma_lz_encoder_memusage(&lz_options);
- if (lz_memusage == UINT64_MAX)
- return UINT64_MAX;
-
- return (uint64_t)(sizeof(lzma_coder)) + lz_memusage;
-}
-
-
-extern bool
-lzma_lzma_lclppb_encode(const lzma_options_lzma *options, uint8_t *byte)
-{
- if (!is_lclppb_valid(options))
- return true;
-
- *byte = (options->pb * 5 + options->lp) * 9 + options->lc;
- assert(*byte <= (4 * 5 + 4) * 9 + 8);
-
- return false;
-}
-
-
-#ifdef HAVE_ENCODER_LZMA1
-extern lzma_ret
-lzma_lzma_props_encode(const void *options, uint8_t *out)
-{
- const lzma_options_lzma *const opt = options;
-
- if (lzma_lzma_lclppb_encode(opt, out))
- return LZMA_PROG_ERROR;
-
- unaligned_write32le(out + 1, opt->dict_size);
-
- return LZMA_OK;
-}
-#endif
-
-
-extern LZMA_API(lzma_bool)
-lzma_mode_is_supported(lzma_mode mode)
-{
- return mode == LZMA_MODE_FAST || mode == LZMA_MODE_NORMAL;
-}
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma_encoder.h r-base-3.3.1/src/extra/xz/lzma/lzma_encoder.h
--- r-base-3.2.3/src/extra/xz/lzma/lzma_encoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma_encoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,54 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma_encoder.h
-/// \brief LZMA encoder API
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_LZMA_ENCODER_H
-#define LZMA_LZMA_ENCODER_H
-
-#include "common.h"
-
-
-extern lzma_ret lzma_lzma_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-
-extern uint64_t lzma_lzma_encoder_memusage(const void *options);
-
-extern lzma_ret lzma_lzma_props_encode(const void *options, uint8_t *out);
-
-
-/// Encodes lc/lp/pb into one byte. Returns false on success and true on error.
-extern bool lzma_lzma_lclppb_encode(
- const lzma_options_lzma *options, uint8_t *byte);
-
-
-#ifdef LZMA_LZ_ENCODER_H
-
-/// Initializes raw LZMA encoder; this is used by LZMA2.
-extern lzma_ret lzma_lzma_encoder_create(
- lzma_coder **coder_ptr, lzma_allocator *allocator,
- const lzma_options_lzma *options, lzma_lz_options *lz_options);
-
-
-/// Resets an already initialized LZMA encoder; this is used by LZMA2.
-extern lzma_ret lzma_lzma_encoder_reset(
- lzma_coder *coder, const lzma_options_lzma *options);
-
-
-extern lzma_ret lzma_lzma_encode(lzma_coder *restrict coder,
- lzma_mf *restrict mf, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size,
- uint32_t read_limit);
-
-#endif
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma_encoder_optimum_fast.c r-base-3.3.1/src/extra/xz/lzma/lzma_encoder_optimum_fast.c
--- r-base-3.2.3/src/extra/xz/lzma/lzma_encoder_optimum_fast.c 2010-11-08 23:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma_encoder_optimum_fast.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,179 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma_encoder_optimum_fast.c
-//
-// Author: Igor Pavlov
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "lzma_encoder_private.h"
-
-
-#define change_pair(small_dist, big_dist) \
- (((big_dist) >> 7) > (small_dist))
-
-
-extern void
-lzma_lzma_optimum_fast(lzma_coder *restrict coder, lzma_mf *restrict mf,
- uint32_t *restrict back_res, uint32_t *restrict len_res)
-{
- const uint32_t nice_len = mf->nice_len;
-
- uint32_t len_main;
- uint32_t matches_count;
- if (mf->read_ahead == 0) {
- len_main = mf_find(mf, &matches_count, coder->matches);
- } else {
- assert(mf->read_ahead == 1);
- len_main = coder->longest_match_length;
- matches_count = coder->matches_count;
- }
-
- const uint8_t *buf = mf_ptr(mf) - 1;
- const uint32_t buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX);
-
- if (buf_avail < 2) {
- // There's not enough input left to encode a match.
- *back_res = UINT32_MAX;
- *len_res = 1;
- return;
- }
-
- // Look for repeated matches; scan the previous four match distances
- uint32_t rep_len = 0;
- uint32_t rep_index = 0;
-
- for (uint32_t i = 0; i < REP_DISTANCES; ++i) {
- // Pointer to the beginning of the match candidate
- const uint8_t *const buf_back = buf - coder->reps[i] - 1;
-
- // If the first two bytes (2 == MATCH_LEN_MIN) do not match,
- // this rep is not useful.
- if (not_equal_16(buf, buf_back))
- continue;
-
- // The first two bytes matched.
- // Calculate the length of the match.
- uint32_t len;
- for (len = 2; len < buf_avail
- && buf[len] == buf_back[len]; ++len) ;
-
- // If we have found a repeated match that is at least
- // nice_len long, return it immediately.
- if (len >= nice_len) {
- *back_res = i;
- *len_res = len;
- mf_skip(mf, len - 1);
- return;
- }
-
- if (len > rep_len) {
- rep_index = i;
- rep_len = len;
- }
- }
-
- // We didn't find a long enough repeated match. Encode it as a normal
- // match if the match length is at least nice_len.
- if (len_main >= nice_len) {
- *back_res = coder->matches[matches_count - 1].dist
- + REP_DISTANCES;
- *len_res = len_main;
- mf_skip(mf, len_main - 1);
- return;
- }
-
- uint32_t back_main = 0;
- if (len_main >= 2) {
- back_main = coder->matches[matches_count - 1].dist;
-
- while (matches_count > 1 && len_main ==
- coder->matches[matches_count - 2].len + 1) {
- if (!change_pair(coder->matches[
- matches_count - 2].dist,
- back_main))
- break;
-
- --matches_count;
- len_main = coder->matches[matches_count - 1].len;
- back_main = coder->matches[matches_count - 1].dist;
- }
-
- if (len_main == 2 && back_main >= 0x80)
- len_main = 1;
- }
-
- if (rep_len >= 2) {
- if (rep_len + 1 >= len_main
- || (rep_len + 2 >= len_main
- && back_main > (UINT32_C(1) << 9))
- || (rep_len + 3 >= len_main
- && back_main > (UINT32_C(1) << 15))) {
- *back_res = rep_index;
- *len_res = rep_len;
- mf_skip(mf, rep_len - 1);
- return;
- }
- }
-
- if (len_main < 2 || buf_avail <= 2) {
- *back_res = UINT32_MAX;
- *len_res = 1;
- return;
- }
-
- // Get the matches for the next byte. If we find a better match,
- // the current byte is encoded as a literal.
- coder->longest_match_length = mf_find(mf,
- &coder->matches_count, coder->matches);
-
- if (coder->longest_match_length >= 2) {
- const uint32_t new_dist = coder->matches[
- coder->matches_count - 1].dist;
-
- if ((coder->longest_match_length >= len_main
- && new_dist < back_main)
- || (coder->longest_match_length == len_main + 1
- && !change_pair(back_main, new_dist))
- || (coder->longest_match_length > len_main + 1)
- || (coder->longest_match_length + 1 >= len_main
- && len_main >= 3
- && change_pair(new_dist, back_main))) {
- *back_res = UINT32_MAX;
- *len_res = 1;
- return;
- }
- }
-
- // In contrast to LZMA SDK, dictionary could not have been moved
- // between mf_find() calls, thus it is safe to just increment
- // the old buf pointer instead of recalculating it with mf_ptr().
- ++buf;
-
- const uint32_t limit = len_main - 1;
-
- for (uint32_t i = 0; i < REP_DISTANCES; ++i) {
- const uint8_t *const buf_back = buf - coder->reps[i] - 1;
-
- if (not_equal_16(buf, buf_back))
- continue;
-
- uint32_t len;
- for (len = 2; len < limit
- && buf[len] == buf_back[len]; ++len) ;
-
- if (len >= limit) {
- *back_res = UINT32_MAX;
- *len_res = 1;
- return;
- }
- }
-
- *back_res = back_main + REP_DISTANCES;
- *len_res = len_main;
- mf_skip(mf, len_main - 2);
- return;
-}
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma_encoder_optimum_normal.c r-base-3.3.1/src/extra/xz/lzma/lzma_encoder_optimum_normal.c
--- r-base-3.2.3/src/extra/xz/lzma/lzma_encoder_optimum_normal.c 2010-11-08 23:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma_encoder_optimum_normal.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,868 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma_encoder_optimum_normal.c
-//
-// Author: Igor Pavlov
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "lzma_encoder_private.h"
-#include "fastpos.h"
-
-
-////////////
-// Prices //
-////////////
-
-static uint32_t
-get_literal_price(const lzma_coder *const coder, const uint32_t pos,
- const uint32_t prev_byte, const bool match_mode,
- uint32_t match_byte, uint32_t symbol)
-{
- const probability *const subcoder = literal_subcoder(coder->literal,
- coder->literal_context_bits, coder->literal_pos_mask,
- pos, prev_byte);
-
- uint32_t price = 0;
-
- if (!match_mode) {
- price = rc_bittree_price(subcoder, 8, symbol);
- } else {
- uint32_t offset = 0x100;
- symbol += UINT32_C(1) << 8;
-
- do {
- match_byte <<= 1;
-
- const uint32_t match_bit = match_byte & offset;
- const uint32_t subcoder_index
- = offset + match_bit + (symbol >> 8);
- const uint32_t bit = (symbol >> 7) & 1;
- price += rc_bit_price(subcoder[subcoder_index], bit);
-
- symbol <<= 1;
- offset &= ~(match_byte ^ symbol);
-
- } while (symbol < (UINT32_C(1) << 16));
- }
-
- return price;
-}
-
-
-static inline uint32_t
-get_len_price(const lzma_length_encoder *const lencoder,
- const uint32_t len, const uint32_t pos_state)
-{
- // NOTE: Unlike the other price tables, length prices are updated
- // in lzma_encoder.c
- return lencoder->prices[pos_state][len - MATCH_LEN_MIN];
-}
-
-
-static inline uint32_t
-get_short_rep_price(const lzma_coder *const coder,
- const lzma_lzma_state state, const uint32_t pos_state)
-{
- return rc_bit_0_price(coder->is_rep0[state])
- + rc_bit_0_price(coder->is_rep0_long[state][pos_state]);
-}
-
-
-static inline uint32_t
-get_pure_rep_price(const lzma_coder *const coder, const uint32_t rep_index,
- const lzma_lzma_state state, uint32_t pos_state)
-{
- uint32_t price;
-
- if (rep_index == 0) {
- price = rc_bit_0_price(coder->is_rep0[state]);
- price += rc_bit_1_price(coder->is_rep0_long[state][pos_state]);
- } else {
- price = rc_bit_1_price(coder->is_rep0[state]);
-
- if (rep_index == 1) {
- price += rc_bit_0_price(coder->is_rep1[state]);
- } else {
- price += rc_bit_1_price(coder->is_rep1[state]);
- price += rc_bit_price(coder->is_rep2[state],
- rep_index - 2);
- }
- }
-
- return price;
-}
-
-
-static inline uint32_t
-get_rep_price(const lzma_coder *const coder, const uint32_t rep_index,
- const uint32_t len, const lzma_lzma_state state,
- const uint32_t pos_state)
-{
- return get_len_price(&coder->rep_len_encoder, len, pos_state)
- + get_pure_rep_price(coder, rep_index, state, pos_state);
-}
-
-
-static inline uint32_t
-get_pos_len_price(const lzma_coder *const coder, const uint32_t pos,
- const uint32_t len, const uint32_t pos_state)
-{
- const uint32_t len_to_pos_state = get_len_to_pos_state(len);
- uint32_t price;
-
- if (pos < FULL_DISTANCES) {
- price = coder->distances_prices[len_to_pos_state][pos];
- } else {
- const uint32_t pos_slot = get_pos_slot_2(pos);
- price = coder->pos_slot_prices[len_to_pos_state][pos_slot]
- + coder->align_prices[pos & ALIGN_MASK];
- }
-
- price += get_len_price(&coder->match_len_encoder, len, pos_state);
-
- return price;
-}
-
-
-static void
-fill_distances_prices(lzma_coder *coder)
-{
- for (uint32_t len_to_pos_state = 0;
- len_to_pos_state < LEN_TO_POS_STATES;
- ++len_to_pos_state) {
-
- uint32_t *const pos_slot_prices
- = coder->pos_slot_prices[len_to_pos_state];
-
- // Price to encode the pos_slot.
- for (uint32_t pos_slot = 0;
- pos_slot < coder->dist_table_size; ++pos_slot)
- pos_slot_prices[pos_slot] = rc_bittree_price(
- coder->pos_slot[len_to_pos_state],
- POS_SLOT_BITS, pos_slot);
-
- // For matches with distance >= FULL_DISTANCES, add the price
- // of the direct bits part of the match distance. (Align bits
- // are handled by fill_align_prices()).
- for (uint32_t pos_slot = END_POS_MODEL_INDEX;
- pos_slot < coder->dist_table_size; ++pos_slot)
- pos_slot_prices[pos_slot] += rc_direct_price(
- ((pos_slot >> 1) - 1) - ALIGN_BITS);
-
- // Distances in the range [0, 3] are fully encoded with
- // pos_slot, so they are used for coder->distances_prices
- // as is.
- for (uint32_t i = 0; i < START_POS_MODEL_INDEX; ++i)
- coder->distances_prices[len_to_pos_state][i]
- = pos_slot_prices[i];
- }
-
- // Distances in the range [4, 127] depend on pos_slot and pos_special.
- // We do this in a loop separate from the above loop to avoid
- // redundant calls to get_pos_slot().
- for (uint32_t i = START_POS_MODEL_INDEX; i < FULL_DISTANCES; ++i) {
- const uint32_t pos_slot = get_pos_slot(i);
- const uint32_t footer_bits = ((pos_slot >> 1) - 1);
- const uint32_t base = (2 | (pos_slot & 1)) << footer_bits;
- const uint32_t price = rc_bittree_reverse_price(
- coder->pos_special + base - pos_slot - 1,
- footer_bits, i - base);
-
- for (uint32_t len_to_pos_state = 0;
- len_to_pos_state < LEN_TO_POS_STATES;
- ++len_to_pos_state)
- coder->distances_prices[len_to_pos_state][i]
- = price + coder->pos_slot_prices[
- len_to_pos_state][pos_slot];
- }
-
- coder->match_price_count = 0;
- return;
-}
-
-
-static void
-fill_align_prices(lzma_coder *coder)
-{
- for (uint32_t i = 0; i < ALIGN_TABLE_SIZE; ++i)
- coder->align_prices[i] = rc_bittree_reverse_price(
- coder->pos_align, ALIGN_BITS, i);
-
- coder->align_price_count = 0;
- return;
-}
-
-
-/////////////
-// Optimal //
-/////////////
-
-static inline void
-make_literal(lzma_optimal *optimal)
-{
- optimal->back_prev = UINT32_MAX;
- optimal->prev_1_is_literal = false;
-}
-
-
-static inline void
-make_short_rep(lzma_optimal *optimal)
-{
- optimal->back_prev = 0;
- optimal->prev_1_is_literal = false;
-}
-
-
-#define is_short_rep(optimal) \
- ((optimal).back_prev == 0)
-
-
-static void
-backward(lzma_coder *restrict coder, uint32_t *restrict len_res,
- uint32_t *restrict back_res, uint32_t cur)
-{
- coder->opts_end_index = cur;
-
- uint32_t pos_mem = coder->opts[cur].pos_prev;
- uint32_t back_mem = coder->opts[cur].back_prev;
-
- do {
- if (coder->opts[cur].prev_1_is_literal) {
- make_literal(&coder->opts[pos_mem]);
- coder->opts[pos_mem].pos_prev = pos_mem - 1;
-
- if (coder->opts[cur].prev_2) {
- coder->opts[pos_mem - 1].prev_1_is_literal
- = false;
- coder->opts[pos_mem - 1].pos_prev
- = coder->opts[cur].pos_prev_2;
- coder->opts[pos_mem - 1].back_prev
- = coder->opts[cur].back_prev_2;
- }
- }
-
- const uint32_t pos_prev = pos_mem;
- const uint32_t back_cur = back_mem;
-
- back_mem = coder->opts[pos_prev].back_prev;
- pos_mem = coder->opts[pos_prev].pos_prev;
-
- coder->opts[pos_prev].back_prev = back_cur;
- coder->opts[pos_prev].pos_prev = cur;
- cur = pos_prev;
-
- } while (cur != 0);
-
- coder->opts_current_index = coder->opts[0].pos_prev;
- *len_res = coder->opts[0].pos_prev;
- *back_res = coder->opts[0].back_prev;
-
- return;
-}
-
-
-//////////
-// Main //
-//////////
-
-static inline uint32_t
-helper1(lzma_coder *restrict coder, lzma_mf *restrict mf,
- uint32_t *restrict back_res, uint32_t *restrict len_res,
- uint32_t position)
-{
- const uint32_t nice_len = mf->nice_len;
-
- uint32_t len_main;
- uint32_t matches_count;
-
- if (mf->read_ahead == 0) {
- len_main = mf_find(mf, &matches_count, coder->matches);
- } else {
- assert(mf->read_ahead == 1);
- len_main = coder->longest_match_length;
- matches_count = coder->matches_count;
- }
-
- const uint32_t buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX);
- if (buf_avail < 2) {
- *back_res = UINT32_MAX;
- *len_res = 1;
- return UINT32_MAX;
- }
-
- const uint8_t *const buf = mf_ptr(mf) - 1;
-
- uint32_t rep_lens[REP_DISTANCES];
- uint32_t rep_max_index = 0;
-
- for (uint32_t i = 0; i < REP_DISTANCES; ++i) {
- const uint8_t *const buf_back = buf - coder->reps[i] - 1;
-
- if (not_equal_16(buf, buf_back)) {
- rep_lens[i] = 0;
- continue;
- }
-
- uint32_t len_test;
- for (len_test = 2; len_test < buf_avail
- && buf[len_test] == buf_back[len_test];
- ++len_test) ;
-
- rep_lens[i] = len_test;
- if (len_test > rep_lens[rep_max_index])
- rep_max_index = i;
- }
-
- if (rep_lens[rep_max_index] >= nice_len) {
- *back_res = rep_max_index;
- *len_res = rep_lens[rep_max_index];
- mf_skip(mf, *len_res - 1);
- return UINT32_MAX;
- }
-
-
- if (len_main >= nice_len) {
- *back_res = coder->matches[matches_count - 1].dist
- + REP_DISTANCES;
- *len_res = len_main;
- mf_skip(mf, len_main - 1);
- return UINT32_MAX;
- }
-
- const uint8_t current_byte = *buf;
- const uint8_t match_byte = *(buf - coder->reps[0] - 1);
-
- if (len_main < 2 && current_byte != match_byte
- && rep_lens[rep_max_index] < 2) {
- *back_res = UINT32_MAX;
- *len_res = 1;
- return UINT32_MAX;
- }
-
- coder->opts[0].state = coder->state;
-
- const uint32_t pos_state = position & coder->pos_mask;
-
- coder->opts[1].price = rc_bit_0_price(
- coder->is_match[coder->state][pos_state])
- + get_literal_price(coder, position, buf[-1],
- !is_literal_state(coder->state),
- match_byte, current_byte);
-
- make_literal(&coder->opts[1]);
-
- const uint32_t match_price = rc_bit_1_price(
- coder->is_match[coder->state][pos_state]);
- const uint32_t rep_match_price = match_price
- + rc_bit_1_price(coder->is_rep[coder->state]);
-
- if (match_byte == current_byte) {
- const uint32_t short_rep_price = rep_match_price
- + get_short_rep_price(
- coder, coder->state, pos_state);
-
- if (short_rep_price < coder->opts[1].price) {
- coder->opts[1].price = short_rep_price;
- make_short_rep(&coder->opts[1]);
- }
- }
-
- const uint32_t len_end = my_max(len_main, rep_lens[rep_max_index]);
-
- if (len_end < 2) {
- *back_res = coder->opts[1].back_prev;
- *len_res = 1;
- return UINT32_MAX;
- }
-
- coder->opts[1].pos_prev = 0;
-
- for (uint32_t i = 0; i < REP_DISTANCES; ++i)
- coder->opts[0].backs[i] = coder->reps[i];
-
- uint32_t len = len_end;
- do {
- coder->opts[len].price = RC_INFINITY_PRICE;
- } while (--len >= 2);
-
-
- for (uint32_t i = 0; i < REP_DISTANCES; ++i) {
- uint32_t rep_len = rep_lens[i];
- if (rep_len < 2)
- continue;
-
- const uint32_t price = rep_match_price + get_pure_rep_price(
- coder, i, coder->state, pos_state);
-
- do {
- const uint32_t cur_and_len_price = price
- + get_len_price(
- &coder->rep_len_encoder,
- rep_len, pos_state);
-
- if (cur_and_len_price < coder->opts[rep_len].price) {
- coder->opts[rep_len].price = cur_and_len_price;
- coder->opts[rep_len].pos_prev = 0;
- coder->opts[rep_len].back_prev = i;
- coder->opts[rep_len].prev_1_is_literal = false;
- }
- } while (--rep_len >= 2);
- }
-
-
- const uint32_t normal_match_price = match_price
- + rc_bit_0_price(coder->is_rep[coder->state]);
-
- len = rep_lens[0] >= 2 ? rep_lens[0] + 1 : 2;
- if (len <= len_main) {
- uint32_t i = 0;
- while (len > coder->matches[i].len)
- ++i;
-
- for(; ; ++len) {
- const uint32_t dist = coder->matches[i].dist;
- const uint32_t cur_and_len_price = normal_match_price
- + get_pos_len_price(coder,
- dist, len, pos_state);
-
- if (cur_and_len_price < coder->opts[len].price) {
- coder->opts[len].price = cur_and_len_price;
- coder->opts[len].pos_prev = 0;
- coder->opts[len].back_prev
- = dist + REP_DISTANCES;
- coder->opts[len].prev_1_is_literal = false;
- }
-
- if (len == coder->matches[i].len)
- if (++i == matches_count)
- break;
- }
- }
-
- return len_end;
-}
-
-
-static inline uint32_t
-helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
- uint32_t len_end, uint32_t position, const uint32_t cur,
- const uint32_t nice_len, const uint32_t buf_avail_full)
-{
- uint32_t matches_count = coder->matches_count;
- uint32_t new_len = coder->longest_match_length;
- uint32_t pos_prev = coder->opts[cur].pos_prev;
- lzma_lzma_state state;
-
- if (coder->opts[cur].prev_1_is_literal) {
- --pos_prev;
-
- if (coder->opts[cur].prev_2) {
- state = coder->opts[coder->opts[cur].pos_prev_2].state;
-
- if (coder->opts[cur].back_prev_2 < REP_DISTANCES)
- update_long_rep(state);
- else
- update_match(state);
-
- } else {
- state = coder->opts[pos_prev].state;
- }
-
- update_literal(state);
-
- } else {
- state = coder->opts[pos_prev].state;
- }
-
- if (pos_prev == cur - 1) {
- if (is_short_rep(coder->opts[cur]))
- update_short_rep(state);
- else
- update_literal(state);
- } else {
- uint32_t pos;
- if (coder->opts[cur].prev_1_is_literal
- && coder->opts[cur].prev_2) {
- pos_prev = coder->opts[cur].pos_prev_2;
- pos = coder->opts[cur].back_prev_2;
- update_long_rep(state);
- } else {
- pos = coder->opts[cur].back_prev;
- if (pos < REP_DISTANCES)
- update_long_rep(state);
- else
- update_match(state);
- }
-
- if (pos < REP_DISTANCES) {
- reps[0] = coder->opts[pos_prev].backs[pos];
-
- uint32_t i;
- for (i = 1; i <= pos; ++i)
- reps[i] = coder->opts[pos_prev].backs[i - 1];
-
- for (; i < REP_DISTANCES; ++i)
- reps[i] = coder->opts[pos_prev].backs[i];
-
- } else {
- reps[0] = pos - REP_DISTANCES;
-
- for (uint32_t i = 1; i < REP_DISTANCES; ++i)
- reps[i] = coder->opts[pos_prev].backs[i - 1];
- }
- }
-
- coder->opts[cur].state = state;
-
- for (uint32_t i = 0; i < REP_DISTANCES; ++i)
- coder->opts[cur].backs[i] = reps[i];
-
- const uint32_t cur_price = coder->opts[cur].price;
-
- const uint8_t current_byte = *buf;
- const uint8_t match_byte = *(buf - reps[0] - 1);
-
- const uint32_t pos_state = position & coder->pos_mask;
-
- const uint32_t cur_and_1_price = cur_price
- + rc_bit_0_price(coder->is_match[state][pos_state])
- + get_literal_price(coder, position, buf[-1],
- !is_literal_state(state), match_byte, current_byte);
-
- bool next_is_literal = false;
-
- if (cur_and_1_price < coder->opts[cur + 1].price) {
- coder->opts[cur + 1].price = cur_and_1_price;
- coder->opts[cur + 1].pos_prev = cur;
- make_literal(&coder->opts[cur + 1]);
- next_is_literal = true;
- }
-
- const uint32_t match_price = cur_price
- + rc_bit_1_price(coder->is_match[state][pos_state]);
- const uint32_t rep_match_price = match_price
- + rc_bit_1_price(coder->is_rep[state]);
-
- if (match_byte == current_byte
- && !(coder->opts[cur + 1].pos_prev < cur
- && coder->opts[cur + 1].back_prev == 0)) {
-
- const uint32_t short_rep_price = rep_match_price
- + get_short_rep_price(coder, state, pos_state);
-
- if (short_rep_price <= coder->opts[cur + 1].price) {
- coder->opts[cur + 1].price = short_rep_price;
- coder->opts[cur + 1].pos_prev = cur;
- make_short_rep(&coder->opts[cur + 1]);
- next_is_literal = true;
- }
- }
-
- if (buf_avail_full < 2)
- return len_end;
-
- const uint32_t buf_avail = my_min(buf_avail_full, nice_len);
-
- if (!next_is_literal && match_byte != current_byte) { // speed optimization
- // try literal + rep0
- const uint8_t *const buf_back = buf - reps[0] - 1;
- const uint32_t limit = my_min(buf_avail_full, nice_len + 1);
-
- uint32_t len_test = 1;
- while (len_test < limit && buf[len_test] == buf_back[len_test])
- ++len_test;
-
- --len_test;
-
- if (len_test >= 2) {
- lzma_lzma_state state_2 = state;
- update_literal(state_2);
-
- const uint32_t pos_state_next = (position + 1) & coder->pos_mask;
- const uint32_t next_rep_match_price = cur_and_1_price
- + rc_bit_1_price(coder->is_match[state_2][pos_state_next])
- + rc_bit_1_price(coder->is_rep[state_2]);
-
- //for (; len_test >= 2; --len_test) {
- const uint32_t offset = cur + 1 + len_test;
-
- while (len_end < offset)
- coder->opts[++len_end].price = RC_INFINITY_PRICE;
-
- const uint32_t cur_and_len_price = next_rep_match_price
- + get_rep_price(coder, 0, len_test,
- state_2, pos_state_next);
-
- if (cur_and_len_price < coder->opts[offset].price) {
- coder->opts[offset].price = cur_and_len_price;
- coder->opts[offset].pos_prev = cur + 1;
- coder->opts[offset].back_prev = 0;
- coder->opts[offset].prev_1_is_literal = true;
- coder->opts[offset].prev_2 = false;
- }
- //}
- }
- }
-
-
- uint32_t start_len = 2; // speed optimization
-
- for (uint32_t rep_index = 0; rep_index < REP_DISTANCES; ++rep_index) {
- const uint8_t *const buf_back = buf - reps[rep_index] - 1;
- if (not_equal_16(buf, buf_back))
- continue;
-
- uint32_t len_test;
- for (len_test = 2; len_test < buf_avail
- && buf[len_test] == buf_back[len_test];
- ++len_test) ;
-
- while (len_end < cur + len_test)
- coder->opts[++len_end].price = RC_INFINITY_PRICE;
-
- const uint32_t len_test_temp = len_test;
- const uint32_t price = rep_match_price + get_pure_rep_price(
- coder, rep_index, state, pos_state);
-
- do {
- const uint32_t cur_and_len_price = price
- + get_len_price(&coder->rep_len_encoder,
- len_test, pos_state);
-
- if (cur_and_len_price < coder->opts[cur + len_test].price) {
- coder->opts[cur + len_test].price = cur_and_len_price;
- coder->opts[cur + len_test].pos_prev = cur;
- coder->opts[cur + len_test].back_prev = rep_index;
- coder->opts[cur + len_test].prev_1_is_literal = false;
- }
- } while (--len_test >= 2);
-
- len_test = len_test_temp;
-
- if (rep_index == 0)
- start_len = len_test + 1;
-
-
- uint32_t len_test_2 = len_test + 1;
- const uint32_t limit = my_min(buf_avail_full,
- len_test_2 + nice_len);
- for (; len_test_2 < limit
- && buf[len_test_2] == buf_back[len_test_2];
- ++len_test_2) ;
-
- len_test_2 -= len_test + 1;
-
- if (len_test_2 >= 2) {
- lzma_lzma_state state_2 = state;
- update_long_rep(state_2);
-
- uint32_t pos_state_next = (position + len_test) & coder->pos_mask;
-
- const uint32_t cur_and_len_literal_price = price
- + get_len_price(&coder->rep_len_encoder,
- len_test, pos_state)
- + rc_bit_0_price(coder->is_match[state_2][pos_state_next])
- + get_literal_price(coder, position + len_test,
- buf[len_test - 1], true,
- buf_back[len_test], buf[len_test]);
-
- update_literal(state_2);
-
- pos_state_next = (position + len_test + 1) & coder->pos_mask;
-
- const uint32_t next_rep_match_price = cur_and_len_literal_price
- + rc_bit_1_price(coder->is_match[state_2][pos_state_next])
- + rc_bit_1_price(coder->is_rep[state_2]);
-
- //for(; len_test_2 >= 2; len_test_2--) {
- const uint32_t offset = cur + len_test + 1 + len_test_2;
-
- while (len_end < offset)
- coder->opts[++len_end].price = RC_INFINITY_PRICE;
-
- const uint32_t cur_and_len_price = next_rep_match_price
- + get_rep_price(coder, 0, len_test_2,
- state_2, pos_state_next);
-
- if (cur_and_len_price < coder->opts[offset].price) {
- coder->opts[offset].price = cur_and_len_price;
- coder->opts[offset].pos_prev = cur + len_test + 1;
- coder->opts[offset].back_prev = 0;
- coder->opts[offset].prev_1_is_literal = true;
- coder->opts[offset].prev_2 = true;
- coder->opts[offset].pos_prev_2 = cur;
- coder->opts[offset].back_prev_2 = rep_index;
- }
- //}
- }
- }
-
-
- //for (uint32_t len_test = 2; len_test <= new_len; ++len_test)
- if (new_len > buf_avail) {
- new_len = buf_avail;
-
- matches_count = 0;
- while (new_len > coder->matches[matches_count].len)
- ++matches_count;
-
- coder->matches[matches_count++].len = new_len;
- }
-
-
- if (new_len >= start_len) {
- const uint32_t normal_match_price = match_price
- + rc_bit_0_price(coder->is_rep[state]);
-
- while (len_end < cur + new_len)
- coder->opts[++len_end].price = RC_INFINITY_PRICE;
-
- uint32_t i = 0;
- while (start_len > coder->matches[i].len)
- ++i;
-
- for (uint32_t len_test = start_len; ; ++len_test) {
- const uint32_t cur_back = coder->matches[i].dist;
- uint32_t cur_and_len_price = normal_match_price
- + get_pos_len_price(coder,
- cur_back, len_test, pos_state);
-
- if (cur_and_len_price < coder->opts[cur + len_test].price) {
- coder->opts[cur + len_test].price = cur_and_len_price;
- coder->opts[cur + len_test].pos_prev = cur;
- coder->opts[cur + len_test].back_prev
- = cur_back + REP_DISTANCES;
- coder->opts[cur + len_test].prev_1_is_literal = false;
- }
-
- if (len_test == coder->matches[i].len) {
- // Try Match + Literal + Rep0
- const uint8_t *const buf_back = buf - cur_back - 1;
- uint32_t len_test_2 = len_test + 1;
- const uint32_t limit = my_min(buf_avail_full,
- len_test_2 + nice_len);
-
- for (; len_test_2 < limit &&
- buf[len_test_2] == buf_back[len_test_2];
- ++len_test_2) ;
-
- len_test_2 -= len_test + 1;
-
- if (len_test_2 >= 2) {
- lzma_lzma_state state_2 = state;
- update_match(state_2);
- uint32_t pos_state_next
- = (position + len_test) & coder->pos_mask;
-
- const uint32_t cur_and_len_literal_price = cur_and_len_price
- + rc_bit_0_price(
- coder->is_match[state_2][pos_state_next])
- + get_literal_price(coder,
- position + len_test,
- buf[len_test - 1],
- true,
- buf_back[len_test],
- buf[len_test]);
-
- update_literal(state_2);
- pos_state_next = (pos_state_next + 1) & coder->pos_mask;
-
- const uint32_t next_rep_match_price
- = cur_and_len_literal_price
- + rc_bit_1_price(
- coder->is_match[state_2][pos_state_next])
- + rc_bit_1_price(coder->is_rep[state_2]);
-
- // for(; len_test_2 >= 2; --len_test_2) {
- const uint32_t offset = cur + len_test + 1 + len_test_2;
-
- while (len_end < offset)
- coder->opts[++len_end].price = RC_INFINITY_PRICE;
-
- cur_and_len_price = next_rep_match_price
- + get_rep_price(coder, 0, len_test_2,
- state_2, pos_state_next);
-
- if (cur_and_len_price < coder->opts[offset].price) {
- coder->opts[offset].price = cur_and_len_price;
- coder->opts[offset].pos_prev = cur + len_test + 1;
- coder->opts[offset].back_prev = 0;
- coder->opts[offset].prev_1_is_literal = true;
- coder->opts[offset].prev_2 = true;
- coder->opts[offset].pos_prev_2 = cur;
- coder->opts[offset].back_prev_2
- = cur_back + REP_DISTANCES;
- }
- //}
- }
-
- if (++i == matches_count)
- break;
- }
- }
- }
-
- return len_end;
-}
-
-
-extern void
-lzma_lzma_optimum_normal(lzma_coder *restrict coder, lzma_mf *restrict mf,
- uint32_t *restrict back_res, uint32_t *restrict len_res,
- uint32_t position)
-{
- // If we have symbols pending, return the next pending symbol.
- if (coder->opts_end_index != coder->opts_current_index) {
- assert(mf->read_ahead > 0);
- *len_res = coder->opts[coder->opts_current_index].pos_prev
- - coder->opts_current_index;
- *back_res = coder->opts[coder->opts_current_index].back_prev;
- coder->opts_current_index = coder->opts[
- coder->opts_current_index].pos_prev;
- return;
- }
-
- // Update the price tables. In LZMA SDK <= 4.60 (and possibly later)
- // this was done in both initialization function and in the main loop.
- // In liblzma they were moved into this single place.
- if (mf->read_ahead == 0) {
- if (coder->match_price_count >= (1 << 7))
- fill_distances_prices(coder);
-
- if (coder->align_price_count >= ALIGN_TABLE_SIZE)
- fill_align_prices(coder);
- }
-
- // TODO: This needs quite a bit of cleaning still. But splitting
- // the original function into two pieces makes it at least a little
- // more readable, since those two parts don't share many variables.
-
- uint32_t len_end = helper1(coder, mf, back_res, len_res, position);
- if (len_end == UINT32_MAX)
- return;
-
- uint32_t reps[REP_DISTANCES];
- memcpy(reps, coder->reps, sizeof(reps));
-
- uint32_t cur;
- for (cur = 1; cur < len_end; ++cur) {
- assert(cur < OPTS);
-
- coder->longest_match_length = mf_find(
- mf, &coder->matches_count, coder->matches);
-
- if (coder->longest_match_length >= mf->nice_len)
- break;
-
- len_end = helper2(coder, reps, mf_ptr(mf) - 1, len_end,
- position + cur, cur, mf->nice_len,
- my_min(mf_avail(mf) + 1, OPTS - 1 - cur));
- }
-
- backward(coder, len_res, back_res, cur);
- return;
-}
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma_encoder_presets.c r-base-3.3.1/src/extra/xz/lzma/lzma_encoder_presets.c
--- r-base-3.2.3/src/extra/xz/lzma/lzma_encoder_presets.c 2015-03-18 23:02:07.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma_encoder_presets.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,63 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma_encoder_presets.c
-/// \brief Encoder presets
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "common.h"
-
-
-extern LZMA_API(lzma_bool)
-lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset)
-{
- const uint32_t level = preset & LZMA_PRESET_LEVEL_MASK;
- const uint32_t flags = preset & ~LZMA_PRESET_LEVEL_MASK;
- const uint32_t supported_flags = LZMA_PRESET_EXTREME;
-
- if (level > 9 || (flags & ~supported_flags))
- return true;
-
- options->preset_dict = NULL;
- options->preset_dict_size = 0;
-
- options->lc = LZMA_LC_DEFAULT;
- options->lp = LZMA_LP_DEFAULT;
- options->pb = LZMA_PB_DEFAULT;
-
- static const uint8_t dict_pow2[]
- = { 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 };
- options->dict_size = UINT32_C(1) << dict_pow2[level];
-
- if (level <= 3) {
- options->mode = LZMA_MODE_FAST;
- options->mf = level == 0 ? LZMA_MF_HC3 : LZMA_MF_HC4;
- options->nice_len = level <= 1 ? 128 : 273;
- static const uint8_t depths[] = { 4, 8, 24, 48 };
- options->depth = depths[level];
- } else {
- options->mode = LZMA_MODE_NORMAL;
- options->mf = LZMA_MF_BT4;
- options->nice_len = level == 4 ? 16 : level == 5 ? 32 : 64;
- options->depth = 0;
- }
-
- if (flags & LZMA_PRESET_EXTREME) {
- options->mode = LZMA_MODE_NORMAL;
- options->mf = LZMA_MF_BT4;
- if (level == 3 || level == 5) {
- options->nice_len = 192;
- options->depth = 0;
- } else {
- options->nice_len = 273;
- options->depth = 512;
- }
- }
-
- return false;
-}
diff -Nru r-base-3.2.3/src/extra/xz/lzma/lzma_encoder_private.h r-base-3.3.1/src/extra/xz/lzma/lzma_encoder_private.h
--- r-base-3.2.3/src/extra/xz/lzma/lzma_encoder_private.h 2010-11-08 23:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/lzma/lzma_encoder_private.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,148 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file lzma_encoder_private.h
-/// \brief Private definitions for LZMA encoder
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_LZMA_ENCODER_PRIVATE_H
-#define LZMA_LZMA_ENCODER_PRIVATE_H
-
-#include "lz_encoder.h"
-#include "range_encoder.h"
-#include "lzma_common.h"
-#include "lzma_encoder.h"
-
-
-// Macro to compare if the first two bytes in two buffers differ. This is
-// needed in lzma_lzma_optimum_*() to test if the match is at least
-// MATCH_LEN_MIN bytes. Unaligned access gives tiny gain so there's no
-// reason to not use it when it is supported.
-#ifdef TUKLIB_FAST_UNALIGNED_ACCESS
-# define not_equal_16(a, b) \
- (*(const uint16_t *)(a) != *(const uint16_t *)(b))
-#else
-# define not_equal_16(a, b) \
- ((a)[0] != (b)[0] || (a)[1] != (b)[1])
-#endif
-
-
-// Optimal - Number of entries in the optimum array.
-#define OPTS (1 << 12)
-
-
-typedef struct {
- probability choice;
- probability choice2;
- probability low[POS_STATES_MAX][LEN_LOW_SYMBOLS];
- probability mid[POS_STATES_MAX][LEN_MID_SYMBOLS];
- probability high[LEN_HIGH_SYMBOLS];
-
- uint32_t prices[POS_STATES_MAX][LEN_SYMBOLS];
- uint32_t table_size;
- uint32_t counters[POS_STATES_MAX];
-
-} lzma_length_encoder;
-
-
-typedef struct {
- lzma_lzma_state state;
-
- bool prev_1_is_literal;
- bool prev_2;
-
- uint32_t pos_prev_2;
- uint32_t back_prev_2;
-
- uint32_t price;
- uint32_t pos_prev; // pos_next;
- uint32_t back_prev;
-
- uint32_t backs[REP_DISTANCES];
-
-} lzma_optimal;
-
-
-struct lzma_coder_s {
- /// Range encoder
- lzma_range_encoder rc;
-
- /// State
- lzma_lzma_state state;
-
- /// The four most recent match distances
- uint32_t reps[REP_DISTANCES];
-
- /// Array of match candidates
- lzma_match matches[MATCH_LEN_MAX + 1];
-
- /// Number of match candidates in matches[]
- uint32_t matches_count;
-
- /// Variable to hold the length of the longest match between calls
- /// to lzma_lzma_optimum_*().
- uint32_t longest_match_length;
-
- /// True if using getoptimumfast
- bool fast_mode;
-
- /// True if the encoder has been initialized by encoding the first
- /// byte as a literal.
- bool is_initialized;
-
- /// True if the range encoder has been flushed, but not all bytes
- /// have been written to the output buffer yet.
- bool is_flushed;
-
- uint32_t pos_mask; ///< (1 << pos_bits) - 1
- uint32_t literal_context_bits;
- uint32_t literal_pos_mask;
-
- // These are the same as in lzma_decoder.c. See comments there.
- probability literal[LITERAL_CODERS_MAX][LITERAL_CODER_SIZE];
- probability is_match[STATES][POS_STATES_MAX];
- probability is_rep[STATES];
- probability is_rep0[STATES];
- probability is_rep1[STATES];
- probability is_rep2[STATES];
- probability is_rep0_long[STATES][POS_STATES_MAX];
- probability pos_slot[LEN_TO_POS_STATES][POS_SLOTS];
- probability pos_special[FULL_DISTANCES - END_POS_MODEL_INDEX];
- probability pos_align[ALIGN_TABLE_SIZE];
-
- // These are the same as in lzma_decoder.c except that the encoders
- // include also price tables.
- lzma_length_encoder match_len_encoder;
- lzma_length_encoder rep_len_encoder;
-
- // Price tables
- uint32_t pos_slot_prices[LEN_TO_POS_STATES][POS_SLOTS];
- uint32_t distances_prices[LEN_TO_POS_STATES][FULL_DISTANCES];
- uint32_t dist_table_size;
- uint32_t match_price_count;
-
- uint32_t align_prices[ALIGN_TABLE_SIZE];
- uint32_t align_price_count;
-
- // Optimal
- uint32_t opts_end_index;
- uint32_t opts_current_index;
- lzma_optimal opts[OPTS];
-};
-
-
-extern void lzma_lzma_optimum_fast(
- lzma_coder *restrict coder, lzma_mf *restrict mf,
- uint32_t *restrict back_res, uint32_t *restrict len_res);
-
-extern void lzma_lzma_optimum_normal(lzma_coder *restrict coder,
- lzma_mf *restrict mf, uint32_t *restrict back_res,
- uint32_t *restrict len_res, uint32_t position);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/Makefile.in r-base-3.3.1/src/extra/xz/Makefile.in
--- r-base-3.2.3/src/extra/xz/Makefile.in 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/Makefile.in 1970-01-01 00:00:00.000000000 +0000
@@ -1,87 +0,0 @@
-#
-# ${R_HOME}/src/extra/xz/Makefile
-
-VPATH = @srcdir@
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-
-top_builddir = ../../..
-subdir = src/extra/xz
-R_HOME = $(top_builddir)
-
-include $(top_builddir)/Makeconf
-
-LZMA_CPPFLAGS = -I$(srcdir)/api
-ALL_CPPFLAGS = $(LZMA_CPPFLAGS) $(R_XTRA_CPPFLAGS) $(CPPFLAGS) $(DEFS)
-
-SOURCES = \
- alone_decoder.c alone_encoder.c arm.c armthumb.c auto_decoder.c \
- block_buffer_decoder.c block_buffer_encoder.c block_decoder.c \
- block_encoder.c block_header_decoder.c block_header_encoder.c block_util.c \
- check.c common.c crc32_fast.c crc32_table.c \
- crc64_fast.c crc64_table.c delta_common.c delta_decoder.c \
- delta_encoder.c easy_buffer_encoder.c easy_decoder_memusage.c easy_encoder.c \
- easy_encoder_memusage.c easy_preset.c fastpos_table.c \
- filter_buffer_decoder.c filter_buffer_encoder.c filter_common.c \
- filter_decoder.c filter_encoder.c filter_flags_decoder.c \
- filter_flags_encoder.c ia64.c index.c index_decoder.c index_encoder.c \
- index_hash.c lz_decoder.c lz_encoder.c lz_encoder_mf.c lzma2_decoder.c \
- lzma2_encoder.c lzma_decoder.c lzma_encoder.c lzma_encoder_optimum_fast.c \
- lzma_encoder_optimum_normal.c lzma_encoder_presets.c powerpc.c \
- price_table.c sha256.c simple_coder.c simple_decoder.c \
- simple_encoder.c sparc.c stream_buffer_decoder.c stream_buffer_encoder.c \
- stream_decoder.c stream_encoder.c stream_flags_common.c \
- stream_flags_decoder.c stream_flags_encoder.c \
- vli_decoder.c vli_encoder.c vli_size.c x86.c
-
-OBJECTS = $(SOURCES:.c=.o)
-@WANT_R_SHLIB_TRUE@ALL_CFLAGS = $(ALL_CFLAGS_LO) @C_VISIBILITY@
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-DISTFILES = Makefile.in Makefile.win R_changes
-noinst_LIBRARIES = liblzma.a
-liblzma_a_SOURCES = $(SOURCES)
-liblzma_a_OBJECTS = $(OBJECTS)
-SUBDIRS_WITH_NO_BUILD = \
- api check common delta lz lzma rangecoder simple
-
-all: @BUILD_XZ_TRUE@ R
-
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
-
-R: Makefile @BUILD_XZ_TRUE@ stamp
- @BUILD_XZ_TRUE@ @$(MAKE) $(noinst_LIBRARIES)
-
-stamp:
- @ln -s $(srcdir)/*/*.c $(srcdir)/*/*.h .
- touch stamp
-
-liblzma.a: $(liblzma_a_OBJECTS)
- rm -f $@
- $(AR) cr $@ $(liblzma_a_OBJECTS)
- $(RANLIB) $@
-
-mostlyclean: clean
-clean:
- @-rm -f Makedeps stamp *.c *.h *.o *.lo *.a
-distclean: clean
- @-rm -f Makefile
-maintainer-clean: distclean
-
-install install-strip uninstall TAGS info dvi check:
-
-distdir: $(DISTFILES)
- @for f in $(DISTFILES); do \
- test -f $(distdir)/$${f} \
- || ln $(srcdir)/$${f} $(distdir)/$${f} 2>/dev/null \
- || cp -p $(srcdir)/$${f} $(distdir)/$${f}; \
- done
- @for d in $(SUBDIRS_WITH_NO_BUILD); do \
- ((cd $(srcdir); $(TAR) -c -f - $(DISTDIR_TAR_EXCLUDE) $${d}) \
- | (cd $(distdir); $(TAR) -x -f -)) \
- || exit 1; \
- done
-
-## Automagically generated dependencies:
-
diff -Nru r-base-3.2.3/src/extra/xz/Makefile.win r-base-3.3.1/src/extra/xz/Makefile.win
--- r-base-3.2.3/src/extra/xz/Makefile.win 2015-03-18 23:02:07.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/Makefile.win 1970-01-01 00:00:00.000000000 +0000
@@ -1,47 +0,0 @@
-#-*- Makefile -*-
-include ../../gnuwin32/MkRules
-
-CPPFLAGS = -I../../include -I. -Iapi -DLZMA_API_STATIC -DHAVE_CONFIG_H -DWIN32
-
-SOURCES = \
- alone_decoder.c alone_encoder.c arm.c armthumb.c auto_decoder.c \
- block_buffer_decoder.c block_buffer_encoder.c block_decoder.c \
- block_encoder.c block_header_decoder.c block_header_encoder.c block_util.c \
- check.c common.c crc32_table.c \
- crc64_table.c delta_common.c delta_decoder.c \
- delta_encoder.c easy_buffer_encoder.c easy_decoder_memusage.c easy_encoder.c \
- easy_encoder_memusage.c easy_preset.c fastpos_table.c \
- filter_buffer_decoder.c filter_buffer_encoder.c filter_common.c \
- filter_decoder.c filter_encoder.c filter_flags_decoder.c \
- filter_flags_encoder.c ia64.c index.c index_decoder.c index_encoder.c \
- index_hash.c lz_decoder.c lz_encoder.c lz_encoder_mf.c lzma2_decoder.c \
- lzma2_encoder.c lzma_decoder.c lzma_encoder.c lzma_encoder_optimum_fast.c \
- lzma_encoder_optimum_normal.c lzma_encoder_presets.c powerpc.c \
- price_table.c sha256.c simple_coder.c simple_decoder.c \
- simple_encoder.c sparc.c stream_buffer_decoder.c stream_buffer_encoder.c \
- stream_decoder.c stream_encoder.c stream_flags_common.c \
- stream_flags_decoder.c stream_flags_encoder.c \
- vli_decoder.c vli_encoder.c vli_size.c x86.c
-
-
-## Use assembler version on i386
-ifeq "$(WIN)" "64"
-OBJECTS = $(SOURCES:.c=.o) crc32_fast.o crc64_fast.o
-else
-OBJECTS = $(SOURCES:.c=.o) crc32_x86.o crc64_x86.o
-endif
-
-all:
- @$(MAKE) -f Makefile.win stamp
- @$(MAKE) -f Makefile.win liblzma.a
-
-stamp:
- @cp -p */*.c */*.h check/*.S .
- touch stamp
-
-liblzma.a: $(OBJECTS)
-
-clean:
- @$(RM) -f Makedeps stamp *.c *.h *.o *.S
-distclean: clean
- @$(RM) liblzma.a
diff -Nru r-base-3.2.3/src/extra/xz/rangecoder/price.h r-base-3.3.1/src/extra/xz/rangecoder/price.h
--- r-base-3.2.3/src/extra/xz/rangecoder/price.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/rangecoder/price.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,92 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file price.h
-/// \brief Probability price calculation
-//
-// Author: Igor Pavlov
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_PRICE_H
-#define LZMA_PRICE_H
-
-
-#define RC_MOVE_REDUCING_BITS 4
-#define RC_BIT_PRICE_SHIFT_BITS 4
-#define RC_PRICE_TABLE_SIZE (RC_BIT_MODEL_TOTAL >> RC_MOVE_REDUCING_BITS)
-
-#define RC_INFINITY_PRICE (UINT32_C(1) << 30)
-
-
-/// Lookup table for the inline functions defined in this file.
-extern const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE];
-
-
-static inline uint32_t
-rc_bit_price(const probability prob, const uint32_t bit)
-{
- return lzma_rc_prices[(prob ^ ((UINT32_C(0) - bit)
- & (RC_BIT_MODEL_TOTAL - 1))) >> RC_MOVE_REDUCING_BITS];
-}
-
-
-static inline uint32_t
-rc_bit_0_price(const probability prob)
-{
- return lzma_rc_prices[prob >> RC_MOVE_REDUCING_BITS];
-}
-
-
-static inline uint32_t
-rc_bit_1_price(const probability prob)
-{
- return lzma_rc_prices[(prob ^ (RC_BIT_MODEL_TOTAL - 1))
- >> RC_MOVE_REDUCING_BITS];
-}
-
-
-static inline uint32_t
-rc_bittree_price(const probability *const probs,
- const uint32_t bit_levels, uint32_t symbol)
-{
- uint32_t price = 0;
- symbol += UINT32_C(1) << bit_levels;
-
- do {
- const uint32_t bit = symbol & 1;
- symbol >>= 1;
- price += rc_bit_price(probs[symbol], bit);
- } while (symbol != 1);
-
- return price;
-}
-
-
-static inline uint32_t
-rc_bittree_reverse_price(const probability *const probs,
- uint32_t bit_levels, uint32_t symbol)
-{
- uint32_t price = 0;
- uint32_t model_index = 1;
-
- do {
- const uint32_t bit = symbol & 1;
- symbol >>= 1;
- price += rc_bit_price(probs[model_index], bit);
- model_index = (model_index << 1) + bit;
- } while (--bit_levels != 0);
-
- return price;
-}
-
-
-static inline uint32_t
-rc_direct_price(const uint32_t bits)
-{
- return bits << RC_BIT_PRICE_SHIFT_BITS;
-}
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/rangecoder/price_table.c r-base-3.3.1/src/extra/xz/rangecoder/price_table.c
--- r-base-3.2.3/src/extra/xz/rangecoder/price_table.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/rangecoder/price_table.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,22 +0,0 @@
-/* This file has been automatically generated by price_tablegen.c. */
-
-#include "range_encoder.h"
-
-const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE] = {
- 128, 103, 91, 84, 78, 73, 69, 66,
- 63, 61, 58, 56, 54, 52, 51, 49,
- 48, 46, 45, 44, 43, 42, 41, 40,
- 39, 38, 37, 36, 35, 34, 34, 33,
- 32, 31, 31, 30, 29, 29, 28, 28,
- 27, 26, 26, 25, 25, 24, 24, 23,
- 23, 22, 22, 22, 21, 21, 20, 20,
- 19, 19, 19, 18, 18, 17, 17, 17,
- 16, 16, 16, 15, 15, 15, 14, 14,
- 14, 13, 13, 13, 12, 12, 12, 11,
- 11, 11, 11, 10, 10, 10, 10, 9,
- 9, 9, 9, 8, 8, 8, 8, 7,
- 7, 7, 7, 6, 6, 6, 6, 5,
- 5, 5, 5, 5, 4, 4, 4, 4,
- 3, 3, 3, 3, 3, 2, 2, 2,
- 2, 2, 2, 1, 1, 1, 1, 1
-};
diff -Nru r-base-3.2.3/src/extra/xz/rangecoder/price_tablegen.c r-base-3.3.1/src/extra/xz/rangecoder/price_tablegen.c
--- r-base-3.2.3/src/extra/xz/rangecoder/price_tablegen.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/rangecoder/price_tablegen.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,87 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file price_tablegen.c
-/// \brief Probability price table generator
-///
-/// Compiling: gcc -std=c99 -o price_tablegen price_tablegen.c
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include
-#include
-#include "range_common.h"
-#include "price.h"
-
-
-static uint32_t rc_prices[RC_PRICE_TABLE_SIZE];
-
-
-static void
-init_price_table(void)
-{
- for (uint32_t i = (UINT32_C(1) << RC_MOVE_REDUCING_BITS) / 2;
- i < RC_BIT_MODEL_TOTAL;
- i += (UINT32_C(1) << RC_MOVE_REDUCING_BITS)) {
- const uint32_t cycles_bits = RC_BIT_PRICE_SHIFT_BITS;
- uint32_t w = i;
- uint32_t bit_count = 0;
-
- for (uint32_t j = 0; j < cycles_bits; ++j) {
- w *= w;
- bit_count <<= 1;
-
- while (w >= (UINT32_C(1) << 16)) {
- w >>= 1;
- ++bit_count;
- }
- }
-
- rc_prices[i >> RC_MOVE_REDUCING_BITS]
- = (RC_BIT_MODEL_TOTAL_BITS << cycles_bits)
- - 15 - bit_count;
- }
-
- return;
-}
-
-
-static void
-print_price_table(void)
-{
- printf("/* This file has been automatically generated by "
- "price_tablegen.c. */\n\n"
- "#include \"range_encoder.h\"\n\n"
- "const uint8_t lzma_rc_prices["
- "RC_PRICE_TABLE_SIZE] = {");
-
- const size_t array_size = sizeof(lzma_rc_prices)
- / sizeof(lzma_rc_prices[0]);
- for (size_t i = 0; i < array_size; ++i) {
- if (i % 8 == 0)
- printf("\n\t");
-
- printf("%4" PRIu32, rc_prices[i]);
-
- if (i != array_size - 1)
- printf(",");
- }
-
- printf("\n};\n");
-
- return;
-}
-
-
-int
-main(void)
-{
- init_price_table();
- print_price_table();
- return 0;
-}
diff -Nru r-base-3.2.3/src/extra/xz/rangecoder/range_common.h r-base-3.3.1/src/extra/xz/rangecoder/range_common.h
--- r-base-3.2.3/src/extra/xz/rangecoder/range_common.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/rangecoder/range_common.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,73 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file range_common.h
-/// \brief Common things for range encoder and decoder
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_RANGE_COMMON_H
-#define LZMA_RANGE_COMMON_H
-
-#ifdef HAVE_CONFIG_H
-# include "common.h"
-#endif
-
-
-///////////////
-// Constants //
-///////////////
-
-#define RC_SHIFT_BITS 8
-#define RC_TOP_BITS 24
-#define RC_TOP_VALUE (UINT32_C(1) << RC_TOP_BITS)
-#define RC_BIT_MODEL_TOTAL_BITS 11
-#define RC_BIT_MODEL_TOTAL (UINT32_C(1) << RC_BIT_MODEL_TOTAL_BITS)
-#define RC_MOVE_BITS 5
-
-
-////////////
-// Macros //
-////////////
-
-// Resets the probability so that both 0 and 1 have probability of 50 %
-#define bit_reset(prob) \
- prob = RC_BIT_MODEL_TOTAL >> 1
-
-// This does the same for a complete bit tree.
-// (A tree represented as an array.)
-#define bittree_reset(probs, bit_levels) \
- for (uint32_t bt_i = 0; bt_i < (1 << (bit_levels)); ++bt_i) \
- bit_reset((probs)[bt_i])
-
-
-//////////////////////
-// Type definitions //
-//////////////////////
-
-/// \brief Type of probabilities used with range coder
-///
-/// This needs to be at least 12-bit integer, so uint16_t is a logical choice.
-/// However, on some architecture and compiler combinations, a bigger type
-/// may give better speed, because the probability variables are accessed
-/// a lot. On the other hand, bigger probability type increases cache
-/// footprint, since there are 2 to 14 thousand probability variables in
-/// LZMA (assuming the limit of lc + lp <= 4; with lc + lp <= 12 there
-/// would be about 1.5 million variables).
-///
-/// With malicious files, the initialization speed of the LZMA decoder can
-/// become important. In that case, smaller probability variables mean that
-/// there is less bytes to write to RAM, which makes initialization faster.
-/// With big probability type, the initialization can become so slow that it
-/// can be a problem e.g. for email servers doing virus scanning.
-///
-/// I will be sticking to uint16_t unless some specific architectures
-/// are *much* faster (20-50 %) with uint32_t.
-typedef uint16_t probability;
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/rangecoder/range_decoder.h r-base-3.3.1/src/extra/xz/rangecoder/range_decoder.h
--- r-base-3.2.3/src/extra/xz/rangecoder/range_decoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/rangecoder/range_decoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,179 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file range_decoder.h
-/// \brief Range Decoder
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_RANGE_DECODER_H
-#define LZMA_RANGE_DECODER_H
-
-#include "range_common.h"
-
-
-typedef struct {
- uint32_t range;
- uint32_t code;
- uint32_t init_bytes_left;
-} lzma_range_decoder;
-
-
-/// Reads the first five bytes to initialize the range decoder.
-static inline bool
-rc_read_init(lzma_range_decoder *rc, const uint8_t *restrict in,
- size_t *restrict in_pos, size_t in_size)
-{
- while (rc->init_bytes_left > 0) {
- if (*in_pos == in_size)
- return false;
-
- rc->code = (rc->code << 8) | in[*in_pos];
- ++*in_pos;
- --rc->init_bytes_left;
- }
-
- return true;
-}
-
-
-/// Makes local copies of range decoder and *in_pos variables. Doing this
-/// improves speed significantly. The range decoder macros expect also
-/// variables `in' and `in_size' to be defined.
-#define rc_to_local(range_decoder, in_pos) \
- lzma_range_decoder rc = range_decoder; \
- size_t rc_in_pos = (in_pos); \
- uint32_t rc_bound
-
-
-/// Stores the local copes back to the range decoder structure.
-#define rc_from_local(range_decoder, in_pos) \
-do { \
- range_decoder = rc; \
- in_pos = rc_in_pos; \
-} while (0)
-
-
-/// Resets the range decoder structure.
-#define rc_reset(range_decoder) \
-do { \
- (range_decoder).range = UINT32_MAX; \
- (range_decoder).code = 0; \
- (range_decoder).init_bytes_left = 5; \
-} while (0)
-
-
-/// When decoding has been properly finished, rc.code is always zero unless
-/// the input stream is corrupt. So checking this can catch some corrupt
-/// files especially if they don't have any other integrity check.
-#define rc_is_finished(range_decoder) \
- ((range_decoder).code == 0)
-
-
-/// Read the next input byte if needed. If more input is needed but there is
-/// no more input available, "goto out" is used to jump out of the main
-/// decoder loop.
-#define rc_normalize(seq) \
-do { \
- if (rc.range < RC_TOP_VALUE) { \
- if (unlikely(rc_in_pos == in_size)) { \
- coder->sequence = seq; \
- goto out; \
- } \
- rc.range <<= RC_SHIFT_BITS; \
- rc.code = (rc.code << RC_SHIFT_BITS) | in[rc_in_pos++]; \
- } \
-} while (0)
-
-
-/// Start decoding a bit. This must be used together with rc_update_0()
-/// and rc_update_1():
-///
-/// rc_if_0(prob, seq) {
-/// rc_update_0(prob);
-/// // Do something
-/// } else {
-/// rc_update_1(prob);
-/// // Do something else
-/// }
-///
-#define rc_if_0(prob, seq) \
- rc_normalize(seq); \
- rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * (prob); \
- if (rc.code < rc_bound)
-
-
-/// Update the range decoder state and the used probability variable to
-/// match a decoded bit of 0.
-#define rc_update_0(prob) \
-do { \
- rc.range = rc_bound; \
- prob += (RC_BIT_MODEL_TOTAL - (prob)) >> RC_MOVE_BITS; \
-} while (0)
-
-
-/// Update the range decoder state and the used probability variable to
-/// match a decoded bit of 1.
-#define rc_update_1(prob) \
-do { \
- rc.range -= rc_bound; \
- rc.code -= rc_bound; \
- prob -= (prob) >> RC_MOVE_BITS; \
-} while (0)
-
-
-/// Decodes one bit and runs action0 or action1 depending on the decoded bit.
-/// This macro is used as the last step in bittree reverse decoders since
-/// those don't use "symbol" for anything else than indexing the probability
-/// arrays.
-#define rc_bit_last(prob, action0, action1, seq) \
-do { \
- rc_if_0(prob, seq) { \
- rc_update_0(prob); \
- action0; \
- } else { \
- rc_update_1(prob); \
- action1; \
- } \
-} while (0)
-
-
-/// Decodes one bit, updates "symbol", and runs action0 or action1 depending
-/// on the decoded bit.
-#define rc_bit(prob, action0, action1, seq) \
- rc_bit_last(prob, \
- symbol <<= 1; action0, \
- symbol = (symbol << 1) + 1; action1, \
- seq);
-
-
-/// Like rc_bit() but add "case seq:" as a prefix. This makes the unrolled
-/// loops more readable because the code isn't littered with "case"
-/// statements. On the other hand this also makes it less readable, since
-/// spotting the places where the decoder loop may be restarted is less
-/// obvious.
-#define rc_bit_case(prob, action0, action1, seq) \
- case seq: rc_bit(prob, action0, action1, seq)
-
-
-/// Decode a bit without using a probability.
-#define rc_direct(dest, seq) \
-do { \
- rc_normalize(seq); \
- rc.range >>= 1; \
- rc.code -= rc.range; \
- rc_bound = UINT32_C(0) - (rc.code >> 31); \
- rc.code += rc.range & rc_bound; \
- dest = (dest << 1) + (rc_bound + 1); \
-} while (0)
-
-
-// NOTE: No macros are provided for bittree decoding. It seems to be simpler
-// to just write them open in the code.
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/rangecoder/range_encoder.h r-base-3.3.1/src/extra/xz/rangecoder/range_encoder.h
--- r-base-3.2.3/src/extra/xz/rangecoder/range_encoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/rangecoder/range_encoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,231 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file range_encoder.h
-/// \brief Range Encoder
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_RANGE_ENCODER_H
-#define LZMA_RANGE_ENCODER_H
-
-#include "range_common.h"
-#include "price.h"
-
-
-/// Maximum number of symbols that can be put pending into lzma_range_encoder
-/// structure between calls to lzma_rc_encode(). For LZMA, 52+5 is enough
-/// (match with big distance and length followed by range encoder flush).
-#define RC_SYMBOLS_MAX 58
-
-
-typedef struct {
- uint64_t low;
- uint64_t cache_size;
- uint32_t range;
- uint8_t cache;
-
- /// Number of symbols in the tables
- size_t count;
-
- /// rc_encode()'s position in the tables
- size_t pos;
-
- /// Symbols to encode
- enum {
- RC_BIT_0,
- RC_BIT_1,
- RC_DIRECT_0,
- RC_DIRECT_1,
- RC_FLUSH,
- } symbols[RC_SYMBOLS_MAX];
-
- /// Probabilities associated with RC_BIT_0 or RC_BIT_1
- probability *probs[RC_SYMBOLS_MAX];
-
-} lzma_range_encoder;
-
-
-static inline void
-rc_reset(lzma_range_encoder *rc)
-{
- rc->low = 0;
- rc->cache_size = 1;
- rc->range = UINT32_MAX;
- rc->cache = 0;
- rc->count = 0;
- rc->pos = 0;
-}
-
-
-static inline void
-rc_bit(lzma_range_encoder *rc, probability *prob, uint32_t bit)
-{
- rc->symbols[rc->count] = bit;
- rc->probs[rc->count] = prob;
- ++rc->count;
-}
-
-
-static inline void
-rc_bittree(lzma_range_encoder *rc, probability *probs,
- uint32_t bit_count, uint32_t symbol)
-{
- uint32_t model_index = 1;
-
- do {
- const uint32_t bit = (symbol >> --bit_count) & 1;
- rc_bit(rc, &probs[model_index], bit);
- model_index = (model_index << 1) + bit;
- } while (bit_count != 0);
-}
-
-
-static inline void
-rc_bittree_reverse(lzma_range_encoder *rc, probability *probs,
- uint32_t bit_count, uint32_t symbol)
-{
- uint32_t model_index = 1;
-
- do {
- const uint32_t bit = symbol & 1;
- symbol >>= 1;
- rc_bit(rc, &probs[model_index], bit);
- model_index = (model_index << 1) + bit;
- } while (--bit_count != 0);
-}
-
-
-static inline void
-rc_direct(lzma_range_encoder *rc,
- uint32_t value, uint32_t bit_count)
-{
- do {
- rc->symbols[rc->count++]
- = RC_DIRECT_0 + ((value >> --bit_count) & 1);
- } while (bit_count != 0);
-}
-
-
-static inline void
-rc_flush(lzma_range_encoder *rc)
-{
- for (size_t i = 0; i < 5; ++i)
- rc->symbols[rc->count++] = RC_FLUSH;
-}
-
-
-static inline bool
-rc_shift_low(lzma_range_encoder *rc,
- uint8_t *out, size_t *out_pos, size_t out_size)
-{
- if ((uint32_t)(rc->low) < (uint32_t)(0xFF000000)
- || (uint32_t)(rc->low >> 32) != 0) {
- do {
- if (*out_pos == out_size)
- return true;
-
- out[*out_pos] = rc->cache + (uint8_t)(rc->low >> 32);
- ++*out_pos;
- rc->cache = 0xFF;
-
- } while (--rc->cache_size != 0);
-
- rc->cache = (rc->low >> 24) & 0xFF;
- }
-
- ++rc->cache_size;
- rc->low = (rc->low & 0x00FFFFFF) << RC_SHIFT_BITS;
-
- return false;
-}
-
-
-static inline bool
-rc_encode(lzma_range_encoder *rc,
- uint8_t *out, size_t *out_pos, size_t out_size)
-{
- assert(rc->count <= RC_SYMBOLS_MAX);
-
- while (rc->pos < rc->count) {
- // Normalize
- if (rc->range < RC_TOP_VALUE) {
- if (rc_shift_low(rc, out, out_pos, out_size))
- return true;
-
- rc->range <<= RC_SHIFT_BITS;
- }
-
- // Encode a bit
- switch (rc->symbols[rc->pos]) {
- case RC_BIT_0: {
- probability prob = *rc->probs[rc->pos];
- rc->range = (rc->range >> RC_BIT_MODEL_TOTAL_BITS)
- * prob;
- prob += (RC_BIT_MODEL_TOTAL - prob) >> RC_MOVE_BITS;
- *rc->probs[rc->pos] = prob;
- break;
- }
-
- case RC_BIT_1: {
- probability prob = *rc->probs[rc->pos];
- const uint32_t bound = prob * (rc->range
- >> RC_BIT_MODEL_TOTAL_BITS);
- rc->low += bound;
- rc->range -= bound;
- prob -= prob >> RC_MOVE_BITS;
- *rc->probs[rc->pos] = prob;
- break;
- }
-
- case RC_DIRECT_0:
- rc->range >>= 1;
- break;
-
- case RC_DIRECT_1:
- rc->range >>= 1;
- rc->low += rc->range;
- break;
-
- case RC_FLUSH:
- // Prevent further normalizations.
- rc->range = UINT32_MAX;
-
- // Flush the last five bytes (see rc_flush()).
- do {
- if (rc_shift_low(rc, out, out_pos, out_size))
- return true;
- } while (++rc->pos < rc->count);
-
- // Reset the range encoder so we are ready to continue
- // encoding if we weren't finishing the stream.
- rc_reset(rc);
- return false;
-
- default:
- assert(0);
- break;
- }
-
- ++rc->pos;
- }
-
- rc->count = 0;
- rc->pos = 0;
-
- return false;
-}
-
-
-static inline uint64_t
-rc_pending(const lzma_range_encoder *rc)
-{
- return rc->cache_size + 5 - 1;
-}
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/R_changes r-base-3.3.1/src/extra/xz/R_changes
--- r-base-3.2.3/src/extra/xz/R_changes 2015-03-18 23:02:07.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/R_changes 1970-01-01 00:00:00.000000000 +0000
@@ -1,96 +0,0 @@
-All the files from xz-utils are in the public domain.
-
-This is (most of) subdirectory src/liblzma of xz-utils, except for
-files Makefile.in, Makefile.win and R_changes and with the patches
-below.
-
-common/{bswap,mythread,tuklib*}.h are from xz-utils/src/common.
-
-common/local.h is a new file (the set of definitions of features to be built).
-
-x86 performance optimizations are only used on (32-bit) Windows: it is
-assumed that on other 32-bit OSes an optimized system liblzma is or
-could be made available (and this directory is not compiled if a
-system version is available).
-
-common/sysdefs.h is a modified copy of xz-utils/src/common/sysdefs.h which
-- includes local.h
-- avoids Mingw versions of stdio.
-- r51513: Change _Bool to _Bool8 to avoid clashes on one Solaris 10 system.
- (Solaris 10 has stdbool.h, but it was not being found on that system.)
-
-We control visibility and make most symbols hidden.
-
---- xz-5.0.7/src/liblzma/common/common.h 2014-09-20 17:48:05.000000000 +0100
-+++ common/common.h 2014-11-21 18:16:04.000000000 +0000
-@@ -23,9 +23,7 @@
- # else
- # define LZMA_API_EXPORT
- # endif
--// Don't use ifdef or defined() below.
--#elif HAVE_VISIBILITY
--# define LZMA_API_EXPORT __attribute__((__visibility__("default")))
-+// R change: we do not want all symbols visible
- #else
- # define LZMA_API_EXPORT
- #endif
-
-
---- xz-5.0.7/src/common/sysdefs.h 2014-09-20 17:48:05.000000000 +0100
-+++ /common/sysdefs.h 2014-11-19 10:07:45.000000000 +0000
-@@ -24,10 +24,12 @@
- # include
- #endif
-
-+// R change
-+#include "local.h"
- // Get standard-compliant stdio functions under MinGW and MinGW-w64.
--#ifdef __MINGW32__
--# define __USE_MINGW_ANSI_STDIO 1
--#endif
-+//#ifdef __MINGW32__
-+//# define __USE_MINGW_ANSI_STDIO 1
-+//#endif
-
- // size_t and NULL
- #include
-@@ -143,9 +145,10 @@
- # include
- #else
- # if ! HAVE__BOOL
--typedef unsigned char _Bool;
-+/* _Bool gave problems on one Solaris system */
-+typedef unsigned char _Bool8;
- # endif
--# define bool _Bool
-+# define bool _Bool8
- # define false 0
- # define true 1
- # define __bool_true_false_are_defined 1
-
---- xz-5.0.7/src/liblzma/check/crc64_fast.c 2014-09-20 17:48:05.000000000 +0100
-+++ check/crc64_fast.c 2014-11-19 10:09:11.000000000 +0000
-@@ -25,8 +25,10 @@
- #endif
-
-
-+// R_Change: Used in package utils, so needs to be visible
-+#include
- // See the comments in crc32_fast.c. They aren't duplicated here.
--extern LZMA_API(uint64_t)
-+extern attribute_visible LZMA_API(uint64_t)
- lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)
- {
- crc = ~crc;
-
---- xz-5.0.7/src/liblzma/check/crc_macros.h 2014-09-20 17:48:05.000000000 +0100
-+++ check/crc_macros.h 2011-03-30 14:00:45.000000000 +0100
-@@ -11,6 +11,8 @@
- ///////////////////////////////////////////////////////////////////////////////
-
- #ifdef WORDS_BIGENDIAN
-+# include "bswap.h"
-+
- # define A(x) ((x) >> 24)
- # define B(x) (((x) >> 16) & 0xFF)
- # define C(x) (((x) >> 8) & 0xFF)
diff -Nru r-base-3.2.3/src/extra/xz/simple/arm.c r-base-3.3.1/src/extra/xz/simple/arm.c
--- r-base-3.2.3/src/extra/xz/simple/arm.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/arm.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,69 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file arm.c
-/// \brief Filter for ARM binaries
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "simple_private.h"
-
-
-static size_t
-arm_code(lzma_simple *simple lzma_attribute((__unused__)),
- uint32_t now_pos, bool is_encoder,
- uint8_t *buffer, size_t size)
-{
- size_t i;
- for (i = 0; i + 4 <= size; i += 4) {
- if (buffer[i + 3] == 0xEB) {
- uint32_t src = (buffer[i + 2] << 16)
- | (buffer[i + 1] << 8)
- | (buffer[i + 0]);
- src <<= 2;
-
- uint32_t dest;
- if (is_encoder)
- dest = now_pos + (uint32_t)(i) + 8 + src;
- else
- dest = src - (now_pos + (uint32_t)(i) + 8);
-
- dest >>= 2;
- buffer[i + 2] = (dest >> 16);
- buffer[i + 1] = (dest >> 8);
- buffer[i + 0] = dest;
- }
- }
-
- return i;
-}
-
-
-static lzma_ret
-arm_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters, bool is_encoder)
-{
- return lzma_simple_coder_init(next, allocator, filters,
- &arm_code, 0, 4, 4, is_encoder);
-}
-
-
-extern lzma_ret
-lzma_simple_arm_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- return arm_coder_init(next, allocator, filters, true);
-}
-
-
-extern lzma_ret
-lzma_simple_arm_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- return arm_coder_init(next, allocator, filters, false);
-}
diff -Nru r-base-3.2.3/src/extra/xz/simple/armthumb.c r-base-3.3.1/src/extra/xz/simple/armthumb.c
--- r-base-3.2.3/src/extra/xz/simple/armthumb.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/armthumb.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,74 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file armthumb.c
-/// \brief Filter for ARM-Thumb binaries
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "simple_private.h"
-
-
-static size_t
-armthumb_code(lzma_simple *simple lzma_attribute((__unused__)),
- uint32_t now_pos, bool is_encoder,
- uint8_t *buffer, size_t size)
-{
- size_t i;
- for (i = 0; i + 4 <= size; i += 2) {
- if ((buffer[i + 1] & 0xF8) == 0xF0
- && (buffer[i + 3] & 0xF8) == 0xF8) {
- uint32_t src = ((buffer[i + 1] & 0x7) << 19)
- | (buffer[i + 0] << 11)
- | ((buffer[i + 3] & 0x7) << 8)
- | (buffer[i + 2]);
-
- src <<= 1;
-
- uint32_t dest;
- if (is_encoder)
- dest = now_pos + (uint32_t)(i) + 4 + src;
- else
- dest = src - (now_pos + (uint32_t)(i) + 4);
-
- dest >>= 1;
- buffer[i + 1] = 0xF0 | ((dest >> 19) & 0x7);
- buffer[i + 0] = (dest >> 11);
- buffer[i + 3] = 0xF8 | ((dest >> 8) & 0x7);
- buffer[i + 2] = (dest);
- i += 2;
- }
- }
-
- return i;
-}
-
-
-static lzma_ret
-armthumb_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters, bool is_encoder)
-{
- return lzma_simple_coder_init(next, allocator, filters,
- &armthumb_code, 0, 4, 2, is_encoder);
-}
-
-
-extern lzma_ret
-lzma_simple_armthumb_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
-{
- return armthumb_coder_init(next, allocator, filters, true);
-}
-
-
-extern lzma_ret
-lzma_simple_armthumb_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
-{
- return armthumb_coder_init(next, allocator, filters, false);
-}
diff -Nru r-base-3.2.3/src/extra/xz/simple/ia64.c r-base-3.3.1/src/extra/xz/simple/ia64.c
--- r-base-3.2.3/src/extra/xz/simple/ia64.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/ia64.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,110 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file ia64.c
-/// \brief Filter for IA64 (Itanium) binaries
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "simple_private.h"
-
-
-static size_t
-ia64_code(lzma_simple *simple lzma_attribute((__unused__)),
- uint32_t now_pos, bool is_encoder,
- uint8_t *buffer, size_t size)
-{
- static const uint32_t BRANCH_TABLE[32] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 4, 4, 6, 6, 0, 0, 7, 7,
- 4, 4, 0, 0, 4, 4, 0, 0
- };
-
- size_t i;
- for (i = 0; i + 16 <= size; i += 16) {
- const uint32_t instr_template = buffer[i] & 0x1F;
- const uint32_t mask = BRANCH_TABLE[instr_template];
- uint32_t bit_pos = 5;
-
- for (size_t slot = 0; slot < 3; ++slot, bit_pos += 41) {
- if (((mask >> slot) & 1) == 0)
- continue;
-
- const size_t byte_pos = (bit_pos >> 3);
- const uint32_t bit_res = bit_pos & 0x7;
- uint64_t instruction = 0;
-
- for (size_t j = 0; j < 6; ++j)
- instruction += (uint64_t)(
- buffer[i + j + byte_pos])
- << (8 * j);
-
- uint64_t inst_norm = instruction >> bit_res;
-
- if (((inst_norm >> 37) & 0xF) == 0x5
- && ((inst_norm >> 9) & 0x7) == 0
- /* && (inst_norm & 0x3F)== 0 */
- ) {
- uint32_t src = (uint32_t)(
- (inst_norm >> 13) & 0xFFFFF);
- src |= ((inst_norm >> 36) & 1) << 20;
-
- src <<= 4;
-
- uint32_t dest;
- if (is_encoder)
- dest = now_pos + (uint32_t)(i) + src;
- else
- dest = src - (now_pos + (uint32_t)(i));
-
- dest >>= 4;
-
- inst_norm &= ~((uint64_t)(0x8FFFFF) << 13);
- inst_norm |= (uint64_t)(dest & 0xFFFFF) << 13;
- inst_norm |= (uint64_t)(dest & 0x100000)
- << (36 - 20);
-
- instruction &= (1 << bit_res) - 1;
- instruction |= (inst_norm << bit_res);
-
- for (size_t j = 0; j < 6; j++)
- buffer[i + j + byte_pos] = (uint8_t)(
- instruction
- >> (8 * j));
- }
- }
- }
-
- return i;
-}
-
-
-static lzma_ret
-ia64_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters, bool is_encoder)
-{
- return lzma_simple_coder_init(next, allocator, filters,
- &ia64_code, 0, 16, 16, is_encoder);
-}
-
-
-extern lzma_ret
-lzma_simple_ia64_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
-{
- return ia64_coder_init(next, allocator, filters, true);
-}
-
-
-extern lzma_ret
-lzma_simple_ia64_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
-{
- return ia64_coder_init(next, allocator, filters, false);
-}
diff -Nru r-base-3.2.3/src/extra/xz/simple/powerpc.c r-base-3.3.1/src/extra/xz/simple/powerpc.c
--- r-base-3.2.3/src/extra/xz/simple/powerpc.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/powerpc.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,73 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file powerpc.c
-/// \brief Filter for PowerPC (big endian) binaries
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "simple_private.h"
-
-
-static size_t
-powerpc_code(lzma_simple *simple lzma_attribute((__unused__)),
- uint32_t now_pos, bool is_encoder,
- uint8_t *buffer, size_t size)
-{
- size_t i;
- for (i = 0; i + 4 <= size; i += 4) {
- // PowerPC branch 6(48) 24(Offset) 1(Abs) 1(Link)
- if ((buffer[i] >> 2) == 0x12
- && ((buffer[i + 3] & 3) == 1)) {
-
- const uint32_t src = ((buffer[i + 0] & 3) << 24)
- | (buffer[i + 1] << 16)
- | (buffer[i + 2] << 8)
- | (buffer[i + 3] & (~3));
-
- uint32_t dest;
- if (is_encoder)
- dest = now_pos + (uint32_t)(i) + src;
- else
- dest = src - (now_pos + (uint32_t)(i));
-
- buffer[i + 0] = 0x48 | ((dest >> 24) & 0x03);
- buffer[i + 1] = (dest >> 16);
- buffer[i + 2] = (dest >> 8);
- buffer[i + 3] &= 0x03;
- buffer[i + 3] |= dest;
- }
- }
-
- return i;
-}
-
-
-static lzma_ret
-powerpc_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters, bool is_encoder)
-{
- return lzma_simple_coder_init(next, allocator, filters,
- &powerpc_code, 0, 4, 4, is_encoder);
-}
-
-
-extern lzma_ret
-lzma_simple_powerpc_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
-{
- return powerpc_coder_init(next, allocator, filters, true);
-}
-
-
-extern lzma_ret
-lzma_simple_powerpc_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
-{
- return powerpc_coder_init(next, allocator, filters, false);
-}
diff -Nru r-base-3.2.3/src/extra/xz/simple/simple_coder.c r-base-3.3.1/src/extra/xz/simple/simple_coder.c
--- r-base-3.2.3/src/extra/xz/simple/simple_coder.c 2012-07-27 22:05:01.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/simple_coder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,277 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file simple_coder.c
-/// \brief Wrapper for simple filters
-///
-/// Simple filters don't change the size of the data i.e. number of bytes
-/// in equals the number of bytes out.
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "simple_private.h"
-
-
-/// Copied or encodes/decodes more data to out[].
-static lzma_ret
-copy_or_code(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- assert(!coder->end_was_reached);
-
- if (coder->next.code == NULL) {
- lzma_bufcpy(in, in_pos, in_size, out, out_pos, out_size);
-
- // Check if end of stream was reached.
- if (coder->is_encoder && action == LZMA_FINISH
- && *in_pos == in_size)
- coder->end_was_reached = true;
-
- } else {
- // Call the next coder in the chain to provide us some data.
- const lzma_ret ret = coder->next.code(
- coder->next.coder, allocator,
- in, in_pos, in_size,
- out, out_pos, out_size, action);
-
- if (ret == LZMA_STREAM_END) {
- assert(!coder->is_encoder
- || action == LZMA_FINISH);
- coder->end_was_reached = true;
-
- } else if (ret != LZMA_OK) {
- return ret;
- }
- }
-
- return LZMA_OK;
-}
-
-
-static size_t
-call_filter(lzma_coder *coder, uint8_t *buffer, size_t size)
-{
- const size_t filtered = coder->filter(coder->simple,
- coder->now_pos, coder->is_encoder,
- buffer, size);
- coder->now_pos += filtered;
- return filtered;
-}
-
-
-static lzma_ret
-simple_code(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- // TODO: Add partial support for LZMA_SYNC_FLUSH. We can support it
- // in cases when the filter is able to filter everything. With most
- // simple filters it can be done at offset that is a multiple of 2,
- // 4, or 16. With x86 filter, it needs good luck, and thus cannot
- // be made to work predictably.
- if (action == LZMA_SYNC_FLUSH)
- return LZMA_OPTIONS_ERROR;
-
- // Flush already filtered data from coder->buffer[] to out[].
- if (coder->pos < coder->filtered) {
- lzma_bufcpy(coder->buffer, &coder->pos, coder->filtered,
- out, out_pos, out_size);
-
- // If we couldn't flush all the filtered data, return to
- // application immediately.
- if (coder->pos < coder->filtered)
- return LZMA_OK;
-
- if (coder->end_was_reached) {
- assert(coder->filtered == coder->size);
- return LZMA_STREAM_END;
- }
- }
-
- // If we get here, there is no filtered data left in the buffer.
- coder->filtered = 0;
-
- assert(!coder->end_was_reached);
-
- // If there is more output space left than there is unfiltered data
- // in coder->buffer[], flush coder->buffer[] to out[], and copy/code
- // more data to out[] hopefully filling it completely. Then filter
- // the data in out[]. This step is where most of the data gets
- // filtered if the buffer sizes used by the application are reasonable.
- const size_t out_avail = out_size - *out_pos;
- const size_t buf_avail = coder->size - coder->pos;
- if (out_avail > buf_avail || buf_avail == 0) {
- // Store the old position so that we know from which byte
- // to start filtering.
- const size_t out_start = *out_pos;
-
- // Flush data from coder->buffer[] to out[], but don't reset
- // coder->pos and coder->size yet. This way the coder can be
- // restarted if the next filter in the chain returns e.g.
- // LZMA_MEM_ERROR.
- memcpy(out + *out_pos, coder->buffer + coder->pos, buf_avail);
- *out_pos += buf_avail;
-
- // Copy/Encode/Decode more data to out[].
- {
- const lzma_ret ret = copy_or_code(coder, allocator,
- in, in_pos, in_size,
- out, out_pos, out_size, action);
- assert(ret != LZMA_STREAM_END);
- if (ret != LZMA_OK)
- return ret;
- }
-
- // Filter out[].
- const size_t size = *out_pos - out_start;
- const size_t filtered = call_filter(
- coder, out + out_start, size);
-
- const size_t unfiltered = size - filtered;
- assert(unfiltered <= coder->allocated / 2);
-
- // Now we can update coder->pos and coder->size, because
- // the next coder in the chain (if any) was successful.
- coder->pos = 0;
- coder->size = unfiltered;
-
- if (coder->end_was_reached) {
- // The last byte has been copied to out[] already.
- // They are left as is.
- coder->size = 0;
-
- } else if (unfiltered > 0) {
- // There is unfiltered data left in out[]. Copy it to
- // coder->buffer[] and rewind *out_pos appropriately.
- *out_pos -= unfiltered;
- memcpy(coder->buffer, out + *out_pos, unfiltered);
- }
- } else if (coder->pos > 0) {
- memmove(coder->buffer, coder->buffer + coder->pos, buf_avail);
- coder->size -= coder->pos;
- coder->pos = 0;
- }
-
- assert(coder->pos == 0);
-
- // If coder->buffer[] isn't empty, try to fill it by copying/decoding
- // more data. Then filter coder->buffer[] and copy the successfully
- // filtered data to out[]. It is probable, that some filtered and
- // unfiltered data will be left to coder->buffer[].
- if (coder->size > 0) {
- {
- const lzma_ret ret = copy_or_code(coder, allocator,
- in, in_pos, in_size,
- coder->buffer, &coder->size,
- coder->allocated, action);
- assert(ret != LZMA_STREAM_END);
- if (ret != LZMA_OK)
- return ret;
- }
-
- coder->filtered = call_filter(
- coder, coder->buffer, coder->size);
-
- // Everything is considered to be filtered if coder->buffer[]
- // contains the last bytes of the data.
- if (coder->end_was_reached)
- coder->filtered = coder->size;
-
- // Flush as much as possible.
- lzma_bufcpy(coder->buffer, &coder->pos, coder->filtered,
- out, out_pos, out_size);
- }
-
- // Check if we got everything done.
- if (coder->end_was_reached && coder->pos == coder->size)
- return LZMA_STREAM_END;
-
- return LZMA_OK;
-}
-
-
-static void
-simple_coder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->next, allocator);
- lzma_free(coder->simple, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-static lzma_ret
-simple_coder_update(lzma_coder *coder, lzma_allocator *allocator,
- const lzma_filter *filters_null lzma_attribute((__unused__)),
- const lzma_filter *reversed_filters)
-{
- // No update support, just call the next filter in the chain.
- return lzma_next_filter_update(
- &coder->next, allocator, reversed_filters + 1);
-}
-
-
-extern lzma_ret
-lzma_simple_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters,
- size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
- bool is_encoder, uint8_t *buffer, size_t size),
- size_t simple_size, size_t unfiltered_max,
- uint32_t alignment, bool is_encoder)
-{
- // Allocate memory for the lzma_coder structure if needed.
- if (next->coder == NULL) {
- // Here we allocate space also for the temporary buffer. We
- // need twice the size of unfiltered_max, because then it
- // is always possible to filter at least unfiltered_max bytes
- // more data in coder->buffer[] if it can be filled completely.
- next->coder = lzma_alloc(sizeof(lzma_coder)
- + 2 * unfiltered_max, allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &simple_code;
- next->end = &simple_coder_end;
- next->update = &simple_coder_update;
-
- next->coder->next = LZMA_NEXT_CODER_INIT;
- next->coder->filter = filter;
- next->coder->allocated = 2 * unfiltered_max;
-
- // Allocate memory for filter-specific data structure.
- if (simple_size > 0) {
- next->coder->simple = lzma_alloc(
- simple_size, allocator);
- if (next->coder->simple == NULL)
- return LZMA_MEM_ERROR;
- } else {
- next->coder->simple = NULL;
- }
- }
-
- if (filters[0].options != NULL) {
- const lzma_options_bcj *simple = filters[0].options;
- next->coder->now_pos = simple->start_offset;
- if (next->coder->now_pos & (alignment - 1))
- return LZMA_OPTIONS_ERROR;
- } else {
- next->coder->now_pos = 0;
- }
-
- // Reset variables.
- next->coder->is_encoder = is_encoder;
- next->coder->end_was_reached = false;
- next->coder->pos = 0;
- next->coder->filtered = 0;
- next->coder->size = 0;
-
- return lzma_next_filter_init(
- &next->coder->next, allocator, filters + 1);
-}
diff -Nru r-base-3.2.3/src/extra/xz/simple/simple_coder.h r-base-3.3.1/src/extra/xz/simple/simple_coder.h
--- r-base-3.2.3/src/extra/xz/simple/simple_coder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/simple_coder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,60 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file simple_coder.h
-/// \brief Wrapper for simple filters
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_SIMPLE_CODER_H
-#define LZMA_SIMPLE_CODER_H
-
-#include "common.h"
-
-
-extern lzma_ret lzma_simple_x86_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-extern lzma_ret lzma_simple_x86_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-
-extern lzma_ret lzma_simple_powerpc_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-extern lzma_ret lzma_simple_powerpc_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-
-extern lzma_ret lzma_simple_ia64_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-extern lzma_ret lzma_simple_ia64_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-
-extern lzma_ret lzma_simple_arm_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-extern lzma_ret lzma_simple_arm_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-
-extern lzma_ret lzma_simple_armthumb_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-extern lzma_ret lzma_simple_armthumb_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-
-extern lzma_ret lzma_simple_sparc_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-extern lzma_ret lzma_simple_sparc_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/simple/simple_decoder.c r-base-3.3.1/src/extra/xz/simple/simple_decoder.c
--- r-base-3.2.3/src/extra/xz/simple/simple_decoder.c 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/simple_decoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,40 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file simple_decoder.c
-/// \brief Properties decoder for simple filters
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "simple_decoder.h"
-
-
-extern lzma_ret
-lzma_simple_props_decode(void **options, lzma_allocator *allocator,
- const uint8_t *props, size_t props_size)
-{
- if (props_size == 0)
- return LZMA_OK;
-
- if (props_size != 4)
- return LZMA_OPTIONS_ERROR;
-
- lzma_options_bcj *opt = lzma_alloc(
- sizeof(lzma_options_bcj), allocator);
- if (opt == NULL)
- return LZMA_MEM_ERROR;
-
- opt->start_offset = unaligned_read32le(props);
-
- // Don't leave an options structure allocated if start_offset is zero.
- if (opt->start_offset == 0)
- lzma_free(opt, allocator);
- else
- *options = opt;
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/simple/simple_decoder.h r-base-3.3.1/src/extra/xz/simple/simple_decoder.h
--- r-base-3.2.3/src/extra/xz/simple/simple_decoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/simple_decoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,22 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file simple_decoder.h
-/// \brief Properties decoder for simple filters
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_SIMPLE_DECODER_H
-#define LZMA_SIMPLE_DECODER_H
-
-#include "simple_coder.h"
-
-extern lzma_ret lzma_simple_props_decode(
- void **options, lzma_allocator *allocator,
- const uint8_t *props, size_t props_size);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/simple/simple_encoder.c r-base-3.3.1/src/extra/xz/simple/simple_encoder.c
--- r-base-3.2.3/src/extra/xz/simple/simple_encoder.c 2010-11-08 23:05:05.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/simple_encoder.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,38 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file simple_encoder.c
-/// \brief Properties encoder for simple filters
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "simple_encoder.h"
-
-
-extern lzma_ret
-lzma_simple_props_size(uint32_t *size, const void *options)
-{
- const lzma_options_bcj *const opt = options;
- *size = (opt == NULL || opt->start_offset == 0) ? 0 : 4;
- return LZMA_OK;
-}
-
-
-extern lzma_ret
-lzma_simple_props_encode(const void *options, uint8_t *out)
-{
- const lzma_options_bcj *const opt = options;
-
- // The default start offset is zero, so we don't need to store any
- // options unless the start offset is non-zero.
- if (opt == NULL || opt->start_offset == 0)
- return LZMA_OK;
-
- unaligned_write32le(out, opt->start_offset);
-
- return LZMA_OK;
-}
diff -Nru r-base-3.2.3/src/extra/xz/simple/simple_encoder.h r-base-3.3.1/src/extra/xz/simple/simple_encoder.h
--- r-base-3.2.3/src/extra/xz/simple/simple_encoder.h 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/simple_encoder.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,23 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file simple_encoder.c
-/// \brief Properties encoder for simple filters
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_SIMPLE_ENCODER_H
-#define LZMA_SIMPLE_ENCODER_H
-
-#include "simple_coder.h"
-
-
-extern lzma_ret lzma_simple_props_size(uint32_t *size, const void *options);
-
-extern lzma_ret lzma_simple_props_encode(const void *options, uint8_t *out);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/simple/simple_private.h r-base-3.3.1/src/extra/xz/simple/simple_private.h
--- r-base-3.2.3/src/extra/xz/simple/simple_private.h 2012-07-27 22:05:01.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/simple_private.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,75 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file simple_private.h
-/// \brief Private definitions for so called simple filters
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_SIMPLE_PRIVATE_H
-#define LZMA_SIMPLE_PRIVATE_H
-
-#include "simple_coder.h"
-
-
-typedef struct lzma_simple_s lzma_simple;
-
-struct lzma_coder_s {
- /// Next filter in the chain
- lzma_next_coder next;
-
- /// True if the next coder in the chain has returned LZMA_STREAM_END.
- bool end_was_reached;
-
- /// True if filter() should encode the data; false to decode.
- /// Currently all simple filters use the same function for encoding
- /// and decoding, because the difference between encoders and decoders
- /// is very small.
- bool is_encoder;
-
- /// Pointer to filter-specific function, which does
- /// the actual filtering.
- size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
- bool is_encoder, uint8_t *buffer, size_t size);
-
- /// Pointer to filter-specific data, or NULL if filter doesn't need
- /// any extra data.
- lzma_simple *simple;
-
- /// The lowest 32 bits of the current position in the data. Most
- /// filters need this to do conversions between absolute and relative
- /// addresses.
- uint32_t now_pos;
-
- /// Size of the memory allocated for the buffer.
- size_t allocated;
-
- /// Flushing position in the temporary buffer. buffer[pos] is the
- /// next byte to be copied to out[].
- size_t pos;
-
- /// buffer[filtered] is the first unfiltered byte. When pos is smaller
- /// than filtered, there is unflushed filtered data in the buffer.
- size_t filtered;
-
- /// Total number of bytes (both filtered and unfiltered) currently
- /// in the temporary buffer.
- size_t size;
-
- /// Temporary buffer
- uint8_t buffer[];
-};
-
-
-extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters,
- size_t (*filter)(lzma_simple *simple, uint32_t now_pos,
- bool is_encoder, uint8_t *buffer, size_t size),
- size_t simple_size, size_t unfiltered_max,
- uint32_t alignment, bool is_encoder);
-
-#endif
diff -Nru r-base-3.2.3/src/extra/xz/simple/sparc.c r-base-3.3.1/src/extra/xz/simple/sparc.c
--- r-base-3.2.3/src/extra/xz/simple/sparc.c 2011-05-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/sparc.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,81 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file sparc.c
-/// \brief Filter for SPARC binaries
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "simple_private.h"
-
-
-static size_t
-sparc_code(lzma_simple *simple lzma_attribute((__unused__)),
- uint32_t now_pos, bool is_encoder,
- uint8_t *buffer, size_t size)
-{
- size_t i;
- for (i = 0; i + 4 <= size; i += 4) {
-
- if ((buffer[i] == 0x40 && (buffer[i + 1] & 0xC0) == 0x00)
- || (buffer[i] == 0x7F
- && (buffer[i + 1] & 0xC0) == 0xC0)) {
-
- uint32_t src = ((uint32_t)buffer[i + 0] << 24)
- | ((uint32_t)buffer[i + 1] << 16)
- | ((uint32_t)buffer[i + 2] << 8)
- | ((uint32_t)buffer[i + 3]);
-
- src <<= 2;
-
- uint32_t dest;
- if (is_encoder)
- dest = now_pos + (uint32_t)(i) + src;
- else
- dest = src - (now_pos + (uint32_t)(i));
-
- dest >>= 2;
-
- dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF)
- | (dest & 0x3FFFFF)
- | 0x40000000;
-
- buffer[i + 0] = (uint8_t)(dest >> 24);
- buffer[i + 1] = (uint8_t)(dest >> 16);
- buffer[i + 2] = (uint8_t)(dest >> 8);
- buffer[i + 3] = (uint8_t)(dest);
- }
- }
-
- return i;
-}
-
-
-static lzma_ret
-sparc_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters, bool is_encoder)
-{
- return lzma_simple_coder_init(next, allocator, filters,
- &sparc_code, 0, 4, 4, is_encoder);
-}
-
-
-extern lzma_ret
-lzma_simple_sparc_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
-{
- return sparc_coder_init(next, allocator, filters, true);
-}
-
-
-extern lzma_ret
-lzma_simple_sparc_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
-{
- return sparc_coder_init(next, allocator, filters, false);
-}
diff -Nru r-base-3.2.3/src/extra/xz/simple/x86.c r-base-3.3.1/src/extra/xz/simple/x86.c
--- r-base-3.2.3/src/extra/xz/simple/x86.c 2010-03-17 14:43:06.000000000 +0000
+++ r-base-3.3.1/src/extra/xz/simple/x86.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,154 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file x86.c
-/// \brief Filter for x86 binaries (BCJ filter)
-///
-// Authors: Igor Pavlov
-// Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "simple_private.h"
-
-
-#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF)
-
-
-struct lzma_simple_s {
- uint32_t prev_mask;
- uint32_t prev_pos;
-};
-
-
-static size_t
-x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
- uint8_t *buffer, size_t size)
-{
- static const bool MASK_TO_ALLOWED_STATUS[8]
- = { true, true, true, false, true, false, false, false };
-
- static const uint32_t MASK_TO_BIT_NUMBER[8]
- = { 0, 1, 2, 2, 3, 3, 3, 3 };
-
- uint32_t prev_mask = simple->prev_mask;
- uint32_t prev_pos = simple->prev_pos;
-
- if (size < 5)
- return 0;
-
- if (now_pos - prev_pos > 5)
- prev_pos = now_pos - 5;
-
- const size_t limit = size - 5;
- size_t buffer_pos = 0;
-
- while (buffer_pos <= limit) {
- uint8_t b = buffer[buffer_pos];
- if (b != 0xE8 && b != 0xE9) {
- ++buffer_pos;
- continue;
- }
-
- const uint32_t offset = now_pos + (uint32_t)(buffer_pos)
- - prev_pos;
- prev_pos = now_pos + (uint32_t)(buffer_pos);
-
- if (offset > 5) {
- prev_mask = 0;
- } else {
- for (uint32_t i = 0; i < offset; ++i) {
- prev_mask &= 0x77;
- prev_mask <<= 1;
- }
- }
-
- b = buffer[buffer_pos + 4];
-
- if (Test86MSByte(b)
- && MASK_TO_ALLOWED_STATUS[(prev_mask >> 1) & 0x7]
- && (prev_mask >> 1) < 0x10) {
-
- uint32_t src = ((uint32_t)(b) << 24)
- | ((uint32_t)(buffer[buffer_pos + 3]) << 16)
- | ((uint32_t)(buffer[buffer_pos + 2]) << 8)
- | (buffer[buffer_pos + 1]);
-
- uint32_t dest;
- while (true) {
- if (is_encoder)
- dest = src + (now_pos + (uint32_t)(
- buffer_pos) + 5);
- else
- dest = src - (now_pos + (uint32_t)(
- buffer_pos) + 5);
-
- if (prev_mask == 0)
- break;
-
- const uint32_t i = MASK_TO_BIT_NUMBER[
- prev_mask >> 1];
-
- b = (uint8_t)(dest >> (24 - i * 8));
-
- if (!Test86MSByte(b))
- break;
-
- src = dest ^ ((1 << (32 - i * 8)) - 1);
- }
-
- buffer[buffer_pos + 4]
- = (uint8_t)(~(((dest >> 24) & 1) - 1));
- buffer[buffer_pos + 3] = (uint8_t)(dest >> 16);
- buffer[buffer_pos + 2] = (uint8_t)(dest >> 8);
- buffer[buffer_pos + 1] = (uint8_t)(dest);
- buffer_pos += 5;
- prev_mask = 0;
-
- } else {
- ++buffer_pos;
- prev_mask |= 1;
- if (Test86MSByte(b))
- prev_mask |= 0x10;
- }
- }
-
- simple->prev_mask = prev_mask;
- simple->prev_pos = prev_pos;
-
- return buffer_pos;
-}
-
-
-static lzma_ret
-x86_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters, bool is_encoder)
-{
- const lzma_ret ret = lzma_simple_coder_init(next, allocator, filters,
- &x86_code, sizeof(lzma_simple), 5, 1, is_encoder);
-
- if (ret == LZMA_OK) {
- next->coder->simple->prev_mask = 0;
- next->coder->simple->prev_pos = (uint32_t)(-5);
- }
-
- return ret;
-}
-
-
-extern lzma_ret
-lzma_simple_x86_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- return x86_coder_init(next, allocator, filters, true);
-}
-
-
-extern lzma_ret
-lzma_simple_x86_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- return x86_coder_init(next, allocator, filters, false);
-}
diff -Nru r-base-3.2.3/src/extra/zlib/adler32.c r-base-3.3.1/src/extra/zlib/adler32.c
--- r-base-3.2.3/src/extra/zlib/adler32.c 2012-02-05 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/adler32.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,179 +0,0 @@
-/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2011 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include "zutil.h"
-
-#define local static
-
-local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
-
-#define BASE 65521 /* largest prime smaller than 65536 */
-#define NMAX 5552
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-
-#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
-#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
-#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
-#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
-#define DO16(buf) DO8(buf,0); DO8(buf,8);
-
-/* use NO_DIVIDE if your processor does not do division in hardware --
- try it both ways to see which is faster */
-#ifdef NO_DIVIDE
-/* note that this assumes BASE is 65521, where 65536 % 65521 == 15
- (thank you to John Reiser for pointing this out) */
-# define CHOP(a) \
- do { \
- unsigned long tmp = a >> 16; \
- a &= 0xffffUL; \
- a += (tmp << 4) - tmp; \
- } while (0)
-# define MOD28(a) \
- do { \
- CHOP(a); \
- if (a >= BASE) a -= BASE; \
- } while (0)
-# define MOD(a) \
- do { \
- CHOP(a); \
- MOD28(a); \
- } while (0)
-# define MOD63(a) \
- do { /* this assumes a is not negative */ \
- z_off64_t tmp = a >> 32; \
- a &= 0xffffffffL; \
- a += (tmp << 8) - (tmp << 5) + tmp; \
- tmp = a >> 16; \
- a &= 0xffffL; \
- a += (tmp << 4) - tmp; \
- tmp = a >> 16; \
- a &= 0xffffL; \
- a += (tmp << 4) - tmp; \
- if (a >= BASE) a -= BASE; \
- } while (0)
-#else
-# define MOD(a) a %= BASE
-# define MOD28(a) a %= BASE
-# define MOD63(a) a %= BASE
-#endif
-
-/* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
- uLong adler;
- const Bytef *buf;
- uInt len;
-{
- unsigned long sum2;
- unsigned n;
-
- /* split Adler-32 into component sums */
- sum2 = (adler >> 16) & 0xffff;
- adler &= 0xffff;
-
- /* in case user likes doing a byte at a time, keep it fast */
- if (len == 1) {
- adler += buf[0];
- if (adler >= BASE)
- adler -= BASE;
- sum2 += adler;
- if (sum2 >= BASE)
- sum2 -= BASE;
- return adler | (sum2 << 16);
- }
-
- /* initial Adler-32 value (deferred check for len == 1 speed) */
- if (buf == Z_NULL)
- return 1L;
-
- /* in case short lengths are provided, keep it somewhat fast */
- if (len < 16) {
- while (len--) {
- adler += *buf++;
- sum2 += adler;
- }
- if (adler >= BASE)
- adler -= BASE;
- MOD28(sum2); /* only added so many BASE's */
- return adler | (sum2 << 16);
- }
-
- /* do length NMAX blocks -- requires just one modulo operation */
- while (len >= NMAX) {
- len -= NMAX;
- n = NMAX / 16; /* NMAX is divisible by 16 */
- do {
- DO16(buf); /* 16 sums unrolled */
- buf += 16;
- } while (--n);
- MOD(adler);
- MOD(sum2);
- }
-
- /* do remaining bytes (less than NMAX, still just one modulo) */
- if (len) { /* avoid modulos if none remaining */
- while (len >= 16) {
- len -= 16;
- DO16(buf);
- buf += 16;
- }
- while (len--) {
- adler += *buf++;
- sum2 += adler;
- }
- MOD(adler);
- MOD(sum2);
- }
-
- /* return recombined sums */
- return adler | (sum2 << 16);
-}
-
-/* ========================================================================= */
-local uLong adler32_combine_(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
- z_off64_t len2;
-{
- unsigned long sum1;
- unsigned long sum2;
- unsigned rem;
-
- /* for negative len, return invalid adler32 as a clue for debugging */
- if (len2 < 0)
- return 0xffffffffUL;
-
- /* the derivation of this formula is left as an exercise for the reader */
- MOD63(len2); /* assumes len2 >= 0 */
- rem = (unsigned)len2;
- sum1 = adler1 & 0xffff;
- sum2 = rem * sum1;
- MOD(sum2);
- sum1 += (adler2 & 0xffff) + BASE - 1;
- sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
- if (sum1 >= BASE) sum1 -= BASE;
- if (sum1 >= BASE) sum1 -= BASE;
- if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
- if (sum2 >= BASE) sum2 -= BASE;
- return sum1 | (sum2 << 16);
-}
-
-/* ========================================================================= */
-uLong ZEXPORT adler32_combine(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
- z_off_t len2;
-{
- return adler32_combine_(adler1, adler2, len2);
-}
-
-uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
- z_off64_t len2;
-{
- return adler32_combine_(adler1, adler2, len2);
-}
diff -Nru r-base-3.2.3/src/extra/zlib/compress.c r-base-3.3.1/src/extra/zlib/compress.c
--- r-base-3.2.3/src/extra/zlib/compress.c 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/compress.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,80 +0,0 @@
-/* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-/* ===========================================================================
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least 0.1% larger than sourceLen plus
- 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
-
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_BUF_ERROR if there was not enough room in the output buffer,
- Z_STREAM_ERROR if the level parameter is invalid.
-*/
-int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
- int level;
-{
- z_stream stream;
- int err;
-
- stream.next_in = (z_const Bytef *)source;
- stream.avail_in = (uInt)sourceLen;
-#ifdef MAXSEG_64K
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-#endif
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
- stream.opaque = (voidpf)0;
-
- err = deflateInit(&stream, level);
- if (err != Z_OK) return err;
-
- err = deflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- deflateEnd(&stream);
- return err == Z_OK ? Z_BUF_ERROR : err;
- }
- *destLen = stream.total_out;
-
- err = deflateEnd(&stream);
- return err;
-}
-
-/* ===========================================================================
- */
-int ZEXPORT compress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
-{
- return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
-}
-
-/* ===========================================================================
- If the default memLevel or windowBits for deflateInit() is changed, then
- this function needs to be updated.
- */
-uLong ZEXPORT compressBound (sourceLen)
- uLong sourceLen;
-{
- return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
- (sourceLen >> 25) + 13;
-}
diff -Nru r-base-3.2.3/src/extra/zlib/crc32.c r-base-3.3.1/src/extra/zlib/crc32.c
--- r-base-3.2.3/src/extra/zlib/crc32.c 2012-05-16 22:05:01.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/crc32.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,425 +0,0 @@
-/* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2006, 2010, 2011, 2012 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Thanks to Rodney Brown for his contribution of faster
- * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
- * tables for updating the shift register in one step with three exclusive-ors
- * instead of four steps with four exclusive-ors. This results in about a
- * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
- */
-
-/* @(#) $Id$ */
-
-/*
- Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
- protection on the static variables used to control the first-use generation
- of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
- first call get_crc_table() to initialize the tables before allowing more than
- one thread to use crc32().
-
- DYNAMIC_CRC_TABLE and MAKECRCH can be #defined to write out crc32.h.
- */
-
-#ifdef MAKECRCH
-# include
-# ifndef DYNAMIC_CRC_TABLE
-# define DYNAMIC_CRC_TABLE
-# endif /* !DYNAMIC_CRC_TABLE */
-#endif /* MAKECRCH */
-
-#include "zutil.h" /* for STDC and FAR definitions */
-
-#define local static
-
-/* Definitions for doing the crc four data bytes at a time. */
-#if !defined(NOBYFOUR) && defined(Z_U4)
-# define BYFOUR
-#endif
-#ifdef BYFOUR
- local unsigned long crc32_little OF((unsigned long,
- const unsigned char FAR *, unsigned));
- local unsigned long crc32_big OF((unsigned long,
- const unsigned char FAR *, unsigned));
-# define TBLS 8
-#else
-# define TBLS 1
-#endif /* BYFOUR */
-
-/* Local functions for crc concatenation */
-local unsigned long gf2_matrix_times OF((unsigned long *mat,
- unsigned long vec));
-local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
-local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2));
-
-
-#ifdef DYNAMIC_CRC_TABLE
-
-local volatile int crc_table_empty = 1;
-local z_crc_t FAR crc_table[TBLS][256];
-local void make_crc_table OF((void));
-#ifdef MAKECRCH
- local void write_table OF((FILE *, const z_crc_t FAR *));
-#endif /* MAKECRCH */
-/*
- Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
- x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
-
- Polynomials over GF(2) are represented in binary, one bit per coefficient,
- with the lowest powers in the most significant bit. Then adding polynomials
- is just exclusive-or, and multiplying a polynomial by x is a right shift by
- one. If we call the above polynomial p, and represent a byte as the
- polynomial q, also with the lowest power in the most significant bit (so the
- byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
- where a mod b means the remainder after dividing a by b.
-
- This calculation is done using the shift-register method of multiplying and
- taking the remainder. The register is initialized to zero, and for each
- incoming bit, x^32 is added mod p to the register if the bit is a one (where
- x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
- x (which is shifting right by one and adding x^32 mod p if the bit shifted
- out is a one). We start with the highest power (least significant bit) of
- q and repeat for all eight bits of q.
-
- The first table is simply the CRC of all possible eight bit values. This is
- all the information needed to generate CRCs on data a byte at a time for all
- combinations of CRC register values and incoming bytes. The remaining tables
- allow for word-at-a-time CRC calculation for both big-endian and little-
- endian machines, where a word is four bytes.
-*/
-local void make_crc_table()
-{
- z_crc_t c;
- int n, k;
- z_crc_t poly; /* polynomial exclusive-or pattern */
- /* terms of polynomial defining this crc (except x^32): */
- static volatile int first = 1; /* flag to limit concurrent making */
- static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
-
- /* See if another task is already doing this (not thread-safe, but better
- than nothing -- significantly reduces duration of vulnerability in
- case the advice about DYNAMIC_CRC_TABLE is ignored) */
- if (first) {
- first = 0;
-
- /* make exclusive-or pattern from polynomial (0xedb88320UL) */
- poly = 0;
- for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++)
- poly |= (z_crc_t)1 << (31 - p[n]);
-
- /* generate a crc for every 8-bit value */
- for (n = 0; n < 256; n++) {
- c = (z_crc_t)n;
- for (k = 0; k < 8; k++)
- c = c & 1 ? poly ^ (c >> 1) : c >> 1;
- crc_table[0][n] = c;
- }
-
-#ifdef BYFOUR
- /* generate crc for each value followed by one, two, and three zeros,
- and then the byte reversal of those as well as the first table */
- for (n = 0; n < 256; n++) {
- c = crc_table[0][n];
- crc_table[4][n] = ZSWAP32(c);
- for (k = 1; k < 4; k++) {
- c = crc_table[0][c & 0xff] ^ (c >> 8);
- crc_table[k][n] = c;
- crc_table[k + 4][n] = ZSWAP32(c);
- }
- }
-#endif /* BYFOUR */
-
- crc_table_empty = 0;
- }
- else { /* not first */
- /* wait for the other guy to finish (not efficient, but rare) */
- while (crc_table_empty)
- ;
- }
-
-#ifdef MAKECRCH
- /* write out CRC tables to crc32.h */
- {
- FILE *out;
-
- out = fopen("crc32.h", "w");
- if (out == NULL) return;
- fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
- fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
- fprintf(out, "local const z_crc_t FAR ");
- fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
- write_table(out, crc_table[0]);
-# ifdef BYFOUR
- fprintf(out, "#ifdef BYFOUR\n");
- for (k = 1; k < 8; k++) {
- fprintf(out, " },\n {\n");
- write_table(out, crc_table[k]);
- }
- fprintf(out, "#endif\n");
-# endif /* BYFOUR */
- fprintf(out, " }\n};\n");
- fclose(out);
- }
-#endif /* MAKECRCH */
-}
-
-#ifdef MAKECRCH
-local void write_table(out, table)
- FILE *out;
- const z_crc_t FAR *table;
-{
- int n;
-
- for (n = 0; n < 256; n++)
- fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ",
- (unsigned long)(table[n]),
- n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
-}
-#endif /* MAKECRCH */
-
-#else /* !DYNAMIC_CRC_TABLE */
-/* ========================================================================
- * Tables of CRC-32s of all single-byte values, made by make_crc_table().
- */
-#include "crc32.h"
-#endif /* DYNAMIC_CRC_TABLE */
-
-/* =========================================================================
- * This function can be used by asm versions of crc32()
- */
-const z_crc_t FAR * ZEXPORT get_crc_table()
-{
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
- return (const z_crc_t FAR *)crc_table;
-}
-
-/* ========================================================================= */
-#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
-#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
-
-/* ========================================================================= */
-unsigned long ZEXPORT crc32(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- uInt len;
-{
- if (buf == Z_NULL) return 0UL;
-
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
-
-#ifdef BYFOUR
- if (sizeof(void *) == sizeof(ptrdiff_t)) {
- z_crc_t endian;
-
- endian = 1;
- if (*((unsigned char *)(&endian)))
- return crc32_little(crc, buf, len);
- else
- return crc32_big(crc, buf, len);
- }
-#endif /* BYFOUR */
- crc = crc ^ 0xffffffffUL;
- while (len >= 8) {
- DO8;
- len -= 8;
- }
- if (len) do {
- DO1;
- } while (--len);
- return crc ^ 0xffffffffUL;
-}
-
-#ifdef BYFOUR
-
-/* ========================================================================= */
-#define DOLIT4 c ^= *buf4++; \
- c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
- crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
-#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
-
-/* ========================================================================= */
-local unsigned long crc32_little(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register z_crc_t c;
- register const z_crc_t FAR *buf4;
-
- c = (z_crc_t)crc;
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- len--;
- }
-
- buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
- while (len >= 32) {
- DOLIT32;
- len -= 32;
- }
- while (len >= 4) {
- DOLIT4;
- len -= 4;
- }
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- } while (--len);
- c = ~c;
- return (unsigned long)c;
-}
-
-/* ========================================================================= */
-#define DOBIG4 c ^= *++buf4; \
- c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
- crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
-#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
-
-/* ========================================================================= */
-local unsigned long crc32_big(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register z_crc_t c;
- register const z_crc_t FAR *buf4;
-
- c = ZSWAP32((z_crc_t)crc);
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- len--;
- }
-
- buf4 = (const z_crc_t FAR *)(const void FAR *)buf;
- buf4--;
- while (len >= 32) {
- DOBIG32;
- len -= 32;
- }
- while (len >= 4) {
- DOBIG4;
- len -= 4;
- }
- buf4++;
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- } while (--len);
- c = ~c;
- return (unsigned long)(ZSWAP32(c));
-}
-
-#endif /* BYFOUR */
-
-#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
-
-/* ========================================================================= */
-local unsigned long gf2_matrix_times(mat, vec)
- unsigned long *mat;
- unsigned long vec;
-{
- unsigned long sum;
-
- sum = 0;
- while (vec) {
- if (vec & 1)
- sum ^= *mat;
- vec >>= 1;
- mat++;
- }
- return sum;
-}
-
-/* ========================================================================= */
-local void gf2_matrix_square(square, mat)
- unsigned long *square;
- unsigned long *mat;
-{
- int n;
-
- for (n = 0; n < GF2_DIM; n++)
- square[n] = gf2_matrix_times(mat, mat[n]);
-}
-
-/* ========================================================================= */
-local uLong crc32_combine_(crc1, crc2, len2)
- uLong crc1;
- uLong crc2;
- z_off64_t len2;
-{
- int n;
- unsigned long row;
- unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
- unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
-
- /* degenerate case (also disallow negative lengths) */
- if (len2 <= 0)
- return crc1;
-
- /* put operator for one zero bit in odd */
- odd[0] = 0xedb88320UL; /* CRC-32 polynomial */
- row = 1;
- for (n = 1; n < GF2_DIM; n++) {
- odd[n] = row;
- row <<= 1;
- }
-
- /* put operator for two zero bits in even */
- gf2_matrix_square(even, odd);
-
- /* put operator for four zero bits in odd */
- gf2_matrix_square(odd, even);
-
- /* apply len2 zeros to crc1 (first square will put the operator for one
- zero byte, eight zero bits, in even) */
- do {
- /* apply zeros operator for this bit of len2 */
- gf2_matrix_square(even, odd);
- if (len2 & 1)
- crc1 = gf2_matrix_times(even, crc1);
- len2 >>= 1;
-
- /* if no more bits set, then done */
- if (len2 == 0)
- break;
-
- /* another iteration of the loop with odd and even swapped */
- gf2_matrix_square(odd, even);
- if (len2 & 1)
- crc1 = gf2_matrix_times(odd, crc1);
- len2 >>= 1;
-
- /* if no more bits set, then done */
- } while (len2 != 0);
-
- /* return combined crc */
- crc1 ^= crc2;
- return crc1;
-}
-
-/* ========================================================================= */
-uLong ZEXPORT crc32_combine(crc1, crc2, len2)
- uLong crc1;
- uLong crc2;
- z_off_t len2;
-{
- return crc32_combine_(crc1, crc2, len2);
-}
-
-uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
- uLong crc1;
- uLong crc2;
- z_off64_t len2;
-{
- return crc32_combine_(crc1, crc2, len2);
-}
diff -Nru r-base-3.2.3/src/extra/zlib/crc32.h r-base-3.3.1/src/extra/zlib/crc32.h
--- r-base-3.2.3/src/extra/zlib/crc32.h 2012-05-16 22:05:01.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/crc32.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,441 +0,0 @@
-/* crc32.h -- tables for rapid CRC calculation
- * Generated automatically by crc32.c
- */
-
-local const z_crc_t FAR crc_table[TBLS][256] =
-{
- {
- 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
- 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
- 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
- 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
- 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
- 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
- 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
- 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
- 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
- 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
- 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
- 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
- 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
- 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
- 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
- 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
- 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
- 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
- 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
- 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
- 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
- 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
- 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
- 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
- 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
- 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
- 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
- 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
- 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
- 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
- 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
- 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
- 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
- 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
- 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
- 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
- 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
- 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
- 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
- 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
- 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
- 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
- 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
- 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
- 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
- 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
- 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
- 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
- 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
- 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
- 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
- 0x2d02ef8dUL
-#ifdef BYFOUR
- },
- {
- 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
- 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
- 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
- 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
- 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
- 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
- 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
- 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
- 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
- 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
- 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
- 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
- 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
- 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
- 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
- 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
- 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
- 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
- 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
- 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
- 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
- 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
- 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
- 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
- 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
- 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
- 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
- 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
- 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
- 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
- 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
- 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
- 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
- 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
- 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
- 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
- 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
- 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
- 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
- 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
- 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
- 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
- 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
- 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
- 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
- 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
- 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
- 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
- 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
- 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
- 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
- 0x9324fd72UL
- },
- {
- 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
- 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
- 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
- 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
- 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
- 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
- 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
- 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
- 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
- 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
- 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
- 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
- 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
- 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
- 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
- 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
- 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
- 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
- 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
- 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
- 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
- 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
- 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
- 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
- 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
- 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
- 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
- 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
- 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
- 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
- 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
- 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
- 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
- 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
- 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
- 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
- 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
- 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
- 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
- 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
- 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
- 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
- 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
- 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
- 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
- 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
- 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
- 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
- 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
- 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
- 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
- 0xbe9834edUL
- },
- {
- 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
- 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
- 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
- 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
- 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
- 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
- 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
- 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
- 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
- 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
- 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
- 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
- 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
- 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
- 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
- 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
- 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
- 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
- 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
- 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
- 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
- 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
- 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
- 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
- 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
- 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
- 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
- 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
- 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
- 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
- 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
- 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
- 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
- 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
- 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
- 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
- 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
- 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
- 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
- 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
- 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
- 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
- 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
- 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
- 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
- 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
- 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
- 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
- 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
- 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
- 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
- 0xde0506f1UL
- },
- {
- 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
- 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
- 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
- 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
- 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
- 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
- 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
- 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
- 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
- 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
- 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
- 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
- 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
- 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
- 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
- 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
- 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
- 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
- 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
- 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
- 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
- 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
- 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
- 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
- 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
- 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
- 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
- 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
- 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
- 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
- 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
- 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
- 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
- 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
- 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
- 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
- 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
- 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
- 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
- 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
- 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
- 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
- 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
- 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
- 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
- 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
- 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
- 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
- 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
- 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
- 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
- 0x8def022dUL
- },
- {
- 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
- 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
- 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
- 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
- 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
- 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
- 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
- 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
- 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
- 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
- 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
- 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
- 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
- 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
- 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
- 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
- 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
- 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
- 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
- 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
- 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
- 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
- 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
- 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
- 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
- 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
- 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
- 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
- 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
- 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
- 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
- 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
- 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
- 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
- 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
- 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
- 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
- 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
- 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
- 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
- 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
- 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
- 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
- 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
- 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
- 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
- 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
- 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
- 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
- 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
- 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
- 0x72fd2493UL
- },
- {
- 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
- 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
- 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
- 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
- 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
- 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
- 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
- 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
- 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
- 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
- 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
- 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
- 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
- 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
- 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
- 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
- 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
- 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
- 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
- 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
- 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
- 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
- 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
- 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
- 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
- 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
- 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
- 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
- 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
- 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
- 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
- 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
- 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
- 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
- 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
- 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
- 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
- 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
- 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
- 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
- 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
- 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
- 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
- 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
- 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
- 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
- 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
- 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
- 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
- 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
- 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
- 0xed3498beUL
- },
- {
- 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
- 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
- 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
- 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
- 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
- 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
- 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
- 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
- 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
- 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
- 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
- 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
- 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
- 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
- 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
- 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
- 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
- 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
- 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
- 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
- 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
- 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
- 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
- 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
- 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
- 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
- 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
- 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
- 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
- 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
- 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
- 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
- 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
- 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
- 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
- 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
- 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
- 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
- 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
- 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
- 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
- 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
- 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
- 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
- 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
- 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
- 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
- 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
- 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
- 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
- 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
- 0xf10605deUL
-#endif
- }
-};
diff -Nru r-base-3.2.3/src/extra/zlib/deflate.c r-base-3.3.1/src/extra/zlib/deflate.c
--- r-base-3.2.3/src/extra/zlib/deflate.c 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/deflate.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,1967 +0,0 @@
-/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process depends on being able to identify portions
- * of the input text which are identical to earlier input (within a
- * sliding window trailing behind the input currently being processed).
- *
- * The most straightforward technique turns out to be the fastest for
- * most input files: try all possible matches and select the longest.
- * The key feature of this algorithm is that insertions into the string
- * dictionary are very simple and thus fast, and deletions are avoided
- * completely. Insertions are performed at each input character, whereas
- * string matches are performed only when the previous match ends. So it
- * is preferable to spend more time in matches to allow very fast string
- * insertions and avoid deletions. The matching algorithm for small
- * strings is inspired from that of Rabin & Karp. A brute force approach
- * is used to find longer strings when a small match has been found.
- * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
- * (by Leonid Broukhis).
- * A previous version of this file used a more sophisticated algorithm
- * (by Fiala and Greene) which is guaranteed to run in linear amortized
- * time, but has a larger average cost, uses more memory and is patented.
- * However the F&G algorithm may be faster for some highly redundant
- * files if the parameter max_chain_length (described below) is too large.
- *
- * ACKNOWLEDGEMENTS
- *
- * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
- * I found it in 'freeze' written by Leonid Broukhis.
- * Thanks to many people for bug reports and testing.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
- * Available in http://tools.ietf.org/html/rfc1951
- *
- * A description of the Rabin and Karp algorithm is given in the book
- * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
- *
- * Fiala,E.R., and Greene,D.H.
- * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
- *
- */
-
-/* @(#) $Id$ */
-
-#include "deflate.h"
-
-const char deflate_copyright[] =
- " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/* ===========================================================================
- * Function prototypes.
- */
-typedef enum {
- need_more, /* block not completed, need more input or more output */
- block_done, /* block flush performed */
- finish_started, /* finish started, need only more output at next deflate */
- finish_done /* finish done, accept no more input or output */
-} block_state;
-
-typedef block_state (*compress_func) OF((deflate_state *s, int flush));
-/* Compression function. Returns the block state after the call. */
-
-local void fill_window OF((deflate_state *s));
-local block_state deflate_stored OF((deflate_state *s, int flush));
-local block_state deflate_fast OF((deflate_state *s, int flush));
-#ifndef FASTEST
-local block_state deflate_slow OF((deflate_state *s, int flush));
-#endif
-local block_state deflate_rle OF((deflate_state *s, int flush));
-local block_state deflate_huff OF((deflate_state *s, int flush));
-local void lm_init OF((deflate_state *s));
-local void putShortMSB OF((deflate_state *s, uInt b));
-local void flush_pending OF((z_streamp strm));
-local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
-#ifdef ASMV
- void match_init OF((void)); /* asm code initialization */
- uInt longest_match OF((deflate_state *s, IPos cur_match));
-#else
-local uInt longest_match OF((deflate_state *s, IPos cur_match));
-#endif
-
-#ifdef DEBUG
-local void check_match OF((deflate_state *s, IPos start, IPos match,
- int length));
-#endif
-
-/* ===========================================================================
- * Local data
- */
-
-#define NIL 0
-/* Tail of hash chains */
-
-#ifndef TOO_FAR
-# define TOO_FAR 4096
-#endif
-/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
-
-/* Values for max_lazy_match, good_match and max_chain_length, depending on
- * the desired pack level (0..9). The values given below have been tuned to
- * exclude worst case performance for pathological files. Better values may be
- * found for specific files.
- */
-typedef struct config_s {
- ush good_length; /* reduce lazy search above this match length */
- ush max_lazy; /* do not perform lazy search above this match length */
- ush nice_length; /* quit search above this match length */
- ush max_chain;
- compress_func func;
-} config;
-
-#ifdef FASTEST
-local const config configuration_table[2] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */
-#else
-local const config configuration_table[10] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
-/* 2 */ {4, 5, 16, 8, deflate_fast},
-/* 3 */ {4, 6, 32, 32, deflate_fast},
-
-/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
-/* 5 */ {8, 16, 32, 32, deflate_slow},
-/* 6 */ {8, 16, 128, 128, deflate_slow},
-/* 7 */ {8, 32, 128, 256, deflate_slow},
-/* 8 */ {32, 128, 258, 1024, deflate_slow},
-/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
-#endif
-
-/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
- * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
- * meaning.
- */
-
-#define EQUAL 0
-/* result of memcmp for equal strings */
-
-#ifndef NO_DUMMY_DECL
-struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
-#endif
-
-/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */
-#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0))
-
-/* ===========================================================================
- * Update a hash value with the given input byte
- * IN assertion: all calls to to UPDATE_HASH are made with consecutive
- * input characters, so that a running hash key can be computed from the
- * previous key instead of complete recalculation each time.
- */
-#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask)
-
-
-/* ===========================================================================
- * Insert string str in the dictionary and set match_head to the previous head
- * of the hash chain (the most recent string with same hash key). Return
- * the previous length of the hash chain.
- * If this file is compiled with -DFASTEST, the compression level is forced
- * to 1, and no hash chains are maintained.
- * IN assertion: all calls to to INSERT_STRING are made with consecutive
- * input characters and the first MIN_MATCH bytes of str are valid
- * (except for the last MIN_MATCH-1 bytes of the input file).
- */
-#ifdef FASTEST
-#define INSERT_STRING(s, str, match_head) \
- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
- match_head = s->head[s->ins_h], \
- s->head[s->ins_h] = (Pos)(str))
-#else
-#define INSERT_STRING(s, str, match_head) \
- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
- match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
- s->head[s->ins_h] = (Pos)(str))
-#endif
-
-/* ===========================================================================
- * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
- * prev[] will be initialized on the fly.
- */
-#define CLEAR_HASH(s) \
- s->head[s->hash_size-1] = NIL; \
- zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
-
-/* ========================================================================= */
-int ZEXPORT deflateInit_(strm, level, version, stream_size)
- z_streamp strm;
- int level;
- const char *version;
- int stream_size;
-{
- return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
- Z_DEFAULT_STRATEGY, version, stream_size);
- /* To do: ignore strm->next_in if we use it as window */
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
- version, stream_size)
- z_streamp strm;
- int level;
- int method;
- int windowBits;
- int memLevel;
- int strategy;
- const char *version;
- int stream_size;
-{
- deflate_state *s;
- int wrap = 1;
- static const char my_version[] = ZLIB_VERSION;
-
- ushf *overlay;
- /* We overlay pending_buf and d_buf+l_buf. This works since the average
- * output size for (length,distance) codes is <= 24 bits.
- */
-
- if (version == Z_NULL || version[0] != my_version[0] ||
- stream_size != sizeof(z_stream)) {
- return Z_VERSION_ERROR;
- }
- if (strm == Z_NULL) return Z_STREAM_ERROR;
-
- strm->msg = Z_NULL;
- if (strm->zalloc == (alloc_func)0) {
-#ifdef Z_SOLO
- return Z_STREAM_ERROR;
-#else
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
-#endif
- }
- if (strm->zfree == (free_func)0)
-#ifdef Z_SOLO
- return Z_STREAM_ERROR;
-#else
- strm->zfree = zcfree;
-#endif
-
-#ifdef FASTEST
- if (level != 0) level = 1;
-#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
-
- if (windowBits < 0) { /* suppress zlib wrapper */
- wrap = 0;
- windowBits = -windowBits;
- }
-#ifdef GZIP
- else if (windowBits > 15) {
- wrap = 2; /* write gzip wrapper instead */
- windowBits -= 16;
- }
-#endif
- if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
- windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
- strategy < 0 || strategy > Z_FIXED) {
- return Z_STREAM_ERROR;
- }
- if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
- s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
- if (s == Z_NULL) return Z_MEM_ERROR;
- strm->state = (struct internal_state FAR *)s;
- s->strm = strm;
-
- s->wrap = wrap;
- s->gzhead = Z_NULL;
- s->w_bits = windowBits;
- s->w_size = 1 << s->w_bits;
- s->w_mask = s->w_size - 1;
-
- s->hash_bits = memLevel + 7;
- s->hash_size = 1 << s->hash_bits;
- s->hash_mask = s->hash_size - 1;
- s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
-
- s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
- s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
- s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
-
- s->high_water = 0; /* nothing written to s->window yet */
-
- s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
-
- overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
- s->pending_buf = (uchf *) overlay;
- s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
-
- if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
- s->pending_buf == Z_NULL) {
- s->status = FINISH_STATE;
- strm->msg = ERR_MSG(Z_MEM_ERROR);
- deflateEnd (strm);
- return Z_MEM_ERROR;
- }
- s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
- s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
-
- s->level = level;
- s->strategy = strategy;
- s->method = (Byte)method;
-
- return deflateReset(strm);
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
- z_streamp strm;
- const Bytef *dictionary;
- uInt dictLength;
-{
- deflate_state *s;
- uInt str, n;
- int wrap;
- unsigned avail;
- z_const unsigned char *next;
-
- if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL)
- return Z_STREAM_ERROR;
- s = strm->state;
- wrap = s->wrap;
- if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
- return Z_STREAM_ERROR;
-
- /* when using zlib wrappers, compute Adler-32 for provided dictionary */
- if (wrap == 1)
- strm->adler = adler32(strm->adler, dictionary, dictLength);
- s->wrap = 0; /* avoid computing Adler-32 in read_buf */
-
- /* if dictionary would fill window, just replace the history */
- if (dictLength >= s->w_size) {
- if (wrap == 0) { /* already empty otherwise */
- CLEAR_HASH(s);
- s->strstart = 0;
- s->block_start = 0L;
- s->insert = 0;
- }
- dictionary += dictLength - s->w_size; /* use the tail */
- dictLength = s->w_size;
- }
-
- /* insert dictionary into window and hash */
- avail = strm->avail_in;
- next = strm->next_in;
- strm->avail_in = dictLength;
- strm->next_in = (z_const Bytef *)dictionary;
- fill_window(s);
- while (s->lookahead >= MIN_MATCH) {
- str = s->strstart;
- n = s->lookahead - (MIN_MATCH-1);
- do {
- UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
-#ifndef FASTEST
- s->prev[str & s->w_mask] = s->head[s->ins_h];
-#endif
- s->head[s->ins_h] = (Pos)str;
- str++;
- } while (--n);
- s->strstart = str;
- s->lookahead = MIN_MATCH-1;
- fill_window(s);
- }
- s->strstart += s->lookahead;
- s->block_start = (long)s->strstart;
- s->insert = s->lookahead;
- s->lookahead = 0;
- s->match_length = s->prev_length = MIN_MATCH-1;
- s->match_available = 0;
- strm->next_in = next;
- strm->avail_in = avail;
- s->wrap = wrap;
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateResetKeep (strm)
- z_streamp strm;
-{
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
- return Z_STREAM_ERROR;
- }
-
- strm->total_in = strm->total_out = 0;
- strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
- strm->data_type = Z_UNKNOWN;
-
- s = (deflate_state *)strm->state;
- s->pending = 0;
- s->pending_out = s->pending_buf;
-
- if (s->wrap < 0) {
- s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
- }
- s->status = s->wrap ? INIT_STATE : BUSY_STATE;
- strm->adler =
-#ifdef GZIP
- s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
-#endif
- adler32(0L, Z_NULL, 0);
- s->last_flush = Z_NO_FLUSH;
-
- _tr_init(s);
-
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateReset (strm)
- z_streamp strm;
-{
- int ret;
-
- ret = deflateResetKeep(strm);
- if (ret == Z_OK)
- lm_init(strm->state);
- return ret;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateSetHeader (strm, head)
- z_streamp strm;
- gz_headerp head;
-{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- if (strm->state->wrap != 2) return Z_STREAM_ERROR;
- strm->state->gzhead = head;
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflatePending (strm, pending, bits)
- unsigned *pending;
- int *bits;
- z_streamp strm;
-{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- if (pending != Z_NULL)
- *pending = strm->state->pending;
- if (bits != Z_NULL)
- *bits = strm->state->bi_valid;
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflatePrime (strm, bits, value)
- z_streamp strm;
- int bits;
- int value;
-{
- deflate_state *s;
- int put;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = strm->state;
- if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3))
- return Z_BUF_ERROR;
- do {
- put = Buf_size - s->bi_valid;
- if (put > bits)
- put = bits;
- s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);
- s->bi_valid += put;
- _tr_flush_bits(s);
- value >>= put;
- bits -= put;
- } while (bits);
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateParams(strm, level, strategy)
- z_streamp strm;
- int level;
- int strategy;
-{
- deflate_state *s;
- compress_func func;
- int err = Z_OK;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = strm->state;
-
-#ifdef FASTEST
- if (level != 0) level = 1;
-#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
- if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
- return Z_STREAM_ERROR;
- }
- func = configuration_table[s->level].func;
-
- if ((strategy != s->strategy || func != configuration_table[level].func) &&
- strm->total_in != 0) {
- /* Flush the last buffer: */
- err = deflate(strm, Z_BLOCK);
- if (err == Z_BUF_ERROR && s->pending == 0)
- err = Z_OK;
- }
- if (s->level != level) {
- s->level = level;
- s->max_lazy_match = configuration_table[level].max_lazy;
- s->good_match = configuration_table[level].good_length;
- s->nice_match = configuration_table[level].nice_length;
- s->max_chain_length = configuration_table[level].max_chain;
- }
- s->strategy = strategy;
- return err;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
- z_streamp strm;
- int good_length;
- int max_lazy;
- int nice_length;
- int max_chain;
-{
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = strm->state;
- s->good_match = good_length;
- s->max_lazy_match = max_lazy;
- s->nice_match = nice_length;
- s->max_chain_length = max_chain;
- return Z_OK;
-}
-
-/* =========================================================================
- * For the default windowBits of 15 and memLevel of 8, this function returns
- * a close to exact, as well as small, upper bound on the compressed size.
- * They are coded as constants here for a reason--if the #define's are
- * changed, then this function needs to be changed as well. The return
- * value for 15 and 8 only works for those exact settings.
- *
- * For any setting other than those defaults for windowBits and memLevel,
- * the value returned is a conservative worst case for the maximum expansion
- * resulting from using fixed blocks instead of stored blocks, which deflate
- * can emit on compressed data for some combinations of the parameters.
- *
- * This function could be more sophisticated to provide closer upper bounds for
- * every combination of windowBits and memLevel. But even the conservative
- * upper bound of about 14% expansion does not seem onerous for output buffer
- * allocation.
- */
-uLong ZEXPORT deflateBound(strm, sourceLen)
- z_streamp strm;
- uLong sourceLen;
-{
- deflate_state *s;
- uLong complen, wraplen;
- Bytef *str;
-
- /* conservative upper bound for compressed data */
- complen = sourceLen +
- ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
-
- /* if can't get parameters, return conservative bound plus zlib wrapper */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return complen + 6;
-
- /* compute wrapper length */
- s = strm->state;
- switch (s->wrap) {
- case 0: /* raw deflate */
- wraplen = 0;
- break;
- case 1: /* zlib wrapper */
- wraplen = 6 + (s->strstart ? 4 : 0);
- break;
- case 2: /* gzip wrapper */
- wraplen = 18;
- if (s->gzhead != Z_NULL) { /* user-supplied gzip header */
- if (s->gzhead->extra != Z_NULL)
- wraplen += 2 + s->gzhead->extra_len;
- str = s->gzhead->name;
- if (str != Z_NULL)
- do {
- wraplen++;
- } while (*str++);
- str = s->gzhead->comment;
- if (str != Z_NULL)
- do {
- wraplen++;
- } while (*str++);
- if (s->gzhead->hcrc)
- wraplen += 2;
- }
- break;
- default: /* for compiler happiness */
- wraplen = 6;
- }
-
- /* if not default parameters, return conservative bound */
- if (s->w_bits != 15 || s->hash_bits != 8 + 7)
- return complen + wraplen;
-
- /* default settings: return tight bound for that case */
- return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
- (sourceLen >> 25) + 13 - 6 + wraplen;
-}
-
-/* =========================================================================
- * Put a short in the pending buffer. The 16-bit value is put in MSB order.
- * IN assertion: the stream state is correct and there is enough room in
- * pending_buf.
- */
-local void putShortMSB (s, b)
- deflate_state *s;
- uInt b;
-{
- put_byte(s, (Byte)(b >> 8));
- put_byte(s, (Byte)(b & 0xff));
-}
-
-/* =========================================================================
- * Flush as much pending output as possible. All deflate() output goes
- * through this function so some applications may wish to modify it
- * to avoid allocating a large strm->next_out buffer and copying into it.
- * (See also read_buf()).
- */
-local void flush_pending(strm)
- z_streamp strm;
-{
- unsigned len;
- deflate_state *s = strm->state;
-
- _tr_flush_bits(s);
- len = s->pending;
- if (len > strm->avail_out) len = strm->avail_out;
- if (len == 0) return;
-
- zmemcpy(strm->next_out, s->pending_out, len);
- strm->next_out += len;
- s->pending_out += len;
- strm->total_out += len;
- strm->avail_out -= len;
- s->pending -= len;
- if (s->pending == 0) {
- s->pending_out = s->pending_buf;
- }
-}
-
-/* ========================================================================= */
-int ZEXPORT deflate (strm, flush)
- z_streamp strm;
- int flush;
-{
- int old_flush; /* value of flush param for previous deflate call */
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_BLOCK || flush < 0) {
- return Z_STREAM_ERROR;
- }
- s = strm->state;
-
- if (strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0) ||
- (s->status == FINISH_STATE && flush != Z_FINISH)) {
- ERR_RETURN(strm, Z_STREAM_ERROR);
- }
- if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
-
- s->strm = strm; /* just in case */
- old_flush = s->last_flush;
- s->last_flush = flush;
-
- /* Write the header */
- if (s->status == INIT_STATE) {
-#ifdef GZIP
- if (s->wrap == 2) {
- strm->adler = crc32(0L, Z_NULL, 0);
- put_byte(s, 31);
- put_byte(s, 139);
- put_byte(s, 8);
- if (s->gzhead == Z_NULL) {
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, OS_CODE);
- s->status = BUSY_STATE;
- }
- else {
- put_byte(s, (s->gzhead->text ? 1 : 0) +
- (s->gzhead->hcrc ? 2 : 0) +
- (s->gzhead->extra == Z_NULL ? 0 : 4) +
- (s->gzhead->name == Z_NULL ? 0 : 8) +
- (s->gzhead->comment == Z_NULL ? 0 : 16)
- );
- put_byte(s, (Byte)(s->gzhead->time & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, s->gzhead->os & 0xff);
- if (s->gzhead->extra != Z_NULL) {
- put_byte(s, s->gzhead->extra_len & 0xff);
- put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
- }
- if (s->gzhead->hcrc)
- strm->adler = crc32(strm->adler, s->pending_buf,
- s->pending);
- s->gzindex = 0;
- s->status = EXTRA_STATE;
- }
- }
- else
-#endif
- {
- uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
- uInt level_flags;
-
- if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
- level_flags = 0;
- else if (s->level < 6)
- level_flags = 1;
- else if (s->level == 6)
- level_flags = 2;
- else
- level_flags = 3;
- header |= (level_flags << 6);
- if (s->strstart != 0) header |= PRESET_DICT;
- header += 31 - (header % 31);
-
- s->status = BUSY_STATE;
- putShortMSB(s, header);
-
- /* Save the adler32 of the preset dictionary: */
- if (s->strstart != 0) {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- strm->adler = adler32(0L, Z_NULL, 0);
- }
- }
-#ifdef GZIP
- if (s->status == EXTRA_STATE) {
- if (s->gzhead->extra != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
-
- while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size)
- break;
- }
- put_byte(s, s->gzhead->extra[s->gzindex]);
- s->gzindex++;
- }
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (s->gzindex == s->gzhead->extra_len) {
- s->gzindex = 0;
- s->status = NAME_STATE;
- }
- }
- else
- s->status = NAME_STATE;
- }
- if (s->status == NAME_STATE) {
- if (s->gzhead->name != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
- int val;
-
- do {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
- }
- }
- val = s->gzhead->name[s->gzindex++];
- put_byte(s, val);
- } while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0) {
- s->gzindex = 0;
- s->status = COMMENT_STATE;
- }
- }
- else
- s->status = COMMENT_STATE;
- }
- if (s->status == COMMENT_STATE) {
- if (s->gzhead->comment != Z_NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
- int val;
-
- do {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
- }
- }
- val = s->gzhead->comment[s->gzindex++];
- put_byte(s, val);
- } while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0)
- s->status = HCRC_STATE;
- }
- else
- s->status = HCRC_STATE;
- }
- if (s->status == HCRC_STATE) {
- if (s->gzhead->hcrc) {
- if (s->pending + 2 > s->pending_buf_size)
- flush_pending(strm);
- if (s->pending + 2 <= s->pending_buf_size) {
- put_byte(s, (Byte)(strm->adler & 0xff));
- put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
- strm->adler = crc32(0L, Z_NULL, 0);
- s->status = BUSY_STATE;
- }
- }
- else
- s->status = BUSY_STATE;
- }
-#endif
-
- /* Flush as much pending output as possible */
- if (s->pending != 0) {
- flush_pending(strm);
- if (strm->avail_out == 0) {
- /* Since avail_out is 0, deflate will be called again with
- * more output space, but possibly with both pending and
- * avail_in equal to zero. There won't be anything to do,
- * but this is not an error situation so make sure we
- * return OK instead of BUF_ERROR at next call of deflate:
- */
- s->last_flush = -1;
- return Z_OK;
- }
-
- /* Make sure there is something to do and avoid duplicate consecutive
- * flushes. For repeated and useless calls with Z_FINISH, we keep
- * returning Z_STREAM_END instead of Z_BUF_ERROR.
- */
- } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
- flush != Z_FINISH) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* User must not provide more input after the first FINISH: */
- if (s->status == FINISH_STATE && strm->avail_in != 0) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* Start a new block or continue the current one.
- */
- if (strm->avail_in != 0 || s->lookahead != 0 ||
- (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
- block_state bstate;
-
- bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
- (s->strategy == Z_RLE ? deflate_rle(s, flush) :
- (*(configuration_table[s->level].func))(s, flush));
-
- if (bstate == finish_started || bstate == finish_done) {
- s->status = FINISH_STATE;
- }
- if (bstate == need_more || bstate == finish_started) {
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
- }
- return Z_OK;
- /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
- * of deflate should use the same flush parameter to make sure
- * that the flush is complete. So we don't have to output an
- * empty block here, this will be done at next call. This also
- * ensures that for a very small output buffer, we emit at most
- * one empty block.
- */
- }
- if (bstate == block_done) {
- if (flush == Z_PARTIAL_FLUSH) {
- _tr_align(s);
- } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
- _tr_stored_block(s, (char*)0, 0L, 0);
- /* For a full flush, this empty block will be recognized
- * as a special marker by inflate_sync().
- */
- if (flush == Z_FULL_FLUSH) {
- CLEAR_HASH(s); /* forget history */
- if (s->lookahead == 0) {
- s->strstart = 0;
- s->block_start = 0L;
- s->insert = 0;
- }
- }
- }
- flush_pending(strm);
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
- return Z_OK;
- }
- }
- }
- Assert(strm->avail_out > 0, "bug2");
-
- if (flush != Z_FINISH) return Z_OK;
- if (s->wrap <= 0) return Z_STREAM_END;
-
- /* Write the trailer */
-#ifdef GZIP
- if (s->wrap == 2) {
- put_byte(s, (Byte)(strm->adler & 0xff));
- put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
- put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
- put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
- put_byte(s, (Byte)(strm->total_in & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
- }
- else
-#endif
- {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- flush_pending(strm);
- /* If avail_out is zero, the application will call deflate again
- * to flush the rest.
- */
- if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
- return s->pending != 0 ? Z_OK : Z_STREAM_END;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateEnd (strm)
- z_streamp strm;
-{
- int status;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-
- status = strm->state->status;
- if (status != INIT_STATE &&
- status != EXTRA_STATE &&
- status != NAME_STATE &&
- status != COMMENT_STATE &&
- status != HCRC_STATE &&
- status != BUSY_STATE &&
- status != FINISH_STATE) {
- return Z_STREAM_ERROR;
- }
-
- /* Deallocate in reverse order of allocations: */
- TRY_FREE(strm, strm->state->pending_buf);
- TRY_FREE(strm, strm->state->head);
- TRY_FREE(strm, strm->state->prev);
- TRY_FREE(strm, strm->state->window);
-
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
-
- return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
-}
-
-/* =========================================================================
- * Copy the source state to the destination state.
- * To simplify the source, this is not supported for 16-bit MSDOS (which
- * doesn't have enough memory anyway to duplicate compression states).
- */
-int ZEXPORT deflateCopy (dest, source)
- z_streamp dest;
- z_streamp source;
-{
-#ifdef MAXSEG_64K
- return Z_STREAM_ERROR;
-#else
- deflate_state *ds;
- deflate_state *ss;
- ushf *overlay;
-
-
- if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
- return Z_STREAM_ERROR;
- }
-
- ss = source->state;
-
- zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
-
- ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
- if (ds == Z_NULL) return Z_MEM_ERROR;
- dest->state = (struct internal_state FAR *) ds;
- zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
- ds->strm = dest;
-
- ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
- ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
- ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
- overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
- ds->pending_buf = (uchf *) overlay;
-
- if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
- ds->pending_buf == Z_NULL) {
- deflateEnd (dest);
- return Z_MEM_ERROR;
- }
- /* following zmemcpy do not work for 16-bit MSDOS */
- zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
- zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
- zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
- zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
-
- ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
- ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
- ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
-
- ds->l_desc.dyn_tree = ds->dyn_ltree;
- ds->d_desc.dyn_tree = ds->dyn_dtree;
- ds->bl_desc.dyn_tree = ds->bl_tree;
-
- return Z_OK;
-#endif /* MAXSEG_64K */
-}
-
-/* ===========================================================================
- * Read a new buffer from the current input stream, update the adler32
- * and total number of bytes read. All deflate() input goes through
- * this function so some applications may wish to modify it to avoid
- * allocating a large strm->next_in buffer and copying from it.
- * (See also flush_pending()).
- */
-local int read_buf(strm, buf, size)
- z_streamp strm;
- Bytef *buf;
- unsigned size;
-{
- unsigned len = strm->avail_in;
-
- if (len > size) len = size;
- if (len == 0) return 0;
-
- strm->avail_in -= len;
-
- zmemcpy(buf, strm->next_in, len);
- if (strm->state->wrap == 1) {
- strm->adler = adler32(strm->adler, buf, len);
- }
-#ifdef GZIP
- else if (strm->state->wrap == 2) {
- strm->adler = crc32(strm->adler, buf, len);
- }
-#endif
- strm->next_in += len;
- strm->total_in += len;
-
- return (int)len;
-}
-
-/* ===========================================================================
- * Initialize the "longest match" routines for a new zlib stream
- */
-local void lm_init (s)
- deflate_state *s;
-{
- s->window_size = (ulg)2L*s->w_size;
-
- CLEAR_HASH(s);
-
- /* Set the default configuration parameters:
- */
- s->max_lazy_match = configuration_table[s->level].max_lazy;
- s->good_match = configuration_table[s->level].good_length;
- s->nice_match = configuration_table[s->level].nice_length;
- s->max_chain_length = configuration_table[s->level].max_chain;
-
- s->strstart = 0;
- s->block_start = 0L;
- s->lookahead = 0;
- s->insert = 0;
- s->match_length = s->prev_length = MIN_MATCH-1;
- s->match_available = 0;
- s->ins_h = 0;
-#ifndef FASTEST
-#ifdef ASMV
- match_init(); /* initialize the asm code */
-#endif
-#endif
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Set match_start to the longest match starting at the given string and
- * return its length. Matches shorter or equal to prev_length are discarded,
- * in which case the result is equal to prev_length and match_start is
- * garbage.
- * IN assertions: cur_match is the head of the hash chain for the current
- * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
- * OUT assertion: the match length is not greater than s->lookahead.
- */
-#ifndef ASMV
-/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
- * match.S. The code will be functionally equivalent.
- */
-local uInt longest_match(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
-{
- unsigned chain_length = s->max_chain_length;/* max hash chain length */
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
- register int len; /* length of current match */
- int best_len = s->prev_length; /* best match length so far */
- int nice_match = s->nice_match; /* stop if match long enough */
- IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
- s->strstart - (IPos)MAX_DIST(s) : NIL;
- /* Stop when cur_match becomes <= limit. To simplify the code,
- * we prevent matches with the string of window index 0.
- */
- Posf *prev = s->prev;
- uInt wmask = s->w_mask;
-
-#ifdef UNALIGNED_OK
- /* Compare two bytes at a time. Note: this is not always beneficial.
- * Try with and without -DUNALIGNED_OK to check.
- */
- register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
- register ush scan_start = *(ushf*)scan;
- register ush scan_end = *(ushf*)(scan+best_len-1);
-#else
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
- register Byte scan_end1 = scan[best_len-1];
- register Byte scan_end = scan[best_len];
-#endif
-
- /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
- Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
- /* Do not waste too much time if we already have a good match: */
- if (s->prev_length >= s->good_match) {
- chain_length >>= 2;
- }
- /* Do not look for matches beyond the end of the input. This is necessary
- * to make deflate deterministic.
- */
- if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
-
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
- do {
- Assert(cur_match < s->strstart, "no future");
- match = s->window + cur_match;
-
- /* Skip to next match if the match length cannot increase
- * or if the match length is less than 2. Note that the checks below
- * for insufficient lookahead only occur occasionally for performance
- * reasons. Therefore uninitialized memory will be accessed, and
- * conditional jumps will be made that depend on those values.
- * However the length of the match is limited to the lookahead, so
- * the output of deflate is not affected by the uninitialized values.
- */
-#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
- /* This code assumes sizeof(unsigned short) == 2. Do not use
- * UNALIGNED_OK if your compiler uses a different size.
- */
- if (*(ushf*)(match+best_len-1) != scan_end ||
- *(ushf*)match != scan_start) continue;
-
- /* It is not necessary to compare scan[2] and match[2] since they are
- * always equal when the other bytes match, given that the hash keys
- * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
- * strstart+3, +5, ... up to strstart+257. We check for insufficient
- * lookahead only every 4th comparison; the 128th check will be made
- * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
- * necessary to put more guard bytes at the end of the window, or
- * to check more often for insufficient lookahead.
- */
- Assert(scan[2] == match[2], "scan[2]?");
- scan++, match++;
- do {
- } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- scan < strend);
- /* The funny "do {}" generates better code on most compilers */
-
- /* Here, scan <= window+strstart+257 */
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
- if (*scan == *match) scan++;
-
- len = (MAX_MATCH - 1) - (int)(strend-scan);
- scan = strend - (MAX_MATCH-1);
-
-#else /* UNALIGNED_OK */
-
- if (match[best_len] != scan_end ||
- match[best_len-1] != scan_end1 ||
- *match != *scan ||
- *++match != scan[1]) continue;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match++;
- Assert(*scan == *match, "match[2]?");
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
- len = MAX_MATCH - (int)(strend - scan);
- scan = strend - MAX_MATCH;
-
-#endif /* UNALIGNED_OK */
-
- if (len > best_len) {
- s->match_start = cur_match;
- best_len = len;
- if (len >= nice_match) break;
-#ifdef UNALIGNED_OK
- scan_end = *(ushf*)(scan+best_len-1);
-#else
- scan_end1 = scan[best_len-1];
- scan_end = scan[best_len];
-#endif
- }
- } while ((cur_match = prev[cur_match & wmask]) > limit
- && --chain_length != 0);
-
- if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
- return s->lookahead;
-}
-#endif /* ASMV */
-
-#else /* FASTEST */
-
-/* ---------------------------------------------------------------------------
- * Optimized version for FASTEST only
- */
-local uInt longest_match(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
-{
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
- register int len; /* length of current match */
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
-
- /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
- Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
- Assert(cur_match < s->strstart, "no future");
-
- match = s->window + cur_match;
-
- /* Return failure if the match length is less than 2:
- */
- if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match += 2;
- Assert(*scan == *match, "match[2]?");
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
- len = MAX_MATCH - (int)(strend - scan);
-
- if (len < MIN_MATCH) return MIN_MATCH - 1;
-
- s->match_start = cur_match;
- return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
-}
-
-#endif /* FASTEST */
-
-#ifdef DEBUG
-/* ===========================================================================
- * Check that the match at match_start is indeed a match.
- */
-local void check_match(s, start, match, length)
- deflate_state *s;
- IPos start, match;
- int length;
-{
- /* check that the match is indeed a match */
- if (zmemcmp(s->window + match,
- s->window + start, length) != EQUAL) {
- fprintf(stderr, " start %u, match %u, length %d\n",
- start, match, length);
- do {
- fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
- } while (--length != 0);
- z_error("invalid match");
- }
- if (z_verbose > 1) {
- fprintf(stderr,"\\[%d,%d]", start-match, length);
- do { putc(s->window[start++], stderr); } while (--length != 0);
- }
-}
-#else
-# define check_match(s, start, match, length)
-#endif /* DEBUG */
-
-/* ===========================================================================
- * Fill the window when the lookahead becomes insufficient.
- * Updates strstart and lookahead.
- *
- * IN assertion: lookahead < MIN_LOOKAHEAD
- * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
- * At least one byte has been read, or avail_in == 0; reads are
- * performed for at least two bytes (required for the zip translate_eol
- * option -- not supported here).
- */
-local void fill_window(s)
- deflate_state *s;
-{
- register unsigned n, m;
- register Posf *p;
- unsigned more; /* Amount of free space at the end of the window. */
- uInt wsize = s->w_size;
-
- Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead");
-
- do {
- more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
-
- /* Deal with !@#$% 64K limit: */
- if (sizeof(int) <= 2) {
- if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
- more = wsize;
-
- } else if (more == (unsigned)(-1)) {
- /* Very unlikely, but possible on 16 bit machine if
- * strstart == 0 && lookahead == 1 (input done a byte at time)
- */
- more--;
- }
- }
-
- /* If the window is almost full and there is insufficient lookahead,
- * move the upper half to the lower one to make room in the upper half.
- */
- if (s->strstart >= wsize+MAX_DIST(s)) {
-
- zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
- s->match_start -= wsize;
- s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
- s->block_start -= (long) wsize;
-
- /* Slide the hash table (could be avoided with 32 bit values
- at the expense of memory usage). We slide even when level == 0
- to keep the hash table consistent if we switch back to level > 0
- later. (Using level 0 permanently is not an optimal usage of
- zlib, so we don't care about this pathological case.)
- */
- n = s->hash_size;
- p = &s->head[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- } while (--n);
-
- n = wsize;
-#ifndef FASTEST
- p = &s->prev[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- /* If n is not on any hash chain, prev[n] is garbage but
- * its value will never be used.
- */
- } while (--n);
-#endif
- more += wsize;
- }
- if (s->strm->avail_in == 0) break;
-
- /* If there was no sliding:
- * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
- * more == window_size - lookahead - strstart
- * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
- * => more >= window_size - 2*WSIZE + 2
- * In the BIG_MEM or MMAP case (not yet supported),
- * window_size == input_size + MIN_LOOKAHEAD &&
- * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
- * Otherwise, window_size == 2*WSIZE so more >= 2.
- * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
- */
- Assert(more >= 2, "more < 2");
-
- n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
- s->lookahead += n;
-
- /* Initialize the hash value now that we have some input: */
- if (s->lookahead + s->insert >= MIN_MATCH) {
- uInt str = s->strstart - s->insert;
- s->ins_h = s->window[str];
- UPDATE_HASH(s, s->ins_h, s->window[str + 1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- while (s->insert) {
- UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]);
-#ifndef FASTEST
- s->prev[str & s->w_mask] = s->head[s->ins_h];
-#endif
- s->head[s->ins_h] = (Pos)str;
- str++;
- s->insert--;
- if (s->lookahead + s->insert < MIN_MATCH)
- break;
- }
- }
- /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
- * but this is not important since only literal bytes will be emitted.
- */
-
- } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
-
- /* If the WIN_INIT bytes after the end of the current data have never been
- * written, then zero those bytes in order to avoid memory check reports of
- * the use of uninitialized (or uninitialised as Julian writes) bytes by
- * the longest match routines. Update the high water mark for the next
- * time through here. WIN_INIT is set to MAX_MATCH since the longest match
- * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
- */
- if (s->high_water < s->window_size) {
- ulg curr = s->strstart + (ulg)(s->lookahead);
- ulg init;
-
- if (s->high_water < curr) {
- /* Previous high water mark below current data -- zero WIN_INIT
- * bytes or up to end of window, whichever is less.
- */
- init = s->window_size - curr;
- if (init > WIN_INIT)
- init = WIN_INIT;
- zmemzero(s->window + curr, (unsigned)init);
- s->high_water = curr + init;
- }
- else if (s->high_water < (ulg)curr + WIN_INIT) {
- /* High water mark at or above current data, but below current data
- * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
- * to end of window, whichever is less.
- */
- init = (ulg)curr + WIN_INIT - s->high_water;
- if (init > s->window_size - s->high_water)
- init = s->window_size - s->high_water;
- zmemzero(s->window + s->high_water, (unsigned)init);
- s->high_water += init;
- }
- }
-
- Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,
- "not enough room for search");
-}
-
-/* ===========================================================================
- * Flush the current block, with given end-of-file flag.
- * IN assertion: strstart is set to the end of the current match.
- */
-#define FLUSH_BLOCK_ONLY(s, last) { \
- _tr_flush_block(s, (s->block_start >= 0L ? \
- (charf *)&s->window[(unsigned)s->block_start] : \
- (charf *)Z_NULL), \
- (ulg)((long)s->strstart - s->block_start), \
- (last)); \
- s->block_start = s->strstart; \
- flush_pending(s->strm); \
- Tracev((stderr,"[FLUSH]")); \
-}
-
-/* Same but force premature exit if necessary. */
-#define FLUSH_BLOCK(s, last) { \
- FLUSH_BLOCK_ONLY(s, last); \
- if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
-}
-
-/* ===========================================================================
- * Copy without compression as much as possible from the input stream, return
- * the current block state.
- * This function does not insert new strings in the dictionary since
- * uncompressible data is probably not useful. This function is used
- * only for the level=0 compression option.
- * NOTE: this function should be optimized to avoid extra copying from
- * window to pending_buf.
- */
-local block_state deflate_stored(s, flush)
- deflate_state *s;
- int flush;
-{
- /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
- * to pending_buf_size, and each stored block has a 5 byte header:
- */
- ulg max_block_size = 0xffff;
- ulg max_start;
-
- if (max_block_size > s->pending_buf_size - 5) {
- max_block_size = s->pending_buf_size - 5;
- }
-
- /* Copy as much as possible from input to output: */
- for (;;) {
- /* Fill the window as much as possible: */
- if (s->lookahead <= 1) {
-
- Assert(s->strstart < s->w_size+MAX_DIST(s) ||
- s->block_start >= (long)s->w_size, "slide too late");
-
- fill_window(s);
- if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
-
- if (s->lookahead == 0) break; /* flush the current block */
- }
- Assert(s->block_start >= 0L, "block gone");
-
- s->strstart += s->lookahead;
- s->lookahead = 0;
-
- /* Emit a stored block if pending_buf will be full: */
- max_start = s->block_start + max_block_size;
- if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
- /* strstart == 0 is possible when wraparound on 16-bit machine */
- s->lookahead = (uInt)(s->strstart - max_start);
- s->strstart = (uInt)max_start;
- FLUSH_BLOCK(s, 0);
- }
- /* Flush if we may have to slide, otherwise block_start may become
- * negative and the data will be gone:
- */
- if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
- FLUSH_BLOCK(s, 0);
- }
- }
- s->insert = 0;
- if (flush == Z_FINISH) {
- FLUSH_BLOCK(s, 1);
- return finish_done;
- }
- if ((long)s->strstart > s->block_start)
- FLUSH_BLOCK(s, 0);
- return block_done;
-}
-
-/* ===========================================================================
- * Compress as much as possible from the input stream, return the current
- * block state.
- * This function does not perform lazy evaluation of matches and inserts
- * new strings in the dictionary only for unmatched strings or for short
- * matches. It is used only for the fast compression options.
- */
-local block_state deflate_fast(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head; /* head of the hash chain */
- int bflush; /* set if current block must be flushed */
-
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- hash_head = NIL;
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- * At this point we have always match_length < MIN_MATCH
- */
- if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
- s->match_length = longest_match (s, hash_head);
- /* longest_match() sets match_start */
- }
- if (s->match_length >= MIN_MATCH) {
- check_match(s, s->strstart, s->match_start, s->match_length);
-
- _tr_tally_dist(s, s->strstart - s->match_start,
- s->match_length - MIN_MATCH, bflush);
-
- s->lookahead -= s->match_length;
-
- /* Insert new strings in the hash table only if the match length
- * is not too large. This saves time but degrades compression.
- */
-#ifndef FASTEST
- if (s->match_length <= s->max_insert_length &&
- s->lookahead >= MIN_MATCH) {
- s->match_length--; /* string at strstart already in table */
- do {
- s->strstart++;
- INSERT_STRING(s, s->strstart, hash_head);
- /* strstart never exceeds WSIZE-MAX_MATCH, so there are
- * always MIN_MATCH bytes ahead.
- */
- } while (--s->match_length != 0);
- s->strstart++;
- } else
-#endif
- {
- s->strstart += s->match_length;
- s->match_length = 0;
- s->ins_h = s->window[s->strstart];
- UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
- * matter since it will be recomputed at next deflate call.
- */
- }
- } else {
- /* No match, output a literal byte */
- Tracevv((stderr,"%c", s->window[s->strstart]));
- _tr_tally_lit (s, s->window[s->strstart], bflush);
- s->lookahead--;
- s->strstart++;
- }
- if (bflush) FLUSH_BLOCK(s, 0);
- }
- s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
- if (flush == Z_FINISH) {
- FLUSH_BLOCK(s, 1);
- return finish_done;
- }
- if (s->last_lit)
- FLUSH_BLOCK(s, 0);
- return block_done;
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Same as above, but achieves better compression. We use a lazy
- * evaluation for matches: a match is finally adopted only if there is
- * no better match at the next window position.
- */
-local block_state deflate_slow(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head; /* head of hash chain */
- int bflush; /* set if current block must be flushed */
-
- /* Process the input block. */
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- hash_head = NIL;
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- */
- s->prev_length = s->match_length, s->prev_match = s->match_start;
- s->match_length = MIN_MATCH-1;
-
- if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
- s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * of window index 0 (in particular we have to avoid a match
- * of the string with itself at the start of the input file).
- */
- s->match_length = longest_match (s, hash_head);
- /* longest_match() sets match_start */
-
- if (s->match_length <= 5 && (s->strategy == Z_FILTERED
-#if TOO_FAR <= 32767
- || (s->match_length == MIN_MATCH &&
- s->strstart - s->match_start > TOO_FAR)
-#endif
- )) {
-
- /* If prev_match is also MIN_MATCH, match_start is garbage
- * but we will ignore the current match anyway.
- */
- s->match_length = MIN_MATCH-1;
- }
- }
- /* If there was a match at the previous step and the current
- * match is not better, output the previous match:
- */
- if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
- uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
- /* Do not insert strings in hash table beyond this. */
-
- check_match(s, s->strstart-1, s->prev_match, s->prev_length);
-
- _tr_tally_dist(s, s->strstart -1 - s->prev_match,
- s->prev_length - MIN_MATCH, bflush);
-
- /* Insert in hash table all strings up to the end of the match.
- * strstart-1 and strstart are already inserted. If there is not
- * enough lookahead, the last two strings are not inserted in
- * the hash table.
- */
- s->lookahead -= s->prev_length-1;
- s->prev_length -= 2;
- do {
- if (++s->strstart <= max_insert) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
- } while (--s->prev_length != 0);
- s->match_available = 0;
- s->match_length = MIN_MATCH-1;
- s->strstart++;
-
- if (bflush) FLUSH_BLOCK(s, 0);
-
- } else if (s->match_available) {
- /* If there was no match at the previous position, output a
- * single literal. If there was a match but the current match
- * is longer, truncate the previous match to a single literal.
- */
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally_lit(s, s->window[s->strstart-1], bflush);
- if (bflush) {
- FLUSH_BLOCK_ONLY(s, 0);
- }
- s->strstart++;
- s->lookahead--;
- if (s->strm->avail_out == 0) return need_more;
- } else {
- /* There is no previous match to compare with, wait for
- * the next step to decide.
- */
- s->match_available = 1;
- s->strstart++;
- s->lookahead--;
- }
- }
- Assert (flush != Z_NO_FLUSH, "no flush?");
- if (s->match_available) {
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally_lit(s, s->window[s->strstart-1], bflush);
- s->match_available = 0;
- }
- s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1;
- if (flush == Z_FINISH) {
- FLUSH_BLOCK(s, 1);
- return finish_done;
- }
- if (s->last_lit)
- FLUSH_BLOCK(s, 0);
- return block_done;
-}
-#endif /* FASTEST */
-
-/* ===========================================================================
- * For Z_RLE, simply look for runs of bytes, generate matches only of distance
- * one. Do not maintain a hash table. (It will be regenerated if this run of
- * deflate switches away from Z_RLE.)
- */
-local block_state deflate_rle(s, flush)
- deflate_state *s;
- int flush;
-{
- int bflush; /* set if current block must be flushed */
- uInt prev; /* byte at distance one to match */
- Bytef *scan, *strend; /* scan goes up to strend for length of run */
-
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the longest run, plus one for the unrolled loop.
- */
- if (s->lookahead <= MAX_MATCH) {
- fill_window(s);
- if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* See how many times the previous byte repeats */
- s->match_length = 0;
- if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
- scan = s->window + s->strstart - 1;
- prev = *scan;
- if (prev == *++scan && prev == *++scan && prev == *++scan) {
- strend = s->window + s->strstart + MAX_MATCH;
- do {
- } while (prev == *++scan && prev == *++scan &&
- prev == *++scan && prev == *++scan &&
- prev == *++scan && prev == *++scan &&
- prev == *++scan && prev == *++scan &&
- scan < strend);
- s->match_length = MAX_MATCH - (int)(strend - scan);
- if (s->match_length > s->lookahead)
- s->match_length = s->lookahead;
- }
- Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan");
- }
-
- /* Emit match if have run of MIN_MATCH or longer, else emit literal */
- if (s->match_length >= MIN_MATCH) {
- check_match(s, s->strstart, s->strstart - 1, s->match_length);
-
- _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
-
- s->lookahead -= s->match_length;
- s->strstart += s->match_length;
- s->match_length = 0;
- } else {
- /* No match, output a literal byte */
- Tracevv((stderr,"%c", s->window[s->strstart]));
- _tr_tally_lit (s, s->window[s->strstart], bflush);
- s->lookahead--;
- s->strstart++;
- }
- if (bflush) FLUSH_BLOCK(s, 0);
- }
- s->insert = 0;
- if (flush == Z_FINISH) {
- FLUSH_BLOCK(s, 1);
- return finish_done;
- }
- if (s->last_lit)
- FLUSH_BLOCK(s, 0);
- return block_done;
-}
-
-/* ===========================================================================
- * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
- * (It will be regenerated if this run of deflate switches away from Huffman.)
- */
-local block_state deflate_huff(s, flush)
- deflate_state *s;
- int flush;
-{
- int bflush; /* set if current block must be flushed */
-
- for (;;) {
- /* Make sure that we have a literal to write. */
- if (s->lookahead == 0) {
- fill_window(s);
- if (s->lookahead == 0) {
- if (flush == Z_NO_FLUSH)
- return need_more;
- break; /* flush the current block */
- }
- }
-
- /* Output a literal byte */
- s->match_length = 0;
- Tracevv((stderr,"%c", s->window[s->strstart]));
- _tr_tally_lit (s, s->window[s->strstart], bflush);
- s->lookahead--;
- s->strstart++;
- if (bflush) FLUSH_BLOCK(s, 0);
- }
- s->insert = 0;
- if (flush == Z_FINISH) {
- FLUSH_BLOCK(s, 1);
- return finish_done;
- }
- if (s->last_lit)
- FLUSH_BLOCK(s, 0);
- return block_done;
-}
diff -Nru r-base-3.2.3/src/extra/zlib/deflate.h r-base-3.3.1/src/extra/zlib/deflate.h
--- r-base-3.2.3/src/extra/zlib/deflate.h 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/deflate.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,346 +0,0 @@
-/* deflate.h -- internal compression state
- * Copyright (C) 1995-2012 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* @(#) $Id$ */
-
-#ifndef DEFLATE_H
-#define DEFLATE_H
-
-#include "zutil.h"
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
- trailer creation by deflate(). NO_GZIP would be used to avoid linking in
- the crc code when it is not needed. For shared libraries, gzip encoding
- should be left enabled. */
-#ifndef NO_GZIP
-# define GZIP
-#endif
-
-/* ===========================================================================
- * Internal compression state.
- */
-
-#define LENGTH_CODES 29
-/* number of length codes, not counting the special END_BLOCK code */
-
-#define LITERALS 256
-/* number of literal bytes 0..255 */
-
-#define L_CODES (LITERALS+1+LENGTH_CODES)
-/* number of Literal or Length codes, including the END_BLOCK code */
-
-#define D_CODES 30
-/* number of distance codes */
-
-#define BL_CODES 19
-/* number of codes used to transfer the bit lengths */
-
-#define HEAP_SIZE (2*L_CODES+1)
-/* maximum heap size */
-
-#define MAX_BITS 15
-/* All codes must not exceed MAX_BITS bits */
-
-#define Buf_size 16
-/* size of bit buffer in bi_buf */
-
-#define INIT_STATE 42
-#define EXTRA_STATE 69
-#define NAME_STATE 73
-#define COMMENT_STATE 91
-#define HCRC_STATE 103
-#define BUSY_STATE 113
-#define FINISH_STATE 666
-/* Stream status */
-
-
-/* Data structure describing a single value and its code string. */
-typedef struct ct_data_s {
- union {
- ush freq; /* frequency count */
- ush code; /* bit string */
- } fc;
- union {
- ush dad; /* father node in Huffman tree */
- ush len; /* length of bit string */
- } dl;
-} FAR ct_data;
-
-#define Freq fc.freq
-#define Code fc.code
-#define Dad dl.dad
-#define Len dl.len
-
-typedef struct static_tree_desc_s static_tree_desc;
-
-typedef struct tree_desc_s {
- ct_data *dyn_tree; /* the dynamic tree */
- int max_code; /* largest code with non zero frequency */
- static_tree_desc *stat_desc; /* the corresponding static tree */
-} FAR tree_desc;
-
-typedef ush Pos;
-typedef Pos FAR Posf;
-typedef unsigned IPos;
-
-/* A Pos is an index in the character window. We use short instead of int to
- * save space in the various tables. IPos is used only for parameter passing.
- */
-
-typedef struct internal_state {
- z_streamp strm; /* pointer back to this zlib stream */
- int status; /* as the name implies */
- Bytef *pending_buf; /* output still pending */
- ulg pending_buf_size; /* size of pending_buf */
- Bytef *pending_out; /* next pending byte to output to the stream */
- uInt pending; /* nb of bytes in the pending buffer */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- gz_headerp gzhead; /* gzip header information to write */
- uInt gzindex; /* where in extra, name, or comment */
- Byte method; /* can only be DEFLATED */
- int last_flush; /* value of flush param for previous deflate call */
-
- /* used by deflate.c: */
-
- uInt w_size; /* LZ77 window size (32K by default) */
- uInt w_bits; /* log2(w_size) (8..16) */
- uInt w_mask; /* w_size - 1 */
-
- Bytef *window;
- /* Sliding window. Input bytes are read into the second half of the window,
- * and move to the first half later to keep a dictionary of at least wSize
- * bytes. With this organization, matches are limited to a distance of
- * wSize-MAX_MATCH bytes, but this ensures that IO is always
- * performed with a length multiple of the block size. Also, it limits
- * the window size to 64K, which is quite useful on MSDOS.
- * To do: use the user input buffer as sliding window.
- */
-
- ulg window_size;
- /* Actual size of window: 2*wSize, except when the user input buffer
- * is directly used as sliding window.
- */
-
- Posf *prev;
- /* Link to older string with same hash index. To limit the size of this
- * array to 64K, this link is maintained only for the last 32K strings.
- * An index in this array is thus a window index modulo 32K.
- */
-
- Posf *head; /* Heads of the hash chains or NIL. */
-
- uInt ins_h; /* hash index of string to be inserted */
- uInt hash_size; /* number of elements in hash table */
- uInt hash_bits; /* log2(hash_size) */
- uInt hash_mask; /* hash_size-1 */
-
- uInt hash_shift;
- /* Number of bits by which ins_h must be shifted at each input
- * step. It must be such that after MIN_MATCH steps, the oldest
- * byte no longer takes part in the hash key, that is:
- * hash_shift * MIN_MATCH >= hash_bits
- */
-
- long block_start;
- /* Window position at the beginning of the current output block. Gets
- * negative when the window is moved backwards.
- */
-
- uInt match_length; /* length of best match */
- IPos prev_match; /* previous match */
- int match_available; /* set if previous match exists */
- uInt strstart; /* start of string to insert */
- uInt match_start; /* start of matching string */
- uInt lookahead; /* number of valid bytes ahead in window */
-
- uInt prev_length;
- /* Length of the best match at previous step. Matches not greater than this
- * are discarded. This is used in the lazy match evaluation.
- */
-
- uInt max_chain_length;
- /* To speed up deflation, hash chains are never searched beyond this
- * length. A higher limit improves compression ratio but degrades the
- * speed.
- */
-
- uInt max_lazy_match;
- /* Attempt to find a better match only when the current match is strictly
- * smaller than this value. This mechanism is used only for compression
- * levels >= 4.
- */
-# define max_insert_length max_lazy_match
- /* Insert new strings in the hash table only if the match length is not
- * greater than this length. This saves time but degrades compression.
- * max_insert_length is used only for compression levels <= 3.
- */
-
- int level; /* compression level (1..9) */
- int strategy; /* favor or force Huffman coding*/
-
- uInt good_match;
- /* Use a faster search when the previous match is longer than this */
-
- int nice_match; /* Stop searching when current match exceeds this */
-
- /* used by trees.c: */
- /* Didn't use ct_data typedef below to suppress compiler warning */
- struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
- struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
- struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
-
- struct tree_desc_s l_desc; /* desc. for literal tree */
- struct tree_desc_s d_desc; /* desc. for distance tree */
- struct tree_desc_s bl_desc; /* desc. for bit length tree */
-
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
- int heap_len; /* number of elements in the heap */
- int heap_max; /* element of largest frequency */
- /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
- * The same heap array is used to build all trees.
- */
-
- uch depth[2*L_CODES+1];
- /* Depth of each subtree used as tie breaker for trees of equal frequency
- */
-
- uchf *l_buf; /* buffer for literals or lengths */
-
- uInt lit_bufsize;
- /* Size of match buffer for literals/lengths. There are 4 reasons for
- * limiting lit_bufsize to 64K:
- * - frequencies can be kept in 16 bit counters
- * - if compression is not successful for the first block, all input
- * data is still in the window so we can still emit a stored block even
- * when input comes from standard input. (This can also be done for
- * all blocks if lit_bufsize is not greater than 32K.)
- * - if compression is not successful for a file smaller than 64K, we can
- * even emit a stored file instead of a stored block (saving 5 bytes).
- * This is applicable only for zip (not gzip or zlib).
- * - creating new Huffman trees less frequently may not provide fast
- * adaptation to changes in the input data statistics. (Take for
- * example a binary file with poorly compressible code followed by
- * a highly compressible string table.) Smaller buffer sizes give
- * fast adaptation but have of course the overhead of transmitting
- * trees more frequently.
- * - I can't count above 4
- */
-
- uInt last_lit; /* running index in l_buf */
-
- ushf *d_buf;
- /* Buffer for distances. To simplify the code, d_buf and l_buf have
- * the same number of elements. To use different lengths, an extra flag
- * array would be necessary.
- */
-
- ulg opt_len; /* bit length of current block with optimal trees */
- ulg static_len; /* bit length of current block with static trees */
- uInt matches; /* number of string matches in current block */
- uInt insert; /* bytes at end of window left to insert */
-
-#ifdef DEBUG
- ulg compressed_len; /* total bit length of compressed file mod 2^32 */
- ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
-#endif
-
- ush bi_buf;
- /* Output buffer. bits are inserted starting at the bottom (least
- * significant bits).
- */
- int bi_valid;
- /* Number of valid bits in bi_buf. All bits above the last valid bit
- * are always zero.
- */
-
- ulg high_water;
- /* High water mark offset in window for initialized bytes -- bytes above
- * this are set to zero in order to avoid memory check warnings when
- * longest match routines access bytes past the input. This is then
- * updated to the new high water mark.
- */
-
-} FAR deflate_state;
-
-/* Output a byte on the stream.
- * IN assertion: there is enough room in pending_buf.
- */
-#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
-
-
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
-/* In order to simplify the code, particularly on 16 bit machines, match
- * distances are limited to MAX_DIST instead of WSIZE.
- */
-
-#define WIN_INIT MAX_MATCH
-/* Number of bytes after end of data in window to initialize in order to avoid
- memory checker errors from longest match routines */
-
- /* in trees.c */
-void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
-int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
-void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
- ulg stored_len, int last));
-void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s));
-void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
-void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
- ulg stored_len, int last));
-
-#define d_code(dist) \
- ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
-/* Mapping from a distance to a distance code. dist is the distance - 1 and
- * must not have side effects. _dist_code[256] and _dist_code[257] are never
- * used.
- */
-
-#ifndef DEBUG
-/* Inline versions of _tr_tally for speed: */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
- extern uch ZLIB_INTERNAL _length_code[];
- extern uch ZLIB_INTERNAL _dist_code[];
-#else
- extern const uch ZLIB_INTERNAL _length_code[];
- extern const uch ZLIB_INTERNAL _dist_code[];
-#endif
-
-# define _tr_tally_lit(s, c, flush) \
- { uch cc = (c); \
- s->d_buf[s->last_lit] = 0; \
- s->l_buf[s->last_lit++] = cc; \
- s->dyn_ltree[cc].Freq++; \
- flush = (s->last_lit == s->lit_bufsize-1); \
- }
-# define _tr_tally_dist(s, distance, length, flush) \
- { uch len = (length); \
- ush dist = (distance); \
- s->d_buf[s->last_lit] = dist; \
- s->l_buf[s->last_lit++] = len; \
- dist--; \
- s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
- s->dyn_dtree[d_code(dist)].Freq++; \
- flush = (s->last_lit == s->lit_bufsize-1); \
- }
-#else
-# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
-# define _tr_tally_dist(s, distance, length, flush) \
- flush = _tr_tally(s, distance, length)
-#endif
-
-#endif /* DEFLATE_H */
diff -Nru r-base-3.2.3/src/extra/zlib/infback.c r-base-3.3.1/src/extra/zlib/infback.c
--- r-base-3.2.3/src/extra/zlib/infback.c 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/infback.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,640 +0,0 @@
-/* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2011 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- This code is largely copied from inflate.c. Normally either infback.o or
- inflate.o would be linked into an application--not both. The interface
- with inffast.c is retained so that optimized assembler-coded versions of
- inflate_fast() can be used with either inflate.c or infback.c.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-
-/*
- strm provides memory allocation functions in zalloc and zfree, or
- Z_NULL to use the library memory allocation functions.
-
- windowBits is in the range 8..15, and window is a user-supplied
- window and output buffer that is 2**windowBits bytes.
- */
-int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
-z_streamp strm;
-int windowBits;
-unsigned char FAR *window;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL || window == Z_NULL ||
- windowBits < 8 || windowBits > 15)
- return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
-#ifdef Z_SOLO
- return Z_STREAM_ERROR;
-#else
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
-#endif
- }
- if (strm->zfree == (free_func)0)
-#ifdef Z_SOLO
- return Z_STREAM_ERROR;
-#else
- strm->zfree = zcfree;
-#endif
- state = (struct inflate_state FAR *)ZALLOC(strm, 1,
- sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (struct internal_state FAR *)state;
- state->dmax = 32768U;
- state->wbits = windowBits;
- state->wsize = 1U << windowBits;
- state->window = window;
- state->wnext = 0;
- state->whave = 0;
- return Z_OK;
-}
-
-/*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-/* Macros for inflateBack(): */
-
-/* Load returned state from inflate_fast() */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Set state from registers for inflate_fast() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Assure that some input is available. If input is requested, but denied,
- then return a Z_BUF_ERROR from inflateBack(). */
-#define PULL() \
- do { \
- if (have == 0) { \
- have = in(in_desc, &next); \
- if (have == 0) { \
- next = Z_NULL; \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflateBack()
- with an error if there is no input available. */
-#define PULLBYTE() \
- do { \
- PULL(); \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflateBack() with
- an error. */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Assure that some output space is available, by writing out the window
- if it's full. If the write fails, return from inflateBack() with a
- Z_BUF_ERROR. */
-#define ROOM() \
- do { \
- if (left == 0) { \
- put = state->window; \
- left = state->wsize; \
- state->whave = left; \
- if (out(out_desc, put, left)) { \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/*
- strm provides the memory allocation functions and window buffer on input,
- and provides information on the unused input on return. For Z_DATA_ERROR
- returns, strm will also provide an error message.
-
- in() and out() are the call-back input and output functions. When
- inflateBack() needs more input, it calls in(). When inflateBack() has
- filled the window with output, or when it completes with data in the
- window, it calls out() to write out the data. The application must not
- change the provided input until in() is called again or inflateBack()
- returns. The application must not change the window/output buffer until
- inflateBack() returns.
-
- in() and out() are called with a descriptor parameter provided in the
- inflateBack() call. This parameter can be a structure that provides the
- information required to do the read or write, as well as accumulated
- information on the input and output such as totals and check values.
-
- in() should return zero on failure. out() should return non-zero on
- failure. If either in() or out() fails, than inflateBack() returns a
- Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it
- was in() or out() that caused in the error. Otherwise, inflateBack()
- returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
- error, or Z_MEM_ERROR if it could not allocate memory for the state.
- inflateBack() can also return Z_STREAM_ERROR if the input parameters
- are not correct, i.e. strm is Z_NULL or the state was not initialized.
- */
-int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
-z_streamp strm;
-in_func in;
-void FAR *in_desc;
-out_func out;
-void FAR *out_desc;
-{
- struct inflate_state FAR *state;
- z_const unsigned char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned copy; /* number of stored or match bytes to copy */
- unsigned char FAR *from; /* where to copy match bytes from */
- code here; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- /* Check that the strm exists and that the state was initialized */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
-
- /* Reset the state */
- strm->msg = Z_NULL;
- state->mode = TYPE;
- state->last = 0;
- state->whave = 0;
- next = strm->next_in;
- have = next != Z_NULL ? strm->avail_in : 0;
- hold = 0;
- bits = 0;
- put = state->window;
- left = state->wsize;
-
- /* Inflate until end of block marked as last */
- for (;;)
- switch (state->mode) {
- case TYPE:
- /* determine and dispatch block type */
- if (state->last) {
- BYTEBITS();
- state->mode = DONE;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = (char *)"invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
-
- case STORED:
- /* get and verify stored block length */
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = (char *)"invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
-
- /* copy stored block from input to output */
- while (state->length != 0) {
- copy = state->length;
- PULL();
- ROOM();
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
-
- case TABLE:
- /* get dynamic table entries descriptor */
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = (char *)"too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
-
- /* get code length code lengths (not a typo) */
- state->have = 0;
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
-
- /* get length and distance code code lengths */
- state->have = 0;
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- here = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(here.bits) <= bits) break;
- PULLBYTE();
- }
- if (here.val < 16) {
- DROPBITS(here.bits);
- state->lens[state->have++] = here.val;
- }
- else {
- if (here.val == 16) {
- NEEDBITS(here.bits + 2);
- DROPBITS(here.bits);
- if (state->have == 0) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = (unsigned)(state->lens[state->have - 1]);
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (here.val == 17) {
- NEEDBITS(here.bits + 3);
- DROPBITS(here.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(here.bits + 7);
- DROPBITS(here.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* handle error breaks in while */
- if (state->mode == BAD) break;
-
- /* check for end-of-block code (better have one) */
- if (state->lens[256] == 0) {
- strm->msg = (char *)"invalid code -- missing end-of-block";
- state->mode = BAD;
- break;
- }
-
- /* build code tables -- note: do not change the lenbits or distbits
- values here (9 and 6) without reading the comments in inftrees.h
- concerning the ENOUGH constants, which depend on those values */
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (code const FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN;
-
- case LEN:
- /* use inflate_fast() if we have enough input and output */
- if (have >= 6 && left >= 258) {
- RESTORE();
- if (state->whave < state->wsize)
- state->whave = state->wsize - left;
- inflate_fast(strm, state->wsize);
- LOAD();
- break;
- }
-
- /* get a literal, length, or end-of-block code */
- for (;;) {
- here = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(here.bits) <= bits) break;
- PULLBYTE();
- }
- if (here.op && (here.op & 0xf0) == 0) {
- last = here;
- for (;;) {
- here = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + here.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(here.bits);
- state->length = (unsigned)here.val;
-
- /* process literal */
- if (here.op == 0) {
- Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", here.val));
- ROOM();
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- }
-
- /* process end of block */
- if (here.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
-
- /* invalid code */
- if (here.op & 64) {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
-
- /* length code -- get extra bits, if any */
- state->extra = (unsigned)(here.op) & 15;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
-
- /* get distance code */
- for (;;) {
- here = state->distcode[BITS(state->distbits)];
- if ((unsigned)(here.bits) <= bits) break;
- PULLBYTE();
- }
- if ((here.op & 0xf0) == 0) {
- last = here;
- for (;;) {
- here = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + here.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(here.bits);
- if (here.op & 64) {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)here.val;
-
- /* get distance extra bits, if any */
- state->extra = (unsigned)(here.op) & 15;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- }
- if (state->offset > state->wsize - (state->whave < state->wsize ?
- left : 0)) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
- Tracevv((stderr, "inflate: distance %u\n", state->offset));
-
- /* copy match from window to output */
- do {
- ROOM();
- copy = state->wsize - state->offset;
- if (copy < left) {
- from = put + copy;
- copy = left - copy;
- }
- else {
- from = put - state->offset;
- copy = left;
- }
- if (copy > state->length) copy = state->length;
- state->length -= copy;
- left -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- } while (state->length != 0);
- break;
-
- case DONE:
- /* inflate stream terminated properly -- write leftover output */
- ret = Z_STREAM_END;
- if (left < state->wsize) {
- if (out(out_desc, state->window, state->wsize - left))
- ret = Z_BUF_ERROR;
- }
- goto inf_leave;
-
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
-
- default: /* can't happen, but makes compilers happy */
- ret = Z_STREAM_ERROR;
- goto inf_leave;
- }
-
- /* Return unused input */
- inf_leave:
- strm->next_in = next;
- strm->avail_in = have;
- return ret;
-}
-
-int ZEXPORT inflateBackEnd(strm)
-z_streamp strm;
-{
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
diff -Nru r-base-3.2.3/src/extra/zlib/inffast.c r-base-3.3.1/src/extra/zlib/inffast.c
--- r-base-3.2.3/src/extra/zlib/inffast.c 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/inffast.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,340 +0,0 @@
-/* inffast.c -- fast decoding
- * Copyright (C) 1995-2008, 2010, 2013 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifndef ASMINF
-
-/* Allow machine dependent optimization for post-increment or pre-increment.
- Based on testing to date,
- Pre-increment preferred for:
- - PowerPC G3 (Adler)
- - MIPS R5000 (Randers-Pehrson)
- Post-increment preferred for:
- - none
- No measurable difference:
- - Pentium III (Anderson)
- - M68060 (Nikl)
- */
-#ifdef POSTINC
-# define OFF 0
-# define PUP(a) *(a)++
-#else
-# define OFF 1
-# define PUP(a) *++(a)
-#endif
-
-/*
- Decode literal, length, and distance codes and write out the resulting
- literal and match bytes until either not enough input or output is
- available, an end-of-block is encountered, or a data error is encountered.
- When large enough input and output buffers are supplied to inflate(), for
- example, a 16K input buffer and a 64K output buffer, more than 95% of the
- inflate execution time is spent in this routine.
-
- Entry assumptions:
-
- state->mode == LEN
- strm->avail_in >= 6
- strm->avail_out >= 258
- start >= strm->avail_out
- state->bits < 8
-
- On return, state->mode is one of:
-
- LEN -- ran out of enough output space or enough available input
- TYPE -- reached end of block code, inflate() to interpret next block
- BAD -- error in block data
-
- Notes:
-
- - The maximum input bits used by a length/distance pair is 15 bits for the
- length code, 5 bits for the length extra, 15 bits for the distance code,
- and 13 bits for the distance extra. This totals 48 bits, or six bytes.
- Therefore if strm->avail_in >= 6, then there is enough input to avoid
- checking for available input while decoding.
-
- - The maximum bytes that a single length/distance pair can output is 258
- bytes, which is the maximum length that can be coded. inflate_fast()
- requires strm->avail_out >= 258 for each loop to avoid checking for
- output space.
- */
-void ZLIB_INTERNAL inflate_fast(strm, start)
-z_streamp strm;
-unsigned start; /* inflate()'s starting value for strm->avail_out */
-{
- struct inflate_state FAR *state;
- z_const unsigned char FAR *in; /* local strm->next_in */
- z_const unsigned char FAR *last; /* have enough input while in < last */
- unsigned char FAR *out; /* local strm->next_out */
- unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
- unsigned char FAR *end; /* while out < end, enough space available */
-#ifdef INFLATE_STRICT
- unsigned dmax; /* maximum distance from zlib header */
-#endif
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned wnext; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
- unsigned long hold; /* local strm->hold */
- unsigned bits; /* local strm->bits */
- code const FAR *lcode; /* local strm->lencode */
- code const FAR *dcode; /* local strm->distcode */
- unsigned lmask; /* mask for first level of length codes */
- unsigned dmask; /* mask for first level of distance codes */
- code here; /* retrieved table entry */
- unsigned op; /* code bits, operation, extra bits, or */
- /* window position, window bytes to copy */
- unsigned len; /* match length, unused bytes */
- unsigned dist; /* match distance */
- unsigned char FAR *from; /* where to copy match from */
-
- /* copy state to local variables */
- state = (struct inflate_state FAR *)strm->state;
- in = strm->next_in - OFF;
- last = in + (strm->avail_in - 5);
- out = strm->next_out - OFF;
- beg = out - (start - strm->avail_out);
- end = out + (strm->avail_out - 257);
-#ifdef INFLATE_STRICT
- dmax = state->dmax;
-#endif
- wsize = state->wsize;
- whave = state->whave;
- wnext = state->wnext;
- window = state->window;
- hold = state->hold;
- bits = state->bits;
- lcode = state->lencode;
- dcode = state->distcode;
- lmask = (1U << state->lenbits) - 1;
- dmask = (1U << state->distbits) - 1;
-
- /* decode literals and length/distances until end-of-block or not enough
- input data or output space */
- do {
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- here = lcode[hold & lmask];
- dolen:
- op = (unsigned)(here.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(here.op);
- if (op == 0) { /* literal */
- Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", here.val));
- PUP(out) = (unsigned char)(here.val);
- }
- else if (op & 16) { /* length base */
- len = (unsigned)(here.val);
- op &= 15; /* number of extra bits */
- if (op) {
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- len += (unsigned)hold & ((1U << op) - 1);
- hold >>= op;
- bits -= op;
- }
- Tracevv((stderr, "inflate: length %u\n", len));
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- here = dcode[hold & dmask];
- dodist:
- op = (unsigned)(here.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(here.op);
- if (op & 16) { /* distance base */
- dist = (unsigned)(here.val);
- op &= 15; /* number of extra bits */
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- }
- dist += (unsigned)hold & ((1U << op) - 1);
-#ifdef INFLATE_STRICT
- if (dist > dmax) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
-#endif
- hold >>= op;
- bits -= op;
- Tracevv((stderr, "inflate: distance %u\n", dist));
- op = (unsigned)(out - beg); /* max distance in output */
- if (dist > op) { /* see if copy from window */
- op = dist - op; /* distance back in window */
- if (op > whave) {
- if (state->sane) {
- strm->msg =
- (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
-#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
- if (len <= op - whave) {
- do {
- PUP(out) = 0;
- } while (--len);
- continue;
- }
- len -= op - whave;
- do {
- PUP(out) = 0;
- } while (--op > whave);
- if (op == 0) {
- from = out - dist;
- do {
- PUP(out) = PUP(from);
- } while (--len);
- continue;
- }
-#endif
- }
- from = window - OFF;
- if (wnext == 0) { /* very common case */
- from += wsize - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- else if (wnext < op) { /* wrap around window */
- from += wsize + wnext - op;
- op -= wnext;
- if (op < len) { /* some from end of window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = window - OFF;
- if (wnext < len) { /* some from start of window */
- op = wnext;
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- }
- else { /* contiguous in window */
- from += wnext - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- while (len > 2) {
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- }
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- else {
- from = out - dist; /* copy direct from output */
- do { /* minimum length is three */
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- } while (len > 2);
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- }
- else if ((op & 64) == 0) { /* 2nd level distance code */
- here = dcode[here.val + (hold & ((1U << op) - 1))];
- goto dodist;
- }
- else {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- }
- else if ((op & 64) == 0) { /* 2nd level length code */
- here = lcode[here.val + (hold & ((1U << op) - 1))];
- goto dolen;
- }
- else if (op & 32) { /* end-of-block */
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
- else {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
- } while (in < last && out < end);
-
- /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
- len = bits >> 3;
- in -= len;
- bits -= len << 3;
- hold &= (1U << bits) - 1;
-
- /* update state and return */
- strm->next_in = in + OFF;
- strm->next_out = out + OFF;
- strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
- strm->avail_out = (unsigned)(out < end ?
- 257 + (end - out) : 257 - (out - end));
- state->hold = hold;
- state->bits = bits;
- return;
-}
-
-/*
- inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
- - Using bit fields for code structure
- - Different op definition to avoid & for extra bits (do & for table bits)
- - Three separate decoding do-loops for direct, window, and wnext == 0
- - Special case for distance > 1 copies to do overlapped load and store copy
- - Explicit branch predictions (based on measured branch probabilities)
- - Deferring match copy and interspersed it with decoding subsequent codes
- - Swapping literal/length else
- - Swapping window/direct else
- - Larger unrolled copy loops (three is about right)
- - Moving len -= 3 statement into middle of loop
- */
-
-#endif /* !ASMINF */
diff -Nru r-base-3.2.3/src/extra/zlib/inffast.h r-base-3.3.1/src/extra/zlib/inffast.h
--- r-base-3.2.3/src/extra/zlib/inffast.h 2011-10-02 22:02:10.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/inffast.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,11 +0,0 @@
-/* inffast.h -- header to use inffast.c
- * Copyright (C) 1995-2003, 2010 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
diff -Nru r-base-3.2.3/src/extra/zlib/inffixed.h r-base-3.3.1/src/extra/zlib/inffixed.h
--- r-base-3.2.3/src/extra/zlib/inffixed.h 2012-02-05 23:05:04.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/inffixed.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,94 +0,0 @@
- /* inffixed.h -- table for decoding fixed codes
- * Generated automatically by makefixed().
- */
-
- /* WARNING: this file should *not* be used by applications.
- It is part of the implementation of this library and is
- subject to change. Applications should only use zlib.h.
- */
-
- static const code lenfix[512] = {
- {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
- {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
- {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
- {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
- {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
- {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
- {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
- {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
- {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
- {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
- {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
- {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
- {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
- {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
- {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
- {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
- {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
- {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
- {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
- {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
- {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
- {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
- {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
- {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
- {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
- {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
- {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
- {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
- {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
- {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
- {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
- {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
- {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
- {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
- {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
- {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
- {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
- {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
- {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
- {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
- {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
- {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
- {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
- {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
- {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
- {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
- {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
- {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
- {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
- {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
- {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
- {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
- {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
- {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
- {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
- {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
- {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
- {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
- {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
- {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
- {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
- {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
- {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
- {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
- {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
- {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
- {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
- {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
- {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
- {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
- {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
- {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
- {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
- {0,9,255}
- };
-
- static const code distfix[32] = {
- {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
- {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
- {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
- {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
- {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
- {22,5,193},{64,5,0}
- };
diff -Nru r-base-3.2.3/src/extra/zlib/inflate.c r-base-3.3.1/src/extra/zlib/inflate.c
--- r-base-3.2.3/src/extra/zlib/inflate.c 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/inflate.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,1512 +0,0 @@
-/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2012 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * Change history:
- *
- * 1.2.beta0 24 Nov 2002
- * - First version -- complete rewrite of inflate to simplify code, avoid
- * creation of window when not needed, minimize use of window when it is
- * needed, make inffast.c even faster, implement gzip decoding, and to
- * improve code readability and style over the previous zlib inflate code
- *
- * 1.2.beta1 25 Nov 2002
- * - Use pointers for available input and output checking in inffast.c
- * - Remove input and output counters in inffast.c
- * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
- * - Remove unnecessary second byte pull from length extra in inffast.c
- * - Unroll direct copy to three copies per loop in inffast.c
- *
- * 1.2.beta2 4 Dec 2002
- * - Change external routine names to reduce potential conflicts
- * - Correct filename to inffixed.h for fixed tables in inflate.c
- * - Make hbuf[] unsigned char to match parameter type in inflate.c
- * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
- * to avoid negation problem on Alphas (64 bit) in inflate.c
- *
- * 1.2.beta3 22 Dec 2002
- * - Add comments on state->bits assertion in inffast.c
- * - Add comments on op field in inftrees.h
- * - Fix bug in reuse of allocated window after inflateReset()
- * - Remove bit fields--back to byte structure for speed
- * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
- * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
- * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
- * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
- * - Use local copies of stream next and avail values, as well as local bit
- * buffer and bit count in inflate()--for speed when inflate_fast() not used
- *
- * 1.2.beta4 1 Jan 2003
- * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
- * - Move a comment on output buffer sizes from inffast.c to inflate.c
- * - Add comments in inffast.c to introduce the inflate_fast() routine
- * - Rearrange window copies in inflate_fast() for speed and simplification
- * - Unroll last copy for window match in inflate_fast()
- * - Use local copies of window variables in inflate_fast() for speed
- * - Pull out common wnext == 0 case for speed in inflate_fast()
- * - Make op and len in inflate_fast() unsigned for consistency
- * - Add FAR to lcode and dcode declarations in inflate_fast()
- * - Simplified bad distance check in inflate_fast()
- * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
- * source file infback.c to provide a call-back interface to inflate for
- * programs like gzip and unzip -- uses window as output buffer to avoid
- * window copying
- *
- * 1.2.beta5 1 Jan 2003
- * - Improved inflateBack() interface to allow the caller to provide initial
- * input in strm.
- * - Fixed stored blocks bug in inflateBack()
- *
- * 1.2.beta6 4 Jan 2003
- * - Added comments in inffast.c on effectiveness of POSTINC
- * - Typecasting all around to reduce compiler warnings
- * - Changed loops from while (1) or do {} while (1) to for (;;), again to
- * make compilers happy
- * - Changed type of window in inflateBackInit() to unsigned char *
- *
- * 1.2.beta7 27 Jan 2003
- * - Changed many types to unsigned or unsigned short to avoid warnings
- * - Added inflateCopy() function
- *
- * 1.2.0 9 Mar 2003
- * - Changed inflateBack() interface to provide separate opaque descriptors
- * for the in() and out() functions
- * - Changed inflateBack() argument and in_func typedef to swap the length
- * and buffer address return values for the input function
- * - Check next_in and next_out for Z_NULL on entry to inflate()
- *
- * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifdef MAKEFIXED
-# ifndef BUILDFIXED
-# define BUILDFIXED
-# endif
-#endif
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
- unsigned copy));
-#ifdef BUILDFIXED
- void makefixed OF((void));
-#endif
-local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
- unsigned len));
-
-int ZEXPORT inflateResetKeep(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- strm->total_in = strm->total_out = state->total = 0;
- strm->msg = Z_NULL;
- if (state->wrap) /* to support ill-conceived Java test suite */
- strm->adler = state->wrap & 1;
- state->mode = HEAD;
- state->last = 0;
- state->havedict = 0;
- state->dmax = 32768U;
- state->head = Z_NULL;
- state->hold = 0;
- state->bits = 0;
- state->lencode = state->distcode = state->next = state->codes;
- state->sane = 1;
- state->back = -1;
- Tracev((stderr, "inflate: reset\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateReset(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- state->wsize = 0;
- state->whave = 0;
- state->wnext = 0;
- return inflateResetKeep(strm);
-}
-
-int ZEXPORT inflateReset2(strm, windowBits)
-z_streamp strm;
-int windowBits;
-{
- int wrap;
- struct inflate_state FAR *state;
-
- /* get the state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
-
- /* extract wrap request from windowBits parameter */
- if (windowBits < 0) {
- wrap = 0;
- windowBits = -windowBits;
- }
- else {
- wrap = (windowBits >> 4) + 1;
-#ifdef GUNZIP
- if (windowBits < 48)
- windowBits &= 15;
-#endif
- }
-
- /* set number of window bits, free window if different */
- if (windowBits && (windowBits < 8 || windowBits > 15))
- return Z_STREAM_ERROR;
- if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
- ZFREE(strm, state->window);
- state->window = Z_NULL;
- }
-
- /* update state and reset the rest of it */
- state->wrap = wrap;
- state->wbits = (unsigned)windowBits;
- return inflateReset(strm);
-}
-
-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
-z_streamp strm;
-int windowBits;
-const char *version;
-int stream_size;
-{
- int ret;
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL) return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
-#ifdef Z_SOLO
- return Z_STREAM_ERROR;
-#else
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
-#endif
- }
- if (strm->zfree == (free_func)0)
-#ifdef Z_SOLO
- return Z_STREAM_ERROR;
-#else
- strm->zfree = zcfree;
-#endif
- state = (struct inflate_state FAR *)
- ZALLOC(strm, 1, sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (struct internal_state FAR *)state;
- state->window = Z_NULL;
- ret = inflateReset2(strm, windowBits);
- if (ret != Z_OK) {
- ZFREE(strm, state);
- strm->state = Z_NULL;
- }
- return ret;
-}
-
-int ZEXPORT inflateInit_(strm, version, stream_size)
-z_streamp strm;
-const char *version;
-int stream_size;
-{
- return inflateInit2_(strm, DEF_WBITS, version, stream_size);
-}
-
-int ZEXPORT inflatePrime(strm, bits, value)
-z_streamp strm;
-int bits;
-int value;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (bits < 0) {
- state->hold = 0;
- state->bits = 0;
- return Z_OK;
- }
- if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
- value &= (1L << bits) - 1;
- state->hold += value << state->bits;
- state->bits += bits;
- return Z_OK;
-}
-
-/*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-#ifdef MAKEFIXED
-#include
-
-/*
- Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also
- defines BUILDFIXED, so the tables are built on the fly. makefixed() writes
- those tables to stdout, which would be piped to inffixed.h. A small program
- can simply call makefixed to do this:
-
- void makefixed(void);
-
- int main(void)
- {
- makefixed();
- return 0;
- }
-
- Then that can be linked with zlib built with MAKEFIXED defined and run:
-
- a.out > inffixed.h
- */
-void makefixed()
-{
- unsigned low, size;
- struct inflate_state state;
-
- fixedtables(&state);
- puts(" /* inffixed.h -- table for decoding fixed codes");
- puts(" * Generated automatically by makefixed().");
- puts(" */");
- puts("");
- puts(" /* WARNING: this file should *not* be used by applications.");
- puts(" It is part of the implementation of this library and is");
- puts(" subject to change. Applications should only use zlib.h.");
- puts(" */");
- puts("");
- size = 1U << 9;
- printf(" static const code lenfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 7) == 0) printf("\n ");
- printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
- state.lencode[low].bits, state.lencode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
- size = 1U << 5;
- printf("\n static const code distfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 6) == 0) printf("\n ");
- printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
- state.distcode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
-}
-#endif /* MAKEFIXED */
-
-/*
- Update the window with the last wsize (normally 32K) bytes written before
- returning. If window does not exist yet, create it. This is only called
- when a window is already in use, or when output has been written during this
- inflate call, but the end of the deflate stream has not been reached yet.
- It is also called to create a window for dictionary data when a dictionary
- is loaded.
-
- Providing output buffers larger than 32K to inflate() should provide a speed
- advantage, since only the last 32K of output is copied to the sliding window
- upon return from inflate(), and since all distances after the first 32K of
- output will fall in the output data, making match copies simpler and faster.
- The advantage may be dependent on the size of the processor's data caches.
- */
-local int updatewindow(strm, end, copy)
-z_streamp strm;
-const Bytef *end;
-unsigned copy;
-{
- struct inflate_state FAR *state;
- unsigned dist;
-
- state = (struct inflate_state FAR *)strm->state;
-
- /* if it hasn't been done already, allocate space for the window */
- if (state->window == Z_NULL) {
- state->window = (unsigned char FAR *)
- ZALLOC(strm, 1U << state->wbits,
- sizeof(unsigned char));
- if (state->window == Z_NULL) return 1;
- }
-
- /* if window not in use yet, initialize */
- if (state->wsize == 0) {
- state->wsize = 1U << state->wbits;
- state->wnext = 0;
- state->whave = 0;
- }
-
- /* copy state->wsize or less output bytes into the circular window */
- if (copy >= state->wsize) {
- zmemcpy(state->window, end - state->wsize, state->wsize);
- state->wnext = 0;
- state->whave = state->wsize;
- }
- else {
- dist = state->wsize - state->wnext;
- if (dist > copy) dist = copy;
- zmemcpy(state->window + state->wnext, end - copy, dist);
- copy -= dist;
- if (copy) {
- zmemcpy(state->window, end - copy, copy);
- state->wnext = copy;
- state->whave = state->wsize;
- }
- else {
- state->wnext += dist;
- if (state->wnext == state->wsize) state->wnext = 0;
- if (state->whave < state->wsize) state->whave += dist;
- }
- }
- return 0;
-}
-
-/* Macros for inflate(): */
-
-/* check function to use adler32() for zlib or crc32() for gzip */
-#ifdef GUNZIP
-# define UPDATE(check, buf, len) \
- (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
-#else
-# define UPDATE(check, buf, len) adler32(check, buf, len)
-#endif
-
-/* check macros for header crc */
-#ifdef GUNZIP
-# define CRC2(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- check = crc32(check, hbuf, 2); \
- } while (0)
-
-# define CRC4(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- hbuf[2] = (unsigned char)((word) >> 16); \
- hbuf[3] = (unsigned char)((word) >> 24); \
- check = crc32(check, hbuf, 4); \
- } while (0)
-#endif
-
-/* Load registers with state in inflate() for speed */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Restore state from registers in inflate() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflate()
- if there is no input available. */
-#define PULLBYTE() \
- do { \
- if (have == 0) goto inf_leave; \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflate(). */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/*
- inflate() uses a state machine to process as much input data and generate as
- much output data as possible before returning. The state machine is
- structured roughly as follows:
-
- for (;;) switch (state) {
- ...
- case STATEn:
- if (not enough input data or output space to make progress)
- return;
- ... make progress ...
- state = STATEm;
- break;
- ...
- }
-
- so when inflate() is called again, the same case is attempted again, and
- if the appropriate resources are provided, the machine proceeds to the
- next state. The NEEDBITS() macro is usually the way the state evaluates
- whether it can proceed or should return. NEEDBITS() does the return if
- the requested bits are not available. The typical use of the BITS macros
- is:
-
- NEEDBITS(n);
- ... do something with BITS(n) ...
- DROPBITS(n);
-
- where NEEDBITS(n) either returns from inflate() if there isn't enough
- input left to load n bits into the accumulator, or it continues. BITS(n)
- gives the low n bits in the accumulator. When done, DROPBITS(n) drops
- the low n bits off the accumulator. INITBITS() clears the accumulator
- and sets the number of available bits to zero. BYTEBITS() discards just
- enough bits to put the accumulator on a byte boundary. After BYTEBITS()
- and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
-
- NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
- if there is no input available. The decoding of variable length codes uses
- PULLBYTE() directly in order to pull just enough bytes to decode the next
- code, and no more.
-
- Some states loop until they get enough input, making sure that enough
- state information is maintained to continue the loop where it left off
- if NEEDBITS() returns in the loop. For example, want, need, and keep
- would all have to actually be part of the saved state in case NEEDBITS()
- returns:
-
- case STATEw:
- while (want < need) {
- NEEDBITS(n);
- keep[want++] = BITS(n);
- DROPBITS(n);
- }
- state = STATEx;
- case STATEx:
-
- As shown above, if the next state is also the next case, then the break
- is omitted.
-
- A state may also return if there is not enough output space available to
- complete that state. Those states are copying stored data, writing a
- literal byte, and copying a matching string.
-
- When returning, a "goto inf_leave" is used to update the total counters,
- update the check value, and determine whether any progress has been made
- during that inflate() call in order to return the proper return code.
- Progress is defined as a change in either strm->avail_in or strm->avail_out.
- When there is a window, goto inf_leave will update the window with the last
- output written. If a goto inf_leave occurs in the middle of decompression
- and there is no window currently, goto inf_leave will create one and copy
- output to the window for the next call of inflate().
-
- In this implementation, the flush parameter of inflate() only affects the
- return code (per zlib.h). inflate() always writes as much as possible to
- strm->next_out, given the space available and the provided input--the effect
- documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
- the allocation of and copying into a sliding window until necessary, which
- provides the effect documented in zlib.h for Z_FINISH when the entire input
- stream available. So the only thing the flush parameter actually does is:
- when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
- will return Z_BUF_ERROR if it has not reached the end of the stream.
- */
-
-int ZEXPORT inflate(strm, flush)
-z_streamp strm;
-int flush;
-{
- struct inflate_state FAR *state;
- z_const unsigned char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned in, out; /* save starting available input and output */
- unsigned copy; /* number of stored or match bytes to copy */
- unsigned char FAR *from; /* where to copy match bytes from */
- code here; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
-#ifdef GUNZIP
- unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
-#endif
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0))
- return Z_STREAM_ERROR;
-
- state = (struct inflate_state FAR *)strm->state;
- if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
- LOAD();
- in = have;
- out = left;
- ret = Z_OK;
- for (;;)
- switch (state->mode) {
- case HEAD:
- if (state->wrap == 0) {
- state->mode = TYPEDO;
- break;
- }
- NEEDBITS(16);
-#ifdef GUNZIP
- if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
- state->check = crc32(0L, Z_NULL, 0);
- CRC2(state->check, hold);
- INITBITS();
- state->mode = FLAGS;
- break;
- }
- state->flags = 0; /* expect zlib header */
- if (state->head != Z_NULL)
- state->head->done = -1;
- if (!(state->wrap & 1) || /* check if zlib header allowed */
-#else
- if (
-#endif
- ((BITS(8) << 8) + (hold >> 8)) % 31) {
- strm->msg = (char *)"incorrect header check";
- state->mode = BAD;
- break;
- }
- if (BITS(4) != Z_DEFLATED) {
- strm->msg = (char *)"unknown compression method";
- state->mode = BAD;
- break;
- }
- DROPBITS(4);
- len = BITS(4) + 8;
- if (state->wbits == 0)
- state->wbits = len;
- else if (len > state->wbits) {
- strm->msg = (char *)"invalid window size";
- state->mode = BAD;
- break;
- }
- state->dmax = 1U << len;
- Tracev((stderr, "inflate: zlib header ok\n"));
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = hold & 0x200 ? DICTID : TYPE;
- INITBITS();
- break;
-#ifdef GUNZIP
- case FLAGS:
- NEEDBITS(16);
- state->flags = (int)(hold);
- if ((state->flags & 0xff) != Z_DEFLATED) {
- strm->msg = (char *)"unknown compression method";
- state->mode = BAD;
- break;
- }
- if (state->flags & 0xe000) {
- strm->msg = (char *)"unknown header flags set";
- state->mode = BAD;
- break;
- }
- if (state->head != Z_NULL)
- state->head->text = (int)((hold >> 8) & 1);
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = TIME;
- case TIME:
- NEEDBITS(32);
- if (state->head != Z_NULL)
- state->head->time = hold;
- if (state->flags & 0x0200) CRC4(state->check, hold);
- INITBITS();
- state->mode = OS;
- case OS:
- NEEDBITS(16);
- if (state->head != Z_NULL) {
- state->head->xflags = (int)(hold & 0xff);
- state->head->os = (int)(hold >> 8);
- }
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = EXLEN;
- case EXLEN:
- if (state->flags & 0x0400) {
- NEEDBITS(16);
- state->length = (unsigned)(hold);
- if (state->head != Z_NULL)
- state->head->extra_len = (unsigned)hold;
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- }
- else if (state->head != Z_NULL)
- state->head->extra = Z_NULL;
- state->mode = EXTRA;
- case EXTRA:
- if (state->flags & 0x0400) {
- copy = state->length;
- if (copy > have) copy = have;
- if (copy) {
- if (state->head != Z_NULL &&
- state->head->extra != Z_NULL) {
- len = state->head->extra_len - state->length;
- zmemcpy(state->head->extra + len, next,
- len + copy > state->head->extra_max ?
- state->head->extra_max - len : copy);
- }
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- state->length -= copy;
- }
- if (state->length) goto inf_leave;
- }
- state->length = 0;
- state->mode = NAME;
- case NAME:
- if (state->flags & 0x0800) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- if (state->head != Z_NULL &&
- state->head->name != Z_NULL &&
- state->length < state->head->name_max)
- state->head->name[state->length++] = len;
- } while (len && copy < have);
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- else if (state->head != Z_NULL)
- state->head->name = Z_NULL;
- state->length = 0;
- state->mode = COMMENT;
- case COMMENT:
- if (state->flags & 0x1000) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- if (state->head != Z_NULL &&
- state->head->comment != Z_NULL &&
- state->length < state->head->comm_max)
- state->head->comment[state->length++] = len;
- } while (len && copy < have);
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- else if (state->head != Z_NULL)
- state->head->comment = Z_NULL;
- state->mode = HCRC;
- case HCRC:
- if (state->flags & 0x0200) {
- NEEDBITS(16);
- if (hold != (state->check & 0xffff)) {
- strm->msg = (char *)"header crc mismatch";
- state->mode = BAD;
- break;
- }
- INITBITS();
- }
- if (state->head != Z_NULL) {
- state->head->hcrc = (int)((state->flags >> 9) & 1);
- state->head->done = 1;
- }
- strm->adler = state->check = crc32(0L, Z_NULL, 0);
- state->mode = TYPE;
- break;
-#endif
- case DICTID:
- NEEDBITS(32);
- strm->adler = state->check = ZSWAP32(hold);
- INITBITS();
- state->mode = DICT;
- case DICT:
- if (state->havedict == 0) {
- RESTORE();
- return Z_NEED_DICT;
- }
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = TYPE;
- case TYPE:
- if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
- case TYPEDO:
- if (state->last) {
- BYTEBITS();
- state->mode = CHECK;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN_; /* decode codes */
- if (flush == Z_TREES) {
- DROPBITS(2);
- goto inf_leave;
- }
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = (char *)"invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
- case STORED:
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = (char *)"invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
- state->mode = COPY_;
- if (flush == Z_TREES) goto inf_leave;
- case COPY_:
- state->mode = COPY;
- case COPY:
- copy = state->length;
- if (copy) {
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- if (copy == 0) goto inf_leave;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- break;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
- case TABLE:
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = (char *)"too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
- state->have = 0;
- state->mode = LENLENS;
- case LENLENS:
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (const code FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
- state->have = 0;
- state->mode = CODELENS;
- case CODELENS:
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- here = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(here.bits) <= bits) break;
- PULLBYTE();
- }
- if (here.val < 16) {
- DROPBITS(here.bits);
- state->lens[state->have++] = here.val;
- }
- else {
- if (here.val == 16) {
- NEEDBITS(here.bits + 2);
- DROPBITS(here.bits);
- if (state->have == 0) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = state->lens[state->have - 1];
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (here.val == 17) {
- NEEDBITS(here.bits + 3);
- DROPBITS(here.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(here.bits + 7);
- DROPBITS(here.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* handle error breaks in while */
- if (state->mode == BAD) break;
-
- /* check for end-of-block code (better have one) */
- if (state->lens[256] == 0) {
- strm->msg = (char *)"invalid code -- missing end-of-block";
- state->mode = BAD;
- break;
- }
-
- /* build code tables -- note: do not change the lenbits or distbits
- values here (9 and 6) without reading the comments in inftrees.h
- concerning the ENOUGH constants, which depend on those values */
- state->next = state->codes;
- state->lencode = (const code FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (const code FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN_;
- if (flush == Z_TREES) goto inf_leave;
- case LEN_:
- state->mode = LEN;
- case LEN:
- if (have >= 6 && left >= 258) {
- RESTORE();
- inflate_fast(strm, out);
- LOAD();
- if (state->mode == TYPE)
- state->back = -1;
- break;
- }
- state->back = 0;
- for (;;) {
- here = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(here.bits) <= bits) break;
- PULLBYTE();
- }
- if (here.op && (here.op & 0xf0) == 0) {
- last = here;
- for (;;) {
- here = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + here.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- state->back += last.bits;
- }
- DROPBITS(here.bits);
- state->back += here.bits;
- state->length = (unsigned)here.val;
- if ((int)(here.op) == 0) {
- Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", here.val));
- state->mode = LIT;
- break;
- }
- if (here.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->back = -1;
- state->mode = TYPE;
- break;
- }
- if (here.op & 64) {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
- state->extra = (unsigned)(here.op) & 15;
- state->mode = LENEXT;
- case LENEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- state->back += state->extra;
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
- state->was = state->length;
- state->mode = DIST;
- case DIST:
- for (;;) {
- here = state->distcode[BITS(state->distbits)];
- if ((unsigned)(here.bits) <= bits) break;
- PULLBYTE();
- }
- if ((here.op & 0xf0) == 0) {
- last = here;
- for (;;) {
- here = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + here.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- state->back += last.bits;
- }
- DROPBITS(here.bits);
- state->back += here.bits;
- if (here.op & 64) {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)here.val;
- state->extra = (unsigned)(here.op) & 15;
- state->mode = DISTEXT;
- case DISTEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- state->back += state->extra;
- }
-#ifdef INFLATE_STRICT
- if (state->offset > state->dmax) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
-#endif
- Tracevv((stderr, "inflate: distance %u\n", state->offset));
- state->mode = MATCH;
- case MATCH:
- if (left == 0) goto inf_leave;
- copy = out - left;
- if (state->offset > copy) { /* copy from window */
- copy = state->offset - copy;
- if (copy > state->whave) {
- if (state->sane) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
-#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
- Trace((stderr, "inflate.c too far\n"));
- copy -= state->whave;
- if (copy > state->length) copy = state->length;
- if (copy > left) copy = left;
- left -= copy;
- state->length -= copy;
- do {
- *put++ = 0;
- } while (--copy);
- if (state->length == 0) state->mode = LEN;
- break;
-#endif
- }
- if (copy > state->wnext) {
- copy -= state->wnext;
- from = state->window + (state->wsize - copy);
- }
- else
- from = state->window + (state->wnext - copy);
- if (copy > state->length) copy = state->length;
- }
- else { /* copy from output */
- from = put - state->offset;
- copy = state->length;
- }
- if (copy > left) copy = left;
- left -= copy;
- state->length -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- if (state->length == 0) state->mode = LEN;
- break;
- case LIT:
- if (left == 0) goto inf_leave;
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- case CHECK:
- if (state->wrap) {
- NEEDBITS(32);
- out -= left;
- strm->total_out += out;
- state->total += out;
- if (out)
- strm->adler = state->check =
- UPDATE(state->check, put - out, out);
- out = left;
- if ((
-#ifdef GUNZIP
- state->flags ? hold :
-#endif
- ZSWAP32(hold)) != state->check) {
- strm->msg = (char *)"incorrect data check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: check matches trailer\n"));
- }
-#ifdef GUNZIP
- state->mode = LENGTH;
- case LENGTH:
- if (state->wrap && state->flags) {
- NEEDBITS(32);
- if (hold != (state->total & 0xffffffffUL)) {
- strm->msg = (char *)"incorrect length check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: length matches trailer\n"));
- }
-#endif
- state->mode = DONE;
- case DONE:
- ret = Z_STREAM_END;
- goto inf_leave;
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
- case MEM:
- return Z_MEM_ERROR;
- case SYNC:
- default:
- return Z_STREAM_ERROR;
- }
-
- /*
- Return from inflate(), updating the total counts and the check value.
- If there was no progress during the inflate() call, return a buffer
- error. Call updatewindow() to create and/or update the window state.
- Note: a memory error from inflate() is non-recoverable.
- */
- inf_leave:
- RESTORE();
- if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
- (state->mode < CHECK || flush != Z_FINISH)))
- if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- in -= strm->avail_in;
- out -= strm->avail_out;
- strm->total_in += in;
- strm->total_out += out;
- state->total += out;
- if (state->wrap && out)
- strm->adler = state->check =
- UPDATE(state->check, strm->next_out - out, out);
- strm->data_type = state->bits + (state->last ? 64 : 0) +
- (state->mode == TYPE ? 128 : 0) +
- (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
- if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
- ret = Z_BUF_ERROR;
- return ret;
-}
-
-int ZEXPORT inflateEnd(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->window != Z_NULL) ZFREE(strm, state->window);
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
-z_streamp strm;
-Bytef *dictionary;
-uInt *dictLength;
-{
- struct inflate_state FAR *state;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
-
- /* copy dictionary */
- if (state->whave && dictionary != Z_NULL) {
- zmemcpy(dictionary, state->window + state->wnext,
- state->whave - state->wnext);
- zmemcpy(dictionary + state->whave - state->wnext,
- state->window, state->wnext);
- }
- if (dictLength != Z_NULL)
- *dictLength = state->whave;
- return Z_OK;
-}
-
-int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
-z_streamp strm;
-const Bytef *dictionary;
-uInt dictLength;
-{
- struct inflate_state FAR *state;
- unsigned long dictid;
- int ret;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->wrap != 0 && state->mode != DICT)
- return Z_STREAM_ERROR;
-
- /* check for correct dictionary identifier */
- if (state->mode == DICT) {
- dictid = adler32(0L, Z_NULL, 0);
- dictid = adler32(dictid, dictionary, dictLength);
- if (dictid != state->check)
- return Z_DATA_ERROR;
- }
-
- /* copy dictionary to window using updatewindow(), which will amend the
- existing dictionary if appropriate */
- ret = updatewindow(strm, dictionary + dictLength, dictLength);
- if (ret) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- state->havedict = 1;
- Tracev((stderr, "inflate: dictionary set\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateGetHeader(strm, head)
-z_streamp strm;
-gz_headerp head;
-{
- struct inflate_state FAR *state;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
-
- /* save header structure */
- state->head = head;
- head->done = 0;
- return Z_OK;
-}
-
-/*
- Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
- or when out of input. When called, *have is the number of pattern bytes
- found in order so far, in 0..3. On return *have is updated to the new
- state. If on return *have equals four, then the pattern was found and the
- return value is how many bytes were read including the last byte of the
- pattern. If *have is less than four, then the pattern has not been found
- yet and the return value is len. In the latter case, syncsearch() can be
- called again with more data and the *have state. *have is initialized to
- zero for the first call.
- */
-local unsigned syncsearch(have, buf, len)
-unsigned FAR *have;
-const unsigned char FAR *buf;
-unsigned len;
-{
- unsigned got;
- unsigned next;
-
- got = *have;
- next = 0;
- while (next < len && got < 4) {
- if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
- got++;
- else if (buf[next])
- got = 0;
- else
- got = 4 - got;
- next++;
- }
- *have = got;
- return next;
-}
-
-int ZEXPORT inflateSync(strm)
-z_streamp strm;
-{
- unsigned len; /* number of bytes to look at or looked at */
- unsigned long in, out; /* temporary to save total_in and total_out */
- unsigned char buf[4]; /* to restore bit buffer to byte string */
- struct inflate_state FAR *state;
-
- /* check parameters */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
-
- /* if first time, start search in bit buffer */
- if (state->mode != SYNC) {
- state->mode = SYNC;
- state->hold <<= state->bits & 7;
- state->bits -= state->bits & 7;
- len = 0;
- while (state->bits >= 8) {
- buf[len++] = (unsigned char)(state->hold);
- state->hold >>= 8;
- state->bits -= 8;
- }
- state->have = 0;
- syncsearch(&(state->have), buf, len);
- }
-
- /* search available input */
- len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
- strm->avail_in -= len;
- strm->next_in += len;
- strm->total_in += len;
-
- /* return no joy or set up to restart inflate() on a new block */
- if (state->have != 4) return Z_DATA_ERROR;
- in = strm->total_in; out = strm->total_out;
- inflateReset(strm);
- strm->total_in = in; strm->total_out = out;
- state->mode = TYPE;
- return Z_OK;
-}
-
-/*
- Returns true if inflate is currently at the end of a block generated by
- Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
- implementation to provide an additional safety check. PPP uses
- Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
- block. When decompressing, PPP checks that at the end of input packet,
- inflate is waiting for these length bytes.
- */
-int ZEXPORT inflateSyncPoint(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- return state->mode == STORED && state->bits == 0;
-}
-
-int ZEXPORT inflateCopy(dest, source)
-z_streamp dest;
-z_streamp source;
-{
- struct inflate_state FAR *state;
- struct inflate_state FAR *copy;
- unsigned char FAR *window;
- unsigned wsize;
-
- /* check input */
- if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
- source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)source->state;
-
- /* allocate space */
- copy = (struct inflate_state FAR *)
- ZALLOC(source, 1, sizeof(struct inflate_state));
- if (copy == Z_NULL) return Z_MEM_ERROR;
- window = Z_NULL;
- if (state->window != Z_NULL) {
- window = (unsigned char FAR *)
- ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
- if (window == Z_NULL) {
- ZFREE(source, copy);
- return Z_MEM_ERROR;
- }
- }
-
- /* copy state */
- zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
- zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
- if (state->lencode >= state->codes &&
- state->lencode <= state->codes + ENOUGH - 1) {
- copy->lencode = copy->codes + (state->lencode - state->codes);
- copy->distcode = copy->codes + (state->distcode - state->codes);
- }
- copy->next = copy->codes + (state->next - state->codes);
- if (window != Z_NULL) {
- wsize = 1U << state->wbits;
- zmemcpy(window, state->window, wsize);
- }
- copy->window = window;
- dest->state = (struct internal_state FAR *)copy;
- return Z_OK;
-}
-
-int ZEXPORT inflateUndermine(strm, subvert)
-z_streamp strm;
-int subvert;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- state->sane = !subvert;
-#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
- return Z_OK;
-#else
- state->sane = 1;
- return Z_DATA_ERROR;
-#endif
-}
-
-long ZEXPORT inflateMark(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
- state = (struct inflate_state FAR *)strm->state;
- return ((long)(state->back) << 16) +
- (state->mode == COPY ? state->length :
- (state->mode == MATCH ? state->was - state->length : 0));
-}
diff -Nru r-base-3.2.3/src/extra/zlib/inflate.h r-base-3.3.1/src/extra/zlib/inflate.h
--- r-base-3.2.3/src/extra/zlib/inflate.h 2011-10-02 22:02:10.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/inflate.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,122 +0,0 @@
-/* inflate.h -- internal inflate state definition
- * Copyright (C) 1995-2009 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
- trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
- the crc code when it is not needed. For shared libraries, gzip decoding
- should be left enabled. */
-#ifndef NO_GZIP
-# define GUNZIP
-#endif
-
-/* Possible inflate modes between inflate() calls */
-typedef enum {
- HEAD, /* i: waiting for magic header */
- FLAGS, /* i: waiting for method and flags (gzip) */
- TIME, /* i: waiting for modification time (gzip) */
- OS, /* i: waiting for extra flags and operating system (gzip) */
- EXLEN, /* i: waiting for extra length (gzip) */
- EXTRA, /* i: waiting for extra bytes (gzip) */
- NAME, /* i: waiting for end of file name (gzip) */
- COMMENT, /* i: waiting for end of comment (gzip) */
- HCRC, /* i: waiting for header crc (gzip) */
- DICTID, /* i: waiting for dictionary check value */
- DICT, /* waiting for inflateSetDictionary() call */
- TYPE, /* i: waiting for type bits, including last-flag bit */
- TYPEDO, /* i: same, but skip check to exit inflate on new block */
- STORED, /* i: waiting for stored size (length and complement) */
- COPY_, /* i/o: same as COPY below, but only first time in */
- COPY, /* i/o: waiting for input or output to copy stored block */
- TABLE, /* i: waiting for dynamic block table lengths */
- LENLENS, /* i: waiting for code length code lengths */
- CODELENS, /* i: waiting for length/lit and distance code lengths */
- LEN_, /* i: same as LEN below, but only first time in */
- LEN, /* i: waiting for length/lit/eob code */
- LENEXT, /* i: waiting for length extra bits */
- DIST, /* i: waiting for distance code */
- DISTEXT, /* i: waiting for distance extra bits */
- MATCH, /* o: waiting for output space to copy string */
- LIT, /* o: waiting for output space to write literal */
- CHECK, /* i: waiting for 32-bit check value */
- LENGTH, /* i: waiting for 32-bit length (gzip) */
- DONE, /* finished check, done -- remain here until reset */
- BAD, /* got a data error -- remain here until reset */
- MEM, /* got an inflate() memory error -- remain here until reset */
- SYNC /* looking for synchronization bytes to restart inflate() */
-} inflate_mode;
-
-/*
- State transitions between above modes -
-
- (most modes can go to BAD or MEM on error -- not shown for clarity)
-
- Process header:
- HEAD -> (gzip) or (zlib) or (raw)
- (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
- HCRC -> TYPE
- (zlib) -> DICTID or TYPE
- DICTID -> DICT -> TYPE
- (raw) -> TYPEDO
- Read deflate blocks:
- TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
- STORED -> COPY_ -> COPY -> TYPE
- TABLE -> LENLENS -> CODELENS -> LEN_
- LEN_ -> LEN
- Read deflate codes in fixed or dynamic block:
- LEN -> LENEXT or LIT or TYPE
- LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
- LIT -> LEN
- Process trailer:
- CHECK -> LENGTH -> DONE
- */
-
-/* state maintained between inflate() calls. Approximately 10K bytes. */
-struct inflate_state {
- inflate_mode mode; /* current inflate mode */
- int last; /* true if processing last block */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- int havedict; /* true if dictionary provided */
- int flags; /* gzip header method and flags (0 if zlib) */
- unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
- unsigned long check; /* protected copy of check value */
- unsigned long total; /* protected copy of output count */
- gz_headerp head; /* where to save gzip header information */
- /* sliding window */
- unsigned wbits; /* log base 2 of requested window size */
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned wnext; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if needed */
- /* bit accumulator */
- unsigned long hold; /* input bit accumulator */
- unsigned bits; /* number of bits in "in" */
- /* for string and stored block copying */
- unsigned length; /* literal or length of data to copy */
- unsigned offset; /* distance back to copy string from */
- /* for table and code decoding */
- unsigned extra; /* extra bits needed */
- /* fixed and dynamic code tables */
- code const FAR *lencode; /* starting table for length/literal codes */
- code const FAR *distcode; /* starting table for distance codes */
- unsigned lenbits; /* index bits for lencode */
- unsigned distbits; /* index bits for distcode */
- /* dynamic table building */
- unsigned ncode; /* number of code length code lengths */
- unsigned nlen; /* number of length code lengths */
- unsigned ndist; /* number of distance code lengths */
- unsigned have; /* number of code lengths in lens[] */
- code FAR *next; /* next available space in codes[] */
- unsigned short lens[320]; /* temporary storage for code lengths */
- unsigned short work[288]; /* work area for code table building */
- code codes[ENOUGH]; /* space for code tables */
- int sane; /* if false, allow invalid distance too far */
- int back; /* bits back of last unprocessed length/lit */
- unsigned was; /* initial length of match */
-};
diff -Nru r-base-3.2.3/src/extra/zlib/inftrees.c r-base-3.3.1/src/extra/zlib/inftrees.c
--- r-base-3.2.3/src/extra/zlib/inftrees.c 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/inftrees.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,306 +0,0 @@
-/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2013 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-
-#define MAXBITS 15
-
-const char inflate_copyright[] =
- " inflate 1.2.8 Copyright 1995-2013 Mark Adler ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/*
- Build a set of tables to decode the provided canonical Huffman code.
- The code lengths are lens[0..codes-1]. The result starts at *table,
- whose indices are 0..2^bits-1. work is a writable array of at least
- lens shorts, which is used as a work area. type is the type of code
- to be generated, CODES, LENS, or DISTS. On return, zero is success,
- -1 is an invalid code, and +1 means that ENOUGH isn't enough. table
- on return points to the next available entry's address. bits is the
- requested root table index bits, and on return it is the actual root
- table index bits. It will differ if the request is greater than the
- longest code or if it is less than the shortest code.
- */
-int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)
-codetype type;
-unsigned short FAR *lens;
-unsigned codes;
-code FAR * FAR *table;
-unsigned FAR *bits;
-unsigned short FAR *work;
-{
- unsigned len; /* a code's length in bits */
- unsigned sym; /* index of code symbols */
- unsigned min, max; /* minimum and maximum code lengths */
- unsigned root; /* number of index bits for root table */
- unsigned curr; /* number of index bits for current table */
- unsigned drop; /* code bits to drop for sub-table */
- int left; /* number of prefix codes available */
- unsigned used; /* code entries in table used */
- unsigned huff; /* Huffman code */
- unsigned incr; /* for incrementing code, index */
- unsigned fill; /* index for replicating entries */
- unsigned low; /* low bits for current root entry */
- unsigned mask; /* mask for low root bits */
- code here; /* table entry for duplication */
- code FAR *next; /* next available space in table */
- const unsigned short FAR *base; /* base value table to use */
- const unsigned short FAR *extra; /* extra bits table to use */
- int end; /* use base and extra for symbol > end */
- unsigned short count[MAXBITS+1]; /* number of codes of each length */
- unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
- static const unsigned short lbase[31] = { /* Length codes 257..285 base */
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
- 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
- static const unsigned short lext[31] = { /* Length codes 257..285 extra */
- 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78};
- static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
- 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
- 8193, 12289, 16385, 24577, 0, 0};
- static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
- 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
- 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
- 28, 28, 29, 29, 64, 64};
-
- /*
- Process a set of code lengths to create a canonical Huffman code. The
- code lengths are lens[0..codes-1]. Each length corresponds to the
- symbols 0..codes-1. The Huffman code is generated by first sorting the
- symbols by length from short to long, and retaining the symbol order
- for codes with equal lengths. Then the code starts with all zero bits
- for the first code of the shortest length, and the codes are integer
- increments for the same length, and zeros are appended as the length
- increases. For the deflate format, these bits are stored backwards
- from their more natural integer increment ordering, and so when the
- decoding tables are built in the large loop below, the integer codes
- are incremented backwards.
-
- This routine assumes, but does not check, that all of the entries in
- lens[] are in the range 0..MAXBITS. The caller must assure this.
- 1..MAXBITS is interpreted as that code length. zero means that that
- symbol does not occur in this code.
-
- The codes are sorted by computing a count of codes for each length,
- creating from that a table of starting indices for each length in the
- sorted table, and then entering the symbols in order in the sorted
- table. The sorted table is work[], with that space being provided by
- the caller.
-
- The length counts are used for other purposes as well, i.e. finding
- the minimum and maximum length codes, determining if there are any
- codes at all, checking for a valid set of lengths, and looking ahead
- at length counts to determine sub-table sizes when building the
- decoding tables.
- */
-
- /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
- for (len = 0; len <= MAXBITS; len++)
- count[len] = 0;
- for (sym = 0; sym < codes; sym++)
- count[lens[sym]]++;
-
- /* bound code lengths, force root to be within code lengths */
- root = *bits;
- for (max = MAXBITS; max >= 1; max--)
- if (count[max] != 0) break;
- if (root > max) root = max;
- if (max == 0) { /* no symbols to code at all */
- here.op = (unsigned char)64; /* invalid code marker */
- here.bits = (unsigned char)1;
- here.val = (unsigned short)0;
- *(*table)++ = here; /* make a table to force an error */
- *(*table)++ = here;
- *bits = 1;
- return 0; /* no symbols, but wait for decoding to report error */
- }
- for (min = 1; min < max; min++)
- if (count[min] != 0) break;
- if (root < min) root = min;
-
- /* check for an over-subscribed or incomplete set of lengths */
- left = 1;
- for (len = 1; len <= MAXBITS; len++) {
- left <<= 1;
- left -= count[len];
- if (left < 0) return -1; /* over-subscribed */
- }
- if (left > 0 && (type == CODES || max != 1))
- return -1; /* incomplete set */
-
- /* generate offsets into symbol table for each length for sorting */
- offs[1] = 0;
- for (len = 1; len < MAXBITS; len++)
- offs[len + 1] = offs[len] + count[len];
-
- /* sort symbols by length, by symbol order within each length */
- for (sym = 0; sym < codes; sym++)
- if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
-
- /*
- Create and fill in decoding tables. In this loop, the table being
- filled is at next and has curr index bits. The code being used is huff
- with length len. That code is converted to an index by dropping drop
- bits off of the bottom. For codes where len is less than drop + curr,
- those top drop + curr - len bits are incremented through all values to
- fill the table with replicated entries.
-
- root is the number of index bits for the root table. When len exceeds
- root, sub-tables are created pointed to by the root entry with an index
- of the low root bits of huff. This is saved in low to check for when a
- new sub-table should be started. drop is zero when the root table is
- being filled, and drop is root when sub-tables are being filled.
-
- When a new sub-table is needed, it is necessary to look ahead in the
- code lengths to determine what size sub-table is needed. The length
- counts are used for this, and so count[] is decremented as codes are
- entered in the tables.
-
- used keeps track of how many table entries have been allocated from the
- provided *table space. It is checked for LENS and DIST tables against
- the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
- the initial root table size constants. See the comments in inftrees.h
- for more information.
-
- sym increments through all symbols, and the loop terminates when
- all codes of length max, i.e. all codes, have been processed. This
- routine permits incomplete codes, so another loop after this one fills
- in the rest of the decoding tables with invalid code markers.
- */
-
- /* set up for code type */
- switch (type) {
- case CODES:
- base = extra = work; /* dummy value--not used */
- end = 19;
- break;
- case LENS:
- base = lbase;
- base -= 257;
- extra = lext;
- extra -= 257;
- end = 256;
- break;
- default: /* DISTS */
- base = dbase;
- extra = dext;
- end = -1;
- }
-
- /* initialize state for loop */
- huff = 0; /* starting code */
- sym = 0; /* starting code symbol */
- len = min; /* starting code length */
- next = *table; /* current table to fill in */
- curr = root; /* current table index bits */
- drop = 0; /* current bits to drop from code for index */
- low = (unsigned)(-1); /* trigger new sub-table when len > root */
- used = 1U << root; /* use root table entries */
- mask = used - 1; /* mask for comparing low */
-
- /* check available table space */
- if ((type == LENS && used > ENOUGH_LENS) ||
- (type == DISTS && used > ENOUGH_DISTS))
- return 1;
-
- /* process all codes and make table entries */
- for (;;) {
- /* create table entry */
- here.bits = (unsigned char)(len - drop);
- if ((int)(work[sym]) < end) {
- here.op = (unsigned char)0;
- here.val = work[sym];
- }
- else if ((int)(work[sym]) > end) {
- here.op = (unsigned char)(extra[work[sym]]);
- here.val = base[work[sym]];
- }
- else {
- here.op = (unsigned char)(32 + 64); /* end of block */
- here.val = 0;
- }
-
- /* replicate for those indices with low len bits equal to huff */
- incr = 1U << (len - drop);
- fill = 1U << curr;
- min = fill; /* save offset to next table */
- do {
- fill -= incr;
- next[(huff >> drop) + fill] = here;
- } while (fill != 0);
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
-
- /* go to next symbol, update count, len */
- sym++;
- if (--(count[len]) == 0) {
- if (len == max) break;
- len = lens[work[sym]];
- }
-
- /* create new sub-table if needed */
- if (len > root && (huff & mask) != low) {
- /* if first time, transition to sub-tables */
- if (drop == 0)
- drop = root;
-
- /* increment past last table */
- next += min; /* here min is 1 << curr */
-
- /* determine length of next table */
- curr = len - drop;
- left = (int)(1 << curr);
- while (curr + drop < max) {
- left -= count[curr + drop];
- if (left <= 0) break;
- curr++;
- left <<= 1;
- }
-
- /* check for enough space */
- used += 1U << curr;
- if ((type == LENS && used > ENOUGH_LENS) ||
- (type == DISTS && used > ENOUGH_DISTS))
- return 1;
-
- /* point entry in root table to sub-table */
- low = huff & mask;
- (*table)[low].op = (unsigned char)curr;
- (*table)[low].bits = (unsigned char)root;
- (*table)[low].val = (unsigned short)(next - *table);
- }
- }
-
- /* fill in remaining table entry if code is incomplete (guaranteed to have
- at most one remaining entry, since if the code is incomplete, the
- maximum code length that was allowed to get this far is one bit) */
- if (huff != 0) {
- here.op = (unsigned char)64; /* invalid code marker */
- here.bits = (unsigned char)(len - drop);
- here.val = (unsigned short)0;
- next[huff] = here;
- }
-
- /* set return parameters */
- *table += used;
- *bits = root;
- return 0;
-}
diff -Nru r-base-3.2.3/src/extra/zlib/inftrees.h r-base-3.3.1/src/extra/zlib/inftrees.h
--- r-base-3.2.3/src/extra/zlib/inftrees.h 2011-10-02 22:02:10.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/inftrees.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,62 +0,0 @@
-/* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-2005, 2010 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* Structure for decoding tables. Each entry provides either the
- information needed to do the operation requested by the code that
- indexed that table entry, or it provides a pointer to another
- table that indexes more bits of the code. op indicates whether
- the entry is a pointer to another table, a literal, a length or
- distance, an end-of-block, or an invalid code. For a table
- pointer, the low four bits of op is the number of index bits of
- that table. For a length or distance, the low four bits of op
- is the number of extra bits to get after the code. bits is
- the number of bits in this code or part of the code to drop off
- of the bit buffer. val is the actual byte to output in the case
- of a literal, the base length or distance, or the offset from
- the current table to the next table. Each entry is four bytes. */
-typedef struct {
- unsigned char op; /* operation, extra bits, table bits */
- unsigned char bits; /* bits in this part of the code */
- unsigned short val; /* offset in table or code value */
-} code;
-
-/* op values as set by inflate_table():
- 00000000 - literal
- 0000tttt - table link, tttt != 0 is the number of table index bits
- 0001eeee - length or distance, eeee is the number of extra bits
- 01100000 - end of block
- 01000000 - invalid code
- */
-
-/* Maximum size of the dynamic table. The maximum number of code structures is
- 1444, which is the sum of 852 for literal/length codes and 592 for distance
- codes. These values were found by exhaustive searches using the program
- examples/enough.c found in the zlib distribtution. The arguments to that
- program are the number of symbols, the initial root table size, and the
- maximum bit length of a code. "enough 286 9 15" for literal/length codes
- returns returns 852, and "enough 30 6 15" for distance codes returns 592.
- The initial root table size (9 or 6) is found in the fifth argument of the
- inflate_table() calls in inflate.c and infback.c. If the root table size is
- changed, then these maximum sizes would be need to be recalculated and
- updated. */
-#define ENOUGH_LENS 852
-#define ENOUGH_DISTS 592
-#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
-
-/* Type of code to build for inflate_table() */
-typedef enum {
- CODES,
- LENS,
- DISTS
-} codetype;
-
-int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
- unsigned codes, code FAR * FAR *table,
- unsigned FAR *bits, unsigned short FAR *work));
diff -Nru r-base-3.2.3/src/extra/zlib/Makefile.in r-base-3.3.1/src/extra/zlib/Makefile.in
--- r-base-3.2.3/src/extra/zlib/Makefile.in 2013-09-26 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/Makefile.in 1970-01-01 00:00:00.000000000 +0000
@@ -1,73 +0,0 @@
-#
-# ${R_HOME}/src/extra/zlib/Makefile
-
-VPATH = @srcdir@
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-
-top_builddir = ../../..
-subdir = src/extra/zlib
-R_HOME = $(top_builddir)
-
-include $(top_builddir)/Makeconf
-
-ZLIB_CPPFLAGS = -I$(srcdir) @USE_MMAP_ZLIB_TRUE@ -DUSE_MMAP
-ALL_CPPFLAGS = $(ZLIB_CPPFLAGS) $(R_XTRA_CPPFLAGS) $(CPPFLAGS) $(DEFS)
-## need to be PIC for use in grDevices
-ALL_CFLAGS = $(R_XTRA_CFLAGS) $(R_OPENMP_CFLAGS) $(MAIN_CFLAGS) $(CFLAGS) $(CPICFLAGS)
-
-SOURCES = adler32.c compress.c crc32.c deflate.c infback.c \
- inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c
-HEADERS = crc32.h deflate.h inffast.h inffixed.h inflate.h inftrees.h \
- trees.h zconf.h zlib.h zutil.h
-DEPENDS = $(SOURCES:.c=.d)
-OBJECTS = $(SOURCES:.c=.o)
-@WANT_R_SHLIB_TRUE@ALL_CFLAGS = $(ALL_CFLAGS_LO) @C_VISIBILITY@
-
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-DISTFILES = R_changes README Makefile.in Makefile.win Rzlib.def \
- $(SOURCES) $(HEADERS)
-noinst_LIBRARIES = @BUILD_ZLIB_TRUE@ libz.a
-libz_a_SOURCES = $(SOURCES)
-libz_a_OBJECTS = $(OBJECTS)
-
-
-all: R
-
-Makefile: $(srcdir)/Makefile.in \
- $(top_builddir)/config.status \
- $(SOURCES)
- @cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
-
-Makedeps: Makefile $(DEPENDS)
- @cat $(DEPENDS) >> Makefile
- @touch $@
-
-R: Makedeps
- @$(MAKE) $(noinst_LIBRARIES)
-
-libz.a: $(libz_a_OBJECTS)
- rm -f $@
- $(AR) cr $@ $(libz_a_OBJECTS)
- $(RANLIB) $@
-
-
-mostlyclean: clean
-clean:
- @-rm -f Makedeps *.d *.o *.lo *.a
-distclean: clean
- @-rm -f Makefile
-maintainer-clean: distclean
-
-install install-strip uninstall TAGS info dvi check:
-
-distdir: $(DISTFILES)
- @for f in $(DISTFILES); do \
- test -f $(distdir)/$${f} \
- || ln $(srcdir)/$${f} $(distdir)/$${f} 2>/dev/null \
- || cp -p $(srcdir)/$${f} $(distdir)/$${f}; \
- done
-
-## Automagically generated dependencies:
-
diff -Nru r-base-3.2.3/src/extra/zlib/Makefile.win r-base-3.3.1/src/extra/zlib/Makefile.win
--- r-base-3.2.3/src/extra/zlib/Makefile.win 2015-03-18 23:02:06.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/Makefile.win 1970-01-01 00:00:00.000000000 +0000
@@ -1,45 +0,0 @@
-#-*- Makefile -*-
-include ../../gnuwin32/MkRules
-
-all: makeMakedeps DLL implib headers
-
-SOURCES = adler32.c compress.c crc32.c deflate.c infback.c \
- inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c
-OBJECTS = $(SOURCES:.c=.o)
-
-CPPFLAGS = -I../../include -DHAVE_CONFIG_H
-
-# libz.a: $(OBJECTS)
-
-DLL: Rzlib.dll
- @cp Rzlib.dll ../../../$(BINDIR)
-
-Rzlib.dll: $(OBJECTS) Rzlib.def
- $(DLL) -shared $(DLLFLAGS) -o $@ Rzlib.def $(OBJECTS)
-
-ifdef USE_IMPLIBS
-implib: libRzlib.dll.a
- @$(MKDIR) -p ../../../lib
- @$(CP) libRzlib.dll.a ../../../lib
-else
-implib:
-endif
-
-libRzlib.dll.a: Rzlib.def
-
-headers:
- @$(CP) -p zlib.h zconf.h ../../../include
-
-clean:
- @$(RM) *.o *~ *.d Makedeps
-distclean: clean
- @$(RM) libz.a Rzlib.dll libRzlib.dll.a
-
-# Dependencies
-DEPS = $(SOURCES:.c=.d)
-
-makeMakedeps: $(DEPS)
- @$(RM) Makedeps
- @cat $(DEPS) >> Makedeps
-
--include Makedeps
diff -Nru r-base-3.2.3/src/extra/zlib/R_changes r-base-3.3.1/src/extra/zlib/R_changes
--- r-base-3.2.3/src/extra/zlib/R_changes 2011-10-02 22:02:10.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/R_changes 1970-01-01 00:00:00.000000000 +0000
@@ -1,71 +0,0 @@
-There are a very few to the source code of zlib-1.2.5 used here.
-
-zconf.h includes R's config.h
-
-Makefile.in is ours, not zlib's, and allows us to use PIC flags so this
-can be included in libR.so.
-
-As from R 2.12.2, on a Unix-alike we remap all the symbols (not just
-those remapped by defining Z_PREFIX) to avoid conflict with system
-versions of zlib (notably 1.2.5) linked into packages' *.so. The
-known problems are with libxml2 and libggobi, both of which are linked
-to libz. This is not needed on Windows where the DLL is named
-Rzlib.dll and symbols are imported from a named DLL. But Rzlib.def is
-used to confine exports to symbols marked ZEXPORT in zlib.h.
-
-From 2.13.0, Z_PREFIX is defined in zconf.h, except on Windows.
-
-Visibility does not work on all platforms in gcc >= 3.3.
-
-diff -u /Users/ripley/Sources/zlib-1.2.5/zconf.h ./zconf.h
---- /Users/ripley/Sources/zlib-1.2.5/zconf.h 2010-04-18 18:58:06.000000000 +0100
-+++ ./zconf.h 2011-04-19 18:49:24.000000000 +0100
-@@ -8,127 +8,84 @@
- #ifndef ZCONF_H
- #define ZCONF_H
-
-+#ifdef HAVE_CONFIG_H
-+#include
-+#endif
-+
-+/* R change */
-+#ifndef WIN32
-+#define Z_PREFIX
-+#endif
-
-plus lots of changes to the defines.
-
-diff -u /Users/ripley/Sources/zlib-1.2.5/zlib.h ./zlib.h
---- /Users/ripley/Sources/zlib-1.2.5/zlib.h 2010-04-20 05:12:48.000000000 +0100
-+++ ./zlib.h 2011-04-19 22:18:56.000000000 +0100
-@@ -1576,8 +1576,15 @@
- # define gzseek gzseek64
- # define gztell gztell64
- # define gzoffset gzoffset64
-+# undef adler32_combine
-+# undef crc32_combine
-+# ifdef Z_PREFIX
-+# define adler32_combine Rz_adler32_combine64
-+# define crc32_combine Rz_crc32_combine64
-+# else
- # define adler32_combine adler32_combine64
- # define crc32_combine crc32_combine64
-+# endif
- # ifdef _LARGEFILE64_SOURCE
- ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
- ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
-
-diff -u /Users/ripley/Sources/zlib-1.2.5/zutil.h ./zutil.h
---- /Users/ripley/Sources/zlib-1.2.5/zutil.h 2010-04-18 20:29:24.000000000 +0100
-+++ ./zutil.h 2011-04-19 19:41:57.000000000 +0100
-@@ -13,6 +13,10 @@
- #ifndef ZUTIL_H
- #define ZUTIL_H
-
-+#ifdef WIN32
-+# define NO_VIZ
-+#endif
-+
- #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
- # define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
- #else
diff -Nru r-base-3.2.3/src/extra/zlib/README r-base-3.3.1/src/extra/zlib/README
--- r-base-3.2.3/src/extra/zlib/README 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/README 1970-01-01 00:00:00.000000000 +0000
@@ -1,115 +0,0 @@
-ZLIB DATA COMPRESSION LIBRARY
-
-zlib 1.2.8 is a general purpose data compression library. All the code is
-thread safe. The data format used by the zlib library is described by RFCs
-(Request for Comments) 1950 to 1952 in the files
-http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
-rfc1952 (gzip format).
-
-All functions of the compression library are documented in the file zlib.h
-(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
-of the library is given in the file test/example.c which also tests that
-the library is working correctly. Another example is given in the file
-test/minigzip.c. The compression library itself is composed of all source
-files in the root directory.
-
-To compile all files and run the test program, follow the instructions given at
-the top of Makefile.in. In short "./configure; make test", and if that goes
-well, "make install" should work for most flavors of Unix. For Windows, use
-one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use
-make_vms.com.
-
-Questions about zlib should be sent to , or to Gilles Vollant
- for the Windows DLL version. The zlib home page is
-http://zlib.net/ . Before reporting a problem, please check this site to
-verify that you have the latest version of zlib; otherwise get the latest
-version and check whether the problem still exists or not.
-
-PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
-
-Mark Nelson wrote an article about zlib for the Jan. 1997
-issue of Dr. Dobb's Journal; a copy of the article is available at
-http://marknelson.us/1997/01/01/zlib-engine/ .
-
-The changes made in version 1.2.8 are documented in the file ChangeLog.
-
-Unsupported third party contributions are provided in directory contrib/ .
-
-zlib is available in Java using the java.util.zip package, documented at
-http://java.sun.com/developer/technicalArticles/Programming/compression/ .
-
-A Perl interface to zlib written by Paul Marquess is available
-at CPAN (Comprehensive Perl Archive Network) sites, including
-http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
-
-A Python interface to zlib written by A.M. Kuchling is
-available in Python 1.5 and later versions, see
-http://docs.python.org/library/zlib.html .
-
-zlib is built into tcl: http://wiki.tcl.tk/4610 .
-
-An experimental package to read and write files in .zip format, written on top
-of zlib by Gilles Vollant , is available in the
-contrib/minizip directory of zlib.
-
-
-Notes for some targets:
-
-- For Windows DLL versions, please see win32/DLL_FAQ.txt
-
-- For 64-bit Irix, deflate.c must be compiled without any optimization. With
- -O, one libpng test fails. The test works in 32 bit mode (with the -n32
- compiler flag). The compiler bug has been reported to SGI.
-
-- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
- when compiled with cc.
-
-- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
- necessary to get gzprintf working correctly. This is done by configure.
-
-- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
- other compilers. Use "make test" to check your compiler.
-
-- gzdopen is not supported on RISCOS or BEOS.
-
-- For PalmOs, see http://palmzlib.sourceforge.net/
-
-
-Acknowledgments:
-
- The deflate format used by zlib was defined by Phil Katz. The deflate and
- zlib specifications were written by L. Peter Deutsch. Thanks to all the
- people who reported problems and suggested various improvements in zlib; they
- are too numerous to cite here.
-
-Copyright notice:
-
- (C) 1995-2013 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- jloup@gzip.org madler@alumni.caltech.edu
-
-If you use the zlib library in a product, we would appreciate *not* receiving
-lengthy legal documents to sign. The sources are provided for free but without
-warranty of any kind. The library has been entirely written by Jean-loup
-Gailly and Mark Adler; it does not include third-party code.
-
-If you redistribute modified sources, we would appreciate that you include in
-the file ChangeLog history information documenting your changes. Please read
-the FAQ for more information on the distribution of modified source versions.
diff -Nru r-base-3.2.3/src/extra/zlib/Rzlib.def r-base-3.3.1/src/extra/zlib/Rzlib.def
--- r-base-3.2.3/src/extra/zlib/Rzlib.def 2011-10-02 22:02:10.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/Rzlib.def 1970-01-01 00:00:00.000000000 +0000
@@ -1,42 +0,0 @@
-EXPORTS
- adler32
- adler32_combine
- adler32_combine64
- compress
- compress2
- compressBound
- crc32
- crc32_combine
- crc32_combine64
- deflate
- deflateBound
- deflateCopy
- deflateEnd
- deflateInit2_
- deflateInit_
- deflateParams
- deflatePrime
- deflateReset
- deflateSetDictionary
- deflateSetHeader
- deflateTune
- get_crc_table
- inflate
- inflateBack
- inflateBackEnd
- inflateBackInit_
- inflateCopy
- inflateEnd
- inflateGetHeader
- inflateInit2_
- inflateInit_
- inflateMark
- inflatePrime
- inflateReset
- inflateReset2
- inflateSetDictionary
- inflateSync
- uncompress
- zError
- zlibCompileFlags
- zlibVersion
diff -Nru r-base-3.2.3/src/extra/zlib/trees.c r-base-3.3.1/src/extra/zlib/trees.c
--- r-base-3.2.3/src/extra/zlib/trees.c 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/trees.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,1226 +0,0 @@
-/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2012 Jean-loup Gailly
- * detect_data_type() function provided freely by Cosmin Truta, 2006
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process uses several Huffman trees. The more
- * common source values are represented by shorter bit sequences.
- *
- * Each code tree is stored in a compressed form which is itself
- * a Huffman encoding of the lengths of all the code strings (in
- * ascending order by source values). The actual code strings are
- * reconstructed from the lengths in the inflate process, as described
- * in the deflate specification.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
- * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
- *
- * Storer, James A.
- * Data Compression: Methods and Theory, pp. 49-50.
- * Computer Science Press, 1988. ISBN 0-7167-8156-5.
- *
- * Sedgewick, R.
- * Algorithms, p290.
- * Addison-Wesley, 1983. ISBN 0-201-06672-6.
- */
-
-/* @(#) $Id$ */
-
-/* #define GEN_TREES_H */
-
-#include "deflate.h"
-
-#ifdef DEBUG
-# include
-#endif
-
-/* ===========================================================================
- * Constants
- */
-
-#define MAX_BL_BITS 7
-/* Bit length codes must not exceed MAX_BL_BITS bits */
-
-#define END_BLOCK 256
-/* end of block literal code */
-
-#define REP_3_6 16
-/* repeat previous bit length 3-6 times (2 bits of repeat count) */
-
-#define REPZ_3_10 17
-/* repeat a zero length 3-10 times (3 bits of repeat count) */
-
-#define REPZ_11_138 18
-/* repeat a zero length 11-138 times (7 bits of repeat count) */
-
-local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
- = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
-
-local const int extra_dbits[D_CODES] /* extra bits for each distance code */
- = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
-
-local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
- = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
-
-local const uch bl_order[BL_CODES]
- = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
-/* The lengths of the bit length codes are sent in order of decreasing
- * probability, to avoid transmitting the lengths for unused bit length codes.
- */
-
-/* ===========================================================================
- * Local data. These are initialized only once.
- */
-
-#define DIST_CODE_LEN 512 /* see definition of array dist_code below */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
-/* non ANSI compilers may not accept trees.h */
-
-local ct_data static_ltree[L_CODES+2];
-/* The static literal tree. Since the bit lengths are imposed, there is no
- * need for the L_CODES extra codes used during heap construction. However
- * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
- * below).
- */
-
-local ct_data static_dtree[D_CODES];
-/* The static distance tree. (Actually a trivial tree since all codes use
- * 5 bits.)
- */
-
-uch _dist_code[DIST_CODE_LEN];
-/* Distance codes. The first 256 values correspond to the distances
- * 3 .. 258, the last 256 values correspond to the top 8 bits of
- * the 15 bit distances.
- */
-
-uch _length_code[MAX_MATCH-MIN_MATCH+1];
-/* length code for each normalized match length (0 == MIN_MATCH) */
-
-local int base_length[LENGTH_CODES];
-/* First normalized length for each code (0 = MIN_MATCH) */
-
-local int base_dist[D_CODES];
-/* First normalized distance for each code (0 = distance of 1) */
-
-#else
-# include "trees.h"
-#endif /* GEN_TREES_H */
-
-struct static_tree_desc_s {
- const ct_data *static_tree; /* static tree or NULL */
- const intf *extra_bits; /* extra bits for each code or NULL */
- int extra_base; /* base index for extra_bits */
- int elems; /* max number of elements in the tree */
- int max_length; /* max bit length for the codes */
-};
-
-local static_tree_desc static_l_desc =
-{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
-
-local static_tree_desc static_d_desc =
-{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
-
-local static_tree_desc static_bl_desc =
-{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
-
-/* ===========================================================================
- * Local (static) routines in this file.
- */
-
-local void tr_static_init OF((void));
-local void init_block OF((deflate_state *s));
-local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
-local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
-local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
-local void build_tree OF((deflate_state *s, tree_desc *desc));
-local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local int build_bl_tree OF((deflate_state *s));
-local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
- int blcodes));
-local void compress_block OF((deflate_state *s, const ct_data *ltree,
- const ct_data *dtree));
-local int detect_data_type OF((deflate_state *s));
-local unsigned bi_reverse OF((unsigned value, int length));
-local void bi_windup OF((deflate_state *s));
-local void bi_flush OF((deflate_state *s));
-local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
- int header));
-
-#ifdef GEN_TREES_H
-local void gen_trees_header OF((void));
-#endif
-
-#ifndef DEBUG
-# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
- /* Send a code of the given tree. c and tree must not have side effects */
-
-#else /* DEBUG */
-# define send_code(s, c, tree) \
- { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
- send_bits(s, tree[c].Code, tree[c].Len); }
-#endif
-
-/* ===========================================================================
- * Output a short LSB first on the stream.
- * IN assertion: there is enough room in pendingBuf.
- */
-#define put_short(s, w) { \
- put_byte(s, (uch)((w) & 0xff)); \
- put_byte(s, (uch)((ush)(w) >> 8)); \
-}
-
-/* ===========================================================================
- * Send a value on a given number of bits.
- * IN assertion: length <= 16 and value fits in length bits.
- */
-#ifdef DEBUG
-local void send_bits OF((deflate_state *s, int value, int length));
-
-local void send_bits(s, value, length)
- deflate_state *s;
- int value; /* value to send */
- int length; /* number of bits */
-{
- Tracevv((stderr," l %2d v %4x ", length, value));
- Assert(length > 0 && length <= 15, "invalid length");
- s->bits_sent += (ulg)length;
-
- /* If not enough room in bi_buf, use (valid) bits from bi_buf and
- * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
- * unused bits in value.
- */
- if (s->bi_valid > (int)Buf_size - length) {
- s->bi_buf |= (ush)value << s->bi_valid;
- put_short(s, s->bi_buf);
- s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
- s->bi_valid += length - Buf_size;
- } else {
- s->bi_buf |= (ush)value << s->bi_valid;
- s->bi_valid += length;
- }
-}
-#else /* !DEBUG */
-
-#define send_bits(s, value, length) \
-{ int len = length;\
- if (s->bi_valid > (int)Buf_size - len) {\
- int val = value;\
- s->bi_buf |= (ush)val << s->bi_valid;\
- put_short(s, s->bi_buf);\
- s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
- s->bi_valid += len - Buf_size;\
- } else {\
- s->bi_buf |= (ush)(value) << s->bi_valid;\
- s->bi_valid += len;\
- }\
-}
-#endif /* DEBUG */
-
-
-/* the arguments must not have side effects */
-
-/* ===========================================================================
- * Initialize the various 'constant' tables.
- */
-local void tr_static_init()
-{
-#if defined(GEN_TREES_H) || !defined(STDC)
- static int static_init_done = 0;
- int n; /* iterates over tree elements */
- int bits; /* bit counter */
- int length; /* length value */
- int code; /* code value */
- int dist; /* distance index */
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- if (static_init_done) return;
-
- /* For some embedded targets, global variables are not initialized: */
-#ifdef NO_INIT_GLOBAL_POINTERS
- static_l_desc.static_tree = static_ltree;
- static_l_desc.extra_bits = extra_lbits;
- static_d_desc.static_tree = static_dtree;
- static_d_desc.extra_bits = extra_dbits;
- static_bl_desc.extra_bits = extra_blbits;
-#endif
-
- /* Initialize the mapping length (0..255) -> length code (0..28) */
- length = 0;
- for (code = 0; code < LENGTH_CODES-1; code++) {
- base_length[code] = length;
- for (n = 0; n < (1< dist code (0..29) */
- dist = 0;
- for (code = 0 ; code < 16; code++) {
- base_dist[code] = dist;
- for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */
- for ( ; code < D_CODES; code++) {
- base_dist[code] = dist << 7;
- for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
- _dist_code[256 + dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "tr_static_init: 256+dist != 512");
-
- /* Construct the codes of the static literal tree */
- for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
- n = 0;
- while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
- while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
- while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
- while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
- /* Codes 286 and 287 do not exist, but we must include them in the
- * tree construction to get a canonical Huffman tree (longest code
- * all ones)
- */
- gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
-
- /* The static distance tree is trivial: */
- for (n = 0; n < D_CODES; n++) {
- static_dtree[n].Len = 5;
- static_dtree[n].Code = bi_reverse((unsigned)n, 5);
- }
- static_init_done = 1;
-
-# ifdef GEN_TREES_H
- gen_trees_header();
-# endif
-#endif /* defined(GEN_TREES_H) || !defined(STDC) */
-}
-
-/* ===========================================================================
- * Genererate the file trees.h describing the static trees.
- */
-#ifdef GEN_TREES_H
-# ifndef DEBUG
-# include
-# endif
-
-# define SEPARATOR(i, last, width) \
- ((i) == (last)? "\n};\n\n" : \
- ((i) % (width) == (width)-1 ? ",\n" : ", "))
-
-void gen_trees_header()
-{
- FILE *header = fopen("trees.h", "w");
- int i;
-
- Assert (header != NULL, "Can't open trees.h");
- fprintf(header,
- "/* header created automatically with -DGEN_TREES_H */\n\n");
-
- fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
- for (i = 0; i < L_CODES+2; i++) {
- fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
- static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
- }
-
- fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
- for (i = 0; i < D_CODES; i++) {
- fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
- static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
- }
-
- fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n");
- for (i = 0; i < DIST_CODE_LEN; i++) {
- fprintf(header, "%2u%s", _dist_code[i],
- SEPARATOR(i, DIST_CODE_LEN-1, 20));
- }
-
- fprintf(header,
- "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
- for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
- fprintf(header, "%2u%s", _length_code[i],
- SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
- }
-
- fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
- for (i = 0; i < LENGTH_CODES; i++) {
- fprintf(header, "%1u%s", base_length[i],
- SEPARATOR(i, LENGTH_CODES-1, 20));
- }
-
- fprintf(header, "local const int base_dist[D_CODES] = {\n");
- for (i = 0; i < D_CODES; i++) {
- fprintf(header, "%5u%s", base_dist[i],
- SEPARATOR(i, D_CODES-1, 10));
- }
-
- fclose(header);
-}
-#endif /* GEN_TREES_H */
-
-/* ===========================================================================
- * Initialize the tree data structures for a new zlib stream.
- */
-void ZLIB_INTERNAL _tr_init(s)
- deflate_state *s;
-{
- tr_static_init();
-
- s->l_desc.dyn_tree = s->dyn_ltree;
- s->l_desc.stat_desc = &static_l_desc;
-
- s->d_desc.dyn_tree = s->dyn_dtree;
- s->d_desc.stat_desc = &static_d_desc;
-
- s->bl_desc.dyn_tree = s->bl_tree;
- s->bl_desc.stat_desc = &static_bl_desc;
-
- s->bi_buf = 0;
- s->bi_valid = 0;
-#ifdef DEBUG
- s->compressed_len = 0L;
- s->bits_sent = 0L;
-#endif
-
- /* Initialize the first block of the first file: */
- init_block(s);
-}
-
-/* ===========================================================================
- * Initialize a new block.
- */
-local void init_block(s)
- deflate_state *s;
-{
- int n; /* iterates over tree elements */
-
- /* Initialize the trees. */
- for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
- for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
- for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
-
- s->dyn_ltree[END_BLOCK].Freq = 1;
- s->opt_len = s->static_len = 0L;
- s->last_lit = s->matches = 0;
-}
-
-#define SMALLEST 1
-/* Index within the heap array of least frequent node in the Huffman tree */
-
-
-/* ===========================================================================
- * Remove the smallest element from the heap and recreate the heap with
- * one less element. Updates heap and heap_len.
- */
-#define pqremove(s, tree, top) \
-{\
- top = s->heap[SMALLEST]; \
- s->heap[SMALLEST] = s->heap[s->heap_len--]; \
- pqdownheap(s, tree, SMALLEST); \
-}
-
-/* ===========================================================================
- * Compares to subtrees, using the tree depth as tie breaker when
- * the subtrees have equal frequency. This minimizes the worst case length.
- */
-#define smaller(tree, n, m, depth) \
- (tree[n].Freq < tree[m].Freq || \
- (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
-
-/* ===========================================================================
- * Restore the heap property by moving down the tree starting at node k,
- * exchanging a node with the smallest of its two sons if necessary, stopping
- * when the heap property is re-established (each father smaller than its
- * two sons).
- */
-local void pqdownheap(s, tree, k)
- deflate_state *s;
- ct_data *tree; /* the tree to restore */
- int k; /* node to move down */
-{
- int v = s->heap[k];
- int j = k << 1; /* left son of k */
- while (j <= s->heap_len) {
- /* Set j to the smallest of the two sons: */
- if (j < s->heap_len &&
- smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
- j++;
- }
- /* Exit if v is smaller than both sons */
- if (smaller(tree, v, s->heap[j], s->depth)) break;
-
- /* Exchange v with the smallest son */
- s->heap[k] = s->heap[j]; k = j;
-
- /* And continue down the tree, setting j to the left son of k */
- j <<= 1;
- }
- s->heap[k] = v;
-}
-
-/* ===========================================================================
- * Compute the optimal bit lengths for a tree and update the total bit length
- * for the current block.
- * IN assertion: the fields freq and dad are set, heap[heap_max] and
- * above are the tree nodes sorted by increasing frequency.
- * OUT assertions: the field len is set to the optimal bit length, the
- * array bl_count contains the frequencies for each bit length.
- * The length opt_len is updated; static_len is also updated if stree is
- * not null.
- */
-local void gen_bitlen(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
-{
- ct_data *tree = desc->dyn_tree;
- int max_code = desc->max_code;
- const ct_data *stree = desc->stat_desc->static_tree;
- const intf *extra = desc->stat_desc->extra_bits;
- int base = desc->stat_desc->extra_base;
- int max_length = desc->stat_desc->max_length;
- int h; /* heap index */
- int n, m; /* iterate over the tree elements */
- int bits; /* bit length */
- int xbits; /* extra bits */
- ush f; /* frequency */
- int overflow = 0; /* number of elements with bit length too large */
-
- for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
-
- /* In a first pass, compute the optimal bit lengths (which may
- * overflow in the case of the bit length tree).
- */
- tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
-
- for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
- n = s->heap[h];
- bits = tree[tree[n].Dad].Len + 1;
- if (bits > max_length) bits = max_length, overflow++;
- tree[n].Len = (ush)bits;
- /* We overwrite tree[n].Dad which is no longer needed */
-
- if (n > max_code) continue; /* not a leaf node */
-
- s->bl_count[bits]++;
- xbits = 0;
- if (n >= base) xbits = extra[n-base];
- f = tree[n].Freq;
- s->opt_len += (ulg)f * (bits + xbits);
- if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
- }
- if (overflow == 0) return;
-
- Trace((stderr,"\nbit length overflow\n"));
- /* This happens for example on obj2 and pic of the Calgary corpus */
-
- /* Find the first bit length which could increase: */
- do {
- bits = max_length-1;
- while (s->bl_count[bits] == 0) bits--;
- s->bl_count[bits]--; /* move one leaf down the tree */
- s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
- s->bl_count[max_length]--;
- /* The brother of the overflow item also moves one step up,
- * but this does not affect bl_count[max_length]
- */
- overflow -= 2;
- } while (overflow > 0);
-
- /* Now recompute all bit lengths, scanning in increasing frequency.
- * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
- * lengths instead of fixing only the wrong ones. This idea is taken
- * from 'ar' written by Haruhiko Okumura.)
- */
- for (bits = max_length; bits != 0; bits--) {
- n = s->bl_count[bits];
- while (n != 0) {
- m = s->heap[--h];
- if (m > max_code) continue;
- if ((unsigned) tree[m].Len != (unsigned) bits) {
- Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
- s->opt_len += ((long)bits - (long)tree[m].Len)
- *(long)tree[m].Freq;
- tree[m].Len = (ush)bits;
- }
- n--;
- }
- }
-}
-
-/* ===========================================================================
- * Generate the codes for a given tree and bit counts (which need not be
- * optimal).
- * IN assertion: the array bl_count contains the bit length statistics for
- * the given tree and the field len is set for all tree elements.
- * OUT assertion: the field code is set for all tree elements of non
- * zero code length.
- */
-local void gen_codes (tree, max_code, bl_count)
- ct_data *tree; /* the tree to decorate */
- int max_code; /* largest code with non zero frequency */
- ushf *bl_count; /* number of codes at each bit length */
-{
- ush next_code[MAX_BITS+1]; /* next code value for each bit length */
- ush code = 0; /* running code value */
- int bits; /* bit index */
- int n; /* code index */
-
- /* The distribution counts are first used to generate the code values
- * without bit reversal.
- */
- for (bits = 1; bits <= MAX_BITS; bits++) {
- next_code[bits] = code = (code + bl_count[bits-1]) << 1;
- }
- /* Check that the bit counts in bl_count are consistent. The last code
- * must be all ones.
- */
- Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree;
- const ct_data *stree = desc->stat_desc->static_tree;
- int elems = desc->stat_desc->elems;
- int n, m; /* iterate over heap elements */
- int max_code = -1; /* largest code with non zero frequency */
- int node; /* new node being created */
-
- /* Construct the initial heap, with least frequent element in
- * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
- * heap[0] is not used.
- */
- s->heap_len = 0, s->heap_max = HEAP_SIZE;
-
- for (n = 0; n < elems; n++) {
- if (tree[n].Freq != 0) {
- s->heap[++(s->heap_len)] = max_code = n;
- s->depth[n] = 0;
- } else {
- tree[n].Len = 0;
- }
- }
-
- /* The pkzip format requires that at least one distance code exists,
- * and that at least one bit should be sent even if there is only one
- * possible code. So to avoid special checks later on we force at least
- * two codes of non zero frequency.
- */
- while (s->heap_len < 2) {
- node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
- tree[node].Freq = 1;
- s->depth[node] = 0;
- s->opt_len--; if (stree) s->static_len -= stree[node].Len;
- /* node is 0 or 1 so it does not have extra bits */
- }
- desc->max_code = max_code;
-
- /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
- * establish sub-heaps of increasing lengths:
- */
- for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
-
- /* Construct the Huffman tree by repeatedly combining the least two
- * frequent nodes.
- */
- node = elems; /* next internal node of the tree */
- do {
- pqremove(s, tree, n); /* n = node of least frequency */
- m = s->heap[SMALLEST]; /* m = node of next least frequency */
-
- s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
- s->heap[--(s->heap_max)] = m;
-
- /* Create a new node father of n and m */
- tree[node].Freq = tree[n].Freq + tree[m].Freq;
- s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
- s->depth[n] : s->depth[m]) + 1);
- tree[n].Dad = tree[m].Dad = (ush)node;
-#ifdef DUMP_BL_TREE
- if (tree == s->bl_tree) {
- fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
- node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
- }
-#endif
- /* and insert the new node in the heap */
- s->heap[SMALLEST] = node++;
- pqdownheap(s, tree, SMALLEST);
-
- } while (s->heap_len >= 2);
-
- s->heap[--(s->heap_max)] = s->heap[SMALLEST];
-
- /* At this point, the fields freq and dad are set. We can now
- * generate the bit lengths.
- */
- gen_bitlen(s, (tree_desc *)desc);
-
- /* The field len is now set, we can generate the bit codes */
- gen_codes ((ct_data *)tree, max_code, s->bl_count);
-}
-
-/* ===========================================================================
- * Scan a literal or distance tree to determine the frequencies of the codes
- * in the bit length tree.
- */
-local void scan_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- if (nextlen == 0) max_count = 138, min_count = 3;
- tree[max_code+1].Len = (ush)0xffff; /* guard */
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- s->bl_tree[curlen].Freq += count;
- } else if (curlen != 0) {
- if (curlen != prevlen) s->bl_tree[curlen].Freq++;
- s->bl_tree[REP_3_6].Freq++;
- } else if (count <= 10) {
- s->bl_tree[REPZ_3_10].Freq++;
- } else {
- s->bl_tree[REPZ_11_138].Freq++;
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Send a literal or distance tree in compressed form, using the codes in
- * bl_tree.
- */
-local void send_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- /* tree[max_code+1].Len = -1; */ /* guard already set */
- if (nextlen == 0) max_count = 138, min_count = 3;
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
-
- } else if (curlen != 0) {
- if (curlen != prevlen) {
- send_code(s, curlen, s->bl_tree); count--;
- }
- Assert(count >= 3 && count <= 6, " 3_6?");
- send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
-
- } else if (count <= 10) {
- send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
-
- } else {
- send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Construct the Huffman tree for the bit lengths and return the index in
- * bl_order of the last bit length code to send.
- */
-local int build_bl_tree(s)
- deflate_state *s;
-{
- int max_blindex; /* index of last bit length code of non zero freq */
-
- /* Determine the bit length frequencies for literal and distance trees */
- scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
- scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
-
- /* Build the bit length tree: */
- build_tree(s, (tree_desc *)(&(s->bl_desc)));
- /* opt_len now includes the length of the tree representations, except
- * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
- */
-
- /* Determine the number of bit length codes to send. The pkzip format
- * requires that at least 4 bit length codes be sent. (appnote.txt says
- * 3 but the actual value used is 4.)
- */
- for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
- if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
- }
- /* Update opt_len to include the bit length tree and counts */
- s->opt_len += 3*(max_blindex+1) + 5+5+4;
- Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
- s->opt_len, s->static_len));
-
- return max_blindex;
-}
-
-/* ===========================================================================
- * Send the header for a block using dynamic Huffman trees: the counts, the
- * lengths of the bit length codes, the literal tree and the distance tree.
- * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
- */
-local void send_all_trees(s, lcodes, dcodes, blcodes)
- deflate_state *s;
- int lcodes, dcodes, blcodes; /* number of codes for each tree */
-{
- int rank; /* index in bl_order */
-
- Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
- Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
- "too many codes");
- Tracev((stderr, "\nbl counts: "));
- send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
- send_bits(s, dcodes-1, 5);
- send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
- for (rank = 0; rank < blcodes; rank++) {
- Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
- send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
- }
- Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
- Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
- Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
-}
-
-/* ===========================================================================
- * Send a stored block
- */
-void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
- deflate_state *s;
- charf *buf; /* input block */
- ulg stored_len; /* length of input block */
- int last; /* one if this is the last block for a file */
-{
- send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
-#ifdef DEBUG
- s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
- s->compressed_len += (stored_len + 4) << 3;
-#endif
- copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
-}
-
-/* ===========================================================================
- * Flush the bits in the bit buffer to pending output (leaves at most 7 bits)
- */
-void ZLIB_INTERNAL _tr_flush_bits(s)
- deflate_state *s;
-{
- bi_flush(s);
-}
-
-/* ===========================================================================
- * Send one empty static block to give enough lookahead for inflate.
- * This takes 10 bits, of which 7 may remain in the bit buffer.
- */
-void ZLIB_INTERNAL _tr_align(s)
- deflate_state *s;
-{
- send_bits(s, STATIC_TREES<<1, 3);
- send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
- s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
-#endif
- bi_flush(s);
-}
-
-/* ===========================================================================
- * Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file.
- */
-void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
- deflate_state *s;
- charf *buf; /* input block, or NULL if too old */
- ulg stored_len; /* length of input block */
- int last; /* one if this is the last block for a file */
-{
- ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
- int max_blindex = 0; /* index of last bit length code of non zero freq */
-
- /* Build the Huffman trees unless a stored block is forced */
- if (s->level > 0) {
-
- /* Check if the file is binary or text */
- if (s->strm->data_type == Z_UNKNOWN)
- s->strm->data_type = detect_data_type(s);
-
- /* Construct the literal and distance trees */
- build_tree(s, (tree_desc *)(&(s->l_desc)));
- Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
-
- build_tree(s, (tree_desc *)(&(s->d_desc)));
- Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
- /* At this point, opt_len and static_len are the total bit lengths of
- * the compressed block data, excluding the tree representations.
- */
-
- /* Build the bit length tree for the above two trees, and get the index
- * in bl_order of the last bit length code to send.
- */
- max_blindex = build_bl_tree(s);
-
- /* Determine the best encoding. Compute the block lengths in bytes. */
- opt_lenb = (s->opt_len+3+7)>>3;
- static_lenb = (s->static_len+3+7)>>3;
-
- Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
- opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
- s->last_lit));
-
- if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
-
- } else {
- Assert(buf != (char*)0, "lost buf");
- opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
- }
-
-#ifdef FORCE_STORED
- if (buf != (char*)0) { /* force stored block */
-#else
- if (stored_len+4 <= opt_lenb && buf != (char*)0) {
- /* 4: two words for the lengths */
-#endif
- /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
- * Otherwise we can't have processed more than WSIZE input bytes since
- * the last block flush, because compression would have been
- * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
- * transform a block into a stored block.
- */
- _tr_stored_block(s, buf, stored_len, last);
-
-#ifdef FORCE_STATIC
- } else if (static_lenb >= 0) { /* force static trees */
-#else
- } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
-#endif
- send_bits(s, (STATIC_TREES<<1)+last, 3);
- compress_block(s, (const ct_data *)static_ltree,
- (const ct_data *)static_dtree);
-#ifdef DEBUG
- s->compressed_len += 3 + s->static_len;
-#endif
- } else {
- send_bits(s, (DYN_TREES<<1)+last, 3);
- send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
- max_blindex+1);
- compress_block(s, (const ct_data *)s->dyn_ltree,
- (const ct_data *)s->dyn_dtree);
-#ifdef DEBUG
- s->compressed_len += 3 + s->opt_len;
-#endif
- }
- Assert (s->compressed_len == s->bits_sent, "bad compressed size");
- /* The above check is made mod 2^32, for files larger than 512 MB
- * and uLong implemented on 32 bits.
- */
- init_block(s);
-
- if (last) {
- bi_windup(s);
-#ifdef DEBUG
- s->compressed_len += 7; /* align on byte boundary */
-#endif
- }
- Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
- s->compressed_len-7*last));
-}
-
-/* ===========================================================================
- * Save the match info and tally the frequency counts. Return true if
- * the current block must be flushed.
- */
-int ZLIB_INTERNAL _tr_tally (s, dist, lc)
- deflate_state *s;
- unsigned dist; /* distance of matched string */
- unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
-{
- s->d_buf[s->last_lit] = (ush)dist;
- s->l_buf[s->last_lit++] = (uch)lc;
- if (dist == 0) {
- /* lc is the unmatched char */
- s->dyn_ltree[lc].Freq++;
- } else {
- s->matches++;
- /* Here, lc is the match length - MIN_MATCH */
- dist--; /* dist = match distance - 1 */
- Assert((ush)dist < (ush)MAX_DIST(s) &&
- (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
- (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
-
- s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
- s->dyn_dtree[d_code(dist)].Freq++;
- }
-
-#ifdef TRUNCATE_BLOCK
- /* Try to guess if it is profitable to stop the current block here */
- if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
- /* Compute an upper bound for the compressed length */
- ulg out_length = (ulg)s->last_lit*8L;
- ulg in_length = (ulg)((long)s->strstart - s->block_start);
- int dcode;
- for (dcode = 0; dcode < D_CODES; dcode++) {
- out_length += (ulg)s->dyn_dtree[dcode].Freq *
- (5L+extra_dbits[dcode]);
- }
- out_length >>= 3;
- Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
- s->last_lit, in_length, out_length,
- 100L - out_length*100L/in_length));
- if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
- }
-#endif
- return (s->last_lit == s->lit_bufsize-1);
- /* We avoid equality with lit_bufsize because of wraparound at 64K
- * on 16 bit machines and because stored blocks are restricted to
- * 64K-1 bytes.
- */
-}
-
-/* ===========================================================================
- * Send the block data compressed using the given Huffman trees
- */
-local void compress_block(s, ltree, dtree)
- deflate_state *s;
- const ct_data *ltree; /* literal tree */
- const ct_data *dtree; /* distance tree */
-{
- unsigned dist; /* distance of matched string */
- int lc; /* match length or unmatched char (if dist == 0) */
- unsigned lx = 0; /* running index in l_buf */
- unsigned code; /* the code to send */
- int extra; /* number of extra bits to send */
-
- if (s->last_lit != 0) do {
- dist = s->d_buf[lx];
- lc = s->l_buf[lx++];
- if (dist == 0) {
- send_code(s, lc, ltree); /* send a literal byte */
- Tracecv(isgraph(lc), (stderr," '%c' ", lc));
- } else {
- /* Here, lc is the match length - MIN_MATCH */
- code = _length_code[lc];
- send_code(s, code+LITERALS+1, ltree); /* send the length code */
- extra = extra_lbits[code];
- if (extra != 0) {
- lc -= base_length[code];
- send_bits(s, lc, extra); /* send the extra length bits */
- }
- dist--; /* dist is now the match distance - 1 */
- code = d_code(dist);
- Assert (code < D_CODES, "bad d_code");
-
- send_code(s, code, dtree); /* send the distance code */
- extra = extra_dbits[code];
- if (extra != 0) {
- dist -= base_dist[code];
- send_bits(s, dist, extra); /* send the extra distance bits */
- }
- } /* literal or match pair ? */
-
- /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
- Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
- "pendingBuf overflow");
-
- } while (lx < s->last_lit);
-
- send_code(s, END_BLOCK, ltree);
-}
-
-/* ===========================================================================
- * Check if the data type is TEXT or BINARY, using the following algorithm:
- * - TEXT if the two conditions below are satisfied:
- * a) There are no non-portable control characters belonging to the
- * "black list" (0..6, 14..25, 28..31).
- * b) There is at least one printable character belonging to the
- * "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
- * - BINARY otherwise.
- * - The following partially-portable control characters form a
- * "gray list" that is ignored in this detection algorithm:
- * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
- * IN assertion: the fields Freq of dyn_ltree are set.
- */
-local int detect_data_type(s)
- deflate_state *s;
-{
- /* black_mask is the bit mask of black-listed bytes
- * set bits 0..6, 14..25, and 28..31
- * 0xf3ffc07f = binary 11110011111111111100000001111111
- */
- unsigned long black_mask = 0xf3ffc07fUL;
- int n;
-
- /* Check for non-textual ("black-listed") bytes. */
- for (n = 0; n <= 31; n++, black_mask >>= 1)
- if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))
- return Z_BINARY;
-
- /* Check for textual ("white-listed") bytes. */
- if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
- || s->dyn_ltree[13].Freq != 0)
- return Z_TEXT;
- for (n = 32; n < LITERALS; n++)
- if (s->dyn_ltree[n].Freq != 0)
- return Z_TEXT;
-
- /* There are no "black-listed" or "white-listed" bytes:
- * this stream either is empty or has tolerated ("gray-listed") bytes only.
- */
- return Z_BINARY;
-}
-
-/* ===========================================================================
- * Reverse the first len bits of a code, using straightforward code (a faster
- * method would use a table)
- * IN assertion: 1 <= len <= 15
- */
-local unsigned bi_reverse(code, len)
- unsigned code; /* the value to invert */
- int len; /* its bit length */
-{
- register unsigned res = 0;
- do {
- res |= code & 1;
- code >>= 1, res <<= 1;
- } while (--len > 0);
- return res >> 1;
-}
-
-/* ===========================================================================
- * Flush the bit buffer, keeping at most 7 bits in it.
- */
-local void bi_flush(s)
- deflate_state *s;
-{
- if (s->bi_valid == 16) {
- put_short(s, s->bi_buf);
- s->bi_buf = 0;
- s->bi_valid = 0;
- } else if (s->bi_valid >= 8) {
- put_byte(s, (Byte)s->bi_buf);
- s->bi_buf >>= 8;
- s->bi_valid -= 8;
- }
-}
-
-/* ===========================================================================
- * Flush the bit buffer and align the output on a byte boundary
- */
-local void bi_windup(s)
- deflate_state *s;
-{
- if (s->bi_valid > 8) {
- put_short(s, s->bi_buf);
- } else if (s->bi_valid > 0) {
- put_byte(s, (Byte)s->bi_buf);
- }
- s->bi_buf = 0;
- s->bi_valid = 0;
-#ifdef DEBUG
- s->bits_sent = (s->bits_sent+7) & ~7;
-#endif
-}
-
-/* ===========================================================================
- * Copy a stored block, storing first the length and its
- * one's complement if requested.
- */
-local void copy_block(s, buf, len, header)
- deflate_state *s;
- charf *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
-{
- bi_windup(s); /* align on byte boundary */
-
- if (header) {
- put_short(s, (ush)len);
- put_short(s, (ush)~len);
-#ifdef DEBUG
- s->bits_sent += 2*16;
-#endif
- }
-#ifdef DEBUG
- s->bits_sent += (ulg)len<<3;
-#endif
- while (len--) {
- put_byte(s, *buf++);
- }
-}
diff -Nru r-base-3.2.3/src/extra/zlib/trees.h r-base-3.3.1/src/extra/zlib/trees.h
--- r-base-3.2.3/src/extra/zlib/trees.h 2011-10-02 22:02:10.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/trees.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,128 +0,0 @@
-/* header created automatically with -DGEN_TREES_H */
-
-local const ct_data static_ltree[L_CODES+2] = {
-{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
-{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
-{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
-{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
-{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
-{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
-{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
-{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
-{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
-{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
-{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
-{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
-{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
-{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
-{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
-{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
-{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
-{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
-{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
-{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
-{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
-{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
-{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
-{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
-{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
-{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
-{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
-{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
-{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
-{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
-{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
-{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
-{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
-{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
-{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
-{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
-{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
-{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
-{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
-{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
-{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
-{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
-{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
-{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
-{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
-{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
-{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
-{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
-{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
-{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
-{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
-{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
-{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
-{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
-{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
-{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
-{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
-{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
-};
-
-local const ct_data static_dtree[D_CODES] = {
-{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
-{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
-{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
-{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
-{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
-{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
-};
-
-const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {
- 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
- 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
-10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
-12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
-18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
-};
-
-const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
-13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
-17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
-19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
-};
-
-local const int base_length[LENGTH_CODES] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
-64, 80, 96, 112, 128, 160, 192, 224, 0
-};
-
-local const int base_dist[D_CODES] = {
- 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
- 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
- 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
-};
-
diff -Nru r-base-3.2.3/src/extra/zlib/uncompr.c r-base-3.3.1/src/extra/zlib/uncompr.c
--- r-base-3.2.3/src/extra/zlib/uncompr.c 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/uncompr.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,59 +0,0 @@
-/* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-/* ===========================================================================
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted.
-*/
-int ZEXPORT uncompress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
-{
- z_stream stream;
- int err;
-
- stream.next_in = (z_const Bytef *)source;
- stream.avail_in = (uInt)sourceLen;
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
-
- err = inflateInit(&stream);
- if (err != Z_OK) return err;
-
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
- return Z_DATA_ERROR;
- return err;
- }
- *destLen = stream.total_out;
-
- err = inflateEnd(&stream);
- return err;
-}
diff -Nru r-base-3.2.3/src/extra/zlib/zconf.h r-base-3.3.1/src/extra/zlib/zconf.h
--- r-base-3.2.3/src/extra/zlib/zconf.h 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/zconf.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,447 +0,0 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZCONF_H
-#define ZCONF_H
-
-#ifdef HAVE_CONFIG_H
-#include
-#endif
-
-/* R change */
-#ifndef WIN32
-#define Z_PREFIX
-#endif
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- * Even better than compiling with -DZ_PREFIX would be to use configure to set
- * this permanently in zconf.h using "./configure --zprefix".
- */
-#ifdef Z_PREFIX
-# define deflateInit_ Rz_deflateInit_
-# define deflate Rz_deflate
-# define deflateEnd Rz_deflateEnd
-# define inflateInit_ Rz_inflateInit_
-# define inflate Rz_inflate
-# define inflateEnd Rz_inflateEnd
-# define deflateInit2_ Rz_deflateInit2_
-# define deflateSetDictionary Rz_deflateSetDictionary
-# define deflateCopy Rz_deflateCopy
-# define deflateReset Rz_deflateReset
-# define deflateParams Rz_deflateParams
-# define deflateBound Rz_deflateBound
-# define deflatePrime Rz_deflatePrime
-# define inflateInit2_ Rz_inflateInit2_
-# define inflateSetDictionary Rz_inflateSetDictionary
-# define inflateSync Rz_inflateSync
-# define inflateSyncPoint Rz_inflateSyncPoint
-# define inflateCopy Rz_inflateCopy
-# define inflateReset Rz_inflateReset
-# define inflateBack Rz_inflateBack
-# define inflateBackEnd Rz_inflateBackEnd
-# define compress Rz_compress
-# define compress2 Rz_compress2
-# define compressBound Rz_compressBound
-# define uncompress Rz_uncompress
-# define adler32 Rz_adler32
-# define crc32 Rz_crc32
-# define get_crc_table Rz_get_crc_table
-# define zError Rz_zError
-
-# define alloc_func Rz_alloc_func
-# define free_func Rz_free_func
-# define in_func Rz_in_func
-# define out_func Rz_out_func
-
-# define adler32_combine Rz_adler32_combine
-# define adler32_combine64 Rz_adler32_combine64
-# define crc32_combine Rz_crc32_combine
-# define crc32_combine64 Rz_crc32_combine64
-# define deflateSetHeader Rz_deflateSetHeader
-# define deflateTune Rz_deflateTune
-# define inflateBackInit_ Rz_inflateBackInit_
-# define inflate_fast Rz_inflate_fast
-# define inflateGetHeader Rz_inflateGetHeader
-# define inflatePrime Rz_inflatePrime
-# define inflate_table Rz_inflate_table
-# define inflateMark Rz_inflateMark
-# define inflateReset2 Rz_inflateReset2
-# define inflateUndermine Rz_inflateUndermine
-# define _tr_align Rz__tr_align
-# define _tr_flush_block Rz__tr_flush_block
-# define _tr_init Rz__tr_init
-# define _tr_stored_block Rz__tr_stored_block
-# define _tr_tally Rz__tr_tally
-# define zcalloc Rz_zcalloc
-# define zcfree Rz_zcfree
-# define zlibCompileFlags Rz_zlibCompileFlags
-# define zlibVersion Rz_zlibVersion
-# define _dist_code Rz_dist_code
-# define _length_code Rz_length_code
-# define z_errmsg Rz_errmsg
-# define deflate_copyright Rz_deflate_copyright
-# define inflate_copyright Rz_inflate_copyright
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-# define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-# define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-# define WINDOWS
-#endif
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
-# ifndef WIN32
-# define WIN32
-# endif
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-# ifndef SYS16BIT
-# define SYS16BIT
-# endif
-# endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-# define MAXSEG_64K
-#endif
-#ifdef MSDOS
-# define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
-# if __STDC_VERSION__ >= 199901L
-# ifndef STDC99
-# define STDC99
-# endif
-# endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-# define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
-
-#if defined(ZLIB_CONST) && !defined(z_const)
-# define z_const const
-#else
-# define z_const
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- (1 << (windowBits+2)) + (1 << (memLevel+9))
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif
-
-#ifndef Z_ARG /* function prototypes for stdarg */
-# if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# define Z_ARG(args) args
-# else
-# define Z_ARG(args) ()
-# endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-# if defined(M_I86SM) || defined(M_I86MM)
- /* MSC small or medium model */
-# define SMALL_MEDIUM
-# ifdef _MSC_VER
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-# if (defined(__SMALL__) || defined(__MEDIUM__))
- /* Turbo C small or medium model */
-# define SMALL_MEDIUM
-# ifdef __BORLANDC__
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
- /* If building or using zlib as a DLL, define ZLIB_DLL.
- * This is not mandatory, but it offers a little performance increase.
- */
-# ifdef ZLIB_DLL
-# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-# ifdef ZLIB_INTERNAL
-# define ZEXTERN extern __declspec(dllexport)
-# else
-# define ZEXTERN extern __declspec(dllimport)
-# endif
-# endif
-# endif /* ZLIB_DLL */
- /* If building or using zlib with the WINAPI/WINAPIV calling convention,
- * define ZLIB_WINAPI.
- * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
- */
-# ifdef ZLIB_WINAPI
-# ifdef FAR
-# undef FAR
-# endif
-# include
- /* No need for _export, use ZLIB.DEF instead. */
- /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-# define ZEXPORT WINAPI
-# ifdef WIN32
-# define ZEXPORTVA WINAPIV
-# else
-# define ZEXPORTVA FAR CDECL
-# endif
-# endif
-#endif
-
-#if defined (__BEOS__)
-# ifdef ZLIB_DLL
-# ifdef ZLIB_INTERNAL
-# define ZEXPORT __declspec(dllexport)
-# define ZEXPORTVA __declspec(dllexport)
-# else
-# define ZEXPORT __declspec(dllimport)
-# define ZEXPORTVA __declspec(dllimport)
-# endif
-# endif
-#endif
-
-#ifndef ZEXTERN
-# define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-# define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-# define ZEXPORTVA
-#endif
-
-#ifndef FAR
-# define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char Byte; /* 8 bits */
-#endif
-typedef unsigned int uInt; /* 16 bits or more */
-typedef unsigned long uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
- /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-# define Bytef Byte FAR
-#else
- typedef Byte FAR Bytef;
-#endif
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
- typedef void const *voidpc;
- typedef void FAR *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte FAR *voidpf;
- typedef Byte *voidp;
-#endif
-
-/* ./configure may #define Z_U4 here */
-
-#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
-# include
-# if (UINT_MAX == 0xffffffffUL)
-# define Z_U4 unsigned
-# elif (ULONG_MAX == 0xffffffffUL)
-# define Z_U4 unsigned long
-# elif (USHRT_MAX == 0xffffffffUL)
-# define Z_U4 unsigned short
-# endif
-#endif
-
-#ifdef Z_U4
- typedef Z_U4 z_crc_t;
-#else
- typedef unsigned long z_crc_t;
-#endif
-
-#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
-# define Z_HAVE_UNISTD_H
-#endif
-
-#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
-# define Z_HAVE_STDARG_H
-#endif
-
-#ifdef STDC
-# ifndef Z_SOLO
-# include /* for off_t */
-# endif
-#endif
-
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# ifndef Z_SOLO
-# include /* for va_list */
-# endif
-#endif
-
-#ifdef _WIN32
-# include /* for wchar_t */
-#endif
-
-/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
- * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
- * though the former does not conform to the LFS document), but considering
- * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
- * equivalently requesting no 64-bit operations
- */
-#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
-# undef _LARGEFILE64_SOURCE
-#endif
-
-#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
-# define Z_HAVE_UNISTD_H
-#endif
-#ifndef Z_SOLO
-# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
-# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
-# ifdef VMS
-# include /* for off_t */
-# endif
-# ifndef z_off_t
-# define z_off_t off_t
-# endif
-# endif
-#endif
-
-#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
-# define Z_LFS64
-#endif
-
-#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
-# define Z_LARGE64
-#endif
-
-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
-# define Z_WANT64
-#endif
-
-#if !defined(SEEK_SET) && !defined(Z_SOLO)
-# define SEEK_SET 0 /* Seek from beginning of file. */
-# define SEEK_CUR 1 /* Seek from current position. */
-# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
-#endif
-
-#ifndef z_off_t
-# define z_off_t long
-#endif
-
-#if !defined(_WIN32) && defined(Z_LARGE64)
-# define z_off64_t off64_t
-#else
-# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
-# define z_off64_t __int64
-# else
-# define z_off64_t z_off_t
-# endif
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
- #pragma map(deflateInit_,"DEIN")
- #pragma map(deflateInit2_,"DEIN2")
- #pragma map(deflateEnd,"DEEND")
- #pragma map(deflateBound,"DEBND")
- #pragma map(inflateInit_,"ININ")
- #pragma map(inflateInit2_,"ININ2")
- #pragma map(inflateEnd,"INEND")
- #pragma map(inflateSync,"INSY")
- #pragma map(inflateSetDictionary,"INSEDI")
- #pragma map(compressBound,"CMBND")
- #pragma map(inflate_table,"INTABL")
- #pragma map(inflate_fast,"INFA")
- #pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */
diff -Nru r-base-3.2.3/src/extra/zlib/zlib.h r-base-3.3.1/src/extra/zlib/zlib.h
--- r-base-3.2.3/src/extra/zlib/zlib.h 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/zlib.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,1771 +0,0 @@
-/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.8, April 28th, 2013
-
- Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- jloup@gzip.org madler@alumni.caltech.edu
-
-
- The data format used by the zlib library is described by RFCs (Request for
- Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
- (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
-*/
-
-#ifndef ZLIB_H
-#define ZLIB_H
-
-#include "zconf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ZLIB_VERSION "1.2.8"
-#define ZLIB_VERNUM 0x1280
-#define ZLIB_VER_MAJOR 1
-#define ZLIB_VER_MINOR 2
-#define ZLIB_VER_REVISION 8
-#define ZLIB_VER_SUBREVISION 0
-
-/*
- The 'zlib' compression library provides in-memory compression and
- decompression functions, including integrity checks of the uncompressed data.
- This version of the library supports only one compression method (deflation)
- but other algorithms will be added later and will have the same stream
- interface.
-
- Compression can be done in a single step if the buffers are large enough,
- or can be done by repeated calls of the compression function. In the latter
- case, the application must provide more input and/or consume the output
- (providing more output space) before each call.
-
- The compressed data format used by default by the in-memory functions is
- the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
- around a deflate stream, which is itself documented in RFC 1951.
-
- The library also supports reading and writing files in gzip (.gz) format
- with an interface similar to that of stdio using the functions that start
- with "gz". The gzip format is different from the zlib format. gzip is a
- gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
-
- This library can optionally read and write gzip streams in memory as well.
-
- The zlib format was designed to be compact and fast for use in memory
- and on communications channels. The gzip format was designed for single-
- file compression on file systems, has a larger header than zlib to maintain
- directory information, and uses a different, slower check method than zlib.
-
- The library does not install any signal handler. The decoder checks
- the consistency of the compressed data, so the library should never crash
- even in case of corrupted input.
-*/
-
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void (*free_func) OF((voidpf opaque, voidpf address));
-
-struct internal_state;
-
-typedef struct z_stream_s {
- z_const Bytef *next_in; /* next input byte */
- uInt avail_in; /* number of bytes available at next_in */
- uLong total_in; /* total number of input bytes read so far */
-
- Bytef *next_out; /* next output byte should be put there */
- uInt avail_out; /* remaining free space at next_out */
- uLong total_out; /* total number of bytes output so far */
-
- z_const char *msg; /* last error message, NULL if no error */
- struct internal_state FAR *state; /* not visible by applications */
-
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
- voidpf opaque; /* private data object passed to zalloc and zfree */
-
- int data_type; /* best guess about the data type: binary or text */
- uLong adler; /* adler32 value of the uncompressed data */
- uLong reserved; /* reserved for future use */
-} z_stream;
-
-typedef z_stream FAR *z_streamp;
-
-/*
- gzip header information passed to and from zlib routines. See RFC 1952
- for more details on the meanings of these fields.
-*/
-typedef struct gz_header_s {
- int text; /* true if compressed data believed to be text */
- uLong time; /* modification time */
- int xflags; /* extra flags (not used when writing a gzip file) */
- int os; /* operating system */
- Bytef *extra; /* pointer to extra field or Z_NULL if none */
- uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
- uInt extra_max; /* space at extra (only when reading header) */
- Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
- uInt name_max; /* space at name (only when reading header) */
- Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
- uInt comm_max; /* space at comment (only when reading header) */
- int hcrc; /* true if there was or will be a header crc */
- int done; /* true when done reading gzip header (not used
- when writing a gzip file) */
-} gz_header;
-
-typedef gz_header FAR *gz_headerp;
-
-/*
- The application must update next_in and avail_in when avail_in has dropped
- to zero. It must update next_out and avail_out when avail_out has dropped
- to zero. The application must initialize zalloc, zfree and opaque before
- calling the init function. All other fields are set by the compression
- library and must not be updated by the application.
-
- The opaque value provided by the application will be passed as the first
- parameter for calls of zalloc and zfree. This can be useful for custom
- memory management. The compression library attaches no meaning to the
- opaque value.
-
- zalloc must return Z_NULL if there is not enough memory for the object.
- If zlib is used in a multi-threaded application, zalloc and zfree must be
- thread safe.
-
- On 16-bit systems, the functions zalloc and zfree must be able to allocate
- exactly 65536 bytes, but will not be required to allocate more than this if
- the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers
- returned by zalloc for objects of exactly 65536 bytes *must* have their
- offset normalized to zero. The default allocation function provided by this
- library ensures this (see zutil.c). To reduce memory requirements and avoid
- any allocation of 64K objects, at the expense of compression ratio, compile
- the library with -DMAX_WBITS=14 (see zconf.h).
-
- The fields total_in and total_out can be used for statistics or progress
- reports. After compression, total_in holds the total size of the
- uncompressed data and may be saved for use in the decompressor (particularly
- if the decompressor wants to decompress everything in a single step).
-*/
-
- /* constants */
-
-#define Z_NO_FLUSH 0
-#define Z_PARTIAL_FLUSH 1
-#define Z_SYNC_FLUSH 2
-#define Z_FULL_FLUSH 3
-#define Z_FINISH 4
-#define Z_BLOCK 5
-#define Z_TREES 6
-/* Allowed flush values; see deflate() and inflate() below for details */
-
-#define Z_OK 0
-#define Z_STREAM_END 1
-#define Z_NEED_DICT 2
-#define Z_ERRNO (-1)
-#define Z_STREAM_ERROR (-2)
-#define Z_DATA_ERROR (-3)
-#define Z_MEM_ERROR (-4)
-#define Z_BUF_ERROR (-5)
-#define Z_VERSION_ERROR (-6)
-/* Return codes for the compression/decompression functions. Negative values
- * are errors, positive values are used for special but normal events.
- */
-
-#define Z_NO_COMPRESSION 0
-#define Z_BEST_SPEED 1
-#define Z_BEST_COMPRESSION 9
-#define Z_DEFAULT_COMPRESSION (-1)
-/* compression levels */
-
-#define Z_FILTERED 1
-#define Z_HUFFMAN_ONLY 2
-#define Z_RLE 3
-#define Z_FIXED 4
-#define Z_DEFAULT_STRATEGY 0
-/* compression strategy; see deflateInit2() below for details */
-
-#define Z_BINARY 0
-#define Z_TEXT 1
-#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
-#define Z_UNKNOWN 2
-/* Possible values of the data_type field (though see inflate()) */
-
-#define Z_DEFLATED 8
-/* The deflate compression method (the only one supported in this version) */
-
-#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
-
-#define zlib_version zlibVersion()
-/* for compatibility with versions < 1.0.2 */
-
-
- /* basic functions */
-
-ZEXTERN const char * ZEXPORT zlibVersion OF((void));
-/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
- If the first character differs, the library code actually used is not
- compatible with the zlib.h header file used by the application. This check
- is automatically made by deflateInit and inflateInit.
- */
-
-/*
-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
-
- Initializes the internal stream state for compression. The fields
- zalloc, zfree and opaque must be initialized before by the caller. If
- zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
- allocation functions.
-
- The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
- 1 gives best speed, 9 gives best compression, 0 gives no compression at all
- (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION
- requests a default compromise between speed and compression (currently
- equivalent to level 6).
-
- deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if level is not a valid compression level, or
- Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
- with the version assumed by the caller (ZLIB_VERSION). msg is set to null
- if there is no error message. deflateInit does not perform any compression:
- this will be done by deflate().
-*/
-
-
-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
-/*
- deflate compresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce
- some output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. deflate performs one or both of the
- following actions:
-
- - Compress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in and avail_in are updated and
- processing will resume at this point for the next call of deflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. This action is forced if the parameter flush is non zero.
- Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications). Some
- output may be provided even if flush is not set.
-
- Before the call of deflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming more
- output, and updating avail_in or avail_out accordingly; avail_out should
- never be zero before the call. The application can consume the compressed
- output when it wants, for example when the output buffer is full (avail_out
- == 0), or after each call of deflate(). If deflate returns Z_OK and with
- zero avail_out, it must be called again after making room in the output
- buffer because there might be more output pending.
-
- Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
- decide how much data to accumulate before producing output, in order to
- maximize compression.
-
- If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
- flushed to the output buffer and the output is aligned on a byte boundary, so
- that the decompressor can get all input data available so far. (In
- particular avail_in is zero after the call if enough output space has been
- provided before the call.) Flushing may degrade compression for some
- compression algorithms and so it should be used only when necessary. This
- completes the current deflate block and follows it with an empty stored block
- that is three bits plus filler bits to the next byte, followed by four bytes
- (00 00 ff ff).
-
- If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
- output buffer, but the output is not aligned to a byte boundary. All of the
- input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
- This completes the current deflate block and follows it with an empty fixed
- codes block that is 10 bits long. This assures that enough bytes are output
- in order for the decompressor to finish the block before the empty fixed code
- block.
-
- If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
- for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
- seven bits of the current block are held to be written as the next byte after
- the next deflate block is completed. In this case, the decompressor may not
- be provided enough bits at this point in order to complete decompression of
- the data provided so far to the compressor. It may need to wait for the next
- block to be emitted. This is for advanced applications that need to control
- the emission of deflate blocks.
-
- If flush is set to Z_FULL_FLUSH, all output is flushed as with
- Z_SYNC_FLUSH, and the compression state is reset so that decompression can
- restart from this point if previous compressed data has been damaged or if
- random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
- compression.
-
- If deflate returns with avail_out == 0, this function must be called again
- with the same value of the flush parameter and more output space (updated
- avail_out), until the flush is complete (deflate returns with non-zero
- avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
- avail_out is greater than six to avoid repeated flush markers due to
- avail_out == 0 on return.
-
- If the parameter flush is set to Z_FINISH, pending input is processed,
- pending output is flushed and deflate returns with Z_STREAM_END if there was
- enough output space; if deflate returns with Z_OK, this function must be
- called again with Z_FINISH and more output space (updated avail_out) but no
- more input data, until it returns with Z_STREAM_END or an error. After
- deflate has returned Z_STREAM_END, the only possible operations on the stream
- are deflateReset or deflateEnd.
-
- Z_FINISH can be used immediately after deflateInit if all the compression
- is to be done in a single step. In this case, avail_out must be at least the
- value returned by deflateBound (see below). Then deflate is guaranteed to
- return Z_STREAM_END. If not enough output space is provided, deflate will
- not return Z_STREAM_END, and it must be called again as described above.
-
- deflate() sets strm->adler to the adler32 checksum of all input read
- so far (that is, total_in bytes).
-
- deflate() may update strm->data_type if it can make a good guess about
- the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect the
- compression algorithm in any manner.
-
- deflate() returns Z_OK if some progress has been made (more input
- processed or more output produced), Z_STREAM_END if all input has been
- consumed and all output has been produced (only when flush is set to
- Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
- (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
- fatal, and deflate() can be called again with more input and more output
- space to continue compressing.
-*/
-
-
-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any pending
- output.
-
- deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
- stream state was inconsistent, Z_DATA_ERROR if the stream was freed
- prematurely (some input or output was discarded). In the error case, msg
- may be set but then points to a static string (which must not be
- deallocated).
-*/
-
-
-/*
-ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
-
- Initializes the internal stream state for decompression. The fields
- next_in, avail_in, zalloc, zfree and opaque must be initialized before by
- the caller. If next_in is not Z_NULL and avail_in is large enough (the
- exact value depends on the compression method), inflateInit determines the
- compression method from the zlib header and allocates all data structures
- accordingly; otherwise the allocation will be deferred to the first call of
- inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
- use default allocation functions.
-
- inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
- version assumed by the caller, or Z_STREAM_ERROR if the parameters are
- invalid, such as a null pointer to the structure. msg is set to null if
- there is no error message. inflateInit does not perform any decompression
- apart from possibly reading the zlib header if present: actual decompression
- will be done by inflate(). (So next_in and avail_in may be modified, but
- next_out and avail_out are unused and unchanged.) The current implementation
- of inflateInit() does not process any header information -- that is deferred
- until inflate() is called.
-*/
-
-
-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
-/*
- inflate decompresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce
- some output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. inflate performs one or both of the
- following actions:
-
- - Decompress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing will
- resume at this point for the next call of inflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. inflate() provides as much output as possible, until there is
- no more input data or no more space in the output buffer (see below about
- the flush parameter).
-
- Before the call of inflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming more
- output, and updating the next_* and avail_* values accordingly. The
- application can consume the uncompressed output when it wants, for example
- when the output buffer is full (avail_out == 0), or after each call of
- inflate(). If inflate returns Z_OK and with zero avail_out, it must be
- called again after making room in the output buffer because there might be
- more output pending.
-
- The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
- Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much
- output as possible to the output buffer. Z_BLOCK requests that inflate()
- stop if and when it gets to the next deflate block boundary. When decoding
- the zlib or gzip format, this will cause inflate() to return immediately
- after the header and before the first block. When doing a raw inflate,
- inflate() will go ahead and process the first block, and will return when it
- gets to the end of that block, or when it runs out of data.
-
- The Z_BLOCK option assists in appending to or combining deflate streams.
- Also to assist in this, on return inflate() will set strm->data_type to the
- number of unused bits in the last byte taken from strm->next_in, plus 64 if
- inflate() is currently decoding the last block in the deflate stream, plus
- 128 if inflate() returned immediately after decoding an end-of-block code or
- decoding the complete header up to just before the first byte of the deflate
- stream. The end-of-block will not be indicated until all of the uncompressed
- data from that block has been written to strm->next_out. The number of
- unused bits may in general be greater than seven, except when bit 7 of
- data_type is set, in which case the number of unused bits will be less than
- eight. data_type is set as noted here every time inflate() returns for all
- flush options, and so can be used to determine the amount of currently
- consumed input in bits.
-
- The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
- end of each deflate block header is reached, before any actual data in that
- block is decoded. This allows the caller to determine the length of the
- deflate block header for later use in random access within a deflate block.
- 256 is added to the value of strm->data_type when inflate() returns
- immediately after reaching the end of the deflate block header.
-
- inflate() should normally be called until it returns Z_STREAM_END or an
- error. However if all decompression is to be performed in a single step (a
- single call of inflate), the parameter flush should be set to Z_FINISH. In
- this case all pending input is processed and all pending output is flushed;
- avail_out must be large enough to hold all of the uncompressed data for the
- operation to complete. (The size of the uncompressed data may have been
- saved by the compressor for this purpose.) The use of Z_FINISH is not
- required to perform an inflation in one step. However it may be used to
- inform inflate that a faster approach can be used for the single inflate()
- call. Z_FINISH also informs inflate to not maintain a sliding window if the
- stream completes, which reduces inflate's memory footprint. If the stream
- does not complete, either because not all of the stream is provided or not
- enough output space is provided, then a sliding window will be allocated and
- inflate() can be called again to continue the operation as if Z_NO_FLUSH had
- been used.
-
- In this implementation, inflate() always flushes as much output as
- possible to the output buffer, and always uses the faster approach on the
- first call. So the effects of the flush parameter in this implementation are
- on the return value of inflate() as noted below, when inflate() returns early
- when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
- memory for a sliding window when Z_FINISH is used.
-
- If a preset dictionary is needed after this call (see inflateSetDictionary
- below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
- chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
- strm->adler to the Adler-32 checksum of all output produced so far (that is,
- total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
- below. At the end of the stream, inflate() checks that its computed adler32
- checksum is equal to that saved by the compressor and returns Z_STREAM_END
- only if the checksum is correct.
-
- inflate() can decompress and check either zlib-wrapped or gzip-wrapped
- deflate data. The header type is detected automatically, if requested when
- initializing with inflateInit2(). Any information contained in the gzip
- header is not retained, so applications that need that information should
- instead use raw inflate, see inflateInit2() below, or inflateBack() and
- perform their own processing of the gzip header and trailer. When processing
- gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
- producted so far. The CRC-32 is checked against the gzip trailer.
-
- inflate() returns Z_OK if some progress has been made (more input processed
- or more output produced), Z_STREAM_END if the end of the compressed data has
- been reached and all uncompressed output has been produced, Z_NEED_DICT if a
- preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
- corrupted (input stream not conforming to the zlib format or incorrect check
- value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
- next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
- Z_BUF_ERROR if no progress is possible or if there was not enough room in the
- output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
- inflate() can be called again with more input and more output space to
- continue decompressing. If Z_DATA_ERROR is returned, the application may
- then call inflateSync() to look for a good compression block if a partial
- recovery of the data is desired.
-*/
-
-
-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any pending
- output.
-
- inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
- static string (which must not be deallocated).
-*/
-
-
- /* Advanced functions */
-
-/*
- The following functions are needed only in some special applications.
-*/
-
-/*
-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
- int level,
- int method,
- int windowBits,
- int memLevel,
- int strategy));
-
- This is another version of deflateInit with more compression options. The
- fields next_in, zalloc, zfree and opaque must be initialized before by the
- caller.
-
- The method parameter is the compression method. It must be Z_DEFLATED in
- this version of the library.
-
- The windowBits parameter is the base two logarithm of the window size
- (the size of the history buffer). It should be in the range 8..15 for this
- version of the library. Larger values of this parameter result in better
- compression at the expense of memory usage. The default value is 15 if
- deflateInit is used instead.
-
- windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
- determines the window size. deflate() will then generate raw deflate data
- with no zlib header or trailer, and will not compute an adler32 check value.
-
- windowBits can also be greater than 15 for optional gzip encoding. Add
- 16 to windowBits to write a simple gzip header and trailer around the
- compressed data instead of a zlib wrapper. The gzip header will have no
- file name, no extra data, no comment, no modification time (set to zero), no
- header crc, and the operating system will be set to 255 (unknown). If a
- gzip stream is being written, strm->adler is a crc32 instead of an adler32.
-
- The memLevel parameter specifies how much memory should be allocated
- for the internal compression state. memLevel=1 uses minimum memory but is
- slow and reduces compression ratio; memLevel=9 uses maximum memory for
- optimal speed. The default value is 8. See zconf.h for total memory usage
- as a function of windowBits and memLevel.
-
- The strategy parameter is used to tune the compression algorithm. Use the
- value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
- filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
- string match), or Z_RLE to limit match distances to one (run-length
- encoding). Filtered data consists mostly of small values with a somewhat
- random distribution. In this case, the compression algorithm is tuned to
- compress them better. The effect of Z_FILTERED is to force more Huffman
- coding and less string matching; it is somewhat intermediate between
- Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as
- fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The
- strategy parameter only affects the compression ratio but not the
- correctness of the compressed output even if it is not set appropriately.
- Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
- decoder for special applications.
-
- deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
- method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
- incompatible with the version assumed by the caller (ZLIB_VERSION). msg is
- set to null if there is no error message. deflateInit2 does not perform any
- compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the compression dictionary from the given byte sequence
- without producing any compressed output. When using the zlib format, this
- function must be called immediately after deflateInit, deflateInit2 or
- deflateReset, and before any call of deflate. When doing raw deflate, this
- function must be called either before any call of deflate, or immediately
- after the completion of a deflate block, i.e. after all input has been
- consumed and all output has been delivered when using any of the flush
- options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The
- compressor and decompressor must use exactly the same dictionary (see
- inflateSetDictionary).
-
- The dictionary should consist of strings (byte sequences) that are likely
- to be encountered later in the data to be compressed, with the most commonly
- used strings preferably put towards the end of the dictionary. Using a
- dictionary is most useful when the data to be compressed is short and can be
- predicted with good accuracy; the data can then be compressed better than
- with the default empty dictionary.
-
- Depending on the size of the compression data structures selected by
- deflateInit or deflateInit2, a part of the dictionary may in effect be
- discarded, for example if the dictionary is larger than the window size
- provided in deflateInit or deflateInit2. Thus the strings most likely to be
- useful should be put at the end of the dictionary, not at the front. In
- addition, the current implementation of deflate will use at most the window
- size minus 262 bytes of the provided dictionary.
-
- Upon return of this function, strm->adler is set to the adler32 value
- of the dictionary; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The adler32 value
- applies to the whole dictionary even if only a subset of the dictionary is
- actually used by the compressor.) If a raw deflate was requested, then the
- adler32 value is not computed and strm->adler is not set.
-
- deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
- parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
- inconsistent (for example if deflate has already been called for this stream
- or if not at a block boundary for raw deflate). deflateSetDictionary does
- not perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when several compression strategies will be
- tried, for example when there are several ways of pre-processing the input
- data with a filter. The streams that will be discarded should then be freed
- by calling deflateEnd. Note that deflateCopy duplicates the internal
- compression state which can be quite large, so this strategy is slow and can
- consume lots of memory.
-
- deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being Z_NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
-/*
- This function is equivalent to deflateEnd followed by deflateInit,
- but does not free and reallocate all the internal compression state. The
- stream will keep the same compression level and any other attributes that
- may have been set by deflateInit2.
-
- deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being Z_NULL).
-*/
-
-ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
- int level,
- int strategy));
-/*
- Dynamically update the compression level and compression strategy. The
- interpretation of level and strategy is as in deflateInit2. This can be
- used to switch between compression and straight copy of the input data, or
- to switch to a different kind of input data requiring a different strategy.
- If the compression level is changed, the input available so far is
- compressed with the old level (and may be flushed); the new level will take
- effect only at the next call of deflate().
-
- Before the call of deflateParams, the stream state must be set as for
- a call of deflate(), since the currently available input may have to be
- compressed and flushed. In particular, strm->avail_out must be non-zero.
-
- deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
- stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
- strm->avail_out was zero.
-*/
-
-ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
- int good_length,
- int max_lazy,
- int nice_length,
- int max_chain));
-/*
- Fine tune deflate's internal compression parameters. This should only be
- used by someone who understands the algorithm used by zlib's deflate for
- searching for the best matching string, and even then only by the most
- fanatic optimizer trying to squeeze out the last compressed bit for their
- specific input data. Read the deflate.c source code for the meaning of the
- max_lazy, good_length, nice_length, and max_chain parameters.
-
- deflateTune() can be called after deflateInit() or deflateInit2(), and
- returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
- */
-
-ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
- uLong sourceLen));
-/*
- deflateBound() returns an upper bound on the compressed size after
- deflation of sourceLen bytes. It must be called after deflateInit() or
- deflateInit2(), and after deflateSetHeader(), if used. This would be used
- to allocate an output buffer for deflation in a single pass, and so would be
- called before deflate(). If that first deflate() call is provided the
- sourceLen input bytes, an output buffer allocated to the size returned by
- deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
- to return Z_STREAM_END. Note that it is possible for the compressed size to
- be larger than the value returned by deflateBound() if flush options other
- than Z_FINISH or Z_NO_FLUSH are used.
-*/
-
-ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
- unsigned *pending,
- int *bits));
-/*
- deflatePending() returns the number of bytes and bits of output that have
- been generated, but not yet provided in the available output. The bytes not
- provided would be due to the available output space having being consumed.
- The number of bits of output not provided are between 0 and 7, where they
- await more bits to join them in order to fill out a full byte. If pending
- or bits are Z_NULL, then those values are not set.
-
- deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
- */
-
-ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
- int bits,
- int value));
-/*
- deflatePrime() inserts bits in the deflate output stream. The intent
- is that this function is used to start off the deflate output with the bits
- leftover from a previous deflate stream when appending to it. As such, this
- function can only be used for raw deflate, and must be used before the first
- deflate() call after a deflateInit2() or deflateReset(). bits must be less
- than or equal to 16, and that many of the least significant bits of value
- will be inserted in the output.
-
- deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough
- room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the
- source stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
- gz_headerp head));
-/*
- deflateSetHeader() provides gzip header information for when a gzip
- stream is requested by deflateInit2(). deflateSetHeader() may be called
- after deflateInit2() or deflateReset() and before the first call of
- deflate(). The text, time, os, extra field, name, and comment information
- in the provided gz_header structure are written to the gzip header (xflag is
- ignored -- the extra flags are set according to the compression level). The
- caller must assure that, if not Z_NULL, name and comment are terminated with
- a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
- available there. If hcrc is true, a gzip header crc is included. Note that
- the current versions of the command-line version of gzip (up through version
- 1.3.x) do not support header crc's, and will report that it is a "multi-part
- gzip file" and give up.
-
- If deflateSetHeader is not used, the default gzip header has text false,
- the time set to zero, and os set to 255, with no extra, name, or comment
- fields. The gzip header is returned to the default state by deflateReset().
-
- deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
- int windowBits));
-
- This is another version of inflateInit with an extra parameter. The
- fields next_in, avail_in, zalloc, zfree and opaque must be initialized
- before by the caller.
-
- The windowBits parameter is the base two logarithm of the maximum window
- size (the size of the history buffer). It should be in the range 8..15 for
- this version of the library. The default value is 15 if inflateInit is used
- instead. windowBits must be greater than or equal to the windowBits value
- provided to deflateInit2() while compressing, or it must be equal to 15 if
- deflateInit2() was not used. If a compressed stream with a larger window
- size is given as input, inflate() will return with the error code
- Z_DATA_ERROR instead of trying to allocate a larger window.
-
- windowBits can also be zero to request that inflate use the window size in
- the zlib header of the compressed stream.
-
- windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
- determines the window size. inflate() will then process raw deflate data,
- not looking for a zlib or gzip header, not generating a check value, and not
- looking for any check values for comparison at the end of the stream. This
- is for use with other formats that use the deflate compressed data format
- such as zip. Those formats provide their own check values. If a custom
- format is developed using the raw deflate format for compressed data, it is
- recommended that a check value such as an adler32 or a crc32 be applied to
- the uncompressed data as is done in the zlib, gzip, and zip formats. For
- most applications, the zlib format should be used as is. Note that comments
- above on the use in deflateInit2() applies to the magnitude of windowBits.
-
- windowBits can also be greater than 15 for optional gzip decoding. Add
- 32 to windowBits to enable zlib and gzip decoding with automatic header
- detection, or add 16 to decode only the gzip format (the zlib format will
- return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
- crc32 instead of an adler32.
-
- inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
- version assumed by the caller, or Z_STREAM_ERROR if the parameters are
- invalid, such as a null pointer to the structure. msg is set to null if
- there is no error message. inflateInit2 does not perform any decompression
- apart from possibly reading the zlib header if present: actual decompression
- will be done by inflate(). (So next_in and avail_in may be modified, but
- next_out and avail_out are unused and unchanged.) The current implementation
- of inflateInit2() does not process any header information -- that is
- deferred until inflate() is called.
-*/
-
-ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the decompression dictionary from the given uncompressed byte
- sequence. This function must be called immediately after a call of inflate,
- if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
- can be determined from the adler32 value returned by that call of inflate.
- The compressor and decompressor must use exactly the same dictionary (see
- deflateSetDictionary). For raw inflate, this function can be called at any
- time to set the dictionary. If the provided dictionary is smaller than the
- window and there is already data in the window, then the provided dictionary
- will amend what's there. The application must insure that the dictionary
- that was used for compression is provided.
-
- inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
- parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
- inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
- expected one (incorrect adler32 value). inflateSetDictionary does not
- perform any decompression: this will be done by subsequent calls of
- inflate().
-*/
-
-ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
- Bytef *dictionary,
- uInt *dictLength));
-/*
- Returns the sliding dictionary being maintained by inflate. dictLength is
- set to the number of bytes in the dictionary, and that many bytes are copied
- to dictionary. dictionary must have enough space, where 32768 bytes is
- always enough. If inflateGetDictionary() is called with dictionary equal to
- Z_NULL, then only the dictionary length is returned, and nothing is copied.
- Similary, if dictLength is Z_NULL, then it is not set.
-
- inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
- stream state is inconsistent.
-*/
-
-ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
-/*
- Skips invalid compressed data until a possible full flush point (see above
- for the description of deflate with Z_FULL_FLUSH) can be found, or until all
- available input is skipped. No output is provided.
-
- inflateSync searches for a 00 00 FF FF pattern in the compressed data.
- All full flush points have this pattern, but not all occurrences of this
- pattern are full flush points.
-
- inflateSync returns Z_OK if a possible full flush point has been found,
- Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
- has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
- In the success case, the application may save the current current value of
- total_in which indicates where valid compressed data was found. In the
- error case, the application may repeatedly call inflateSync, providing more
- input each time, until success or end of the input data.
-*/
-
-ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when randomly accessing a large stream. The
- first pass through the stream can periodically record the inflate state,
- allowing restarting inflate at those points when randomly accessing the
- stream.
-
- inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being Z_NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
-/*
- This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state. The
- stream will keep attributes that may have been set by inflateInit2.
-
- inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being Z_NULL).
-*/
-
-ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
- int windowBits));
-/*
- This function is the same as inflateReset, but it also permits changing
- the wrap and window size requests. The windowBits parameter is interpreted
- the same as it is for inflateInit2.
-
- inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being Z_NULL), or if
- the windowBits parameter is invalid.
-*/
-
-ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
- int bits,
- int value));
-/*
- This function inserts bits in the inflate input stream. The intent is
- that this function is used to start inflating at a bit position in the
- middle of a byte. The provided bits will be used before any bytes are used
- from next_in. This function should only be used with raw inflate, and
- should be used before the first inflate() call after inflateInit2() or
- inflateReset(). bits must be less than or equal to 16, and that many of the
- least significant bits of value will be inserted in the input.
-
- If bits is negative, then the input stream bit buffer is emptied. Then
- inflatePrime() can be called again to put bits in the buffer. This is used
- to clear out bits leftover after feeding inflate a block description prior
- to feeding inflate codes.
-
- inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
-/*
- This function returns two values, one in the lower 16 bits of the return
- value, and the other in the remaining upper bits, obtained by shifting the
- return value down 16 bits. If the upper value is -1 and the lower value is
- zero, then inflate() is currently decoding information outside of a block.
- If the upper value is -1 and the lower value is non-zero, then inflate is in
- the middle of a stored block, with the lower value equaling the number of
- bytes from the input remaining to copy. If the upper value is not -1, then
- it is the number of bits back from the current bit position in the input of
- the code (literal or length/distance pair) currently being processed. In
- that case the lower value is the number of bytes already emitted for that
- code.
-
- A code is being processed if inflate is waiting for more input to complete
- decoding of the code, or if it has completed decoding but is waiting for
- more output space to write the literal or match data.
-
- inflateMark() is used to mark locations in the input data for random
- access, which may be at bit positions, and to note those cases where the
- output of a code may span boundaries of random access blocks. The current
- location in the input stream can be determined from avail_in and data_type
- as noted in the description for the Z_BLOCK flush parameter for inflate.
-
- inflateMark returns the value noted above or -1 << 16 if the provided
- source stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
- gz_headerp head));
-/*
- inflateGetHeader() requests that gzip header information be stored in the
- provided gz_header structure. inflateGetHeader() may be called after
- inflateInit2() or inflateReset(), and before the first call of inflate().
- As inflate() processes the gzip stream, head->done is zero until the header
- is completed, at which time head->done is set to one. If a zlib stream is
- being decoded, then head->done is set to -1 to indicate that there will be
- no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be
- used to force inflate() to return immediately after header processing is
- complete and before any actual data is decompressed.
-
- The text, time, xflags, and os fields are filled in with the gzip header
- contents. hcrc is set to true if there is a header CRC. (The header CRC
- was valid if done is set to one.) If extra is not Z_NULL, then extra_max
- contains the maximum number of bytes to write to extra. Once done is true,
- extra_len contains the actual extra field length, and extra contains the
- extra field, or that field truncated if extra_max is less than extra_len.
- If name is not Z_NULL, then up to name_max characters are written there,
- terminated with a zero unless the length is greater than name_max. If
- comment is not Z_NULL, then up to comm_max characters are written there,
- terminated with a zero unless the length is greater than comm_max. When any
- of extra, name, or comment are not Z_NULL and the respective field is not
- present in the header, then that field is set to Z_NULL to signal its
- absence. This allows the use of deflateSetHeader() with the returned
- structure to duplicate the header. However if those fields are set to
- allocated memory, then the application will need to save those pointers
- elsewhere so that they can be eventually freed.
-
- If inflateGetHeader is not used, then the header information is simply
- discarded. The header is always checked for validity, including the header
- CRC if present. inflateReset() will reset the process to discard the header
- information. The application would need to call inflateGetHeader() again to
- retrieve the header from the next gzip stream.
-
- inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
- unsigned char FAR *window));
-
- Initialize the internal stream state for decompression using inflateBack()
- calls. The fields zalloc, zfree and opaque in strm must be initialized
- before the call. If zalloc and zfree are Z_NULL, then the default library-
- derived memory allocation routines are used. windowBits is the base two
- logarithm of the window size, in the range 8..15. window is a caller
- supplied buffer of that size. Except for special applications where it is
- assured that deflate was used with small window sizes, windowBits must be 15
- and a 32K byte window must be supplied to be able to decompress general
- deflate streams.
-
- See inflateBack() for the usage of these routines.
-
- inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
- the parameters are invalid, Z_MEM_ERROR if the internal state could not be
- allocated, or Z_VERSION_ERROR if the version of the library does not match
- the version of the header file.
-*/
-
-typedef unsigned (*in_func) OF((void FAR *,
- z_const unsigned char FAR * FAR *));
-typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
-
-ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
- in_func in, void FAR *in_desc,
- out_func out, void FAR *out_desc));
-/*
- inflateBack() does a raw inflate with a single call using a call-back
- interface for input and output. This is potentially more efficient than
- inflate() for file i/o applications, in that it avoids copying between the
- output and the sliding window by simply making the window itself the output
- buffer. inflate() can be faster on modern CPUs when used with large
- buffers. inflateBack() trusts the application to not change the output
- buffer passed by the output function, at least until inflateBack() returns.
-
- inflateBackInit() must be called first to allocate the internal state
- and to initialize the state with the user-provided window buffer.
- inflateBack() may then be used multiple times to inflate a complete, raw
- deflate stream with each call. inflateBackEnd() is then called to free the
- allocated state.
-
- A raw deflate stream is one with no zlib or gzip header or trailer.
- This routine would normally be used in a utility that reads zip or gzip
- files and writes out uncompressed files. The utility would decode the
- header and process the trailer on its own, hence this routine expects only
- the raw deflate stream to decompress. This is different from the normal
- behavior of inflate(), which expects either a zlib or gzip header and
- trailer around the deflate stream.
-
- inflateBack() uses two subroutines supplied by the caller that are then
- called by inflateBack() for input and output. inflateBack() calls those
- routines until it reads a complete deflate stream and writes out all of the
- uncompressed data, or until it encounters an error. The function's
- parameters and return types are defined above in the in_func and out_func
- typedefs. inflateBack() will call in(in_desc, &buf) which should return the
- number of bytes of provided input, and a pointer to that input in buf. If
- there is no input available, in() must return zero--buf is ignored in that
- case--and inflateBack() will return a buffer error. inflateBack() will call
- out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
- should return zero on success, or non-zero on failure. If out() returns
- non-zero, inflateBack() will return with an error. Neither in() nor out()
- are permitted to change the contents of the window provided to
- inflateBackInit(), which is also the buffer that out() uses to write from.
- The length written by out() will be at most the window size. Any non-zero
- amount of input may be provided by in().
-
- For convenience, inflateBack() can be provided input on the first call by
- setting strm->next_in and strm->avail_in. If that input is exhausted, then
- in() will be called. Therefore strm->next_in must be initialized before
- calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
- immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
- must also be initialized, and then if strm->avail_in is not zero, input will
- initially be taken from strm->next_in[0 .. strm->avail_in - 1].
-
- The in_desc and out_desc parameters of inflateBack() is passed as the
- first parameter of in() and out() respectively when they are called. These
- descriptors can be optionally used to pass any information that the caller-
- supplied in() and out() functions need to do their job.
-
- On return, inflateBack() will set strm->next_in and strm->avail_in to
- pass back any unused input that was provided by the last in() call. The
- return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
- if in() or out() returned an error, Z_DATA_ERROR if there was a format error
- in the deflate stream (in which case strm->msg is set to indicate the nature
- of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
- In the case of Z_BUF_ERROR, an input or output error can be distinguished
- using strm->next_in which will be Z_NULL only if in() returned an error. If
- strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
- non-zero. (in() will always be called before out(), so strm->next_in is
- assured to be defined if out() returns non-zero.) Note that inflateBack()
- cannot return Z_OK.
-*/
-
-ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
-/*
- All memory allocated by inflateBackInit() is freed.
-
- inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
- state was inconsistent.
-*/
-
-ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
-/* Return flags indicating compile-time options.
-
- Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
- 1.0: size of uInt
- 3.2: size of uLong
- 5.4: size of voidpf (pointer)
- 7.6: size of z_off_t
-
- Compiler, assembler, and debug options:
- 8: DEBUG
- 9: ASMV or ASMINF -- use ASM code
- 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
- 11: 0 (reserved)
-
- One-time table building (smaller code, but not thread-safe if true):
- 12: BUILDFIXED -- build static block decoding tables when needed
- 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
- 14,15: 0 (reserved)
-
- Library content (indicates missing functionality):
- 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
- deflate code when not needed)
- 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
- and decode gzip streams (to avoid linking crc code)
- 18-19: 0 (reserved)
-
- Operation variations (changes in library functionality):
- 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
- 21: FASTEST -- deflate algorithm with only one, lowest compression level
- 22,23: 0 (reserved)
-
- The sprintf variant used by gzprintf (zero is best):
- 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
- 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
- 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
-
- Remainder:
- 27-31: 0 (reserved)
- */
-
-#ifndef Z_SOLO
-
- /* utility functions */
-
-/*
- The following utility functions are implemented on top of the basic
- stream-oriented functions. To simplify the interface, some default options
- are assumed (compression level and memory usage, standard memory allocation
- functions). The source code of these utility functions can be modified if
- you need special options.
-*/
-
-ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total size
- of the destination buffer, which must be at least the value returned by
- compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
-
- compress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer.
-*/
-
-ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen,
- int level));
-/*
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least the value returned by
- compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
-
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_BUF_ERROR if there was not enough room in the output buffer,
- Z_STREAM_ERROR if the level parameter is invalid.
-*/
-
-ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
-/*
- compressBound() returns an upper bound on the compressed size after
- compress() or compress2() on sourceLen bytes. It would be used before a
- compress() or compress2() call to allocate the destination buffer.
-*/
-
-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total size
- of the destination buffer, which must be large enough to hold the entire
- uncompressed data. (The size of the uncompressed data must have been saved
- previously by the compressor and transmitted to the decompressor by some
- mechanism outside the scope of this compression library.) Upon exit, destLen
- is the actual size of the uncompressed buffer.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In
- the case where there is not enough room, uncompress() will fill the output
- buffer with the uncompressed data up to that point.
-*/
-
- /* gzip file access functions */
-
-/*
- This library supports reading and writing files in gzip (.gz) format with
- an interface similar to that of stdio, using the functions that start with
- "gz". The gzip format is different from the zlib format. gzip is a gzip
- wrapper, documented in RFC 1952, wrapped around a deflate stream.
-*/
-
-typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
-
-/*
-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
-
- Opens a gzip (.gz) file for reading or writing. The mode parameter is as
- in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
- a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
- compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
- for fixed code compression as in "wb9F". (See the description of
- deflateInit2 for more information about the strategy parameter.) 'T' will
- request transparent writing or appending with no compression and not using
- the gzip format.
-
- "a" can be used instead of "w" to request that the gzip stream that will
- be written be appended to the file. "+" will result in an error, since
- reading and writing to the same gzip file is not supported. The addition of
- "x" when writing will create the file exclusively, which fails if the file
- already exists. On systems that support it, the addition of "e" when
- reading or writing will set the flag to close the file on an execve() call.
-
- These functions, as well as gzip, will read and decode a sequence of gzip
- streams in a file. The append function of gzopen() can be used to create
- such a file. (Also see gzflush() for another way to do this.) When
- appending, gzopen does not test whether the file begins with a gzip stream,
- nor does it look for the end of the gzip streams to begin appending. gzopen
- will simply append a gzip stream to the existing file.
-
- gzopen can be used to read a file which is not in gzip format; in this
- case gzread will directly read from the file without decompression. When
- reading, this will be detected automatically by looking for the magic two-
- byte gzip header.
-
- gzopen returns NULL if the file could not be opened, if there was
- insufficient memory to allocate the gzFile state, or if an invalid mode was
- specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
- errno can be checked to determine if the reason gzopen failed was that the
- file could not be opened.
-*/
-
-ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
-/*
- gzdopen associates a gzFile with the file descriptor fd. File descriptors
- are obtained from calls like open, dup, creat, pipe or fileno (if the file
- has been previously opened with fopen). The mode parameter is as in gzopen.
-
- The next call of gzclose on the returned gzFile will also close the file
- descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
- fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
- mode);. The duplicated descriptor should be saved to avoid a leak, since
- gzdopen does not close fd if it fails. If you are using fileno() to get the
- file descriptor from a FILE *, then you will have to use dup() to avoid
- double-close()ing the file descriptor. Both gzclose() and fclose() will
- close the associated file descriptor, so they need to have different file
- descriptors.
-
- gzdopen returns NULL if there was insufficient memory to allocate the
- gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
- provided, or '+' was provided), or if fd is -1. The file descriptor is not
- used until the next gz* read, write, seek, or close operation, so gzdopen
- will not detect if fd is invalid (unless fd is -1).
-*/
-
-ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
-/*
- Set the internal buffer size used by this library's functions. The
- default buffer size is 8192 bytes. This function must be called after
- gzopen() or gzdopen(), and before any other calls that read or write the
- file. The buffer memory allocation is always deferred to the first read or
- write. Two buffers are allocated, either both of the specified size when
- writing, or one of the specified size and the other twice that size when
- reading. A larger buffer size of, for example, 64K or 128K bytes will
- noticeably increase the speed of decompression (reading).
-
- The new buffer size also affects the maximum length for gzprintf().
-
- gzbuffer() returns 0 on success, or -1 on failure, such as being called
- too late.
-*/
-
-ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
-/*
- Dynamically update the compression level or strategy. See the description
- of deflateInit2 for the meaning of these parameters.
-
- gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
- opened for writing.
-*/
-
-ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
-/*
- Reads the given number of uncompressed bytes from the compressed file. If
- the input file is not in gzip format, gzread copies the given number of
- bytes into the buffer directly from the file.
-
- After reaching the end of a gzip stream in the input, gzread will continue
- to read, looking for another gzip stream. Any number of gzip streams may be
- concatenated in the input file, and will all be decompressed by gzread().
- If something other than a gzip stream is encountered after a gzip stream,
- that remaining trailing garbage is ignored (and no error is returned).
-
- gzread can be used to read a gzip file that is being concurrently written.
- Upon reaching the end of the input, gzread will return with the available
- data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then
- gzclearerr can be used to clear the end of file indicator in order to permit
- gzread to be tried again. Z_OK indicates that a gzip stream was completed
- on the last gzread. Z_BUF_ERROR indicates that the input file ended in the
- middle of a gzip stream. Note that gzread does not return -1 in the event
- of an incomplete gzip stream. This error is deferred until gzclose(), which
- will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
- stream. Alternatively, gzerror can be used before gzclose to detect this
- case.
-
- gzread returns the number of uncompressed bytes actually read, less than
- len for end of file, or -1 for error.
-*/
-
-ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
- voidpc buf, unsigned len));
-/*
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of uncompressed bytes written or 0 in case of
- error.
-*/
-
-ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
-/*
- Converts, formats, and writes the arguments to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written, or 0 in case of error. The number of
- uncompressed bytes written is limited to 8191, or one less than the buffer
- size given to gzbuffer(). The caller should assure that this limit is not
- exceeded. If it is exceeded, then gzprintf() will return an error (0) with
- nothing written. In this case, there may also be a buffer overflow with
- unpredictable consequences, which is possible only if zlib was compiled with
- the insecure functions sprintf() or vsprintf() because the secure snprintf()
- or vsnprintf() functions were not available. This can be determined using
- zlibCompileFlags().
-*/
-
-ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
-/*
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
-
- gzputs returns the number of characters written, or -1 in case of error.
-*/
-
-ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
-/*
- Reads bytes from the compressed file until len-1 characters are read, or a
- newline character is read and transferred to buf, or an end-of-file
- condition is encountered. If any characters are read or if len == 1, the
- string is terminated with a null character. If no characters are read due
- to an end-of-file or len < 1, then the buffer is left untouched.
-
- gzgets returns buf which is a null-terminated string, or it returns NULL
- for end-of-file or in case of error. If there was an error, the contents at
- buf are indeterminate.
-*/
-
-ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
-/*
- Writes c, converted to an unsigned char, into the compressed file. gzputc
- returns the value that was written, or -1 in case of error.
-*/
-
-ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
-/*
- Reads one byte from the compressed file. gzgetc returns this byte or -1
- in case of end of file or error. This is implemented as a macro for speed.
- As such, it does not do all of the checking the other functions do. I.e.
- it does not check to see if file is NULL, nor whether the structure file
- points to has been clobbered or not.
-*/
-
-ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
-/*
- Push one character back onto the stream to be read as the first character
- on the next read. At least one character of push-back is allowed.
- gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
- fail if c is -1, and may fail if a character has been pushed but not read
- yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
- output buffer size of pushed characters is allowed. (See gzbuffer above.)
- The pushed character will be discarded if the stream is repositioned with
- gzseek() or gzrewind().
-*/
-
-ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
-/*
- Flushes all pending output into the compressed file. The parameter flush
- is as in the deflate() function. The return value is the zlib error number
- (see function gzerror below). gzflush is only permitted when writing.
-
- If the flush parameter is Z_FINISH, the remaining data is written and the
- gzip stream is completed in the output. If gzwrite() is called again, a new
- gzip stream will be started in the output. gzread() is able to read such
- concatented gzip streams.
-
- gzflush should be called only when strictly necessary because it will
- degrade compression if called too often.
-*/
-
-/*
-ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
- z_off_t offset, int whence));
-
- Sets the starting position for the next gzread or gzwrite on the given
- compressed file. The offset represents a number of bytes in the
- uncompressed data stream. The whence parameter is defined as in lseek(2);
- the value SEEK_END is not supported.
-
- If the file is opened for reading, this function is emulated but can be
- extremely slow. If the file is opened for writing, only forward seeks are
- supported; gzseek then compresses a sequence of zeroes up to the new
- starting position.
-
- gzseek returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error, in
- particular if the file is opened for writing and the new starting position
- would be before the current position.
-*/
-
-ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
-/*
- Rewinds the given file. This function is supported only for reading.
-
- gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
-*/
-
-/*
-ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
-
- Returns the starting position for the next gzread or gzwrite on the given
- compressed file. This position represents a number of bytes in the
- uncompressed data stream, and is zero when starting, even if appending or
- reading a gzip stream from the middle of a file using gzdopen().
-
- gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
-*/
-
-/*
-ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
-
- Returns the current offset in the file being read or written. This offset
- includes the count of bytes that precede the gzip stream, for example when
- appending or when using gzdopen() for reading. When reading, the offset
- does not include as yet unused buffered input. This information can be used
- for a progress indicator. On error, gzoffset() returns -1.
-*/
-
-ZEXTERN int ZEXPORT gzeof OF((gzFile file));
-/*
- Returns true (1) if the end-of-file indicator has been set while reading,
- false (0) otherwise. Note that the end-of-file indicator is set only if the
- read tried to go past the end of the input, but came up short. Therefore,
- just like feof(), gzeof() may return false even if there is no more data to
- read, in the event that the last read request was for the exact number of
- bytes remaining in the input file. This will happen if the input file size
- is an exact multiple of the buffer size.
-
- If gzeof() returns true, then the read functions will return no more data,
- unless the end-of-file indicator is reset by gzclearerr() and the input file
- has grown since the previous end of file was detected.
-*/
-
-ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
-/*
- Returns true (1) if file is being copied directly while reading, or false
- (0) if file is a gzip stream being decompressed.
-
- If the input file is empty, gzdirect() will return true, since the input
- does not contain a gzip stream.
-
- If gzdirect() is used immediately after gzopen() or gzdopen() it will
- cause buffers to be allocated to allow reading the file to determine if it
- is a gzip file. Therefore if gzbuffer() is used, it should be called before
- gzdirect().
-
- When writing, gzdirect() returns true (1) if transparent writing was
- requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note:
- gzdirect() is not needed when writing. Transparent writing must be
- explicitly requested, so the application already knows the answer. When
- linking statically, using gzdirect() will include all of the zlib code for
- gzip file reading and decompression, which may not be desired.)
-*/
-
-ZEXTERN int ZEXPORT gzclose OF((gzFile file));
-/*
- Flushes all pending output if necessary, closes the compressed file and
- deallocates the (de)compression state. Note that once file is closed, you
- cannot call gzerror with file, since its structures have been deallocated.
- gzclose must not be called more than once on the same file, just as free
- must not be called more than once on the same allocation.
-
- gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
- file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the
- last read ended in the middle of a gzip stream, or Z_OK on success.
-*/
-
-ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
-ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
-/*
- Same as gzclose(), but gzclose_r() is only for use when reading, and
- gzclose_w() is only for use when writing or appending. The advantage to
- using these instead of gzclose() is that they avoid linking in zlib
- compression or decompression code that is not used when only reading or only
- writing respectively. If gzclose() is used, then both compression and
- decompression code will be included the application when linking to a static
- zlib library.
-*/
-
-ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
-/*
- Returns the error message for the last error which occurred on the given
- compressed file. errnum is set to zlib error number. If an error occurred
- in the file system and not in the compression library, errnum is set to
- Z_ERRNO and the application may consult errno to get the exact error code.
-
- The application must not modify the returned string. Future calls to
- this function may invalidate the previously returned string. If file is
- closed, then the string previously returned by gzerror will no longer be
- available.
-
- gzerror() should be used to distinguish errors from end-of-file for those
- functions above that do not distinguish those cases in their return values.
-*/
-
-ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
-/*
- Clears the error and end-of-file flags for file. This is analogous to the
- clearerr() function in stdio. This is useful for continuing to read a gzip
- file that is being written concurrently.
-*/
-
-#endif /* !Z_SOLO */
-
- /* checksum functions */
-
-/*
- These functions are not related to compression but are exported
- anyway because they might be useful in applications using the compression
- library.
-*/
-
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
-/*
- Update a running Adler-32 checksum with the bytes buf[0..len-1] and
- return the updated checksum. If buf is Z_NULL, this function returns the
- required initial value for the checksum.
-
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
- much faster.
-
- Usage example:
-
- uLong adler = adler32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- adler = adler32(adler, buffer, length);
- }
- if (adler != original_adler) error();
-*/
-
-/*
-ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
- z_off_t len2));
-
- Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
- and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
- each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
- seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note
- that the z_off_t type (like off_t) is a signed integer. If len2 is
- negative, the result has no meaning or utility.
-*/
-
-ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
-/*
- Update a running CRC-32 with the bytes buf[0..len-1] and return the
- updated CRC-32. If buf is Z_NULL, this function returns the required
- initial value for the crc. Pre- and post-conditioning (one's complement) is
- performed within this function so it shouldn't be done by the application.
-
- Usage example:
-
- uLong crc = crc32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- crc = crc32(crc, buffer, length);
- }
- if (crc != original_crc) error();
-*/
-
-/*
-ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
-
- Combine two CRC-32 check values into one. For two sequences of bytes,
- seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
- calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
- check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
- len2.
-*/
-
-
- /* various hacks, don't look :) */
-
-/* deflateInit and inflateInit are macros to allow checking the zlib version
- * and the compiler's view of z_stream:
- */
-ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
- int windowBits, int memLevel,
- int strategy, const char *version,
- int stream_size));
-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
- unsigned char FAR *window,
- const char *version,
- int stream_size));
-#define deflateInit(strm, level) \
- deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
-#define inflateInit(strm) \
- inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
- (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
- (int)sizeof(z_stream))
-#define inflateBackInit(strm, windowBits, window) \
- inflateBackInit_((strm), (windowBits), (window), \
- ZLIB_VERSION, (int)sizeof(z_stream))
-
-#ifndef Z_SOLO
-
-/* gzgetc() macro and its supporting function and exposed data structure. Note
- * that the real internal state is much larger than the exposed structure.
- * This abbreviated structure exposes just enough for the gzgetc() macro. The
- * user should not mess with these exposed elements, since their names or
- * behavior could change in the future, perhaps even capriciously. They can
- * only be used by the gzgetc() macro. You have been warned.
- */
-struct gzFile_s {
- unsigned have;
- unsigned char *next;
- z_off64_t pos;
-};
-ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
-#ifdef Z_PREFIX_SET
-# undef z_gzgetc
-# define z_gzgetc(g) \
- ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
-#else
-# define gzgetc(g) \
- ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
-#endif
-
-/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
- * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
- * both are true, the application gets the *64 functions, and the regular
- * functions are changed to 64 bits) -- in case these are set on systems
- * without large file support, _LFS64_LARGEFILE must also be true
- */
-#ifdef Z_LARGE64
- ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
- ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
- ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
- ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
- ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
- ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
-#endif
-
-#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
-# ifdef Z_PREFIX_SET
-# define z_gzopen z_gzopen64
-# define z_gzseek z_gzseek64
-# define z_gztell z_gztell64
-# define z_gzoffset z_gzoffset64
-# define z_adler32_combine z_adler32_combine64
-# define z_crc32_combine z_crc32_combine64
-# else
-# define gzopen gzopen64
-# define gzseek gzseek64
-# define gztell gztell64
-# define gzoffset gzoffset64
-/* R change */
-# undef adler32_combine
-# define adler32_combine Rz_adler32_combine64
-# undef crc32_combine
-# define crc32_combine Rz_crc32_combine64
-# endif
-# ifndef Z_LARGE64
- ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
- ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
- ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
- ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
- ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
- ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
-# endif
-#else
- ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
- ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
- ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
- ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
- ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
- ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
-#endif
-
-#else /* Z_SOLO */
-
- ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
- ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
-
-#endif /* !Z_SOLO */
-
-/* hack for buggy compilers */
-#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
- struct internal_state {int dummy;};
-#endif
-
-/* undocumented functions */
-ZEXTERN const char * ZEXPORT zError OF((int));
-ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
-ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
-ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
-ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
-ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
-#if defined(_WIN32) && !defined(Z_SOLO)
-ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
- const char *mode));
-#endif
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# ifndef Z_SOLO
-ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file,
- const char *format,
- va_list va));
-# endif
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ZLIB_H */
diff -Nru r-base-3.2.3/src/extra/zlib/zutil.c r-base-3.3.1/src/extra/zlib/zutil.c
--- r-base-3.2.3/src/extra/zlib/zutil.c 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/zutil.c 1970-01-01 00:00:00.000000000 +0000
@@ -1,325 +0,0 @@
-/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include "zutil.h"
-#ifndef Z_SOLO
-/* R change */
-//# include "gzguts.h"
-#endif
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-z_const char * const z_errmsg[10] = {
-"need dictionary", /* Z_NEED_DICT 2 */
-"stream end", /* Z_STREAM_END 1 */
-"", /* Z_OK 0 */
-"file error", /* Z_ERRNO (-1) */
-"stream error", /* Z_STREAM_ERROR (-2) */
-"data error", /* Z_DATA_ERROR (-3) */
-"insufficient memory", /* Z_MEM_ERROR (-4) */
-"buffer error", /* Z_BUF_ERROR (-5) */
-"incompatible version",/* Z_VERSION_ERROR (-6) */
-""};
-
-
-const char * ZEXPORT zlibVersion()
-{
- return ZLIB_VERSION;
-}
-
-uLong ZEXPORT zlibCompileFlags()
-{
- uLong flags;
-
- flags = 0;
- switch ((int)(sizeof(uInt))) {
- case 2: break;
- case 4: flags += 1; break;
- case 8: flags += 2; break;
- default: flags += 3;
- }
- switch ((int)(sizeof(uLong))) {
- case 2: break;
- case 4: flags += 1 << 2; break;
- case 8: flags += 2 << 2; break;
- default: flags += 3 << 2;
- }
- switch ((int)(sizeof(voidpf))) {
- case 2: break;
- case 4: flags += 1 << 4; break;
- case 8: flags += 2 << 4; break;
- default: flags += 3 << 4;
- }
- switch ((int)(sizeof(z_off_t))) {
- case 2: break;
- case 4: flags += 1 << 6; break;
- case 8: flags += 2 << 6; break;
- default: flags += 3 << 6;
- }
-#ifdef DEBUG
- flags += 1 << 8;
-#endif
-#if defined(ASMV) || defined(ASMINF)
- flags += 1 << 9;
-#endif
-#ifdef ZLIB_WINAPI
- flags += 1 << 10;
-#endif
-#ifdef BUILDFIXED
- flags += 1 << 12;
-#endif
-#ifdef DYNAMIC_CRC_TABLE
- flags += 1 << 13;
-#endif
-#ifdef NO_GZCOMPRESS
- flags += 1L << 16;
-#endif
-#ifdef NO_GZIP
- flags += 1L << 17;
-#endif
-#ifdef PKZIP_BUG_WORKAROUND
- flags += 1L << 20;
-#endif
-#ifdef FASTEST
- flags += 1L << 21;
-#endif
-#if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# ifdef NO_vsnprintf
- flags += 1L << 25;
-# ifdef HAS_vsprintf_void
- flags += 1L << 26;
-# endif
-# else
-# ifdef HAS_vsnprintf_void
- flags += 1L << 26;
-# endif
-# endif
-#else
- flags += 1L << 24;
-# ifdef NO_snprintf
- flags += 1L << 25;
-# ifdef HAS_sprintf_void
- flags += 1L << 26;
-# endif
-# else
-# ifdef HAS_snprintf_void
- flags += 1L << 26;
-# endif
-# endif
-#endif
- return flags;
-}
-
-#ifdef DEBUG
-
-# ifndef verbose
-# define verbose 0
-# endif
-int ZLIB_INTERNAL z_verbose = verbose;
-
-void ZLIB_INTERNAL z_error (m)
- char *m;
-{
- fprintf(stderr, "%s\n", m);
- exit(1);
-}
-#endif
-
-/* exported to allow conversion of error code to string for compress() and
- * uncompress()
- */
-const char * ZEXPORT zError(err)
- int err;
-{
- return ERR_MSG(err);
-}
-
-#if defined(_WIN32_WCE)
- /* The Microsoft C Run-Time Library for Windows CE doesn't have
- * errno. We define it as a global variable to simplify porting.
- * Its value is always 0 and should not be used.
- */
- int errno = 0;
-#endif
-
-#ifndef HAVE_MEMCPY
-
-void ZLIB_INTERNAL zmemcpy(dest, source, len)
- Bytef* dest;
- const Bytef* source;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = *source++; /* ??? to be unrolled */
- } while (--len != 0);
-}
-
-int ZLIB_INTERNAL zmemcmp(s1, s2, len)
- const Bytef* s1;
- const Bytef* s2;
- uInt len;
-{
- uInt j;
-
- for (j = 0; j < len; j++) {
- if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
- }
- return 0;
-}
-
-void ZLIB_INTERNAL zmemzero(dest, len)
- Bytef* dest;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = 0; /* ??? to be unrolled */
- } while (--len != 0);
-}
-#endif
-
-#ifndef Z_SOLO
-
-#ifdef SYS16BIT
-
-#ifdef __TURBOC__
-/* Turbo C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
- * and farmalloc(64K) returns a pointer with an offset of 8, so we
- * must fix the pointer. Warning: the pointer must be put back to its
- * original form in order to free it, use zcfree().
- */
-
-#define MAX_PTR 10
-/* 10*64K = 640K */
-
-local int next_ptr = 0;
-
-typedef struct ptr_table_s {
- voidpf org_ptr;
- voidpf new_ptr;
-} ptr_table;
-
-local ptr_table table[MAX_PTR];
-/* This table is used to remember the original form of pointers
- * to large buffers (64K). Such pointers are normalized with a zero offset.
- * Since MSDOS is not a preemptive multitasking OS, this table is not
- * protected from concurrent access. This hack doesn't work anyway on
- * a protected system like OS/2. Use Microsoft C instead.
- */
-
-voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- voidpf buf = opaque; /* just to make some compilers happy */
- ulg bsize = (ulg)items*size;
-
- /* If we allocate less than 65520 bytes, we assume that farmalloc
- * will return a usable pointer which doesn't have to be normalized.
- */
- if (bsize < 65520L) {
- buf = farmalloc(bsize);
- if (*(ush*)&buf != 0) return buf;
- } else {
- buf = farmalloc(bsize + 16L);
- }
- if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
- table[next_ptr].org_ptr = buf;
-
- /* Normalize the pointer to seg:0 */
- *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
- *(ush*)&buf = 0;
- table[next_ptr++].new_ptr = buf;
- return buf;
-}
-
-void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
-{
- int n;
- if (*(ush*)&ptr != 0) { /* object < 64K */
- farfree(ptr);
- return;
- }
- /* Find the original pointer */
- for (n = 0; n < next_ptr; n++) {
- if (ptr != table[n].new_ptr) continue;
-
- farfree(table[n].org_ptr);
- while (++n < next_ptr) {
- table[n-1] = table[n];
- }
- next_ptr--;
- return;
- }
- ptr = opaque; /* just to make some compilers happy */
- Assert(0, "zcfree: ptr not found");
-}
-
-#endif /* __TURBOC__ */
-
-
-#ifdef M_I86
-/* Microsoft C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
-# define _halloc halloc
-# define _hfree hfree
-#endif
-
-voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- return _halloc((long)items, size);
-}
-
-void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- _hfree(ptr);
-}
-
-#endif /* M_I86 */
-
-#endif /* SYS16BIT */
-
-
-#ifndef MY_ZCALLOC /* Any system without a special alloc function */
-
-#ifndef STDC
-extern voidp malloc OF((uInt size));
-extern voidp calloc OF((uInt items, uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
-voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
- voidpf opaque;
- unsigned items;
- unsigned size;
-{
- if (opaque) items += size - size; /* make compiler happy */
- return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
- (voidpf)calloc(items, size);
-}
-
-void ZLIB_INTERNAL zcfree (opaque, ptr)
- voidpf opaque;
- voidpf ptr;
-{
- free(ptr);
- if (opaque) return; /* make compiler happy */
-}
-
-#endif /* MY_ZCALLOC */
-
-#endif /* !Z_SOLO */
diff -Nru r-base-3.2.3/src/extra/zlib/zutil.h r-base-3.3.1/src/extra/zlib/zutil.h
--- r-base-3.2.3/src/extra/zlib/zutil.h 2013-06-05 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/extra/zlib/zutil.h 1970-01-01 00:00:00.000000000 +0000
@@ -1,253 +0,0 @@
-/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2013 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZUTIL_H
-#define ZUTIL_H
-
-#ifdef HAVE_HIDDEN
-# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
-#else
-# define ZLIB_INTERNAL
-#endif
-
-#include "zlib.h"
-
-#if defined(STDC) && !defined(Z_SOLO)
-# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
-# include
-# endif
-# include
-# include
-#endif
-
-#ifdef Z_SOLO
- typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
-#endif
-
-#ifndef local
-# define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-typedef unsigned char uch;
-typedef uch FAR uchf;
-typedef unsigned short ush;
-typedef ush FAR ushf;
-typedef unsigned long ulg;
-
-extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
-/* (size given to avoid silly warnings with Visual C++) */
-
-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
-
-#define ERR_RETURN(strm,err) \
- return (strm->msg = ERR_MSG(err), (err))
-/* To be used only when the state is known to be valid */
-
- /* common constants */
-
-#ifndef DEF_WBITS
-# define DEF_WBITS MAX_WBITS
-#endif
-/* default windowBits for decompression. MAX_WBITS is for compression only */
-
-#if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
-#else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
-#endif
-/* default memLevel */
-
-#define STORED_BLOCK 0
-#define STATIC_TREES 1
-#define DYN_TREES 2
-/* The three kinds of block type */
-
-#define MIN_MATCH 3
-#define MAX_MATCH 258
-/* The minimum and maximum match lengths */
-
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
-
- /* target dependencies */
-
-#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
-# define OS_CODE 0x00
-# ifndef Z_SOLO
-# if defined(__TURBOC__) || defined(__BORLANDC__)
-# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
- /* Allow compilation with ANSI keywords only enabled */
- void _Cdecl farfree( void *block );
- void *_Cdecl farmalloc( unsigned long nbytes );
-# else
-# include
-# endif
-# else /* MSC or DJGPP */
-# include
-# endif
-# endif
-#endif
-
-#ifdef AMIGA
-# define OS_CODE 0x01
-#endif
-
-#if defined(VAXC) || defined(VMS)
-# define OS_CODE 0x02
-# define F_OPEN(name, mode) \
- fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
-#endif
-
-#if defined(ATARI) || defined(atarist)
-# define OS_CODE 0x05
-#endif
-
-#ifdef OS2
-# define OS_CODE 0x06
-# if defined(M_I86) && !defined(Z_SOLO)
-# include
-# endif
-#endif
-
-#if defined(MACOS) || defined(TARGET_OS_MAC)
-# define OS_CODE 0x07
-# ifndef Z_SOLO
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
-# endif
-# endif
-#endif
-
-#ifdef TOPS20
-# define OS_CODE 0x0a
-#endif
-
-#ifdef WIN32
-# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
-# define OS_CODE 0x0b
-# endif
-#endif
-
-#ifdef __50SERIES /* Prime/PRIMOS */
-# define OS_CODE 0x0f
-#endif
-
-#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
-#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
-# if defined(_WIN32_WCE)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# ifndef _PTRDIFF_T_DEFINED
- typedef int ptrdiff_t;
-# define _PTRDIFF_T_DEFINED
-# endif
-# else
-# define fdopen(fd,type) _fdopen(fd,type)
-# endif
-#endif
-
-#if defined(__BORLANDC__) && !defined(MSDOS)
- #pragma warn -8004
- #pragma warn -8008
- #pragma warn -8066
-#endif
-
-/* provide prototypes for these when building zlib without LFS */
-#if !defined(_WIN32) && \
- (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
- ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
- ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
-#endif
-
- /* common defaults */
-
-#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
-#endif
-
-#ifndef F_OPEN
-# define F_OPEN(name, mode) fopen((name), (mode))
-#endif
-
- /* functions */
-
-#if defined(pyr) || defined(Z_SOLO)
-# define NO_MEMCPY
-#endif
-#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
- /* Use our own functions for small and medium model with MSC <= 5.0.
- * You may have to use the same strategy for Borland C (untested).
- * The __SC__ check is for Symantec.
- */
-# define NO_MEMCPY
-#endif
-#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
-# define HAVE_MEMCPY
-#endif
-#ifdef HAVE_MEMCPY
-# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
-# define zmemcpy _fmemcpy
-# define zmemcmp _fmemcmp
-# define zmemzero(dest, len) _fmemset(dest, 0, len)
-# else
-# define zmemcpy memcpy
-# define zmemcmp memcmp
-# define zmemzero(dest, len) memset(dest, 0, len)
-# endif
-#else
- void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
- int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
- void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
-#endif
-
-/* Diagnostic functions */
-#ifdef DEBUG
-# include
- extern int ZLIB_INTERNAL z_verbose;
- extern void ZLIB_INTERNAL z_error OF((char *m));
-# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
-# define Trace(x) {if (z_verbose>=0) fprintf x ;}
-# define Tracev(x) {if (z_verbose>0) fprintf x ;}
-# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-#ifndef Z_SOLO
- voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
- unsigned size));
- void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
-#endif
-
-#define ZALLOC(strm, items, size) \
- (*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
-
-/* Reverse the bytes in a 32-bit value */
-#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
- (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
-
-#endif /* ZUTIL_H */
diff -Nru r-base-3.2.3/src/gnuwin32/console.c r-base-3.3.1/src/gnuwin32/console.c
--- r-base-3.2.3/src/gnuwin32/console.c 2015-08-25 22:19:05.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/console.c 2016-02-06 23:15:09.000000000 +0000
@@ -3,7 +3,7 @@
* file console.c
* Copyright (C) 1998--2003 Guido Masarotto and Brian Ripley
* Copyright (C) 2004-8 The R Foundation
- * Copyright (C) 2004-2014 The R Core Team
+ * Copyright (C) 2004-2016 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -342,7 +342,7 @@
p->lbuf = NULL;
p->kbuf = NULL;
}
- p->bm = NULL;
+ BM = NULL;
p->rows = rows;
p->cols = cols;
for (int i=0; inewfv = p->newfc = 0;
+ NEWFV = NEWFC = 0;
p->firstkey = p->numkeys = 0;
p->clp = NULL;
- p->r = -1;
+ CURROW = -1;
p->overwrite = 0;
p->needredraw = 0;
p->wipe_completion = 0;
@@ -427,7 +427,7 @@
/* This is right, since columns are of fixed size */
r = rect(BORDERX + fch * FW, BORDERY + j * FH, (lch - fch + 1) * FW, FH);
- gfillrect(p->bm, bgr, r);
+ gfillrect(BM, bgr, r);
if (len > FC+fch) {
/* Some of the string is visible: */
@@ -461,7 +461,7 @@
if((len > FC+COLS) && (lch == COLS - 1)) *q++ = L'$';
else *q++ = *P++;
*q = L'\0';
- gdrawwcs(p->bm, p->f, fgr, pt(r.x, r.y), buff);
+ gdrawwcs(BM, p->f, fgr, pt(r.x, r.y), buff);
} else {
int last;
wchar_t ch, chf, chl;
@@ -472,7 +472,7 @@
} else chl = L'\0';
last = FC + lch + 1;
if (len > last) {ch = s[last]; s[last] = L'\0';} else ch = L'\0';
- gdrawwcs(p->bm, p->f, fgr, pt(r.x, r.y), &s[FC+fch]);
+ gdrawwcs(BM, p->f, fgr, pt(r.x, r.y), &s[FC+fch]);
/* restore the string */
if (ch) s[last] = ch;
if (chl) s[FC+lch] = chl;
@@ -549,7 +549,7 @@
} else
WLHELPER(0, col1, fg, bg);
/* This is the cursor, and it may need to be variable-width */
- if ((p->r >= 0) && (CURCOL >= FC) && (CURCOL < FC + COLS) &&
+ if ((CURROW >= 0) && (CURCOL >= FC) && (CURCOL < FC + COLS) &&
(i == NUMLINES - 1) && (p->sel == 0 || !intersect_input(p, 0))) {
if (!p->overwrite) {
if (p->cursor_blink) {
@@ -560,7 +560,7 @@
if (p->cursor_blink < 2) {
r = rect(BORDERX + (CURCOL - FC) * FW, BORDERY + j * FH, FW/4, FH);
- gfillrect(p->bm, highlight, r);
+ gfillrect(BM, highlight, r);
}
} else if(mbcslocale) { /* determine the width of the current char */
int w0;
@@ -581,8 +581,8 @@
if (p->cursor_blink < 2) {
r = rect(BORDERX + (CURCOL - FC) * FW, BORDERY + j * FH,
w0 * FW, FH);
- gfillrect(p->bm, highlight, r);
- gdrawwcs(p->bm, p->f, bg, pt(r.x, r.y), nn);
+ gfillrect(BM, highlight, r);
+ gdrawwcs(BM, p->f, bg, pt(r.x, r.y), nn);
}
} else {
if (p->cursor_blink) {
@@ -906,7 +906,7 @@
static void performCompletion(control c)
{
ConsoleData p = getdata(c);
- int i, alen, alen2, max_show = 10, cursor_position = p->c - prompt_wid;
+ int i, alen, alen2, max_show = 10, cursor_position = CURCOL - prompt_wid;
wchar_t *partial_line = LINE(NUMLINES - 1) + prompt_wid;
const char *additional_text;
SEXP cmdSexp, cmdexpr, ans = R_NilValue;
@@ -1059,9 +1059,9 @@
storekey(c, '\n');
/* if we are editing we save the actual line
FIXME: not right if Unicode */
- if (p->r > -1) {
+ if (CURROW > -1) {
char buf[2000], *cp; /* maximum 2 bytes/char */
- wchar_t *wc = &(p->lbuf->s[p->lbuf->ns - 1][prompt_len]);
+ wchar_t *wc = &(LINE(NUMLINES - 1)[prompt_len]);
memset(buf, 0, 2000);
wcstombs(buf, wc, 1000);
for (cp = buf; *cp; cp++) storekey(c, *cp);
@@ -1531,7 +1531,7 @@
/* now zap it */
for(i = 0; i < len; i++) xbufaddxc(p->lbuf, L'\b');
if (incomplete) {
- p->lbuf->ns--;
+ NUMLINES--;
p->lbuf->free--;
p->lbuf->av++;
}
@@ -1548,11 +1548,11 @@
if (!p->lazyupdate) {
setfirstvisible(c, NUMLINES - ROWS);
REDRAW;
- } else if (p->r >= 0)
+ } else if (CURROW >= 0)
setfirstvisible(c, NUMLINES - ROWS);
else {
- p->newfv = NUMLINES - ROWS;
- if (p->newfv < 0) p->newfv = 0;
+ NEWFV = NUMLINES - ROWS;
+ if (NEWFV < 0) NEWFV = 0;
}
if(p->input) REDRAW;
return 0;
@@ -1561,7 +1561,7 @@
void freeConsoleData(ConsoleData p)
{
if (!p) return;
- if (p->bm) del(p->bm);
+ if (BM) del(BM);
if (p->kind == CONSOLE) {
if (p->lbuf) xbufdel(p->lbuf);
if (p->kbuf) free(p->kbuf);
@@ -1666,8 +1666,8 @@
if (p->needredraw) {
REDRAW;
} else {
- WRITELINE(NUMLINES - 1, p->r);
- RSHOW(RLINE(p->r));
+ WRITELINE(NUMLINES - 1, CURROW);
+ RSHOW(RLINE(CURROW));
}
}
@@ -1718,14 +1718,14 @@
USER(NUMLINES - 1) = w0;
prompt_wid = wcswidth(aLine);
if (NUMLINES > ROWS) {
- p->r = ROWS - 1;
- p->newfv = NUMLINES - ROWS;
+ CURROW = ROWS - 1;
+ NEWFV = NUMLINES - ROWS;
} else {
- p->r = NUMLINES - 1;
- p->newfv = 0;
+ CURROW = NUMLINES - 1;
+ NEWFV = 0;
}
CURCOL = prompt_wid;
- p->fc = 0;
+ FC = 0;
cur_pos = 0;
max_pos = 0;
cur_line = &aLine[prompt_len];
@@ -1743,11 +1743,11 @@
cur_line = LINE(NUMLINES - 1) + prompt_len;
ns0 = NUMLINES;
if (NUMLINES > ROWS) {
- p->r = ROWS - 1;
- p->newfv = NUMLINES - ROWS;
+ CURROW = ROWS - 1;
+ NEWFV = NUMLINES - ROWS;
} else {
- p->r = NUMLINES - 1;
- p->newfv = 0;
+ CURROW = NUMLINES - 1;
+ NEWFV = 0;
}
USER(NUMLINES - 1) = prompt_wid;
p->needredraw = 1;
@@ -1842,7 +1842,7 @@
wcstobuf(buf, len, cur_line);
//sprintf(buf, "%ls", cur_line);
//if(strlen(buf) == 0) strcpy(buf, "invalid input\n");
- p->r = -1;
+ CURROW = -1;
cur_line[max_pos] = L'\0';
if (max_pos && addtohistory) wgl_histadd(cur_line);
xbuffixl(p->lbuf);
@@ -1884,7 +1884,7 @@
{
ConsoleData p = getdata(c);
- return p->cols;
+ return COLS;
}
void consoleresize(console c, rect r)
@@ -1911,6 +1911,8 @@
HEIGHT = r.height;
BORDERX = (WIDTH - COLS*FW) / 2;
BORDERY = (HEIGHT - ROWS*FH) / 2;
+ NEWFV = NUMLINES - ROWS;
+ if (NEWFV < 0) NEWFV = 0;
del(BM);
BM = newbitmap(r.width, r.height, 2);
if (!BM) {
@@ -1919,11 +1921,11 @@
}
if(!p->lbuf) return;; /* don't implement resize if no content
yet in pager */
- if (p->r >= 0) {
+ if (CURROW >= 0) {
if (NUMLINES > ROWS) {
- p->r = ROWS - 1;
+ CURROW = ROWS - 1;
} else
- p->r = NUMLINES - 1;
+ CURROW = NUMLINES - 1;
}
clear(c);
p->needredraw = 1;
@@ -2273,6 +2275,6 @@
xbufshift(l);
l->shift = oldshift;
NEWFV = 0;
- p->r = 0;
+ CURROW = 0;
REDRAW;
}
diff -Nru r-base-3.2.3/src/gnuwin32/COPYRIGHTS.win r-base-3.3.1/src/gnuwin32/COPYRIGHTS.win
--- r-base-3.2.3/src/gnuwin32/COPYRIGHTS.win 2014-06-26 22:15:03.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/COPYRIGHTS.win 2016-06-09 22:15:06.000000000 +0000
@@ -125,7 +125,7 @@
contents.
The build of Tcl/Tk contained in the binary installer is taken via
-Rtools from http://www.stats.ox.ac.uk/pub/Rtools/, which hosts the
+Rtools from https://www.stats.ox.ac.uk/pub/Rtools/, which hosts the
sources used and links to the scripts used for the build.
Rbitmap.dll is built against static libraries for libpng, jpeg and
@@ -136,7 +136,7 @@
A binay build may contain compiled sources from cairographics,
distributed under LGPL 2.1 (our choice) or MPL 1.1. The binary
-distribution used is that at http://www.rforge.net/Cairo/files/ .
+distribution used is that at https://www.rforge.net/Cairo/files/ .
A binary build may contain compiled components from ICU, whose license
can be viewed at
diff -Nru r-base-3.2.3/src/gnuwin32/cran/index.in r-base-3.3.1/src/gnuwin32/cran/index.in
--- r-base-3.2.3/src/gnuwin32/cran/index.in 2015-08-16 22:15:07.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/cran/index.in 2016-03-16 23:04:30.000000000 +0000
@@ -49,7 +49,7 @@
diff -Nru r-base-3.2.3/src/gnuwin32/fixed/etc/Makeconf r-base-3.3.1/src/gnuwin32/fixed/etc/Makeconf
--- r-base-3.2.3/src/gnuwin32/fixed/etc/Makeconf 2015-03-18 23:04:05.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/fixed/etc/Makeconf 2016-06-09 22:15:06.000000000 +0000
@@ -17,6 +17,7 @@
## Things which are substituted by fixed/Makefile (and also -O3 -> -O2)
WIN = 32
BINPREF =
+COMPILED_BY =
# SYMPAT = 's/^.* [BCDRT] _/ /p' for 32-bit
# SYMPAT = 's/^.* [BCDRT] / /p' for 64-bit
SYMPAT = @SYMPAT@
@@ -62,8 +63,6 @@
ZLIB_LIBS = -lz
AR = $(BINPREF)ar
-## Used by packages 'maps' and 'mapdata'
-AWK = gawk
BLAS_LIBS = -L"$(R_HOME)/$(IMPDIR)" -lRblas
C_VISIBILITY =
CC = $(BINPREF)gcc $(M_ARCH)
@@ -93,7 +92,7 @@
F77 = $(BINPREF)gfortran $(M_ARCH)
F77_VISIBILITY =
FFLAGS = -O3 $(DEBUGFLAG) @EOPTS@
-FLIBS = -lgfortran
+FLIBS = -lgfortran -lm -lquadmath
FCPICFLAGS =
FPICFLAGS =
FOUNDATION_CPPFLAGS =
diff -Nru r-base-3.2.3/src/gnuwin32/fixed/h/config.h r-base-3.3.1/src/gnuwin32/fixed/h/config.h
--- r-base-3.2.3/src/gnuwin32/fixed/h/config.h 2015-03-19 23:15:06.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/fixed/h/config.h 2016-03-16 23:04:28.000000000 +0000
@@ -68,9 +68,6 @@
/* Define to 1 if you have the `atanpi' function. */
/* #undef HAVE_ATANPI */
-/* Define if you have BSD networking headers and libraries. */
-/* #undef HAVE_BSD_NETWORKING */
-
/* Define to 1 if the compiler understands __builtin_expect. (For intl) */
#define HAVE_BUILTIN_EXPECT 1
@@ -153,14 +150,14 @@
/* Define to 1 if you have the `ctan' function. */
#define HAVE_CTAN 1
+/* Define to 1 if you have the `ctanh' function. */
+#define HAVE_CTANH 1
+
/* Define to 1 if you have the header file.
Set on the command line where supported.
*/
/* #undef HAVE_CURL_CURL_H */
-/* Define to 1 if you have the `ctanh' function. */
-#define HAVE_CTANH 1
-
/* define if the compiler supports basic C++11 syntax */
#define HAVE_CXX11 1
@@ -375,9 +372,6 @@
/* Define to 1 if the system has the type `int64_t'. */
#define HAVE_INT64_T 1
-/* Define if you have support for ftp/http access. */
-#define HAVE_INTERNET 1
-
/* Define if you have the 'intmax_t' type in or . (For
intl) */
#define HAVE_INTMAX_T 1
@@ -428,8 +422,10 @@
/* Define if your file defines LC_MESSAGES. */
/* #undef HAVE_LC_MESSAGES */
-/* Define to 1 if you have the `cc_dynamic' library (-lcc_dynamic). */
-/* #undef HAVE_LIBCC_DYNAMIC */
+/* Define if your system has libcurl >= 7.28.0 with support for https.
+ Set on the command line where supported.
+ */
+/* #undef HAVE_LIBCURL */
/* Define if __libc_stack_end is visible. */
/* #undef HAVE_LIBC_STACK_END */
@@ -672,9 +668,6 @@
/* Define to 1 if you have the `snprintf' function. */
#define HAVE_SNPRINTF 1
-/* Define if you have support for sockets. */
-#define HAVE_SOCKETS 1
-
/* Define to 1 if the system has the type `stack_t'. */
/* #undef HAVE_STACK_T */
@@ -949,8 +942,7 @@
/* Define if you have 32 bit ints. */
#define INT_32_BITS 1
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
/* Define if mktime sets errno. */
@@ -1070,6 +1062,11 @@
/* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T @ST@
+/* Workaround for win64 pow() precision issue in Mingw-w64 V3 and higher
+ See http://sourceforge.net/p/mingw-w64/bugs/466 for discussion. */
+#if defined(_WIN64) && defined(__MINGW64_VERSION_MAJOR) && __MINGW64_VERSION_MAJOR >= 3
+#define USE_POWL_IN_R_POW 1
+#endif
/* Define as the maximum value of type 'size_t', if the system doesn't define
it. (For intl) */
@@ -1086,9 +1083,6 @@
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
-/* Define if you provide support for the libxml ftp/http functions. */
-#define SUPPORT_LIBXML 1
-
/* Define if you have C/C++/Fortran OpenMP support for package code. */
/* #undef SUPPORT_OPENMP */
diff -Nru r-base-3.2.3/src/gnuwin32/fixed/h/Rconfig.h r-base-3.3.1/src/gnuwin32/fixed/h/Rconfig.h
--- r-base-3.2.3/src/gnuwin32/fixed/h/Rconfig.h 2015-07-21 22:15:06.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/fixed/h/Rconfig.h 2016-01-03 23:15:03.000000000 +0000
@@ -15,6 +15,7 @@
#define SUPPORT_MBCS 1
#define ENABLE_NLS 1
/* #undef HAVE_AQUA */
+/* Deprecated: use _OPENMP instead */
/* #undef SUPPORT_OPENMP */
#ifdef _WIN64
#define SIZEOF_SIZE_T 8
diff -Nru r-base-3.2.3/src/gnuwin32/fixed/html/rwin.html r-base-3.3.1/src/gnuwin32/fixed/html/rwin.html
--- r-base-3.2.3/src/gnuwin32/fixed/html/rwin.html 2012-04-27 22:05:03.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/fixed/html/rwin.html 2016-03-16 23:04:28.000000000 +0000
@@ -8,7 +8,7 @@
Statistical Data Analysis
-
+
diff -Nru r-base-3.2.3/src/gnuwin32/fixed/Makefile r-base-3.3.1/src/gnuwin32/fixed/Makefile
--- r-base-3.2.3/src/gnuwin32/fixed/Makefile 2015-03-18 23:04:05.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/fixed/Makefile 2016-03-25 23:15:12.000000000 +0000
@@ -28,7 +28,8 @@
$(SED) -e 's/WIN = 32/WIN = 64/' \
-e "s/-O3/-O2/" \
-e "s/@EOPTS@/$(EOPTS)/" \
- -e "s|BINPREF =|BINPREF = $(BINPREF)|" \
+ -e "s|BINPREF =|BINPREF ?= $(BINPREF)|" \
+ -e "s|COMPILED_BY =|COMPILED_BY = $(COMPILED_BY)|" \
-e "s|IMPDIR = bin|IMPDIR = $(IMPDIR)|" \
-e "s|LOCAL_SOFT =|LOCAL_SOFT = $(LOCAL_SOFT)|" \
-e "s|R_ARCH =|R_ARCH = $(R_ARCH)|" \
@@ -44,7 +45,8 @@
else
$(SED) -e "s|IMPDIR = bin|IMPDIR = $(IMPDIR)|" \
-e "s/@EOPTS@/$(EOPTS)/" \
- -e "s|BINPREF =|BINPREF = $(BINPREF)|" \
+ -e "s|BINPREF =|BINPREF ?= $(BINPREF)|" \
+ -e "s|COMPILED_BY =|COMPILED_BY = $(COMPILED_BY)|" \
-e "s|LOCAL_SOFT =|LOCAL_SOFT = $(LOCAL_SOFT)|" \
-e "s|R_ARCH =|R_ARCH = $(R_ARCH)|" \
-e "s|DT_ARCH =|DT_ARCH = $(DT_ARCH)|" \
Binary files /tmp/tmpr1xlqo/rKiOMPh78h/r-base-3.2.3/src/gnuwin32/front-ends/R.ico and /tmp/tmpr1xlqo/EboCyhHyzT/r-base-3.3.1/src/gnuwin32/front-ends/R.ico differ
diff -Nru r-base-3.2.3/src/gnuwin32/installer/Makefile r-base-3.3.1/src/gnuwin32/installer/Makefile
--- r-base-3.2.3/src/gnuwin32/installer/Makefile 2015-08-03 13:05:31.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/installer/Makefile 2016-04-04 22:15:06.000000000 +0000
@@ -95,14 +95,16 @@
# files to make source packages
$(MKDIR) -p $(RPREFIX)/share \
$(RPREFIX)/src/library $(RPREFIX)/src/gnuwin32
- $(CP) $(R_HOME)/doc/html/logo.jpg $(RPREFIX)/doc/html
+ $(CP) $(R_HOME)/doc/html/logo.jpg $(R_HOME)/doc/html/Rlogo.svg $(RPREFIX)/doc/html
$(CP) $(R_HOME)/doc/KEYWORDS* $(RPREFIX)/doc
$(CP) -pR $(R_HOME)/include $(RPREFIX)
$(CP) -pR $(foreach i,$(SHARE_DIRS),$(R_HOME)/share/$i) $(RPREFIX)/share
# This is odd -- better to clean the copy
(cd ..; $(MAKE) --no-print-directory PKGDIR=. pkgclean-windlgs)
$(CP) -pR ../windlgs $(RPREFIX)/src/library
-#
+# Edit Makeconf
+ $(SED) -e 's!^BINPREF [?]= .*!BINPREF ?= c:/Rtools/mingw_64/bin/!' \
+ $(R_HOME)/etc/x64/Makeconf > $(RPREFIX)/etc/x64/Makeconf
# test dir
mkdir $(RPREFIX)/tests
$(MAKE) --no-print-directory -C ../../../tests -f Makefile.win \
@@ -144,6 +146,9 @@
../../../library/$${f}/DESCRIPTION \
> $(RPREFIX)/library/$${f}/DESCRIPTION; \
done
+# Edit Makeconf file to default Rtools location
+ $(SED) -e 's!^BINPREF [?]= .*!BINPREF ?= c:/Rtools/mingw_32/bin/!' \
+ $(HOME32)/etc/i386/Makeconf > $(RPREFIX)/etc/i386/Makeconf
else
@echo "------------ not including 32-bit files"
endif
Binary files /tmp/tmpr1xlqo/rKiOMPh78h/r-base-3.2.3/src/gnuwin32/installer/R.bmp and /tmp/tmpr1xlqo/EboCyhHyzT/r-base-3.3.1/src/gnuwin32/installer/R.bmp differ
diff -Nru r-base-3.2.3/src/gnuwin32/MkRules.dist r-base-3.3.1/src/gnuwin32/MkRules.dist
--- r-base-3.2.3/src/gnuwin32/MkRules.dist 2015-10-04 22:15:04.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/MkRules.dist 2016-03-25 23:15:12.000000000 +0000
@@ -9,7 +9,7 @@
## =========== configuration macros for building packages ================
# Absolute path to '/usr/local' software collection. The versions used
-# on CRAN can be found at http://www.stats.ox.ac.uk/pub/Rtools/libs.html
+# on CRAN can be found at https://www.stats.ox.ac.uk/pub/Rtools/libs.html
# It can be interrogated by 'R CMD config LOCAL_SOFT'
# Use 'make rsync-extsoft' to populate the default directory.
# LOCAL_SOFT = $(R_HOME)/extsoft
@@ -19,7 +19,7 @@
# Path of library directory containing zlib, bzlib, liblzma, pcre,
# libpng, libjpeg, libtiff.
# A suitable version can be found at
-# http://www.stats.ox.ac.uk/pub/Rtools/libs.html
+# https://www.stats.ox.ac.uk/pub/Rtools/libs.html
# or use 'make rsync-extsoft' to populate the default directory.
# EXT_LIBS = $(LOCAL_SOFT)
@@ -57,6 +57,8 @@
# BINPREF = c:/Rtools/gcc492_32/bin/
# prefix for 64-bit:
# BINPREF64 = c:/Rtools/gcc492_64/bin/
+# Set this to indicate a non-gcc compiler and version
+# COMPILED_BY =
# Others use a -m64 or -m32 option to select architectures
# M_ARCH =
@@ -70,10 +72,10 @@
# 32- or 64-bit Windows?
# WIN = 32
-# The gcc 4.9.2 64 bit toolchain is set up for the 'medium code' model and needs
-# to remove the .refptr entries from the exports list; this is the default
+# The gcc 4.9.3 64 bit toolchain is set up for the 'medium code' model and needs
+# to remove the .refptr and .weak entries from the exports list; this is the default
# when WIN = 64, with blank for WIN = 32:
-# NM_FILTER = | $(SED) -e '/.refptr./d'
+# NM_FILTER = | $(SED) -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d'
# We normally link directly against DLLs,
# but this macro forces the use of import libs
@@ -100,7 +102,7 @@
# For the cairographics devices
# Optionally use a static build of cairographics from
-# http://www.rforge.net/Cairo/files/cairo-current-win.tar.gz
+# https://www.rforge.net/Cairo/files/cairo-current-win.tar.gz
# and set CAIRO_HOME to the parent of the win32/win64 directories
#
# If CAIRO_HOME is not set the devices are not built.
diff -Nru r-base-3.2.3/src/gnuwin32/MkRules.rules r-base-3.3.1/src/gnuwin32/MkRules.rules
--- r-base-3.2.3/src/gnuwin32/MkRules.rules 2015-10-04 22:15:04.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/MkRules.rules 2016-03-25 23:15:12.000000000 +0000
@@ -11,6 +11,7 @@
TOOL_PATH ?=
BINPREF ?=
BINPREF64 ?= x86_64-w64-mingw32-
+COMPILED_BY ?= gcc-$(shell $(CC) --version | egrep -o "([0-9]{1,}\.){2,}[0-9]{1,}")
M_ARCH ?=
AS_ARCH ?=
RC_ARCH ?=
@@ -61,7 +62,7 @@
arch_DEFS = -DR_ARCH='"x64"'
BINPREF = $(BINPREF64)
SYMPAT = 's/^.* [BCDRT] / /p'
-NM_FILTER ?= | $(SED) -e '/.refptr./d'
+NM_FILTER ?= | $(SED) -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d'
else
R_ARCH = /i386
arch_DEFS = -DR_ARCH='"i386"'
@@ -83,7 +84,6 @@
endif
AR=$(BINPREF)ar
-# AWK=gawk
CAT=cat
CC=$(BINPREF)gcc$(GCC4_SUFF) $(C99FLAG) $(M_ARCH)
CP=cp
diff -Nru r-base-3.2.3/src/gnuwin32/Rdll.hide r-base-3.3.1/src/gnuwin32/Rdll.hide
--- r-base-3.2.3/src/gnuwin32/Rdll.hide 2015-08-16 22:15:07.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/Rdll.hide 2016-03-16 23:04:29.000000000 +0000
@@ -60,6 +60,7 @@
NO_SPECIAL_SYMBOLS
PrintUsage
ProfileEvent
+ RExitContext
R_BCNodeStackBase
R_BCNodeStackEnd
R_BCNodeStackTop
@@ -89,6 +90,7 @@
R_FinalizeSrcRefState
R_FreeSEXP
R_FreeStringBufferL
+ R_GCEnabled
R_GE_VStrHeight
R_GE_VStrWidth
R_GE_VText
@@ -192,8 +194,10 @@
R_decompress2
R_decompress3
R_dlsym
+ R_doDotCall
R_do_data_class
R_do_set_class
+ R_dotCallFn
R_dot_Class
R_dot_Generic
R_dot_GenericCallEnv
@@ -707,6 +711,7 @@
do_first_min
do_flush
do_for
+ do_forceAndCall
do_formals
do_format
do_formatC
@@ -724,6 +729,7 @@
do_getIdentification
do_getNSRegistry
do_getNumRtoCConverters
+ do_getNumericRounding
do_getOption
do_getRegNS
do_getRegisteredRoutines
@@ -788,6 +794,7 @@
do_lazyLoadDBinsertValue
do_length
do_lengthgets
+ do_lengths
do_levelsgets
do_list2env
do_listdirs
@@ -847,7 +854,6 @@
do_nextn
do_ngettext
do_normalizepath
- do_nsl
do_nzchar
do_onexit
do_open
@@ -882,6 +888,7 @@
do_quit
do_quote
do_radixsort
+ do_radixsort2
do_random1
do_random2
do_random3
@@ -941,6 +948,7 @@
do_set
do_setFileTime
do_setInternet2
+ do_setNumericRounding
do_setS4Object
do_setSessionTimeLimit
do_setStatusBar
@@ -977,6 +985,7 @@
do_stopHTTPD
do_storage_mode
do_strptime
+ do_strrep
do_strsplit
do_strtoi
do_strtrim
@@ -1006,6 +1015,7 @@
do_system
do_systime
do_sysumask
+ do_syswhich
do_tabulate
do_tempdir
do_tempfile
@@ -1036,6 +1046,8 @@
do_url
do_usemethod
do_utf8ToInt
+ do_validEnc
+ do_validUTF8
do_vapply
do_version
do_warning
@@ -1509,6 +1521,13 @@
xbufdel
xbufgrow
xcalloc_impl
+ xcopyComplexWithRecycle
+ xcopyIntegerWithRecycle
+ xcopyLogicalWithRecycle
+ xcopyRawWithRecycle
+ xcopyRealWithRecycle
+ xcopyStringWithRecycle
+ xcopyVectorWithRecycle
xdr_bool
xdr_bytes
xdr_char
@@ -1528,6 +1547,13 @@
xdr_void
xdr_wrapstring
xdrstdio_create
+ xfillComplexMatrixWithRecycle
+ xfillIntegerMatrixWithRecycle
+ xfillLogicalMatrixWithRecycle
+ xfillRawMatrixWithRecycle
+ xfillRealMatrixWithRecycle
+ xfillStringMatrixWithRecycle
+ xfillVectorMatrixWithRecycle
xfree_impl
xmalloc_configure
xmalloc_current
diff -Nru r-base-3.2.3/src/gnuwin32/rui.c r-base-3.3.1/src/gnuwin32/rui.c
--- r-base-3.2.3/src/gnuwin32/rui.c 2015-10-23 22:15:08.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/rui.c 2016-03-16 23:04:28.000000000 +0000
@@ -1,7 +1,7 @@
/*
* R : A Computer Langage for Statistical Data Analysis
* Copyright (C) 1998--2005 Guido Masarotto and Brian Ripley
- * Copyright (C) 2004--2014 The R Foundation
+ * Copyright (C) 2004--2015 The R Foundation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -917,7 +917,7 @@
MCHECK(pmenu->mpkgu = newmenuitem(G_("Update packages..."), 0,
menupkgupdate));
MCHECK(newmenuitem("-", 0, NULL));
- MCHECK(pmenu->mpkgil = newmenuitem(G_("Install package(s) from local zip files..."),
+ MCHECK(pmenu->mpkgil = newmenuitem(G_("Install package(s) from local files..."),
0, menupkginstalllocal));
return 0;
}
diff -Nru r-base-3.2.3/src/gnuwin32/system.c r-base-3.3.1/src/gnuwin32/system.c
--- r-base-3.2.3/src/gnuwin32/system.c 2015-08-25 22:19:06.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/system.c 2016-03-16 23:04:29.000000000 +0000
@@ -57,7 +57,6 @@
int Rwin_graphicsx = -25, Rwin_graphicsy = 0;
R_size_t R_max_memory = INT_MAX;
-Rboolean UseInternet2 = TRUE; // used in main/internet.c
extern SA_TYPE SaveAction; /* from ../main/startup.c */
Rboolean DebugMenuitem = FALSE; /* exported for rui.c */
@@ -723,6 +722,12 @@
putenv(UserRHome);
}
+
+ /* This is here temporarily while the GCC version is chosen */
+ char gccversion[30];
+ snprintf(gccversion, 30, "R_COMPILED_BY=gcc %d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
+ putenv(gccversion);
+
/* Rterm and Rgui set CharacterMode during startup, then set Rp->CharacterMode
from it in cmdlineoptions(). Rproxy never calls cmdlineoptions, so we need the
line below */
@@ -991,7 +996,7 @@
InThreadReadConsole = FileReadConsole;
setvbuf(stdout, NULL, _IONBF, 0);
} else if (!strcmp(*av, "--internet2")) {
-/* UseInternet2 = TRUE; This is now the default */
+/* This is now the default */
} else if (!strcmp(*av, "--mdi")) {
MDIset = 1;
} else if (!strcmp(*av, "--sdi") || !strcmp(*av, "--no-mdi")) {
diff -Nru r-base-3.2.3/src/gnuwin32/sys-win32.c r-base-3.3.1/src/gnuwin32/sys-win32.c
--- r-base-3.2.3/src/gnuwin32/sys-win32.c 2015-08-25 22:19:05.000000000 +0000
+++ r-base-3.3.1/src/gnuwin32/sys-win32.c 2016-03-16 23:04:28.000000000 +0000
@@ -107,6 +107,7 @@
SEXP do_machine(SEXP call, SEXP op, SEXP args, SEXP env)
{
+ checkArity(op, args);
return mkString("Win32");
}
diff -Nru r-base-3.2.3/src/include/config.h.in r-base-3.3.1/src/include/config.h.in
--- r-base-3.2.3/src/include/config.h.in 2015-03-18 23:02:16.000000000 +0000
+++ r-base-3.3.1/src/include/config.h.in 2016-03-16 23:02:20.000000000 +0000
@@ -67,9 +67,6 @@
/* Define to 1 if you have the `atanpi' function. */
#undef HAVE_ATANPI
-/* Define if you have BSD networking headers and libraries. */
-#undef HAVE_BSD_NETWORKING
-
/* Define to 1 if the compiler understands __builtin_expect. (For intl) */
#undef HAVE_BUILTIN_EXPECT
@@ -312,6 +309,9 @@
/* Define to 1 if you have the `getgrgid' function. */
#undef HAVE_GETGRGID
+/* Define to 1 if you have the `getline' function. */
+#undef HAVE_GETLINE
+
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
@@ -370,9 +370,6 @@
/* Define to 1 if the system has the type `int64_t'. */
#undef HAVE_INT64_T
-/* Define if you have support for ftp/http access. */
-#undef HAVE_INTERNET
-
/* Define if you have the 'intmax_t' type in or . (For
intl) */
#undef HAVE_INTMAX_T
@@ -423,8 +420,8 @@
/* Define if your file defines LC_MESSAGES. */
#undef HAVE_LC_MESSAGES
-/* Define to 1 if you have the `cc_dynamic' library (-lcc_dynamic). */
-#undef HAVE_LIBCC_DYNAMIC
+/* Define if your system has libcurl >= 7.28.0 with support for https. */
+#undef HAVE_LIBCURL
/* Define if __libc_stack_end is visible. */
#undef HAVE_LIBC_STACK_END
@@ -662,9 +659,6 @@
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
-/* Define if you have support for sockets. */
-#undef HAVE_SOCKETS
-
/* Define to 1 if the system has the type `stack_t'. */
#undef HAVE_STACK_T
@@ -922,9 +916,18 @@
/* Define if you have the X11/Xmu headers and libraries. */
#undef HAVE_X11_Xmu
+/* Define to 1 if you have the `__cospi' function. */
+#undef HAVE___COSPI
+
/* Define to 1 if you have the `__fsetlocking' function. */
#undef HAVE___FSETLOCKING
+/* Define to 1 if you have the `__sinpi' function. */
+#undef HAVE___SINPI
+
+/* Define to 1 if you have the `__tanpi' function. */
+#undef HAVE___TANPI
+
/* Define as const if the declaration of iconv() needs const. */
#undef ICONV_CONST
@@ -937,8 +940,7 @@
/* Define if you have 32 bit ints. */
#undef INT_32_BITS
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Define if mktime sets errno. */
@@ -1057,9 +1059,6 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* Define if you provide support for the libxml ftp/http functions. */
-#undef SUPPORT_LIBXML
-
/* Define if you have C/C++/Fortran OpenMP support for package code. */
#undef SUPPORT_OPENMP
diff -Nru r-base-3.2.3/src/include/Defn.h r-base-3.3.1/src/include/Defn.h
--- r-base-3.2.3/src/include/Defn.h 2015-08-25 22:15:24.000000000 +0000
+++ r-base-3.3.1/src/include/Defn.h 2016-03-16 23:02:20.000000000 +0000
@@ -18,6 +18,8 @@
* https://www.R-project.org/Licenses/
*/
+/* Internal header, not installed */
+
#ifndef DEFN_H_
#define DEFN_H_
@@ -91,7 +93,6 @@
extern0 SEXP R_ConnIdSymbol; /* "conn_id" */
extern0 SEXP R_DevicesSymbol; /* ".Devices" */
-extern0 SEXP R_dot_Generic; /* ".Generic" */
extern0 SEXP R_dot_Methods; /* ".Methods" */
extern0 SEXP R_dot_Group; /* ".Group" */
extern0 SEXP R_dot_Class; /* ".Class" */
@@ -325,8 +326,8 @@
typedef enum {
PREC_FN = 0,
- PREC_LEFT = 1,
- PREC_EQ = 2,
+ PREC_EQ = 1,
+ PREC_LEFT = 2,
PREC_RIGHT = 3,
PREC_TILDE = 4,
PREC_OR = 5,
@@ -339,9 +340,9 @@
PREC_COLON = 12,
PREC_SIGN = 13,
PREC_POWER = 14,
- PREC_DOLLAR = 15,
- PREC_NS = 16,
- PREC_SUBSET = 17
+ PREC_SUBSET = 15,
+ PREC_DOLLAR = 16,
+ PREC_NS = 17
} PPprec;
typedef struct {
@@ -521,6 +522,7 @@
void *cenddata; /* data for C "on.exit" thunk */
void *vmax; /* top of R_alloc stack */
int intsusp; /* interrupts are suspended */
+ int gcenabled; /* R_GCenabled value */
SEXP handlerstack; /* condition handler stack */
SEXP restartstack; /* stack of available restarts */
struct RPRSTACK *prstack; /* stack of pending promises */
@@ -531,6 +533,8 @@
SEXP srcref; /* The source line in effect */
int browserfinish; /* should browser finish this context without stopping */
SEXP returnValue; /* only set during on.exit calls */
+ struct RCNTXT *jumptarget; /* target for a continuing jump */
+ int jumpmask; /* associated LONGJMP argument */
} RCNTXT, *context;
/* The Various Context Types.
@@ -638,6 +642,7 @@
/* Memory Management */
extern0 R_size_t R_NSize INI_as(R_NSIZE);/* Size of cons cell heap */
extern0 R_size_t R_VSize INI_as(R_VSIZE);/* Size of the vector heap */
+extern0 int R_GCEnabled INI_as(1);
extern0 SEXP R_NHeap; /* Start of the cons cell heap */
extern0 SEXP R_FreeSEXP; /* Cons cell free list */
extern0 R_size_t R_Collected; /* Number of free cons cells (after gc) */
@@ -670,6 +675,8 @@
extern0 int R_WarnLength INI_as(1000); /* Error/warning max length */
extern0 int R_nwarnings INI_as(50);
extern uintptr_t R_CStackLimit INI_as((uintptr_t)-1); /* C stack limit */
+extern uintptr_t R_OldCStackLimit INI_as((uintptr_t)0); /* Old value while
+ handling overflow */
extern uintptr_t R_CStackStart INI_as((uintptr_t)-1); /* Initial stack address */
extern int R_CStackDir INI_as(1); /* C stack direction */
@@ -769,6 +776,9 @@
extern void R_init_jit_enabled(void);
extern void R_initAsignSymbols(void);
+LibExtern SEXP R_CachedScalarReal INI_as(NULL);
+LibExtern SEXP R_CachedScalarInteger INI_as(NULL);
+
LibExtern int R_num_math_threads INI_as(1);
LibExtern int R_max_num_math_threads INI_as(1);
@@ -808,10 +818,6 @@
LibExtern SEXP R_FalseValue INI_as(NULL);
LibExtern SEXP R_LogicalNAValue INI_as(NULL);
-#ifdef Win32
-LibExtern Rboolean UseInternet2;
-#endif
-
#ifdef __MAIN__
# undef extern
# undef extern0
@@ -856,7 +862,6 @@
# define EncodeString Rf_EncodeString
# define EnsureString Rf_EnsureString
# define endcontext Rf_endcontext
-# define envlength Rf_envlength
# define ErrorMessage Rf_ErrorMessage
# define evalList Rf_evalList
# define evalListKeepMissing Rf_evalListKeepMissing
@@ -910,6 +915,8 @@
# define matchPar Rf_matchPar
# define Mbrtowc Rf_mbrtowc
# define mbtoucs Rf_mbtoucs
+# define mbcsToUcs2 Rf_mbcsToUcs2
+# define memtrace_report Rf_memtrace_report
# define mkCLOSXP Rf_mkCLOSXP
# define mkFalse Rf_mkFalse
# define mkPROMISE Rf_mkPROMISE
@@ -996,7 +1003,8 @@
double R_FileMtime(const char *);
/* environment cell access */
-typedef struct R_varloc_st *R_varloc_t;
+typedef struct { SEXP cell; } R_varloc_t; /* use struct to prevent casting */
+#define R_VARLOC_IS_NULL(loc) ((loc).cell == NULL)
R_varloc_t R_findVarLocInFrame(SEXP, SEXP);
SEXP R_GetVarLocValue(R_varloc_t);
SEXP R_GetVarLocSymbol(R_varloc_t);
@@ -1055,10 +1063,12 @@
int DispatchAnyOrEval(SEXP, SEXP, const char *, SEXP, SEXP, SEXP*, int, int);
int DispatchOrEval(SEXP, SEXP, const char *, SEXP, SEXP, SEXP*, int, int);
int DispatchGroup(const char *, SEXP,SEXP,SEXP,SEXP,SEXP*);
+R_xlen_t dispatch_xlength(SEXP, SEXP, SEXP);
+R_len_t dispatch_length(SEXP, SEXP, SEXP);
+SEXP dispatch_subset2(SEXP, R_xlen_t, SEXP, SEXP);
SEXP duplicated(SEXP, Rboolean);
R_xlen_t any_duplicated(SEXP, Rboolean);
R_xlen_t any_duplicated3(SEXP, SEXP, Rboolean);
-int envlength(SEXP);
SEXP evalList(SEXP, SEXP, SEXP, int);
SEXP evalListKeepMissing(SEXP, SEXP);
int factorsConform(SEXP, SEXP);
@@ -1187,7 +1197,7 @@
SEXP R_sysfunction(int,RCNTXT*);
void R_run_onexits(RCNTXT *);
-void R_restore_globals(RCNTXT *);
+void NORET R_jumpctxt(RCNTXT *, int, SEXP);
#endif
/* ../main/bind.c */
diff -Nru r-base-3.2.3/src/include/Errormsg.h r-base-3.3.1/src/include/Errormsg.h
--- r-base-3.2.3/src/include/Errormsg.h 2015-08-25 22:15:22.000000000 +0000
+++ r-base-3.3.1/src/include/Errormsg.h 2016-01-29 23:15:06.000000000 +0000
@@ -18,6 +18,8 @@
* https://www.R-project.org/Licenses/
*/
+/* Internal header, not installed */
+
#ifndef ERRORMSG_H
#define ERRORMSG_H
diff -Nru r-base-3.2.3/src/include/Fileio.h r-base-3.3.1/src/include/Fileio.h
--- r-base-3.2.3/src/include/Fileio.h 2015-08-25 22:15:23.000000000 +0000
+++ r-base-3.3.1/src/include/Fileio.h 2016-03-16 23:02:20.000000000 +0000
@@ -18,6 +18,8 @@
* https://www.R-project.org/Licenses/
*/
+/* Internal header, not installed */
+
#ifndef RFILEIO_H_
#define RFILEIO_H_
diff -Nru r-base-3.2.3/src/include/Graphics.h r-base-3.3.1/src/include/Graphics.h
--- r-base-3.2.3/src/include/Graphics.h 2015-08-25 22:15:22.000000000 +0000
+++ r-base-3.3.1/src/include/Graphics.h 2016-01-29 23:15:06.000000000 +0000
@@ -18,11 +18,11 @@
* https://www.R-project.org/Licenses/
*/
+/* Internal header, not installed */
+
#ifndef GRAPHICS_H_
#define GRAPHICS_H_
-/* This is a private header */
-
#include
#include
@@ -31,8 +31,6 @@
#define R_GRAPHICS 1
#include /* RUnit */
-//typedef unsigned int rcolor;
-
/* base.c, graphics.c, par.c */
#define MAX_LAYOUT_ROWS 200
#define MAX_LAYOUT_COLS 200
diff -Nru r-base-3.2.3/src/include/Internal.h r-base-3.3.1/src/include/Internal.h
--- r-base-3.2.3/src/include/Internal.h 2015-08-25 22:15:24.000000000 +0000
+++ r-base-3.3.1/src/include/Internal.h 2016-03-16 23:02:20.000000000 +0000
@@ -1,7 +1,7 @@
/*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
- * Copyright (C) 1997--2015 The R Core Team
+ * Copyright (C) 1997--2016 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,7 +33,6 @@
#if Win32
SEXP do_mkjunction(SEXP, SEXP, SEXP, SEXP);
SEXP do_shellexec(SEXP, SEXP, SEXP, SEXP);
-SEXP do_setInternet2(SEXP, SEXP, SEXP, SEXP);
SEXP do_syswhich(SEXP, SEXP, SEXP, SEXP);
SEXP do_tzone_name(SEXP, SEXP, SEXP, SEXP);
#else
@@ -64,6 +63,7 @@
SEXP do_asmatrixdf(SEXP, SEXP, SEXP, SEXP);
SEXP do_assign(SEXP, SEXP, SEXP, SEXP);
SEXP do_asvector(SEXP, SEXP, SEXP, SEXP);
+SEXP do_asCharacterFactor(SEXP, SEXP, SEXP, SEXP);
SEXP do_AT(SEXP call, SEXP op, SEXP args, SEXP env);
SEXP do_attach(SEXP,SEXP,SEXP,SEXP);
SEXP do_attr(SEXP, SEXP, SEXP, SEXP);
@@ -112,12 +112,8 @@
SEXP do_curlGetHeaders(SEXP, SEXP, SEXP, SEXP);
SEXP do_curlVersion(SEXP, SEXP, SEXP, SEXP);
SEXP do_D2POSIXlt(SEXP, SEXP, SEXP, SEXP);
-SEXP do_dataentry(SEXP, SEXP, SEXP, SEXP);
-SEXP do_dataframe(SEXP, SEXP, SEXP, SEXP);
-SEXP do_dataviewer(SEXP, SEXP, SEXP, SEXP);
SEXP do_date(SEXP, SEXP, SEXP, SEXP);
SEXP do_debug(SEXP, SEXP, SEXP, SEXP);
-SEXP do_devAskNewPage(SEXP, SEXP, SEXP, SEXP);
SEXP do_delayed(SEXP, SEXP, SEXP, SEXP);
SEXP do_deparse(SEXP, SEXP, SEXP, SEXP);
SEXP do_detach(SEXP,SEXP,SEXP,SEXP);
@@ -161,7 +157,6 @@
SEXP do_filechoose(SEXP, SEXP, SEXP, SEXP);
SEXP do_filecopy(SEXP, SEXP, SEXP, SEXP);
SEXP do_filecreate(SEXP, SEXP, SEXP, SEXP);
-SEXP do_fileedit(SEXP, SEXP, SEXP, SEXP);
SEXP do_fileexists(SEXP, SEXP, SEXP, SEXP);
SEXP do_fileinfo(SEXP, SEXP, SEXP, SEXP);
SEXP do_filelink(SEXP, SEXP, SEXP, SEXP);
@@ -173,7 +168,6 @@
SEXP do_findinterval(SEXP, SEXP, SEXP, SEXP);
SEXP do_first_min(SEXP, SEXP, SEXP, SEXP);
SEXP do_flush(SEXP, SEXP, SEXP, SEXP);
-SEXP do_flushconsole(SEXP, SEXP, SEXP, SEXP);
SEXP do_for(SEXP, SEXP, SEXP, SEXP);
SEXP do_forceAndCall(SEXP, SEXP, SEXP, SEXP);
SEXP do_format(SEXP, SEXP, SEXP, SEXP);
@@ -203,12 +197,9 @@
SEXP do_getwd(SEXP, SEXP, SEXP, SEXP);
SEXP do_glob(SEXP, SEXP, SEXP, SEXP);
SEXP do_globalenv(SEXP, SEXP, SEXP, SEXP);
-SEXP do_gray(SEXP, SEXP, SEXP, SEXP);
SEXP do_grep(SEXP, SEXP, SEXP, SEXP);
SEXP do_grepraw(SEXP, SEXP, SEXP, SEXP);
SEXP do_gsub(SEXP, SEXP, SEXP, SEXP);
-SEXP do_hsv(SEXP, SEXP, SEXP, SEXP);
-SEXP do_hcl(SEXP, SEXP, SEXP, SEXP);
SEXP do_iconv(SEXP, SEXP, SEXP, SEXP);
SEXP do_ICUget(SEXP, SEXP, SEXP, SEXP);
SEXP do_ICUset(SEXP, SEXP, SEXP, SEXP);
@@ -285,7 +276,6 @@
SEXP do_onexit(SEXP, SEXP, SEXP, SEXP);
SEXP do_options(SEXP, SEXP, SEXP, SEXP);
SEXP do_order(SEXP, SEXP, SEXP, SEXP);
-SEXP do_pack(SEXP, SEXP, SEXP, SEXP);
SEXP do_packBits(SEXP, SEXP, SEXP, SEXP);
SEXP do_paren(SEXP, SEXP, SEXP, SEXP);
SEXP do_parentenv(SEXP, SEXP, SEXP, SEXP);
@@ -340,15 +330,12 @@
SEXP do_rep_len(SEXP, SEXP, SEXP, SEXP);
SEXP do_repeat(SEXP, SEXP, SEXP, SEXP);
SEXP do_resetCondHands(SEXP, SEXP, SEXP, SEXP);
-SEXP do_restart(SEXP, SEXP, SEXP, SEXP);
SEXP NORET do_return(SEXP, SEXP, SEXP, SEXP);
SEXP do_returnValue(SEXP, SEXP, SEXP, SEXP);
SEXP do_rgb(SEXP, SEXP, SEXP, SEXP);
-SEXP do_RGB2hsv(SEXP, SEXP, SEXP, SEXP);
SEXP do_Rhome(SEXP, SEXP, SEXP, SEXP);
SEXP do_RNGkind(SEXP, SEXP, SEXP, SEXP);
SEXP do_rowsum(SEXP, SEXP, SEXP, SEXP);
-SEXP do_rownames(SEXP, SEXP, SEXP, SEXP);
SEXP do_rowscols(SEXP, SEXP, SEXP, SEXP);
SEXP do_S4on(SEXP, SEXP, SEXP, SEXP);
SEXP do_sample(SEXP, SEXP, SEXP, SEXP);
@@ -358,7 +345,6 @@
SEXP do_saveplot(SEXP, SEXP, SEXP, SEXP);
SEXP do_scan(SEXP, SEXP, SEXP, SEXP);
SEXP do_search(SEXP, SEXP, SEXP, SEXP);
-SEXP do_selectlist(SEXP, SEXP, SEXP, SEXP);
SEXP do_seq(SEXP, SEXP, SEXP, SEXP);
SEXP do_seq_along(SEXP, SEXP, SEXP, SEXP);
SEXP do_seq_len(SEXP, SEXP, SEXP, SEXP);
@@ -386,8 +372,10 @@
SEXP do_split(SEXP, SEXP, SEXP, SEXP);
SEXP do_sprintf(SEXP, SEXP, SEXP, SEXP);
SEXP do_standardGeneric(SEXP, SEXP, SEXP, SEXP);
+SEXP do_startsWith(SEXP, SEXP, SEXP, SEXP);
SEXP NORET do_stop(SEXP, SEXP, SEXP, SEXP);
SEXP do_storage_mode(SEXP, SEXP, SEXP, SEXP);
+SEXP do_strrep(SEXP, SEXP, SEXP, SEXP);
SEXP do_strsplit(SEXP,SEXP,SEXP,SEXP);
SEXP do_strptime(SEXP,SEXP,SEXP,SEXP);
SEXP do_strtrim(SEXP,SEXP,SEXP,SEXP);
@@ -401,15 +389,11 @@
SEXP do_subassign2(SEXP, SEXP, SEXP, SEXP);
SEXP do_subassign2_dflt(SEXP, SEXP, SEXP, SEXP);
SEXP do_subassign3(SEXP, SEXP, SEXP, SEXP);
-SEXP do_subassigndf(SEXP, SEXP, SEXP, SEXP);
-SEXP do_subassigndf2(SEXP, SEXP, SEXP, SEXP);
SEXP do_subset(SEXP, SEXP, SEXP, SEXP);
SEXP do_subset_dflt(SEXP, SEXP, SEXP, SEXP);
SEXP do_subset2(SEXP, SEXP, SEXP, SEXP);
SEXP do_subset2_dflt(SEXP, SEXP, SEXP, SEXP);
SEXP do_subset3(SEXP, SEXP, SEXP, SEXP);
-SEXP do_subsetdf(SEXP, SEXP, SEXP, SEXP);
-SEXP do_subsetdf2(SEXP, SEXP, SEXP, SEXP);
SEXP do_substitute(SEXP, SEXP, SEXP, SEXP);
SEXP do_substr(SEXP,SEXP,SEXP,SEXP);
SEXP do_substrgets(SEXP,SEXP,SEXP,SEXP);
@@ -437,9 +421,10 @@
SEXP do_unlist(SEXP, SEXP, SEXP, SEXP);
SEXP do_unserializeFromConn(SEXP, SEXP, SEXP, SEXP);
SEXP do_unsetenv(SEXP, SEXP, SEXP, SEXP);
-SEXP do_unzip(SEXP, SEXP, SEXP, SEXP);
SEXP NORET do_usemethod(SEXP, SEXP, SEXP, SEXP);
SEXP do_utf8ToInt(SEXP, SEXP, SEXP, SEXP);
+SEXP do_validEnc(SEXP, SEXP, SEXP, SEXP);
+SEXP do_validUTF8(SEXP, SEXP, SEXP, SEXP);
SEXP do_vapply(SEXP, SEXP, SEXP, SEXP);
SEXP do_version(SEXP, SEXP, SEXP, SEXP);
SEXP do_warning(SEXP, SEXP, SEXP, SEXP);
@@ -473,7 +458,6 @@
SEXP do_stdin(SEXP, SEXP, SEXP, SEXP);
SEXP do_stdout(SEXP, SEXP, SEXP, SEXP);
SEXP do_stderr(SEXP, SEXP, SEXP, SEXP);
-SEXP do_readlines(SEXP, SEXP, SEXP, SEXP);
SEXP do_writelines(SEXP, SEXP, SEXP, SEXP);
SEXP do_readbin(SEXP, SEXP, SEXP, SEXP);
SEXP do_writebin(SEXP, SEXP, SEXP, SEXP);
@@ -501,7 +485,6 @@
SEXP do_getconnection(SEXP, SEXP, SEXP, SEXP);
SEXP do_getallconnections(SEXP, SEXP, SEXP, SEXP);
SEXP do_sumconnection(SEXP, SEXP, SEXP, SEXP);
-SEXP do_download(SEXP, SEXP, SEXP, SEXP);
SEXP do_sockconn(SEXP, SEXP, SEXP, SEXP);
SEXP do_sockselect(SEXP, SEXP, SEXP, SEXP);
SEXP do_gzcon(SEXP, SEXP, SEXP, SEXP);
diff -Nru r-base-3.2.3/src/include/IOStuff.h r-base-3.3.1/src/include/IOStuff.h
--- r-base-3.2.3/src/include/IOStuff.h 2015-08-25 22:15:24.000000000 +0000
+++ r-base-3.3.1/src/include/IOStuff.h 2016-01-29 23:15:06.000000000 +0000
@@ -18,6 +18,8 @@
* https://www.R-project.org/Licenses/
*/
+/* Internal header, not installed */
+
#ifndef R_IOSTUFF_H
#define R_IOSTUFF_H
diff -Nru r-base-3.2.3/src/include/Parse.h r-base-3.3.1/src/include/Parse.h
--- r-base-3.2.3/src/include/Parse.h 2015-08-25 22:15:23.000000000 +0000
+++ r-base-3.3.1/src/include/Parse.h 2016-01-29 23:15:06.000000000 +0000
@@ -17,6 +17,8 @@
* https://www.R-project.org/Licenses/
*/
+/* Internal header, not installed */
+
#ifndef R_PARSE_H
#define R_PARSE_H
diff -Nru r-base-3.2.3/src/include/Print.h r-base-3.3.1/src/include/Print.h
--- r-base-3.2.3/src/include/Print.h 2015-08-25 22:15:21.000000000 +0000
+++ r-base-3.3.1/src/include/Print.h 2016-01-29 23:15:06.000000000 +0000
@@ -18,6 +18,8 @@
* https://www.R-project.org/Licenses/
*/
+/* Internal header, not installed */
+
#ifndef PRINT_H_
#define PRINT_H_
diff -Nru r-base-3.2.3/src/include/Rconnections.h r-base-3.3.1/src/include/Rconnections.h
--- r-base-3.2.3/src/include/Rconnections.h 2015-08-25 22:15:23.000000000 +0000
+++ r-base-3.3.1/src/include/Rconnections.h 2016-01-29 23:15:06.000000000 +0000
@@ -17,6 +17,8 @@
* https://www.R-project.org/Licenses/
*/
+/* Internal header, not installed */
+
#ifndef R_CONNECTIONS_H_
#define R_CONNECTIONS_H_
diff -Nru r-base-3.2.3/src/include/Rdefines.h r-base-3.3.1/src/include/Rdefines.h
--- r-base-3.2.3/src/include/Rdefines.h 2015-08-25 22:15:21.000000000 +0000
+++ r-base-3.3.1/src/include/Rdefines.h 2016-03-16 23:02:19.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 1999-2013 The R Core Team.
+ * Copyright (C) 1999-2016 The R Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -17,6 +17,13 @@
* https://www.R-project.org/Licenses/
*/
+/* From 'Writing R Extensions:
+
+ 'these are not kept up to date and are not recommended for new projects.'
+
+ As from R 3.3.0 they have been adjusted to work when R_NO_REMAP is defined.
+*/
+
#ifndef R_DEFINES_H
#define R_DEFINES_H
@@ -48,34 +55,43 @@
#define NULL_USER_OBJECT R_NilValue
-#define AS_LOGICAL(x) coerceVector(x,LGLSXP)
-#define AS_INTEGER(x) coerceVector(x,INTSXP)
-#define AS_NUMERIC(x) coerceVector(x,REALSXP)
-#define AS_CHARACTER(x) coerceVector(x,STRSXP)
-#define AS_COMPLEX(x) coerceVector(x,CPLXSXP)
-#define AS_VECTOR(x) coerceVector(x,VECSXP)
-#define AS_LIST(x) coerceVector(x,VECSXP)
-#define AS_RAW(x) coerceVector(x,RAWSXP)
-
-#define IS_LOGICAL(x) isLogical(x)
-#define IS_INTEGER(x) isInteger(x)
-#define IS_NUMERIC(x) isReal(x)
-#define IS_CHARACTER(x) isString(x)
-#define IS_COMPLEX(x) isComplex(x)
-/* NB: is this right? It means atomic or VECSXP or EXPRSXP */
-#define IS_VECTOR(x) isVector(x)
+#define AS_LOGICAL(x) Rf_coerceVector(x,LGLSXP)
+#define AS_INTEGER(x) Rf_coerceVector(x,INTSXP)
+#define AS_NUMERIC(x) Rf_coerceVector(x,REALSXP)
+#define AS_CHARACTER(x) Rf_coerceVector(x,STRSXP)
+#define AS_COMPLEX(x) Rf_coerceVector(x,CPLXSXP)
+#define AS_VECTOR(x) Rf_coerceVector(x,VECSXP)
+#define AS_LIST(x) Rf_coerceVector(x,VECSXP)
+#define AS_RAW(x) Rf_coerceVector(x,RAWSXP)
+
+#ifdef USE_RINTERNALS
+// This is not documented to be supported, and may not be in future
+# define IS_LOGICAL(x) isLogical(x)
+# define IS_INTEGER(x) isInteger(x)
+# define IS_NUMERIC(x) isReal(x)
+# define IS_CHARACTER(x) isString(x)
+# define IS_COMPLEX(x) isComplex(x)
+#else
+# define IS_LOGICAL(x) Rf_isLogical(x)
+# define IS_INTEGER(x) Rf_isInteger(x)
+# define IS_NUMERIC(x) Rf_isReal(x)
+# define IS_CHARACTER(x) Rf_isString(x)
+# define IS_COMPLEX(x) Rf_isComplex(x)
+#endif
+/* NB: is this right? It means atomic or VECSXP or EXPRSXP */
+#define IS_VECTOR(x) Rf_isVector(x)
/* And this cannot be right: isVectorList(x)? */
#define IS_LIST(x) IS_VECTOR(x)
#define IS_RAW(x) (TYPEOF(x) == RAWSXP)
-#define NEW_LOGICAL(n) allocVector(LGLSXP,n)
-#define NEW_INTEGER(n) allocVector(INTSXP,n)
-#define NEW_NUMERIC(n) allocVector(REALSXP,n)
-#define NEW_CHARACTER(n) allocVector(STRSXP,n)
-#define NEW_COMPLEX(n) allocVector(CPLXSXP,n)
-#define NEW_LIST(n) allocVector(VECSXP,n)
+#define NEW_LOGICAL(n) Rf_allocVector(LGLSXP,n)
+#define NEW_INTEGER(n) Rf_allocVector(INTSXP,n)
+#define NEW_NUMERIC(n) Rf_allocVector(REALSXP,n)
+#define NEW_CHARACTER(n) Rf_allocVector(STRSXP,n)
+#define NEW_COMPLEX(n) Rf_allocVector(CPLXSXP,n)
+#define NEW_LIST(n) Rf_allocVector(VECSXP,n)
#define NEW_STRING(n) NEW_CHARACTER(n)
-#define NEW_RAW(n) allocVector(RAWSXP,n)
+#define NEW_RAW(n) Rf_allocVector(RAWSXP,n)
#define LOGICAL_POINTER(x) LOGICAL(x)
#define INTEGER_POINTER(x) INTEGER(x)
@@ -109,33 +125,33 @@
#define RECURSIVE_DATA(x) (VECTOR_PTR(x))
#define VECTOR_DATA(x) (VECTOR_PTR(x))
-#define LOGICAL_VALUE(x) asLogical(x)
-#define INTEGER_VALUE(x) asInteger(x)
-#define NUMERIC_VALUE(x) asReal(x)
-#define CHARACTER_VALUE(x) CHAR(asChar(x))
-#define STRING_VALUE(x) CHAR(asChar(x))
-#define LIST_VALUE(x) error("the 'value' of a list object is not defined")
-#define RAW_VALUE(x) error("the 'value' of a raw object is not defined")
+#define LOGICAL_VALUE(x) Rf_asLogical(x)
+#define INTEGER_VALUE(x) Rf_asInteger(x)
+#define NUMERIC_VALUE(x) Rf_asReal(x)
+#define CHARACTER_VALUE(x) CHAR(Rf_asChar(x))
+#define STRING_VALUE(x) CHAR(Rf_asChar(x))
+#define LIST_VALUE(x) Rf_error("the 'value' of a list object is not defined")
+#define RAW_VALUE(x) Rf_error("the 'value' of a raw object is not defined")
#define SET_ELEMENT(x, i, val) SET_VECTOR_ELT(x, i, val)
-#define GET_ATTR(x,what) getAttrib(x, what)
-#define GET_CLASS(x) getAttrib(x, R_ClassSymbol)
-#define GET_DIM(x) getAttrib(x, R_DimSymbol)
-#define GET_DIMNAMES(x) getAttrib(x, R_DimNamesSymbol)
-#define GET_COLNAMES(x) GetColNames(x)
-#define GET_ROWNAMES(x) GetRowNames(x)
-#define GET_LEVELS(x) getAttrib(x, R_LevelsSymbol)
-#define GET_TSP(x) getAttrib(x, R_TspSymbol)
-#define GET_NAMES(x) getAttrib(x, R_NamesSymbol)
-#define SET_ATTR(x, what, n) setAttrib(x, what, n)
-#define SET_CLASS(x, n) setAttrib(x, R_ClassSymbol, n)
-#define SET_DIM(x, n) setAttrib(x, R_DimSymbol, n)
-#define SET_DIMNAMES(x, n) setAttrib(x, R_DimNamesSymbol, n)
-#define SET_LEVELS(x, l) setAttrib(x, R_LevelsSymbol, l)
-#define SET_NAMES(x, n) setAttrib(x, R_NamesSymbol, n)
+#define GET_ATTR(x,what) Rf_getAttrib(x, what)
+#define GET_CLASS(x) Rf_getAttrib(x, R_ClassSymbol)
+#define GET_DIM(x) Rf_getAttrib(x, R_DimSymbol)
+#define GET_DIMNAMES(x) Rf_getAttrib(x, R_DimNamesSymbol)
+#define GET_COLNAMES(x) Rf_GetColNames(x)
+#define GET_ROWNAMES(x) Rf_GetRowNames(x)
+#define GET_LEVELS(x) Rf_getAttrib(x, R_LevelsSymbol)
+#define GET_TSP(x) Rf_getAttrib(x, R_TspSymbol)
+#define GET_NAMES(x) Rf_getAttrib(x, R_NamesSymbol)
+#define SET_ATTR(x, what, n) Rf_setAttrib(x, what, n)
+#define SET_CLASS(x, n) Rf_setAttrib(x, R_ClassSymbol, n)
+#define SET_DIM(x, n) Rf_setAttrib(x, R_DimSymbol, n)
+#define SET_DIMNAMES(x, n) Rf_setAttrib(x, R_DimNamesSymbol, n)
+#define SET_LEVELS(x, l) Rf_setAttrib(x, R_LevelsSymbol, l)
+#define SET_NAMES(x, n) Rf_setAttrib(x, R_NamesSymbol, n)
/* These do not support long vectors */
-#define GET_LENGTH(x) length(x)
-#define SET_LENGTH(x, n) (x = lengthgets(x, n))
+#define GET_LENGTH(x) Rf_length(x)
+#define SET_LENGTH(x, n) (x = Rf_lengthgets(x, n))
#define GET_SLOT(x, what) R_do_slot(x, what)
#define SET_SLOT(x, what, value) R_do_slot_assign(x, what, value)
diff -Nru r-base-3.2.3/src/include/Rdynpriv.h r-base-3.3.1/src/include/Rdynpriv.h
--- r-base-3.2.3/src/include/Rdynpriv.h 2015-08-25 22:15:24.000000000 +0000
+++ r-base-3.3.1/src/include/Rdynpriv.h 2016-03-16 23:02:20.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 2001-12 The R Core Team.
+ * Copyright (C) 2001-2016 The R Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
/*****************************************************
These are internal routines and definitions subject
to unannounced changes. Do not use for packages, etc.
+ (The header is not installed.)
There is a great deal of repetition in the definitions
of the user-level method definitions and in the internal
@@ -33,11 +34,6 @@
*****************************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
#ifdef Win32
#include
#define CACHE_DLL_SYM 1
@@ -207,8 +203,4 @@
DL_FUNC R_dotCallFn(SEXP, SEXP, int);
SEXP R_doDotCall(DL_FUNC, int, SEXP *, SEXP);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* ifdef R_DYNPRIV_H */
diff -Nru r-base-3.2.3/src/include/Rembedded.h r-base-3.3.1/src/include/Rembedded.h
--- r-base-3.2.3/src/include/Rembedded.h 2015-08-25 22:15:23.000000000 +0000
+++ r-base-3.3.1/src/include/Rembedded.h 2016-01-29 23:15:06.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 2006-8 The R Core Team.
+ * Copyright (C) 2006-2016 The R Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,12 +23,12 @@
#ifndef REMBEDDED_H_
#define REMBEDDED_H_
+#include
+
#ifdef __cplusplus
extern "C" {
#endif
-#include
-
extern int Rf_initEmbeddedR(int argc, char *argv[]);
extern void Rf_endEmbeddedR(int fatal);
@@ -53,12 +53,7 @@
LibExtern char *R_TempDir;
extern void R_SaveGlobalEnv(void);
-
-#ifdef unix
-void fpu_setup(Rboolean start);
-#endif
-
-#ifdef Win32
+#ifdef _WIN32
extern char *getDLLVersion(void), *getRUser(void), *get_R_HOME(void);
extern void setup_term_ui(void);
LibExtern int UserBreak;
@@ -67,6 +62,8 @@
extern int GA_initapp(int, char **);
extern void GA_appcleanup(void);
extern void readconsolecfg(void);
+#else
+void fpu_setup(Rboolean start);
#endif
#ifdef __cplusplus
diff -Nru r-base-3.2.3/src/include/R_ext/Applic.h r-base-3.3.1/src/include/R_ext/Applic.h
--- r-base-3.2.3/src/include/R_ext/Applic.h 2015-08-25 22:15:20.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/Applic.h 2016-03-16 23:02:15.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 1998-2013 The R Core Team
+ * Copyright (C) 1998-2015 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -84,6 +84,7 @@
int findInterval(double *xt, int n, double x,
Rboolean rightmost_closed, Rboolean all_inside, int ilo,
int *mflag);
+// findInterval2() is only in Utils.h (and hence Rinternals.h)
/* ------------------ Entry points NOT in the R API --------------- */
diff -Nru r-base-3.2.3/src/include/R_ext/Arith.h r-base-3.3.1/src/include/R_ext/Arith.h
--- r-base-3.2.3/src/include/R_ext/Arith.h 2015-08-25 22:15:18.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/Arith.h 2016-03-16 23:02:15.000000000 +0000
@@ -1,7 +1,7 @@
/*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
- * Copyright (C) 1998--2015 The R Core Team.
+ * Copyright (C) 1998--2016 The R Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -24,21 +24,10 @@
#define R_ARITH_H_
/*
- This used to define _BSD_SOURCE to make declarations of finite and
- isnan visible in glibc. But that was deprecated in glibc 2.20, and
- --std=c99 suffices nowadays.
+ This used to define _BSD_SOURCE to make declarations of isfinite
+ and isnan visible in glibc. But that was deprecated in glibc 2.20,
+ and --std=c99 suffices nowadays.
*/
-#if defined HAVE_FEATURES_H
-# include
-# ifdef __GNUC_PREREQ
-# if __GNUC_PREREQ(2,20) && !defined(_DEFAULT_SOURCE_)
-# define _DEFAULT_SOURCE 1
-# endif
-# endif
-#endif
-#if defined(HAVE_GLIBC2) && !defined(_DEFAULT_SOURCE_) && !defined(_BSD_SOURCE)
-# define _BSD_SOURCE 1
-#endif
#include
#ifdef __cplusplus
diff -Nru r-base-3.2.3/src/include/R_ext/Callbacks.h r-base-3.3.1/src/include/R_ext/Callbacks.h
--- r-base-3.2.3/src/include/R_ext/Callbacks.h 2015-08-25 22:15:20.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/Callbacks.h 2016-03-02 23:02:03.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 2001-2 The R Core Team.
+ * Copyright (C) 2001-2016 The R Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -72,8 +72,8 @@
separate package on Omegahat and these declarations allow the package
to interface to the internal R code.
- See http://developer.r-project.org/RObjectTables.pdf,
- http://www.omegahat.org/RObjectTables/
+ See https://developer.r-project.org/RObjectTables.pdf,
+ http://www.omegahat.net/RObjectTables/
*/
typedef struct _R_ObjectTable R_ObjectTable;
diff -Nru r-base-3.2.3/src/include/R_ext/Connections.h r-base-3.3.1/src/include/R_ext/Connections.h
--- r-base-3.2.3/src/include/R_ext/Connections.h 2015-08-25 22:15:20.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/Connections.h 2016-03-24 23:15:12.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 2000-2013 The R Core Team.
+ * Copyright (C) 2000-2016 The R Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,8 +23,13 @@
#include
#ifndef NO_C_HEADERS
-# include /* for size_t */
-# include /* for va_list */
+# if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS)
+# include
+# include
+# else
+# include /* for size_t */
+# include /* for va_list */
+# endif
#endif
/* IMPORTANT: we do not expect future connection APIs to be
@@ -83,6 +88,7 @@
SEXP R_new_custom_connection(const char *description, const char *mode, const char *class_name, Rconnection *ptr);
size_t R_ReadConnection(Rconnection con, void *buf, size_t n);
size_t R_WriteConnection(Rconnection con, void *buf, size_t n);
+Rconnection R_GetConnection(SEXP sConn);
#ifdef __cplusplus
}
diff -Nru r-base-3.2.3/src/include/R_ext/eventloop.h r-base-3.3.1/src/include/R_ext/eventloop.h
--- r-base-3.2.3/src/include/R_ext/eventloop.h 2015-08-25 22:15:19.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/eventloop.h 2016-03-16 23:02:15.000000000 +0000
@@ -28,9 +28,9 @@
#define R_EXT_EVENTLOOP_H
#ifndef NO_C_HEADERS
-#ifdef HAVE_SYS_SELECT_H
-# include /* for fd_set according to recent POSIX */
-#endif
+# ifdef HAVE_SYS_SELECT_H
+# include /* for fd_set according to recent POSIX */
+# endif
/* NOTE: Needed at least on FreeBSD so that fd_set is defined. */
# include
#endif
diff -Nru r-base-3.2.3/src/include/R_ext/GraphicsEngine.h r-base-3.3.1/src/include/R_ext/GraphicsEngine.h
--- r-base-3.2.3/src/include/R_ext/GraphicsEngine.h 2015-08-25 22:15:20.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/GraphicsEngine.h 2016-03-16 23:02:15.000000000 +0000
@@ -57,9 +57,16 @@
* haveCapture, haveLocator. (R 2.14.0)
* Version 10: For R 3.0.0. Typedef and use 'rcolor',
* Remove name2col (R_GE_str2col does the job).
+ * Version 11: For R 3.3.0.
+ * Official support for saving/restoring display lists
+ * across R sessions (via recordPlot() and replayPlot())
+ * - added grid DL to snapshots (used to be NULL)
+ * - added this version number to snapshots (as attribute)
+ * - added R version number to snapshots (as attribute)
+ * - added pkgName to graphics system state info (as attribute)
*/
-#define R_GE_version 10
+#define R_GE_version 11
int R_GE_getVersion(void);
diff -Nru r-base-3.2.3/src/include/R_ext/Itermacros.h r-base-3.3.1/src/include/R_ext/Itermacros.h
--- r-base-3.2.3/src/include/R_ext/Itermacros.h 2015-08-25 22:15:19.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/Itermacros.h 2016-03-16 23:02:15.000000000 +0000
@@ -51,7 +51,27 @@
LOOP_WITH_INTERRUPT_CHECK(R_ITERATE_CORE, ncheck, n, i, loop_body); \
} while (0)
-#define MOD_ITERATE_CORE(n, n1, n2, i, i1, i2, loop_body) do { \
+
+#define MOD_ITERATE1_CORE(n, n1, i, i1, loop_body) do { \
+ for (; i < n; \
+ i1 = (++i1 == n1) ? 0 : i1, \
+ ++i) { \
+ loop_body \
+ } \
+ } while (0)
+
+#define MOD_ITERATE1(n, n1, i, i1, loop_body) do { \
+ i = i1 = 0; \
+ MOD_ITERATE1_CORE(n, n1, i, i1, loop_body); \
+ } while (0)
+
+#define MOD_ITERATE1_CHECK(ncheck, n, n1, i, i1, loop_body) do { \
+ i = i1 = 0; \
+ LOOP_WITH_INTERRUPT_CHECK(MOD_ITERATE1_CORE, ncheck, n, \
+ n1, i, i1, loop_body); \
+ } while (0)
+
+#define MOD_ITERATE2_CORE(n, n1, n2, i, i1, i2, loop_body) do { \
for (; i < n; \
i1 = (++i1 == n1) ? 0 : i1, \
i2 = (++i2 == n2) ? 0 : i2, \
@@ -60,17 +80,21 @@
} \
} while (0)
-#define MOD_ITERATE(n, n1, n2, i, i1, i2, loop_body) do { \
+#define MOD_ITERATE2(n, n1, n2, i, i1, i2, loop_body) do { \
i = i1 = i2 = 0; \
- MOD_ITERATE_CORE(n, n1, n2, i, i1, i2, loop_body); \
+ MOD_ITERATE2_CORE(n, n1, n2, i, i1, i2, loop_body); \
} while (0)
-#define MOD_ITERATE_CHECK(ncheck, n, n1, n2, i, i1, i2, loop_body) do { \
+#define MOD_ITERATE2_CHECK(ncheck, n, n1, n2, i, i1, i2, loop_body) do { \
i = i1 = i2 = 0; \
- LOOP_WITH_INTERRUPT_CHECK(MOD_ITERATE_CORE, ncheck, n, \
+ LOOP_WITH_INTERRUPT_CHECK(MOD_ITERATE2_CORE, ncheck, n, \
n1, n2, i, i1, i2, loop_body); \
} while (0)
+#define MOD_ITERATE MOD_ITERATE2
+#define MOD_ITERATE_CORE MOD_ITERATE2_CORE
+#define MOD_ITERATE_CHECK MOD_ITERATE2_CHECK
+
#define MOD_ITERATE3_CORE(n, n1, n2, n3, i, i1, i2, i3, loop_body) do { \
for (; i < n; \
i1 = (++i1 == n1) ? 0 : i1, \
diff -Nru r-base-3.2.3/src/include/R_ext/Lapack.h r-base-3.3.1/src/include/R_ext/Lapack.h
--- r-base-3.2.3/src/include/R_ext/Lapack.h 2015-08-25 22:15:17.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/Lapack.h 2016-03-16 23:02:15.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 2003-2015 The R Core Team.
+ * Copyright (C) 2003-2016 The R Core Team.
* Copyright (C) 2008 The R Foundation
*
* This program is free software; you can redistribute it and/or modify
@@ -36,11 +36,6 @@
#include /* for Rcomplex */
#include
-/* The LAPACK version: might change after installation with
- external LAPACK
-*/
-extern void F77_NAME(ilaver)(int *major, int *minor, int *patch);
-
/*
LAPACK function names are [dz](), where d denotes the real
@@ -52,6 +47,11 @@
extern "C" {
#endif
+/* The LAPACK version: might change after installation with
+ external LAPACK
+*/
+extern void F77_NAME(ilaver)(int *major, int *minor, int *patch);
+
// Never defined by R itself.
#ifndef La_extern
#define La_extern extern
@@ -244,18 +244,6 @@
double* vr, const int* ldvr, int* ilo, int* ihi,
double* scale, double* abnrm, double* rconde, double* rcondv,
double* work, const int* lwork, int* iwork, int* info);
-/* DGEGV - compute for a pair of n-by-n real nonsymmetric */
-/* matrices A and B, the generalized eigenvalues (alphar +/- */
-/* alphai*i, beta);, and optionally, the left and/or right */
-/* generalized eigenvectors (VL and VR); */
-La_extern void
-F77_NAME(dgegv)(const char* jobvl, const char* jobvr,
- const int* n, double* a, const int* lda,
- double* b, const int* ldb,
- double* alphar, double* alphai,
- const double* beta, double* vl, const int* ldvl,
- double* vr, const int* ldvr,
- double* work, const int* lwork, int* info);
/* DGEHD2 - reduce a real general matrix A to upper Hessenberg */
/* form H by an orthogonal similarity transformation */
La_extern void
@@ -315,11 +303,6 @@
F77_NAME(dgeqp3)(const int* m, const int* n, double* a, const int* lda,
int* jpvt, double* tau, double* work, const int* lwork,
int* info);
-/* DGEQPF - compute a QR factorization with column pivoting of a */
-/* real M-by-N matrix A */
-La_extern void
-F77_NAME(dgeqpf)(const int* m, const int* n, double* a, const int* lda,
- int* jpvt, double* tau, double* work, int* info);
/* DGEQR2 - compute a QR factorization of a real m by n matrix A */
La_extern void
F77_NAME(dgeqr2)(const int* m, const int* n, double* a, const int* lda,
@@ -459,20 +442,6 @@
double* a, const int* lda, double* taua,
double* b, const int* ldb, double* taub,
double* work, const int* lwork, int* info);
-/* DGGSVD - compute the generalized singular value decomposition */
-/* (GSVD) of an M-by-N real matrix A and P-by-N real matrix B */
-La_extern void
-F77_NAME(dggsvd)(const char* jobu, const char* jobv, const char* jobq,
- const int* m, const int* n, const int* p,
- const int* k, const int* l,
- double* a, const int* lda,
- double* b, const int* ldb,
- const double* alpha, const double* beta,
- double* u, const int* ldu,
- double* v, const int* ldv,
- double* q, const int* ldq,
- double* work, int* iwork, int* info);
-
//* Double precision General Tridiagonal matrices -> DGT
@@ -1597,14 +1566,6 @@
const double* a, const int* lda,
double* b, const int* ldb, int* info);
-/* DTZRQF - reduce the M-by-N ( M<=N ); real upper trapezoidal */
-/* matrix A to upper triangular form by means of orthogonal */
-/* transformations */
-La_extern void
-F77_NAME(dtzrqf)(const int* m, const int* n,
- double* a, const int* lda,
- double* tau, int* info);
-
//* Double precision utilities in Lapack
@@ -1868,14 +1829,6 @@
double* H, const int* ldh, double* wr, double* wi,
const int* iloz, const int* ihiz,
double* z, const int* ldz, int* info);
-/* DLAHRD - reduce the first NB columns of a real general */
-/* n-by-(n-k+1); matrix A so that elements below the k-th */
-/* subdiagonal are zero */
-La_extern void
-F77_NAME(dlahrd)(const int* n, const int* k, const int* nb,
- double* a, const int* lda,
- double* tau, double* t, const int* ldt,
- double* y, const int* ldy);
/* DLAIC1 - apply one step of incremental condition estimation in */
/* its simplest version */
La_extern void
@@ -2238,13 +2191,6 @@
const char* diag, const char* normin,
const int* n, const double* a, const int* lda,
double* x, double* scale, double* cnorm, int* info);
-/* DLATZM - apply a Householder matrix generated by DTZRQF to a */
-/* matrix */
-La_extern void
-F77_NAME(dlatzm)(const char* side, const int* m, const int* n,
- const double* v, const int* incv,
- const double* tau, double* c1, double* c2,
- const int* ldc, double* work);
/* DLAUU2 - compute the product U * U' or L' * const int* l, where the */
/* triangular factor U or L is stored in the upper or lower */
/* triangular part of the array A */
@@ -2377,25 +2323,12 @@
int *ldvt, double *q, int *iq, double *work, int * iwork, int *info);
La_extern void
-F77_NAME(dgegs)(char *jobvsl, char *jobvsr, int *n,
- double *a, int *lda, double *b, int *ldb, double *
- alphar, double *alphai, double *beta, double *vsl,
- int *ldvsl, double *vsr, int *ldvsr, double *work,
- int *lwork, int *info);
-
-La_extern void
F77_NAME(dgelsd)(int *m, int *n, int *nrhs,
double *a, int *lda, double *b, int *ldb, double *
s, double *rcond, int *rank, double *work, int *lwork,
int *iwork, int *info);
La_extern void
-F77_NAME(dgelsx)(int *m, int *n, int *nrhs,
- double *a, int *lda, double *b, int *ldb, int *
- jpvt, double *rcond, int *rank, double *work, int *
- info);
-
-La_extern void
F77_NAME(dgesc2)(int *n, double *a, int *lda,
double *rhs, int *ipiv, int *jpiv, double *scale);
@@ -2443,14 +2376,6 @@
bwork, int *info);
La_extern void
-F77_NAME(dggsvp)(char *jobu, char *jobv, char *jobq, int *m,
- int *p, int *n, double *a, int *lda, double *b,
- int *ldb, double *tola, double *tolb, int *k, int
- *l, double *u, int *ldu, double *v, int *ldv,
- double *q, int *ldq, int *iwork, double *tau,
- double *work, int *info);
-
-La_extern void
F77_NAME(dgtts2)(int *itrans, int *n, int *nrhs,
double *dl, double *d, double *du, double *du2,
int *ipiv, double *b, int *ldb);
@@ -2896,11 +2821,6 @@
Rcomplex *w, int *iloz, int *ihiz, Rcomplex *z,
int *ldz, int *info);
-La_extern void
-F77_NAME(zlahrd)(int *n, int *k, int *nb,
- Rcomplex *a, int *lda, Rcomplex *tau, Rcomplex *t,
- int *ldt, Rcomplex *y, int *ldy);
-
La_extern double
F77_NAME(zlange)(char *norm, int *m, int *n, Rcomplex *a, int *lda,
double *work);
@@ -3096,6 +3016,100 @@
double *rcond, int *rank,
Rcomplex *work, int *lwork, double *rwork, int *iwork, int *info);
+/* =========================== DEPRECATED ==============================
+
+ Routines below were deprecated in LAPACK 3.6.0, and are not
+ included in a default build of LAPACK.
+
+ Currently dgegv, dgeqpf, dggsvd and dggsvp are included in R, but
+ that may change before release of R 3.3.0.
+ */
+
+/* DGEGV - compute for a pair of n-by-n real nonsymmetric */
+/* matrices A and B, the generalized eigenvalues (alphar +/- */
+/* alphai*i, beta);, and optionally, the left and/or right */
+/* generalized eigenvectors (VL and VR); */
+La_extern void
+F77_NAME(dgegv)(const char* jobvl, const char* jobvr,
+ const int* n, double* a, const int* lda,
+ double* b, const int* ldb,
+ double* alphar, double* alphai,
+ const double* beta, double* vl, const int* ldvl,
+ double* vr, const int* ldvr,
+ double* work, const int* lwork, int* info);
+
+/* DGEQPF - compute a QR factorization with column pivoting of a */
+/* real M-by-N matrix A */
+La_extern void
+F77_NAME(dgeqpf)(const int* m, const int* n, double* a, const int* lda,
+ int* jpvt, double* tau, double* work, int* info);
+
+/* DGGSVD - compute the generalized singular value decomposition */
+/* (GSVD) of an M-by-N real matrix A and P-by-N real matrix B */
+La_extern void
+F77_NAME(dggsvd)(const char* jobu, const char* jobv, const char* jobq,
+ const int* m, const int* n, const int* p,
+ const int* k, const int* l,
+ double* a, const int* lda,
+ double* b, const int* ldb,
+ const double* alpha, const double* beta,
+ double* u, const int* ldu,
+ double* v, const int* ldv,
+ double* q, const int* ldq,
+ double* work, int* iwork, int* info);
+
+/* DTZRQF - reduce the M-by-N ( M<=N ); real upper trapezoidal */
+/* matrix A to upper triangular form by means of orthogonal */
+/* transformations */
+La_extern void
+F77_NAME(dtzrqf)(const int* m, const int* n,
+ double* a, const int* lda,
+ double* tau, int* info);
+
+/* DLAHRD - reduce the first NB columns of a real general */
+/* n-by-(n-k+1); matrix A so that elements below the k-th */
+/* subdiagonal are zero */
+La_extern void
+F77_NAME(dlahrd)(const int* n, const int* k, const int* nb,
+ double* a, const int* lda,
+ double* tau, double* t, const int* ldt,
+ double* y, const int* ldy);
+
+/* DLATZM - apply a Householder matrix generated by DTZRQF to a */
+/* matrix */
+La_extern void
+F77_NAME(dlatzm)(const char* side, const int* m, const int* n,
+ const double* v, const int* incv,
+ const double* tau, double* c1, double* c2,
+ const int* ldc, double* work);
+
+La_extern void
+F77_NAME(dgegs)(char *jobvsl, char *jobvsr, int *n,
+ double *a, int *lda, double *b, int *ldb, double *
+ alphar, double *alphai, double *beta, double *vsl,
+ int *ldvsl, double *vsr, int *ldvsr, double *work,
+ int *lwork, int *info);
+
+La_extern void
+F77_NAME(dgelsx)(int *m, int *n, int *nrhs,
+ double *a, int *lda, double *b, int *ldb, int *
+ jpvt, double *rcond, int *rank, double *work, int *
+ info);
+
+La_extern void
+F77_NAME(dggsvp)(char *jobu, char *jobv, char *jobq, int *m,
+ int *p, int *n, double *a, int *lda, double *b,
+ int *ldb, double *tola, double *tolb, int *k, int
+ *l, double *u, int *ldu, double *v, int *ldv,
+ double *q, int *ldq, int *iwork, double *tau,
+ double *work, int *info);
+
+La_extern void
+F77_NAME(zlahrd)(int *n, int *k, int *nb,
+ Rcomplex *a, int *lda, Rcomplex *tau, Rcomplex *t,
+ int *ldt, Rcomplex *y, int *ldy);
+
+
#ifdef __cplusplus
}
#endif
diff -Nru r-base-3.2.3/src/include/R_ext/Memory.h r-base-3.3.1/src/include/R_ext/Memory.h
--- r-base-3.2.3/src/include/R_ext/Memory.h 2015-08-25 22:15:18.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/Memory.h 2016-03-16 23:02:15.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 1998-2007 The R Core Team
+ * Copyright (C) 1998-2016 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -26,7 +26,12 @@
#define R_EXT_MEMORY_H_
#ifndef NO_C_HEADERS
-# include /* for size_t */
+# if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS)
+# include
+using std::size_t;
+# else
+# include /* for size_t */
+# endif
#endif
#ifdef __cplusplus
diff -Nru r-base-3.2.3/src/include/R_ext/Rallocators.h r-base-3.3.1/src/include/R_ext/Rallocators.h
--- r-base-3.2.3/src/include/R_ext/Rallocators.h 2015-08-25 22:15:19.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/Rallocators.h 2016-03-16 23:02:15.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 2014 The R Core Team
+ * Copyright (C) 2014-2016 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -25,7 +25,11 @@
#define R_EXT_RALLOCATORS_H_
#ifndef NO_C_HEADERS
-# include /* for size_t */
+# if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS)
+# include
+# else
+# include /* for size_t */
+# endif
#endif
/* R_allocator_t typedef is also declared in Rinternals.h
diff -Nru r-base-3.2.3/src/include/R_ext/Random.h r-base-3.3.1/src/include/R_ext/Random.h
--- r-base-3.2.3/src/include/R_ext/Random.h 2015-08-25 22:15:19.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/Random.h 2016-03-16 23:02:15.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 1998-2014 The R Core Team
+ * Copyright (C) 1998-2016 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -22,12 +22,12 @@
#ifndef R_RANDOM_H
#define R_RANDOM_H
+#include
+
#ifdef __cplusplus
extern "C" {
#endif
-#include
-
typedef enum {
WICHMANN_HILL,
MARSAGLIA_MULTICARRY,
diff -Nru r-base-3.2.3/src/include/R_ext/R-ftp-http.h r-base-3.3.1/src/include/R_ext/R-ftp-http.h
--- r-base-3.2.3/src/include/R_ext/R-ftp-http.h 2015-08-25 22:15:17.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/R-ftp-http.h 2016-03-16 23:02:15.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 2001-2014 The R Core Team.
+ * Copyright (C) 2001-2016 The R Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -28,7 +28,13 @@
allow for 'large' files (>= 2GB) on 32-bit systems, where supported.
*/
/* required by C99/C11 */
-#include
+#ifndef NO_C_HEADERS
+# ifdef __cplusplus
+# include
+# else
+# include
+# endif
+#endif
typedef int_fast64_t DLsize_t; // used for download lengths and sizes
#ifdef __cplusplus
diff -Nru r-base-3.2.3/src/include/R_ext/RS.h r-base-3.3.1/src/include/R_ext/RS.h
--- r-base-3.2.3/src/include/R_ext/RS.h 2015-08-25 22:15:20.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/RS.h 2016-03-16 23:02:15.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 1999-2007 The R Core Team.
+ * Copyright (C) 1999-2016 The R Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -23,7 +23,14 @@
#define R_RS_H
#ifndef NO_C_HEADERS
-# include /* for memcpy, memset */
+# if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS)
+# include
+# include
+using std::size_t;
+# else
+# include /* for memcpy, memset */
+# include /* for size_t */
+# endif
#endif
#include /* for F77_APPEND_UNDERSCORE */
diff -Nru r-base-3.2.3/src/include/R_ext/Utils.h r-base-3.3.1/src/include/R_ext/Utils.h
--- r-base-3.2.3/src/include/R_ext/Utils.h 2015-08-25 22:15:19.000000000 +0000
+++ r-base-3.3.1/src/include/R_ext/Utils.h 2016-03-16 23:02:15.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 1998-2012 The R Core Team
+ * Copyright (C) 1998-2016 The R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -27,7 +27,15 @@
#include
#include
-#include
+
+#ifndef NO_C_HEADERS
+# if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS)
+# include
+using std::size_t;
+# else
+# include
+# endif
+#endif
#define revsort Rf_revsort
#define iPsort Rf_iPsort
@@ -91,6 +99,9 @@
int findInterval(double *xt, int n, double x,
Rboolean rightmost_closed, Rboolean all_inside, int ilo,
int *mflag);
+int findInterval2(double *xt, int n, double x,
+ Rboolean rightmost_closed, Rboolean all_inside, Rboolean left_open,
+ int ilo, int *mflag);
#ifdef R_RS_H
int F77_SUB(interv)(double *xt, int *n, double *x,
Rboolean *rightmost_closed, Rboolean *all_inside,
diff -Nru r-base-3.2.3/src/include/Rgraphics.h r-base-3.3.1/src/include/Rgraphics.h
--- r-base-3.2.3/src/include/Rgraphics.h 2015-08-25 22:15:24.000000000 +0000
+++ r-base-3.3.1/src/include/Rgraphics.h 2016-03-16 23:02:20.000000000 +0000
@@ -1,7 +1,7 @@
/*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
- * Copyright (C) 1998--2008 R Core Team
+ * Copyright (C) 1998--2016 R Core Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -21,11 +21,7 @@
#ifndef RGRAPHICS_H_
#define RGRAPHICS_H_
-/* This was a public header in R < 2.8.0, but no longer */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+/* Internal header, not installed */
/* possible coordinate systems (for specifying locations) */
typedef enum {
@@ -282,8 +278,4 @@
double xNPCtoUsr(double, pGEDevDesc);
double yNPCtoUsr(double, pGEDevDesc);
-#ifdef __cplusplus
-}
-#endif
-
#endif /* RGRAPHICS_H_ */
diff -Nru r-base-3.2.3/src/include/R.h r-base-3.3.1/src/include/R.h
--- r-base-3.2.3/src/include/R.h 2015-08-25 22:15:22.000000000 +0000
+++ r-base-3.3.1/src/include/R.h 2016-05-16 22:15:06.000000000 +0000
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
- * Copyright (C) 2000-2013 The R Core Team.
+ * Copyright (C) 2000-2016 The R Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@@ -25,15 +25,40 @@
#endif
#ifndef NO_C_HEADERS
-#include
-#include /* Used by several packages, remove in due course */
-#include /* for INT_MAX */
-#include
+/* same as Rmath.h: needed for cospi etc */
+# ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
+# define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
+# endif
+/* The C++ headers in Solaris Studio are strict C++98, and many
+ packages fail because of not using e.g. std::round
+ or using C99 functions such as snprintf.
+*/
+# ifdef __SUNPRO_CC
+# define DO_NOT_USE_CXX_HEADERS
+# endif
+# if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS)
+# include
+# include
+# include
+# include