Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: readspss
Type: Package
Title: Importing and Exporting SPSS Files
Version: 0.18.1
Version: 0.19
Authors@R: c(
person("Jan Marvin", "Garbuszus",
email = "jan.garbuszus@ruhr-uni-bochum.de", role = c("aut", "cre")),
Expand All @@ -22,18 +22,17 @@ LazyData: TRUE
Language: en-US
Imports:
Rcpp (>= 0.11.2)
Suggests:
covr,
Suggests:
datasets,
foreign,
knitr,
rmarkdown,
roxygen2,
testthat
LinkingTo: Rcpp, BH
LinkingTo: Rcpp
ByteCompile: yes
SystemRequirements: OpenSSL >= 1.0.2
VignetteBuilder: knitr
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
4 changes: 2 additions & 2 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ BEGIN_RCPP
END_RCPP
}
// readpor
List readpor(const char * filePath, const bool debug, std::string encStr, bool override);
Rcpp::List readpor(const char * filePath, const bool debug, std::string encStr, bool override);
RcppExport SEXP _readspss_readpor(SEXP filePathSEXP, SEXP debugSEXP, SEXP encStrSEXP, SEXP overrideSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Expand All @@ -63,7 +63,7 @@ BEGIN_RCPP
END_RCPP
}
// readsav
List readsav(const char * filePath, const bool debug, std::string encStr, std::string const ownEnc);
Rcpp::List readsav(const char * filePath, const bool debug, std::string encStr, std::string const ownEnc);
RcppExport SEXP _readspss_readsav(SEXP filePathSEXP, SEXP debugSEXP, SEXP encStrSEXP, SEXP ownEncSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Expand Down
11 changes: 3 additions & 8 deletions src/boost_split.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Jan Marvin Garbuszus
* Copyright (C) 2018-2025 Jan Marvin Garbuszus
*
* 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 the
Expand All @@ -15,11 +15,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <Rcpp.h>
#include <string>

#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include "spss.h"

//' split character vector at "="
//'
Expand All @@ -32,8 +28,7 @@ Rcpp::CharacterVector boost_split(std::string val_s) {

std::vector<std::string> vec_r;

boost::split(vec_r, val_s,
boost::is_any_of("="), boost::token_compress_on);
vec_r = split(val_s, "=", true);

return(Rcpp::wrap(vec_r));
}
7 changes: 3 additions & 4 deletions src/fast_factor.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include <Rcpp.h>
using namespace Rcpp;


template <int RTYPE>
IntegerVector fast_factor_template( const Vector<RTYPE>& x,
const Vector<RTYPE>& y) {
IntegerVector out = match(x, y);
Rcpp::IntegerVector fast_factor_template( const Rcpp::Vector<RTYPE>& x,
const Rcpp::Vector<RTYPE>& y) {
Rcpp::IntegerVector out = match(x, y);

out.attr("levels") = y.attr("names");
out.attr("class") = "factor";
Expand Down
13 changes: 4 additions & 9 deletions src/read_sav_encrypted.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Jan Marvin Garbuszus
* Copyright (C) 2018-2025 Jan Marvin Garbuszus
* Copyright (c) 2013 Ben Pfaff
*
* This program is free software; you can redistribute it and/or modify it
Expand All @@ -22,12 +22,9 @@
#include <fstream>
#include <streambuf>

#include <boost/regex.hpp>

#include <openssl/aes.h>
#include <openssl/cmac.h>

using namespace Rcpp;

#include "spss.h"
#include "read_sav_encrypted.h"
Expand All @@ -52,12 +49,10 @@ int encryptfile (const char * filePath, std::string &outpath, std::string pass)
std::string fileheader(36, '\0');
fileheader = readstring(fileheader, sav);

if (!boost::regex_search(fileheader, boost::regex("ENCRYPTEDSAV"))) {
stop("The file header indicates that it is not an SPSS sav file.");
if (fileheader.find("ENCRYPTEDSAV") == std::string::npos) {
Rcpp::stop("The file header indicates that it is not an SPSS sav file.");
}



/* Read first ciphertext block and use it to verify the password. Try the
password as plaintext first, then try decoding it. */

Expand Down Expand Up @@ -125,7 +120,7 @@ Rcpp::List readencrypted(const char * filePath, const bool debug,
// remove encrypted sav-file
std::remove(outPath.c_str());
} else {
stop("stopping");
Rcpp::stop("stopping");
}

return df;
Expand Down
16 changes: 5 additions & 11 deletions src/read_sav_known_n.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Jan Marvin Garbuszus
* Copyright (C) 2018-2025 Jan Marvin Garbuszus
*
* 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 the
Expand All @@ -19,8 +19,6 @@
#include <fstream>
#include <streambuf>

#include <boost/regex.hpp>

#include "spss.h"

Rcpp::List read_sav_known_n (Rcpp::List& df, std::fstream& sav,
Expand Down Expand Up @@ -165,8 +163,7 @@ Rcpp::List read_sav_known_n (Rcpp::List& df, std::fstream& sav,
if (res_i == res_kk-1) {

// trim additional whitespaces to the right
start = boost::regex_replace(start,
boost::regex(" +$"), "$1");
rtrim(start);

Rcpp::as<Rcpp::CharacterVector>(df[kk])[nn] = start;

Expand Down Expand Up @@ -250,8 +247,7 @@ Rcpp::List read_sav_known_n (Rcpp::List& df, std::fstream& sav,
if (res_i == res_kk-1) {

// trim additional whitespaces to the right
start = boost::regex_replace(start,
boost::regex(" +$"), "$1");
rtrim(start);

Rcpp::as<Rcpp::CharacterVector>(df[kk])[nn] = start;

Expand Down Expand Up @@ -294,8 +290,7 @@ Rcpp::List read_sav_known_n (Rcpp::List& df, std::fstream& sav,
if (res_i == res_kk-1) {

// trim additional whitespaces to the right
start = boost::regex_replace(start,
boost::regex(" +$"), "$1");
rtrim(start);

Rcpp::as<Rcpp::CharacterVector>(df[kk])[nn] = start;

Expand Down Expand Up @@ -418,8 +413,7 @@ Rcpp::List read_sav_known_n (Rcpp::List& df, std::fstream& sav,
val_s.erase(type, std::string::npos);

// trim additional whitespaces
val_s = boost::regex_replace(val_s,
boost::regex("^ +| +$"), "$1");
trim(val_s);

// Rcpp::Rcout << val_s << std::endl;
Rcpp::as<Rcpp::CharacterVector>(df[kk])[nn] = val_s;
Expand Down
2 changes: 1 addition & 1 deletion src/read_sav_uncompress.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Jan Marvin Garbuszus
* Copyright (C) 2018-2025 Jan Marvin Garbuszus
*
* zlib header information by Evan Miller
*
Expand Down
Loading
Loading