diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 14159b7..21cd717 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -44,7 +44,15 @@ jobs: extra-packages: any::rcmdcheck needs: check - - uses: r-lib/actions/check-r-package@v2 - with: - upload-snapshots: true - build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' + - name: Install dependencies + run: | + sudo apt-get update && sudo apt-get install -y clang + - name: Run R CMD check with ASAN + run: | + export CC=clang + export CFLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer" + export CXX=clang++ + export CXXFLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer" + R CMD build . + R CMD check --as-cran read.dbc_*.tar.gz + shell: bash diff --git a/Makefile b/Makefile index fee0eed..50c97ef 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SRC=./src .PHONY: lib lib: clean # build the shared library version of dbc2dbf - R CMD SHLIB -o src/db2dbf.so src/*.c -fsanitize=undefined + R CMD SHLIB -o src/db2dbf.so src/*.c -fsanitize=address,undefined .PHONY: clean clean: # clean generated files diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/DESCRIPTION b/read.dbc.Rcheck/00_pkg_src/read.dbc/DESCRIPTION new file mode 100644 index 0000000..015b207 --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/DESCRIPTION @@ -0,0 +1,23 @@ +Package: read.dbc +Title: Read Data Stored in DBC (Compressed DBF) Files +Description: Functions for reading and decompressing the DBC (compressed DBF) files. Please note that this is the file format used by the Brazilian Ministry of Health (DATASUS) to publish healthcare datasets. It is not related to the FoxPro or CANdb DBC file formats. +Version: 1.0.7 +Depends: R (>= 3.3.0) +Imports: foreign +Authors@R: c( + person("Daniela", "Petruzalek", email = "daniela.petruzalek@gmail.com", role = c("aut", "cre", "cph")), + person("Mark", "Adler", email = "madler@alumni.caltech.edu", role = c("cph", "ctb")), + person("Pablo", "Marcondes Fonseca", email = "pablo.mmarcondes@gmail.com", role = c("cph", "ctb")) + ) +Maintainer: Daniela Petruzalek +URL: https://github.com/danicat/read.dbc +BugReports: https://github.com/danicat/read.dbc/issues +Copyright: 2016 Daniela Petruzalek +License: AGPL-3 +Encoding: UTF-8 +RoxygenNote: 7.3.1 +NeedsCompilation: yes +Packaged: 2025-07-14 23:14:25 UTC; jules +Author: Daniela Petruzalek [aut, cre, cph], + Mark Adler [cph, ctb], + Pablo Marcondes Fonseca [cph, ctb] diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/NAMESPACE b/read.dbc.Rcheck/00_pkg_src/read.dbc/NAMESPACE new file mode 100644 index 0000000..4e810d7 --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/NAMESPACE @@ -0,0 +1,5 @@ +# Generated by roxygen2: do not edit by hand + +export(dbc2dbf) +export(read.dbc) +useDynLib(read.dbc) diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/NEWS.md b/read.dbc.Rcheck/00_pkg_src/read.dbc/NEWS.md new file mode 100644 index 0000000..b082da5 --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/NEWS.md @@ -0,0 +1,7 @@ +# read.dbc 1.0.7 + +* Removed broken links +* Improved error handling in blast.c to prevent runtime errors (fixes gcc-UBSAN) +* Update DESCRIPTION with collaborators +* Documentation edits for conciseness +* Overall doc improvements diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/R/dbc2dbf.R b/read.dbc.Rcheck/00_pkg_src/read.dbc/R/dbc2dbf.R new file mode 100644 index 0000000..d5d053c --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/R/dbc2dbf.R @@ -0,0 +1,61 @@ +# dbc2dbf.R +# Copyright (C) 2016 Daniela Petruzalek +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +#' Decompress a DBC file +#' +#' This function allows you decompress a DBC file. When decompressed, it becomes a regular DBF file. +#' +#' @param input.file The name of the DBC file (including extension) +#' @param output.file The output file name (including extension) +#' @return Return TRUE if succeed, FALSE otherwise. +#' @details +#' DBC is the extension for compressed DBF files (from the 'XBASE' family of databases). +#' This is a proprietary file format used by the Brazilian government to publish public healthcare data. +#' When decompressed, it becomes a regular DBF file. +#' +#' Please note that this is the file format is not related to the FoxPro or CANdb DBC file formats. +#' @source +#' The internal C code for \code{dbc2dbf} is based on \code{blast} decompressor and \code{blast-dbf} (see \emph{References}). +#' @keywords dbc dbf +#' @export +#' @useDynLib read.dbc +#' @author Daniela Petruzalek, \email{daniela.petruzalek@gmail.com} +#' @seealso \code{\link{read.dbc}} +#' @examples +#' # Input file name +#' input <- system.file("files/sids.dbc", package = "read.dbc") +#' +#' # Output file name +#' output <- tempfile(fileext = ".dbc") +#' +#' # The call returns TRUE on success +#' if( dbc2dbf(input.file = input, output.file = output) ) { +#' print("File decompressed!") +#' # do things with the file +#' } +#' +#' file.remove(output) # clean up example, don't do in real life :) +#' +#' @references +#' \code{blast} source code in C: \url{https://github.com/madler/zlib/tree/master/contrib/blast} +#' \code{blast-dbf}, DBC to DBF command-line decompression tool: \url{https://github.com/eaglebh/blast-dbf} +#' +dbc2dbf <- function(input.file, output.file) { + if( !file.exists(input.file) ) + stop("Input file does not exist.") + out <- .C("dbc2dbf", input = as.character(path.expand(input.file)), output = as.character(path.expand(output.file))) + file.exists(output.file) +} diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/R/read.dbc.R b/read.dbc.Rcheck/00_pkg_src/read.dbc/R/read.dbc.R new file mode 100644 index 0000000..b87cd62 --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/R/read.dbc.R @@ -0,0 +1,68 @@ +# read.dbc.R +# Copyright (C) 2016 Daniela Petruzalek +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +#' Read Data Stored in DBC (Compressed DBF) Files +#' +#' This function allows you to read a DBC (compressed DBF) file into a data frame. +#' @details +#' DBC is the extension for compressed DBF files (from the 'XBASE' family of databases). +#' This is a proprietary file format used by the Brazilian government to publish public healthcare data, and it is not related to the FoxPro or CANdb DBC file formats. +#' +#' The \code{read.dbc} function will decompress the input DBC file into a temporary DBF file and call \code{\link{read.dbf}} from the \code{foreign} package to read it into a data frame. +#' +#' @note +#' DATASUS is the name of the Department of Informatics of the Brazilian Health System (Sistema Único de Saúde - SUS) and is responsible for publishing public healthcare data in Brazil. +#' Besides the DATASUS, the Brazilian National Agency for Supplementary Health (ANS) also uses this file format for its public data. +#' +#' This function was tested using files from both DATASUS and ANS to ensure compliance with the format, and hence ensure its usability by researchers. +#' +#' Neither this project, nor its author, has any association with the Brazilian government. +#' @param file The name of the DBC file (including extension) +#' @param ... Further arguments to be passed to \code{\link{read.dbf}} +#' @return A data.frame of the data from the DBC file. +#' @keywords dbc datasus +#' @export +#' @author Daniela Petruzalek, \email{daniela.petruzalek@gmail.com} +#' @seealso \code{\link{dbc2dbf}} +#' @examples +#' # The 'sids.dbc' file is the compressed version of 'sids.dbf' from the "foreign" package. +#' file <- system.file("files/sids.dbc", package="read.dbc") +#' sids <- read.dbc(file) +#' str(sids) +#' summary(sids) +#' +#' # This is a small subset of U.S. NOAA storm database. +#' file <- system.file("files/storm.dbc", package="read.dbc") +#' storm <- read.dbc(file) +#' head(storm) +#' str(storm) +#' +read.dbc <- function(file, ...) { + # Output file name + out <- tempfile(fileext = ".dbf") + + # Decompress the dbc file using the blast library wrapper. + if( dbc2dbf(file, out) ) { + # Use read.dbf from foreing package to read the uncompressed file + df <- foreign::read.dbf(out, ...) + + # Delete temp file + file.remove(out) + + # Return data frame + return(df) + } +} diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/README.md b/read.dbc.Rcheck/00_pkg_src/read.dbc/README.md new file mode 100644 index 0000000..f94dc6e --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/README.md @@ -0,0 +1,100 @@ + + [![R-CMD-check](https://github.com/danicat/read.dbc/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/danicat/read.dbc/actions/workflows/R-CMD-check.yaml) + +# read.dbc + +Author: Daniela Petruzalek +e-mail: daniela.petruzalek@gmail.com +License: AGPLv3 + +## Introduction + +`read.dbc` is a R package to enable importing data from `DBC` (compressed `DBF`) files into data frames. Please note that this is the file format used by DATASUS and it is not related to Microsoft FoxPro or CANdb DBC file formats. + +DATASUS is the name of the Department of Informatics of Brazil's Healthcare System (Sistema Unico de Saúde - SUS). They are responsible for publishing Brazilian public healthcare data. Besides DATASUS, the Brazilian National Agency for Supplementary Health (ANS) also uses this file format for its public data. + +This code was tested using files from both DATASUS and ANS to ensure compliance with the format, and hence ensure its usability by researchers. + +This project is based on the work of [Mark Adler](https://github.com/madler/zlib/tree/master/contrib/blast) (blast) and [Pablo Fonseca](https://github.com/eaglebh/blast-dbf) (blast-dbf). + +Neither this project, nor its author, is related in any way to the Brazilian government. + +## Changelog + +For a complete description of the changes, please check [CHANGELOG.md](/inst/CHANGELOG.md). + +## Repository Contents + +- `README.md`: this file. +- `CHANGELOG.md`: change history. +- `src/blast.c`: decompression tools for PKWare Data Compression Library (DCL). +- `src/blast.h`: `blast.c` header and usage notes. +- `src/dbc2dbf.c`: the main program to decompress the dbc files to dbf. +- `R/read.dbc.R`: the code for reading `.dbc` files within R. +- `R/dbc2dbf.R`: a helper function to decompress the `.dbc` files, it works as a wrapper to the "blast" code. +- `man/*`: package manuals +- `inst/*`: test and misc files + +## Installation + +As of June, 7 of 2016, this package officialy became part of [CRAN](https://cran.r-project.org/package=read.dbc) (The Comprehensive R Archive Network). Therefore, it's current stable version can be installed by running `install.packages`: + + install.packages("read.dbc") + +In case you want to install the development version of this package, you still can do it using the `devtools` library: + + devtools::install_github("danicat/read.dbc") + +## Usage + +Reading a DBC file to a data frame: + + # The 'sids.dbc' file is the compressed version of 'sids.dbf' from the "foreign" package. + sids <- read.dbc(system.file("files/sids.dbc", package="read.dbc")) + str(sids) + summary(sids) + + # The following code will download data from the "Declarations of Death" database for + # the Brazilian state of Parana, year 2013. Source: DATASUS / Brazilian Ministry of Health + url <- "ftp://ftp.datasus.gov.br/dissemin/publicos/SIM/CID10/DORES/DOPR2013.dbc" + download.file(url, destfile = "DOPR2013.dbc", mode = "wb") + dopr <- read.dbc("DOPR2013.dbc") + head(dopr) + str(dopr) + +Decompressing a DBC file to a DBF: + + # Input file name + in.f <- system.file("files/sids.dbc", package = "read.dbc") + + # Output file name + out.f <- tempfile(fileext = ".dbc") + + # The call return logi = TRUE on success + if( dbc2dbf(input.file = in.f, output.file = out.f) ) { + print("File decompressed!") + file.remove(out.f) + } + +## Contact Info + +If you have any questions, please contact me at [daniela.petruzalek@gmail.com](mailto:daniela.petruzalek@gmail.com). + +## Developer Information + +### Mac OS X + +Setup: +- Install Xcode +- Install R: https://cran.r-project.org/bin/macosx/ +- Install Rstudio: https://posit.co/download/rstudio-desktop/ +- Run `make setup` to install R dependencies +- Run `make check` to verify the package + +You can also run `make help` to see a list of available commands. + +## Submitting to CRAN + +First make sure all the checks are passing by running `make cran`. + +Once ready, use `devtools::submit_cran()`. This needs to run from RStudio or the R interpreter itself as the tool doesn't allow non-interactive runs. diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/inst/CHANGELOG.md b/read.dbc.Rcheck/00_pkg_src/read.dbc/inst/CHANGELOG.md new file mode 100644 index 0000000..9ef0208 --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/inst/CHANGELOG.md @@ -0,0 +1,48 @@ +## CHANGELOG.md + +### Version 1.0.7 + +* Removed broken links +* Improved error handling in blast.c to prevent runtime errors (fixes gcc-UBSAN) +* Update DESCRIPTION with collaborators +* Documentation edits for conciseness +* Overall doc improvements + +### Version 1.0.5 +- Fixed BUG that left files open on error (Issue #4) + +### Version 1.0.4 +- Fixed BUG on the Solaris port +- Small code cleanups + +### Version 1.0.3 +- Cleanup of the manual - disambiguation of the file format +- This DBC file is not compatible with FoxPro or CANdb +- Added path expansion to handle '~' in file names + +### Version 1.0.2 +- Preparations for CRAN +- Improved error handling in C code +- Improved examples in documentation +- Removed keep.dbf parameter from read.dbc. (useless?) +- Fixed read.dbc to use tempfiles. + +### Version 1.0.1 +- Documentation cleanup +- Added test files sids.dbc and storm.dbc +- Separation of code from the command-line decompressor blast-dbf to avoid conditional compilation +- Removed unused files + +### Version 1.0.0: Packaged release +- Project was converted into a R package +- Now it can be installed with devtools::install_github("danicat/read.dbc") +- Added documentation +- Minor fixes and code reorganization + +### Version 0.1: (Initial Release) + +- Fork of the code available on https://github.com/eaglebh/blast-dbf. +- Fixed the code to work with standard input/output redirection. +- Split the core blast code (blast.c) from the dbc2dbf code (dbc2dbf.c). +- Added conditional compilation to shared library (.so) or command line. +- Note: the original test.pk decompression test is broken in this version because it has no header (as opposed to a .dbc file). diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/inst/files/sids.dbc b/read.dbc.Rcheck/00_pkg_src/read.dbc/inst/files/sids.dbc new file mode 100644 index 0000000..51b0d27 Binary files /dev/null and b/read.dbc.Rcheck/00_pkg_src/read.dbc/inst/files/sids.dbc differ diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/inst/files/storm.dbc b/read.dbc.Rcheck/00_pkg_src/read.dbc/inst/files/storm.dbc new file mode 100644 index 0000000..1e6af42 Binary files /dev/null and b/read.dbc.Rcheck/00_pkg_src/read.dbc/inst/files/storm.dbc differ diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/man/dbc2dbf.Rd b/read.dbc.Rcheck/00_pkg_src/read.dbc/man/dbc2dbf.Rd new file mode 100644 index 0000000..cf18ab5 --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/man/dbc2dbf.Rd @@ -0,0 +1,57 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/dbc2dbf.R +\name{dbc2dbf} +\alias{dbc2dbf} +\title{Decompress a DBC file} +\source{ +The internal C code for \code{dbc2dbf} is based on \code{blast} decompressor and \code{blast-dbf} (see \emph{References}). +} +\usage{ +dbc2dbf(input.file, output.file) +} +\arguments{ +\item{input.file}{The name of the DBC file (including extension)} + +\item{output.file}{The output file name (including extension)} +} +\value{ +Return TRUE if succeed, FALSE otherwise. +} +\description{ +This function allows you decompress a DBC file. When decompressed, it becomes a regular DBF file. +} +\details{ +DBC is the extension for compressed DBF files (from the 'XBASE' family of databases). +This is a proprietary file format used by the Brazilian government to publish public healthcare data. +When decompressed, it becomes a regular DBF file. + +Please note that this is the file format is not related to the FoxPro or CANdb DBC file formats. +} +\examples{ +# Input file name +input <- system.file("files/sids.dbc", package = "read.dbc") + +# Output file name +output <- tempfile(fileext = ".dbc") + +# The call returns TRUE on success +if( dbc2dbf(input.file = input, output.file = output) ) { + print("File decompressed!") + # do things with the file +} + +file.remove(output) # clean up example, don't do in real life :) + +} +\references{ +\code{blast} source code in C: \url{https://github.com/madler/zlib/tree/master/contrib/blast} +\code{blast-dbf}, DBC to DBF command-line decompression tool: \url{https://github.com/eaglebh/blast-dbf} +} +\seealso{ +\code{\link{read.dbc}} +} +\author{ +Daniela Petruzalek, \email{daniela.petruzalek@gmail.com} +} +\keyword{dbc} +\keyword{dbf} diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/man/read.dbc.Rd b/read.dbc.Rcheck/00_pkg_src/read.dbc/man/read.dbc.Rd new file mode 100644 index 0000000..47cc91c --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/man/read.dbc.Rd @@ -0,0 +1,55 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/read.dbc.R +\name{read.dbc} +\alias{read.dbc} +\title{Read Data Stored in DBC (Compressed DBF) Files} +\usage{ +read.dbc(file, ...) +} +\arguments{ +\item{file}{The name of the DBC file (including extension)} + +\item{...}{Further arguments to be passed to \code{\link{read.dbf}}} +} +\value{ +A data.frame of the data from the DBC file. +} +\description{ +This function allows you to read a DBC (compressed DBF) file into a data frame. +} +\details{ +DBC is the extension for compressed DBF files (from the 'XBASE' family of databases). +This is a proprietary file format used by the Brazilian government to publish public healthcare data, and it is not related to the FoxPro or CANdb DBC file formats. + +The \code{read.dbc} function will decompress the input DBC file into a temporary DBF file and call \code{\link{read.dbf}} from the \code{foreign} package to read it into a data frame. +} +\note{ +DATASUS is the name of the Department of Informatics of the Brazilian Health System (Sistema Único de Saúde - SUS) and is responsible for publishing public healthcare data in Brazil. +Besides the DATASUS, the Brazilian National Agency for Supplementary Health (ANS) also uses this file format for its public data. + +This function was tested using files from both DATASUS and ANS to ensure compliance with the format, and hence ensure its usability by researchers. + +Neither this project, nor its author, has any association with the Brazilian government. +} +\examples{ +# The 'sids.dbc' file is the compressed version of 'sids.dbf' from the "foreign" package. +file <- system.file("files/sids.dbc", package="read.dbc") +sids <- read.dbc(file) +str(sids) +summary(sids) + +# This is a small subset of U.S. NOAA storm database. +file <- system.file("files/storm.dbc", package="read.dbc") +storm <- read.dbc(file) +head(storm) +str(storm) + +} +\seealso{ +\code{\link{dbc2dbf}} +} +\author{ +Daniela Petruzalek, \email{daniela.petruzalek@gmail.com} +} +\keyword{datasus} +\keyword{dbc} diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/src/Makevars b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/Makevars new file mode 100644 index 0000000..22e20f6 --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/Makevars @@ -0,0 +1,7 @@ +CC=clang +CFLAGS=-fsanitize=address,undefined -fno-omit-frame-pointer +CXX=clang++ +CXXFLAGS=-fsanitize=address,undefined -fno-omit-frame-pointer +FC=gfortran +F77=gfortran +FLIBS=-lgfortran diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/src/blast.c b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/blast.c new file mode 100644 index 0000000..61ea87e --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/blast.c @@ -0,0 +1,414 @@ +/* blast.c + * Copyright (C) 2003, 2012 Mark Adler + * For conditions of distribution and use, see copyright notice in blast.h + * version 1.2, 24 Oct 2012 + * + * blast.c decompresses data compressed by the PKWare Compression Library. + * This function provides functionality similar to the explode() function of + * the PKWare library, hence the name "blast". + * + * This decompressor is based on the excellent format description provided by + * Ben Rudiak-Gould in comp.compression on August 13, 2001. Interestingly, the + * example Ben provided in the post is incorrect. The distance 110001 should + * instead be 111000. When corrected, the example byte stream becomes: + * + * 00 04 82 24 25 8f 80 7f + * + * which decompresses to "AIAIAIAIAIAIA" (without the quotes). + */ + +/* + * Change history: + * + * 1.0 12 Feb 2003 - First version + * 1.1 16 Feb 2003 - Fixed distance check for > 4 GB uncompressed data + * 1.2 24 Oct 2012 - Add note about using binary mode in stdio + * - Fix comparisons of differently signed integers + */ + +#include /* for setjmp(), longjmp(), and jmp_buf */ +#include "blast.h" /* prototype for blast() */ + +#define MAXBITS 13 /* maximum code length */ +#define MAXWIN 4096 /* maximum window size */ + +/* input and output state */ +struct state { + /* input state */ + blast_in infun; /* input function provided by user */ + void *inhow; /* opaque information passed to infun() */ + unsigned char *in; /* next input location */ + unsigned left; /* available input at in */ + int bitbuf; /* bit buffer */ + int bitcnt; /* number of bits in bit buffer */ + + /* input limit error return state for bits() and decode() */ + jmp_buf env; + + /* output state */ + blast_out outfun; /* output function provided by user */ + void *outhow; /* opaque information passed to outfun() */ + unsigned next; /* index of next write location in out[] */ + int first; /* true to check distances (for first 4K) */ + unsigned char out[MAXWIN]; /* output buffer and sliding window */ +}; + +/* + * Return need bits from the input stream. This always leaves less than + * eight bits in the buffer. bits() works properly for need == 0. + * + * Format notes: + * + * - Bits are stored in bytes from the least significant bit to the most + * significant bit. Therefore bits are dropped from the bottom of the bit + * buffer, using shift right, and new bytes are appended to the top of the + * bit buffer, using shift left. + */ +static int bits(struct state *s, int need) +{ + int val; /* bit accumulator */ + + /* load at least need bits into val */ + val = s->bitbuf; + while (s->bitcnt < need) { + if (s->left == 0) { + s->left = s->infun(s->inhow, &(s->in)); + if (s->left == 0) longjmp(s->env, 1); /* out of input */ + } + val |= (int)(*(s->in)++) << s->bitcnt; /* load eight bits */ + s->left--; + s->bitcnt += 8; + } + + /* drop need bits and update buffer, always zero to seven bits left */ + s->bitbuf = val >> need; + s->bitcnt -= need; + + /* return need bits, zeroing the bits above that */ + return val & ((1 << need) - 1); +} + +/* + * Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of + * each length, which for a canonical code are stepped through in order. + * symbol[] are the symbol values in canonical order, where the number of + * entries is the sum of the counts in count[]. The decoding process can be + * seen in the function decode() below. + */ +struct huffman { + short *count; /* number of symbols of each length */ + short *symbol; /* canonically ordered symbols */ +}; + +/* + * Decode a code from the stream s using huffman table h. Return the symbol or + * a negative value if there is an error. If all of the lengths are zero, i.e. + * an empty code, or if the code is incomplete and an invalid code is received, + * then -9 is returned after reading MAXBITS bits. + * + * Format notes: + * + * - The codes as stored in the compressed data are bit-reversed relative to + * a simple integer ordering of codes of the same lengths. Hence below the + * bits are pulled from the compressed data one at a time and used to + * build the code value reversed from what is in the stream in order to + * permit simple integer comparisons for decoding. + * + * - The first code for the shortest length is all ones. Subsequent codes of + * the same length are simply integer decrements of the previous code. When + * moving up a length, a one bit is appended to the code. For a complete + * code, the last code of the longest length will be all zeros. To support + * this ordering, the bits pulled during decoding are inverted to apply the + * more "natural" ordering starting with all zeros and incrementing. + */ +static int decode(struct state *s, struct huffman *h) +{ + int len; /* current number of bits in code */ + int code; /* len bits being decoded */ + int first; /* first code of length len */ + int count; /* number of codes of length len */ + int index; /* index of first code of length len in symbol table */ + int bitbuf; /* bits from stream */ + int left; /* bits left in next or left to process */ + short *next; /* next number of codes */ + + bitbuf = s->bitbuf; + left = s->bitcnt; + code = first = index = 0; + len = 1; + next = h->count + 1; + while (1) { + while (left--) { + code |= (bitbuf & 1) ^ 1; /* invert code */ + bitbuf >>= 1; + count = *next++; + if (code < first + count) { /* if length len, return symbol */ + s->bitbuf = bitbuf; + s->bitcnt = (s->bitcnt - len) & 7; + return h->symbol[index + (code - first)]; + } + index += count; /* else update for next length */ + first += count; + first <<= 1; + code <<= 1; + len++; + } + left = (MAXBITS+1) - len; + if (left == 0) break; + if (s->left == 0) { + s->left = s->infun(s->inhow, &(s->in)); + if (s->left == 0) longjmp(s->env, 1); /* out of input */ + } + bitbuf = *(s->in)++; + s->left--; + if (left > 8) left = 8; + } + return -9; /* ran out of codes */ +} + +/* + * Given a list of repeated code lengths rep[0..n-1], where each byte is a + * count (high four bits + 1) and a code length (low four bits), generate the + * list of code lengths. This compaction reduces the size of the object code. + * Then given the list of code lengths length[0..n-1] representing a canonical + * Huffman code for n symbols, construct the tables required to decode those + * codes. Those tables are the number of codes of each length, and the symbols + * sorted by length, retaining their original order within each length. The + * return value is zero for a complete code set, negative for an over- + * subscribed code set, and positive for an incomplete code set. The tables + * can be used if the return value is zero or positive, but they cannot be used + * if the return value is negative. If the return value is zero, it is not + * possible for decode() using that table to return an error--any stream of + * enough bits will resolve to a symbol. If the return value is positive, then + * it is possible for decode() using that table to return an error for received + * codes past the end of the incomplete lengths. + */ +static int construct(struct huffman *h, const unsigned char *rep, int n) +{ + int symbol; /* current symbol when stepping through length[] */ + int len; /* current length when stepping through h->count[] */ + int left; /* number of possible codes left of current length */ + short offs[MAXBITS+1]; /* offsets in symbol table for each length */ + short length[256]; /* code lengths */ + + /* convert compact repeat counts into symbol bit length list */ + symbol = 0; + do { + len = *rep++; + left = (len >> 4) + 1; + len &= 15; + do { + length[symbol++] = len; + } while (--left); + } while (--n); + n = symbol; + + /* count number of codes of each length */ + for (len = 0; len <= MAXBITS; len++) + h->count[len] = 0; + for (symbol = 0; symbol < n; symbol++) + (h->count[length[symbol]])++; /* assumes lengths are within bounds */ + if (h->count[0] == n) /* no codes! */ + return 0; /* complete, but decode() will fail */ + + /* check for an over-subscribed or incomplete set of lengths */ + left = 1; /* one possible code of zero length */ + for (len = 1; len <= MAXBITS; len++) { + left <<= 1; /* one more bit, double codes left */ + left -= h->count[len]; /* deduct count from possible codes */ + if (left < 0) return left; /* over-subscribed--return negative */ + } /* left > 0 means incomplete */ + + /* generate offsets into symbol table for each length for sorting */ + offs[1] = 0; + for (len = 1; len < MAXBITS; len++) + offs[len + 1] = offs[len] + h->count[len]; + + /* + * put symbols in table sorted by length, by symbol order within each + * length + */ + for (symbol = 0; symbol < n; symbol++) + if (length[symbol] != 0) + h->symbol[offs[length[symbol]]++] = symbol; + + /* return zero for complete set, positive for incomplete set */ + return left; +} + +/* + * Decode PKWare Compression Library stream. + * + * Format notes: + * + * - First byte is 0 if literals are uncoded or 1 if they are coded. Second + * byte is 4, 5, or 6 for the number of extra bits in the distance code. + * This is the base-2 logarithm of the dictionary size minus six. + * + * - Compressed data is a combination of literals and length/distance pairs + * terminated by an end code. Literals are either Huffman coded or + * uncoded bytes. A length/distance pair is a coded length followed by a + * coded distance to represent a string that occurs earlier in the + * uncompressed data that occurs again at the current location. + * + * - A bit preceding a literal or length/distance pair indicates which comes + * next, 0 for literals, 1 for length/distance. + * + * - If literals are uncoded, then the next eight bits are the literal, in the + * normal bit order in th stream, i.e. no bit-reversal is needed. Similarly, + * no bit reversal is needed for either the length extra bits or the distance + * extra bits. + * + * - Literal bytes are simply written to the output. A length/distance pair is + * an instruction to copy previously uncompressed bytes to the output. The + * copy is from distance bytes back in the output stream, copying for length + * bytes. + * + * - Distances pointing before the beginning of the output data are not + * permitted. + * + * - Overlapped copies, where the length is greater than the distance, are + * allowed and common. For example, a distance of one and a length of 518 + * simply copies the last byte 518 times. A distance of four and a length of + * twelve copies the last four bytes three times. A simple forward copy + * ignoring whether the length is greater than the distance or not implements + * this correctly. + */ +static int decomp(struct state *s) +{ + int lit; /* true if literals are coded */ + int dict; /* log2(dictionary size) - 6 */ + int symbol; /* decoded symbol, extra bits for distance */ + int len; /* length for copy */ + unsigned dist; /* distance for copy */ + int copy; /* copy counter */ + unsigned char *from, *to; /* copy pointers */ + static int virgin = 1; /* build tables once */ + static short litcnt[MAXBITS+1], litsym[256]; /* litcode memory */ + static short lencnt[MAXBITS+1], lensym[16]; /* lencode memory */ + static short distcnt[MAXBITS+1], distsym[64]; /* distcode memory */ + static struct huffman litcode = {litcnt, litsym}; /* length code */ + static struct huffman lencode = {lencnt, lensym}; /* length code */ + static struct huffman distcode = {distcnt, distsym};/* distance code */ + /* bit lengths of literal codes */ + static const unsigned char litlen[] = { + 11, 124, 8, 7, 28, 7, 188, 13, 76, 4, 10, 8, 12, 10, 12, 10, 8, 23, 8, + 9, 7, 6, 7, 8, 7, 6, 55, 8, 23, 24, 12, 11, 7, 9, 11, 12, 6, 7, 22, 5, + 7, 24, 6, 11, 9, 6, 7, 22, 7, 11, 38, 7, 9, 8, 25, 11, 8, 11, 9, 12, + 8, 12, 5, 38, 5, 38, 5, 11, 7, 5, 6, 21, 6, 10, 53, 8, 7, 24, 10, 27, + 44, 253, 253, 253, 252, 252, 252, 13, 12, 45, 12, 45, 12, 61, 12, 45, + 44, 173}; + /* bit lengths of length codes 0..15 */ + static const unsigned char lenlen[] = {2, 35, 36, 53, 38, 23}; + /* bit lengths of distance codes 0..63 */ + static const unsigned char distlen[] = {2, 20, 53, 230, 247, 151, 248}; + static const short base[16] = { /* base for length codes */ + 3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 16, 24, 40, 72, 136, 264}; + static const char extra[16] = { /* extra bits for length codes */ + 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8}; + + /* set up decoding tables (once--might not be thread-safe) */ + if (virgin) { + construct(&litcode, litlen, sizeof(litlen)); + construct(&lencode, lenlen, sizeof(lenlen)); + construct(&distcode, distlen, sizeof(distlen)); + virgin = 0; + } + + /* read header */ + lit = bits(s, 8); + if (lit > 1) return -1; + dict = bits(s, 8); + if (dict < 4 || dict > 6) return -2; + + /* decode literals and length/distance pairs */ + do { + if (bits(s, 1)) { + /* get length */ + symbol = decode(s, &lencode); + if (symbol < 0) { + return symbol; + } + + len = base[symbol] + bits(s, extra[symbol]); + if (len == 519) break; /* end code */ + + /* get distance */ + symbol = len == 2 ? 2 : dict; + dist = decode(s, &distcode) << symbol; + if (dist < 0) { + return dist; + } + + dist += bits(s, symbol); + dist++; + if (s->first && dist > s->next) + return -3; /* distance too far back */ + + /* copy length bytes from distance bytes back */ + do { + to = s->out + s->next; + from = to - dist; + copy = MAXWIN; + if (s->next < dist) { + from += copy; + copy = dist; + } + copy -= s->next; + if (copy > len) copy = len; + len -= copy; + s->next += copy; + do { + *to++ = *from++; + } while (--copy); + if (s->next == MAXWIN) { + if (s->outfun(s->outhow, s->out, s->next)) return 1; + s->next = 0; + s->first = 0; + } + } while (len != 0); + } + else { + /* get literal and write it */ + symbol = lit ? decode(s, &litcode) : bits(s, 8); + s->out[s->next++] = symbol; + if (s->next == MAXWIN) { + if (s->outfun(s->outhow, s->out, s->next)) return 1; + s->next = 0; + s->first = 0; + } + } + } while (1); + return 0; +} + +/* See comments in blast.h */ +int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow) +{ + struct state s; /* input/output state */ + int err; /* return value */ + + /* initialize input state */ + s.infun = infun; + s.inhow = inhow; + s.left = 0; + s.bitbuf = 0; + s.bitcnt = 0; + + /* initialize output state */ + s.outfun = outfun; + s.outhow = outhow; + s.next = 0; + s.first = 1; + + /* return if bits() or decode() tries to read past available input */ + if (setjmp(s.env) != 0) /* if came back here via longjmp(), */ + err = 2; /* then skip decomp(), return error */ + else + err = decomp(&s); /* decompress */ + + /* write any leftover output and update the error code if needed */ + if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0) + err = 1; + return err; +} diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/src/blast.h b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/blast.h new file mode 100644 index 0000000..658cfd3 --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/blast.h @@ -0,0 +1,75 @@ +/* blast.h -- interface for blast.c + Copyright (C) 2003, 2012 Mark Adler + version 1.2, 24 Oct 2012 + + This software is provided 'as-is', without any express or implied + warranty. In no event will the author 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. + + Mark Adler madler@alumni.caltech.edu + */ + + +/* + * blast() decompresses the PKWare Data Compression Library (DCL) compressed + * format. It provides the same functionality as the explode() function in + * that library. (Note: PKWare overused the "implode" verb, and the format + * used by their library implode() function is completely different and + * incompatible with the implode compression method supported by PKZIP.) + * + * The binary mode for stdio functions should be used to assure that the + * compressed data is not corrupted when read or written. For example: + * fopen(..., "rb") and fopen(..., "wb"). + */ + + +typedef unsigned (*blast_in)(void *how, unsigned char **buf); +typedef int (*blast_out)(void *how, unsigned char *buf, unsigned len); +/* Definitions for input/output functions passed to blast(). See below for + * what the provided functions need to do. + */ + + +int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow); +/* Decompress input to output using the provided infun() and outfun() calls. + * On success, the return value of blast() is zero. If there is an error in + * the source data, i.e. it is not in the proper format, then a negative value + * is returned. If there is not enough input available or there is not enough + * output space, then a positive error is returned. + * + * The input function is invoked: len = infun(how, &buf), where buf is set by + * infun() to point to the input buffer, and infun() returns the number of + * available bytes there. If infun() returns zero, then blast() returns with + * an input error. (blast() only asks for input if it needs it.) inhow is for + * use by the application to pass an input descriptor to infun(), if desired. + * + * The output function is invoked: err = outfun(how, buf, len), where the bytes + * to be written are buf[0..len-1]. If err is not zero, then blast() returns + * with an output error. outfun() is always called with len <= 4096. outhow + * is for use by the application to pass an output descriptor to outfun(), if + * desired. + * + * The return codes are: + * + * 2: ran out of input before completing decompression + * 1: output error before completing decompression + * 0: successful decompression + * -1: literal flag not zero or one + * -2: dictionary size not in 4..6 + * -3: distance is too far back + * + * At the bottom of blast.c is an example program that uses blast() that can be + * compiled to produce a command-line decompression filter by defining TEST. + */ diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/src/dbc2dbf.c b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/dbc2dbf.c new file mode 100644 index 0000000..bc5b39e --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/dbc2dbf.c @@ -0,0 +1,142 @@ +/* dbc2dbf.c + Copyright (C) 2016 Daniela Petruzalek + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +/* + Author Notes + ============ + + This program decompresses .dbc files to .dbf. This code is based on the work + of Mark Adler (zlib/blast) and Pablo Fonseca + (https://github.com/eaglebh/blast-dbf). +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "blast.h" + +#define CHUNK 4096 + +/* Input file helper function */ +static unsigned inf(void *how, unsigned char **buf) +{ + static unsigned char hold[CHUNK]; + + *buf = hold; + return fread(hold, 1, CHUNK, (FILE *)how); +} + +/* Output file helper function */ +static int outf(void *how, unsigned char *buf, unsigned len) +{ + return fwrite(buf, 1, len, (FILE *)how) != len; +} + + +/* Close open files before exit */ +void cleanup(FILE* input, FILE* output) { + if( input ) fclose(input); + if( output ) fclose(output); +} + +/* + dbc2dbf(char** input_file, char** output_file) + This function decompresses a given .dbc input file into the corresponding .dbf. + + Please provide fully qualified names, including file extension. + */ +void dbc2dbf(char** input_file, char** output_file) { + FILE *input = 0, *output = 0; + int ret = 0; + unsigned char rawHeader[2]; + uint16_t header = 0; + + /* Open input file */ + input = fopen(input_file[0], "rb"); + if(input == NULL) { + error("Error reading input file %s: %s", input_file[0], strerror(errno)); + } + + /* Open output file */ + output = fopen(output_file[0], "wb"); + if(output == NULL) { + cleanup(input, output); + error("Error reading output file %s: %s", output_file[0], strerror(errno)); + } + + /* Process file header - skip 8 bytes */ + if( fseek(input, 8, SEEK_SET) ) { + cleanup(input, output); + error("Error processing input file %s: %s", input_file[0], strerror(errno)); + } + + /* Reads two bytes from the header = header size */ + ret = fread(rawHeader, 2, 1, input); + if( ferror(input) ) { + cleanup(input, output); + error("Error reading input file %s: %s", input_file[0], strerror(errno)); + } + + /* Platform independent code (header is stored in little endian format) */ + header = rawHeader[0] + (rawHeader[1] << 8); + + /* Reset file pointer */ + rewind(input); + + /* Copy file header from input to output */ + unsigned char buf[header]; + + ret = fread(buf, 1, header, input); + if( ferror(input) ) { + cleanup(input, output); + error("Error reading input file %s: %s", input_file[0], strerror(errno)); + } + + ret = fwrite(buf, 1, header, output); + if( ferror(output) ) { + cleanup(input, output); + error("Error writing output file %s: %s", output_file[0], strerror(errno)); + } + + /* Jump to the data (Skip CRC32) */ + if( fseek(input, header + 4, SEEK_SET) ) { + cleanup(input, output); + error("Error processing input file %s: %s", input_file[0], strerror(errno)); + } + + /* decompress */ + ret = blast(inf, input, outf, output); + if( ret ) { + cleanup(input, output); + error("error decompressing file: %d", ret); + } + + /* see if there are any leftover bytes */ + int n = 0; + while (fgetc(input) != EOF) n++; + if (n) { + cleanup(input, output); + error("blast warning: %d unused bytes of input\n", n); + } + + cleanup(input, output); +} diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/src/read_dbc_init.c b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/read_dbc_init.c new file mode 100644 index 0000000..4ffa2cc --- /dev/null +++ b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/read_dbc_init.c @@ -0,0 +1,16 @@ +#include // for NULL +#include + +/* .C calls */ +extern void dbc2dbf(void *, void *); + +static const R_CMethodDef CEntries[] = { + {"dbc2dbf", (DL_FUNC) &dbc2dbf, 2}, + {NULL, NULL, 0} +}; + +void R_init_read_dbc(DllInfo *dll) +{ + R_registerRoutines(dll, CEntries, NULL, NULL, NULL); + R_useDynamicSymbols(dll, FALSE); +} diff --git a/read.dbc.Rcheck/00_pkg_src/read.dbc/src/symbols.rds b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/symbols.rds new file mode 100644 index 0000000..9698a96 Binary files /dev/null and b/read.dbc.Rcheck/00_pkg_src/read.dbc/src/symbols.rds differ diff --git a/read.dbc.Rcheck/00check.log b/read.dbc.Rcheck/00check.log new file mode 100644 index 0000000..c6fbf14 --- /dev/null +++ b/read.dbc.Rcheck/00check.log @@ -0,0 +1,105 @@ +* using log directory ‘/app/read.dbc.Rcheck’ +* using R version 4.3.3 (2024-02-29) +* using platform: x86_64-pc-linux-gnu (64-bit) +* R was compiled by + gcc (Ubuntu 13.2.0-23ubuntu3) 13.2.0 + GNU Fortran (Ubuntu 13.2.0-23ubuntu3) 13.2.0 +* running under: Ubuntu 24.04.2 LTS +* using session charset: UTF-8 +* using option ‘--as-cran’ +* checking for file ‘read.dbc/DESCRIPTION’ ... OK +* this is package ‘read.dbc’ version ‘1.0.7’ +* package encoding: UTF-8 +* checking CRAN incoming feasibility ... [7s/14s] WARNING +Maintainer: ‘Daniela Petruzalek ’ + +New submission + +Package was archived on CRAN + +Insufficient package version (submitted: 1.0.7, existing: 1.0.7) + +CRAN repository db overrides: + X-CRAN-Comment: Archived on 2024-07-06 as errors were not corrected. +* checking package namespace information ... OK +* checking package dependencies ... OK +* checking if this is a source package ... OK +* checking if there is a namespace ... OK +* checking for executable files ... OK +* checking for hidden files and directories ... OK +* checking for portable file names ... OK +* checking for sufficient/correct file permissions ... OK +* checking serialization versions ... OK +* checking whether package ‘read.dbc’ can be installed ... OK +* used C compiler: ‘gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0’ +* checking installed package size ... OK +* checking package directory ... OK +* checking for future file timestamps ... NOTE +unable to verify current time +* checking DESCRIPTION meta-information ... OK +* checking top-level files ... OK +* checking for left-over files ... OK +* checking index information ... OK +* checking package subdirectories ... OK +* checking R files for non-ASCII characters ... OK +* checking R files for syntax errors ... OK +* checking whether the package can be loaded ... OK +* checking whether the package can be loaded with stated dependencies ... OK +* checking whether the package can be unloaded cleanly ... OK +* checking whether the namespace can be loaded with stated dependencies ... OK +* checking whether the namespace can be unloaded cleanly ... OK +* checking loading without being on the library search path ... OK +* checking use of S3 registration ... OK +* checking dependencies in R code ... OK +* checking S3 generic/method consistency ... OK +* checking replacement functions ... OK +* checking foreign function calls ... OK +* checking R code for possible problems ... OK +* checking Rd files ... OK +* checking Rd metadata ... OK +* checking Rd line widths ... OK +* checking Rd cross-references ... OK +* checking for missing documentation entries ... OK +* checking for code/documentation mismatches ... OK +* checking Rd \usage sections ... OK +* checking Rd contents ... OK +* checking for unstated dependencies in examples ... OK +* checking line endings in C/C++/Fortran sources/headers ... OK +* checking line endings in Makefiles ... OK +* checking compilation flags in Makevars ... WARNING +Variables overriding user/site settings: + CFLAGS: -fsanitize=address,undefined -fno-omit-frame-pointer + CXXFLAGS: -fsanitize=address,undefined -fno-omit-frame-pointer +* checking for GNU extensions in Makefiles ... OK +* checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK +* checking use of PKG_*FLAGS in Makefiles ... OK +* checking use of SHLIB_OPENMP_*FLAGS in Makefiles ... OK +* checking pragmas in C/C++ headers and code ... OK +* checking compilation flags used ... NOTE +Compilation used the following non-portable flag(s): + ‘-mno-omit-leaf-frame-pointer’ +* checking compiled code ... OK +* checking examples ... OK +* checking PDF version of manual ... WARNING +LaTeX errors when creating PDF version. +This typically indicates Rd problems. +LaTeX errors found: +! LaTeX Error: File `inconsolata.sty' not found. + +Type X to quit or to proceed, +or enter new name. (Default extension: sty) + +! Emergency stop. + + +l.303 ^^M + +! ==> Fatal error occurred, no output PDF file produced! +* checking PDF version of manual without index ... ERROR +* checking HTML version of manual ... OK +* checking for non-standard things in the check directory ... NOTE +Found the following files/directories: + ‘read.dbc-manual.tex’ +* checking for detritus in the temp directory ... OK +* DONE +Status: 1 ERROR, 3 WARNINGs, 3 NOTEs diff --git a/read.dbc.Rcheck/00install.out b/read.dbc.Rcheck/00install.out new file mode 100644 index 0000000..db08304 --- /dev/null +++ b/read.dbc.Rcheck/00install.out @@ -0,0 +1,20 @@ +* installing *source* package ‘read.dbc’ ... +** using staged installation +** libs +using C compiler: ‘gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0’ +gcc -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/build/r-base-FPSnzf/r-base-4.3.3=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/build/r-base-FPSnzf/r-base-4.3.3=/usr/src/r-base-4.3.3-2build2 -Wdate-time -D_FORTIFY_SOURCE=3 -c blast.c -o blast.o +gcc -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/build/r-base-FPSnzf/r-base-4.3.3=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/build/r-base-FPSnzf/r-base-4.3.3=/usr/src/r-base-4.3.3-2build2 -Wdate-time -D_FORTIFY_SOURCE=3 -c dbc2dbf.c -o dbc2dbf.o +gcc -I"/usr/share/R/include" -DNDEBUG -fpic -g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/build/r-base-FPSnzf/r-base-4.3.3=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/build/r-base-FPSnzf/r-base-4.3.3=/usr/src/r-base-4.3.3-2build2 -Wdate-time -D_FORTIFY_SOURCE=3 -c read_dbc_init.c -o read_dbc_init.o +gcc -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -o read.dbc.so blast.o dbc2dbf.o read_dbc_init.o -L/usr/lib/R/lib -lR +installing to /app/read.dbc.Rcheck/00LOCK-read.dbc/00new/read.dbc/libs +** R +** inst +** byte-compile and prepare package for lazy loading +** help +*** installing help indices +** building package indices +** testing if installed package can be loaded from temporary location +** checking absolute paths in shared objects and dynamic libraries +** testing if installed package can be loaded from final location +** testing if installed package keeps a record of temporary installation path +* DONE (read.dbc) diff --git a/read.dbc.Rcheck/R_check_bin/R b/read.dbc.Rcheck/R_check_bin/R new file mode 100755 index 0000000..3e289bc --- /dev/null +++ b/read.dbc.Rcheck/R_check_bin/R @@ -0,0 +1,2 @@ +echo "'R' should not be used without a path -- see par. 1.6 of the manual" +exit 1 diff --git a/read.dbc.Rcheck/R_check_bin/Rscript b/read.dbc.Rcheck/R_check_bin/Rscript new file mode 100755 index 0000000..6fead74 --- /dev/null +++ b/read.dbc.Rcheck/R_check_bin/Rscript @@ -0,0 +1,2 @@ +echo "'Rscript' should not be used without a path -- see par. 1.6 of the manual" +exit 1 diff --git a/read.dbc.Rcheck/Rdlatex.log b/read.dbc.Rcheck/Rdlatex.log new file mode 100644 index 0000000..505d7ea --- /dev/null +++ b/read.dbc.Rcheck/Rdlatex.log @@ -0,0 +1,161 @@ +Hmm ... looks like a package +Converting parsed Rd's to LaTeX +Creating pdf output from LaTeX ... +Warning in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : + texi2dvi script/program not available, using emulation +This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdflatex) + restricted \write18 enabled. +entering extended mode +(./Rd2.tex +LaTeX2e <2023-11-01> patch level 1 +L3 programming layer <2024-01-22> + +(/usr/share/texlive/texmf-dist/tex/latex/base/book.cls +Document Class: book 2023/05/17 v1.4n Standard LaTeX document class +(/usr/share/texlive/texmf-dist/tex/latex/base/bk10.clo)) +(/usr/share/R/share/texmf/tex/latex/Rd.sty +(/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty) +(/usr/share/texlive/texmf-dist/tex/latex/tools/longtable.sty) +(/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty) +(/usr/share/texlive/texmf-dist/tex/latex/base/alltt.sty) +(/usr/share/texlive/texmf-dist/tex/latex/tools/verbatim.sty) +(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty) +(/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty) +(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty +For additional information on amsmath, use the `?' option. +(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty +(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) +(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) +(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) +(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty) +(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty) +(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/eucal.sty) +(/usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty) +(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty) +(/usr/share/texlive/texmf-dist/tex/latex/psnfss/times.sty) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/color.sty +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg) +(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/mathcolor.ltx)) +(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty +(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty) +(/usr/share/texlive/texmf-dist/tex/latex/kvsetkeys/kvsetkeys.sty) +(/usr/share/texlive/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty) +(/usr/share/texlive/texmf-dist/tex/generic/pdfescape/pdfescape.sty +(/usr/share/texlive/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty) +(/usr/share/texlive/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty +(/usr/share/texlive/texmf-dist/tex/generic/infwarerr/infwarerr.sty))) +(/usr/share/texlive/texmf-dist/tex/latex/hycolor/hycolor.sty) +(/usr/share/texlive/texmf-dist/tex/latex/auxhook/auxhook.sty) +(/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty +(/usr/share/texlive/texmf-dist/tex/latex/refcount/refcount.sty) +(/usr/share/texlive/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty +(/usr/share/texlive/texmf-dist/tex/latex/kvoptions/kvoptions.sty))) + +! LaTeX Error: File `etoolbox.sty' not found. + +Type X to quit or to proceed, +or enter new name. (Default extension: sty) + +Enter file name: +! Emergency stop. + + +l.117 \def + \Hy@Error{\PackageError{hyperref}}^^M +! ==> Fatal error occurred, no output PDF file produced! +Transcript written on Rd2.log. +Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : + unable to run pdflatex on 'Rd2.tex' +LaTeX errors: +! LaTeX Error: File `etoolbox.sty' not found. + +Type X to quit or to proceed, +or enter new name. (Default extension: sty) + +! Emergency stop. + + +l.117 \def + \Hy@Error{\PackageError{hyperref}}^^M +! ==> Fatal error occurred, no output PDF file produced! +Warning in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : + texi2dvi script/program not available, using emulation +This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) (preloaded format=pdflatex) + restricted \write18 enabled. +entering extended mode +(./Rd2.tex +LaTeX2e <2023-11-01> patch level 1 +L3 programming layer <2024-01-22> + +(/usr/share/texlive/texmf-dist/tex/latex/base/book.cls +Document Class: book 2023/05/17 v1.4n Standard LaTeX document class +(/usr/share/texlive/texmf-dist/tex/latex/base/bk10.clo)) +(/usr/share/R/share/texmf/tex/latex/Rd.sty +(/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty) +(/usr/share/texlive/texmf-dist/tex/latex/tools/longtable.sty) +(/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty) +(/usr/share/texlive/texmf-dist/tex/latex/base/alltt.sty) +(/usr/share/texlive/texmf-dist/tex/latex/tools/verbatim.sty) +(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty) +(/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty) +(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty +For additional information on amsmath, use the `?' option. +(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty +(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) +(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) +(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) +(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty) +(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty) +(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/eucal.sty) +(/usr/share/texlive/texmf-dist/tex/generic/iftex/iftex.sty) +(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty) +(/usr/share/texlive/texmf-dist/tex/latex/psnfss/times.sty) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/color.sty +(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg) +(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def) +(/usr/share/texlive/texmf-dist/tex/latex/graphics/mathcolor.ltx)) +(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty +(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty) +(/usr/share/texlive/texmf-dist/tex/latex/kvsetkeys/kvsetkeys.sty) +(/usr/share/texlive/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.sty) +(/usr/share/texlive/texmf-dist/tex/generic/pdfescape/pdfescape.sty +(/usr/share/texlive/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty) +(/usr/share/texlive/texmf-dist/tex/generic/pdftexcmds/pdftexcmds.sty +(/usr/share/texlive/texmf-dist/tex/generic/infwarerr/infwarerr.sty))) +(/usr/share/texlive/texmf-dist/tex/latex/hycolor/hycolor.sty) +(/usr/share/texlive/texmf-dist/tex/latex/auxhook/auxhook.sty) +(/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty +(/usr/share/texlive/texmf-dist/tex/latex/refcount/refcount.sty) +(/usr/share/texlive/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty +(/usr/share/texlive/texmf-dist/tex/latex/kvoptions/kvoptions.sty))) + +! LaTeX Error: File `etoolbox.sty' not found. + +Type X to quit or to proceed, +or enter new name. (Default extension: sty) + +Enter file name: +! Emergency stop. + + +l.117 \def + \Hy@Error{\PackageError{hyperref}}^^M +! ==> Fatal error occurred, no output PDF file produced! +Transcript written on Rd2.log. +Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, : + unable to run pdflatex on 'Rd2.tex' +LaTeX errors: +! LaTeX Error: File `etoolbox.sty' not found. + +Type X to quit or to proceed, +or enter new name. (Default extension: sty) + +! Emergency stop. + + +l.117 \def + \Hy@Error{\PackageError{hyperref}}^^M +! ==> Fatal error occurred, no output PDF file produced! +Error in running tools::texi2pdf() +You may want to clean up by 'rm -Rf /tmp/RtmpYT6ZOo/Rd2pdf18c33accd112' diff --git a/read.dbc.Rcheck/read.dbc-Ex.R b/read.dbc.Rcheck/read.dbc-Ex.R new file mode 100644 index 0000000..b200bdc --- /dev/null +++ b/read.dbc.Rcheck/read.dbc-Ex.R @@ -0,0 +1,95 @@ +pkgname <- "read.dbc" +source(file.path(R.home("share"), "R", "examples-header.R")) +options(warn = 1) +base::assign(".ExTimings", "read.dbc-Ex.timings", pos = 'CheckExEnv') +base::cat("name\tuser\tsystem\telapsed\n", file=base::get(".ExTimings", pos = 'CheckExEnv')) +base::assign(".format_ptime", +function(x) { + if(!is.na(x[4L])) x[1L] <- x[1L] + x[4L] + if(!is.na(x[5L])) x[2L] <- x[2L] + x[5L] + options(OutDec = '.') + format(x[1L:3L], digits = 7L) +}, +pos = 'CheckExEnv') + +### * +library('read.dbc') + +base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') +base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') +cleanEx() +nameEx("dbc2dbf") +### * dbc2dbf + +flush(stderr()); flush(stdout()) + +base::assign(".ptime", proc.time(), pos = "CheckExEnv") +### Name: dbc2dbf +### Title: Decompress a DBC file +### Aliases: dbc2dbf +### Keywords: dbc dbf + +### ** Examples + +# Input file name +input <- system.file("files/sids.dbc", package = "read.dbc") + +# Output file name +output <- tempfile(fileext = ".dbc") + +# The call returns TRUE on success +if( dbc2dbf(input.file = input, output.file = output) ) { + print("File decompressed!") + # do things with the file +} + +file.remove(output) # clean up example, don't do in real life :) + + + + +base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") +base::cat("dbc2dbf", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") +cleanEx() +nameEx("read.dbc") +### * read.dbc + +flush(stderr()); flush(stdout()) + +base::assign(".ptime", proc.time(), pos = "CheckExEnv") +### Name: read.dbc +### Title: Read Data Stored in DBC (Compressed DBF) Files +### Aliases: read.dbc +### Keywords: datasus dbc + +### ** Examples + +# The 'sids.dbc' file is the compressed version of 'sids.dbf' from the "foreign" package. +file <- system.file("files/sids.dbc", package="read.dbc") +sids <- read.dbc(file) +str(sids) +summary(sids) + +# This is a small subset of U.S. NOAA storm database. +file <- system.file("files/storm.dbc", package="read.dbc") +storm <- read.dbc(file) +head(storm) +str(storm) + + + + +base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") +base::cat("read.dbc", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") +### *