Skip to content

Commit

Permalink
Merge pull request #10 from kota7/develop
Browse files Browse the repository at this point in the history
Develop, fixed typo to fix #9
  • Loading branch information
kota7 authored Dec 4, 2017
2 parents f6e94ed + f895c9b commit 68b5f13
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: striprtf
Type: Package
Title: Extract Text from RTF File
Version: 0.4.5
Version: 0.4.6
Authors@R: c(
person("Kota", "Mori", email = "[email protected]", role = c("aut", "cre"))
)
Expand Down
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
striprtf v0.4.6 (Release date: 2017-12-04)
==============

* fixed bugs for parsing lower quote (`\u2018`)



striprtf v0.4.5 (Release date: 2017-07-04)
==============

Expand Down
6 changes: 3 additions & 3 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

to_hexstr <- function(x, pad = 4L) {
.Call('striprtf_to_hexstr', PACKAGE = 'striprtf', x, pad)
.Call('_striprtf_to_hexstr', PACKAGE = 'striprtf', x, pad)
}

hex_to_int <- function(h, sep = 'x') {
.Call('striprtf_hex_to_int', PACKAGE = 'striprtf', h, sep)
.Call('_striprtf_hex_to_int', PACKAGE = 'striprtf', h, sep)
}

strip_helper <- function(match_mat, dest_names, special_keys, special_hex, verbose) {
.Call('striprtf_strip_helper', PACKAGE = 'striprtf', match_mat, dest_names, special_keys, special_hex, verbose)
.Call('_striprtf_strip_helper', PACKAGE = 'striprtf', match_mat, dest_names, special_keys, special_hex, verbose)
}

2 changes: 1 addition & 1 deletion R/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
# - \cell ... end of each cell
"row", "cell"),
hexstr = c("x2022", "x2014", "x2003", "x2013", "x2002",
"x201C", "x000A", "xu2018", "x000Ax000A", "x000A",
"x201C", "x000A", "x2018", "x000Ax000A", "x000A",
"x2005", "x201D", "x2019", "x000Ax000A", "x0009",
"x000A", "x0009"),
str = c("\u2022", "\u2014", "\u2003", "\u2013", "\u2002",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


<!-- README.md is generated from README.Rmd. Please edit that file -->
[![Build Status](https://travis-ci.org/kota7/striprtf.svg?branch=master)](https://travis-ci.org/kota7/striprtf) [![CRAN Status](https://www.r-pkg.org/badges/version/striprtf)](https://www.r-pkg.org/badges/version/striprtf) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/kota7/striprtf?branch=master&svg=true)](https://ci.appveyor.com/project/kota7/striprtf) [![](http://cranlogs.r-pkg.org/badges/striprtf)](https://cran.r-project.org/package=striprtf)

Expand Down
18 changes: 15 additions & 3 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace Rcpp;

// to_hexstr
std::string to_hexstr(int x, int pad);
RcppExport SEXP striprtf_to_hexstr(SEXP xSEXP, SEXP padSEXP) {
RcppExport SEXP _striprtf_to_hexstr(SEXP xSEXP, SEXP padSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Expand All @@ -19,7 +19,7 @@ END_RCPP
}
// hex_to_int
IntegerVector hex_to_int(std::string h, char sep);
RcppExport SEXP striprtf_hex_to_int(SEXP hSEXP, SEXP sepSEXP) {
RcppExport SEXP _striprtf_hex_to_int(SEXP hSEXP, SEXP sepSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Expand All @@ -31,7 +31,7 @@ END_RCPP
}
// strip_helper
List strip_helper(CharacterMatrix match_mat, CharacterVector dest_names, CharacterVector special_keys, CharacterVector special_hex, bool verbose);
RcppExport SEXP striprtf_strip_helper(SEXP match_matSEXP, SEXP dest_namesSEXP, SEXP special_keysSEXP, SEXP special_hexSEXP, SEXP verboseSEXP) {
RcppExport SEXP _striprtf_strip_helper(SEXP match_matSEXP, SEXP dest_namesSEXP, SEXP special_keysSEXP, SEXP special_hexSEXP, SEXP verboseSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Expand All @@ -44,3 +44,15 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
{"_striprtf_to_hexstr", (DL_FUNC) &_striprtf_to_hexstr, 2},
{"_striprtf_hex_to_int", (DL_FUNC) &_striprtf_hex_to_int, 2},
{"_striprtf_strip_helper", (DL_FUNC) &_striprtf_strip_helper, 5},
{NULL, NULL, 0}
};

RcppExport void R_init_striprtf(DllInfo *dll) {
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}
14 changes: 10 additions & 4 deletions src/dechex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,23 @@ IntegerVector hex_to_int(std::string h, char sep)
//
// returns:
// integer vector
//
// error if:
// h contains a letter other than 0-9, a-f, A-F, and sep

h += sep; // make sure the last hex is read

IntegerVector out;
bool started = false;
int start = 0;
for (int i = 0; i < h.size(); i++)
{
int start;
if (h[i] == sep) {
if (!started) {
start = i + 1;
started = true;
} else {
int end = i;

int tmp = 0;
int base = 1;
for (int k = end-1; k >= start; k--)
Expand All @@ -64,8 +66,12 @@ IntegerVector hex_to_int(std::string h, char sep)
if (c >= '0' && c <= '9') n = c - '0';
else if (c >= 'A' && c <= 'F') n = c - 'A' + 10;
else if (c >= 'a' && c <= 'f') n = c - 'a' + 10;
else stop("invalid hex");

else {
std::string mess = "invalid hex found: ";
mess += c;
mess += ", around: " + h.substr(start, 10);
stop(mess);
}
tmp += base*n;
base *= 16;
}
Expand Down
2 changes: 2 additions & 0 deletions src/strip_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ List strip_helper(CharacterMatrix match_mat,
if (curhex.size() > 0 && (hex == "" || curhex.size() == 4)) {
// make sure the length is 4
while (curhex.size() < 4) curhex = '0' + curhex;
//Rcout << curhex << "\n";
append_out(doc, 'x' + curhex, true, intable);
curhex = "";
}
Expand Down Expand Up @@ -249,6 +250,7 @@ List strip_helper(CharacterMatrix match_mat,
} else if (ignorable) {
continue;
} else if (specialchars.haskey(word)) {
//Rcout << specialchars.getvalue(word) << "\n";
append_out(doc, specialchars.getvalue(word), false, intable);
if (word == "row") {
intable = false;
Expand Down
26 changes: 0 additions & 26 deletions src/striprtf_init.c

This file was deleted.

0 comments on commit 68b5f13

Please sign in to comment.