Update to latest version.

This commit is contained in:
Elliott Sales de Andrade 2018-08-19 22:14:03 -04:00
parent eb01f64dcf
commit 27a1291d10
4 changed files with 14 additions and 78 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/fansi_0.2.3.tar.gz
/fansi_0.3.0.tar.gz

View File

@ -1,71 +0,0 @@
From ec3f270ca0d10a68d168c90f5760ef396ab5d707 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Wed, 25 Jul 2018 02:11:30 -0400
Subject: [PATCH] Handle systems where char is unsigned.
The code currently assumes that char is signed and that values>127 mean
checking for < 0. This is not guaranteed by the spec, and on systems
where char is unsigned, these checks fail.
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
src/read.c | 4 ++--
src/utf8.c | 11 ++++++++---
src/utils.c | 2 +-
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/read.c b/src/read.c
index c6ab6be..ff7331a 100644
--- a/src/read.c
+++ b/src/read.c
@@ -613,8 +613,8 @@ struct FANSI_state FANSI_read_next(struct FANSI_state state) {
// Normal ASCII characters
if(chr_val >= 0x20 && chr_val < 0x7F) state = read_ascii(state);
- // UTF8 characters (chr_val is signed, so > 0x7f will be negative)
- else if (chr_val < 0) state = read_utf8(state);
+ // UTF8 characters (if chr_val is signed, then > 0x7f will be negative)
+ else if (chr_val < 0 || chr_val > 0x7f) state = read_utf8(state);
// ESC sequences
else if (chr_val == 0x1B) state = read_esc(state);
// C0 escapes (e.g. \t, \n, etc)
diff --git a/src/utf8.c b/src/utf8.c
index 8393df5..79951fc 100644
--- a/src/utf8.c
+++ b/src/utf8.c
@@ -27,11 +27,16 @@
* it.
*/
-// check whether any bytes are greater than 127; doesn't really actually confirm
-// this is UTF8
+// Check whether any bytes are greater than 127; doesn't really actually confirm
+// this is UTF8. Note, char may be signed, so > 127 means < 0.
int FANSI_has_utf8(const char * x) {
- while(*x) {if(*(x++) < 0) return 1;}
+ while(*x) {
+ if(*x < 0 || *x > 127) {
+ return 1;
+ }
+ x++;
+ }
return 0;
}
// nocov start
diff --git a/src/utils.c b/src/utils.c
index 9dfb8d1..7e283d2 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -116,7 +116,7 @@ struct FANSI_csi_pos FANSI_find_esc(const char * x, int what) {
int found_this = 0;
// If not normal ASCII or UTF8, examine whether we need to found
- if(!((x_val > 31 && x_val < 127) || x_val < 0)) {
+ if(!((x_val > 31 && x_val < 127) || x_val < 0 || x_val > 127)) {
if(!found) {
// Keep resetting strip start point until we find something we want to
// mark
--
2.17.1

View File

@ -2,26 +2,29 @@
%global rlibdir %{_libdir}/R/library
Name: R-%{packname}
Version: 0.2.3
Version: 0.3.0
Release: 1%{?dist}
Summary: ANSI Control Sequence Aware String Functions
License: GPLv2+
URL: https://cran.r-project.org/web/packages/%{packname}/index.html
Source0: https://cran.r-project.org/src/contrib/%{packname}_%{version}.tar.gz
Patch0001: 0001-Handle-systems-where-char-is-unsigned.patch
# Here's the R view of the dependencies world:
# Depends:
# Imports:
# Suggests: R-unitizer
# Suggests: R-unitizer, R-knitr, R-rmarkdown
# LinkingTo:
# Enhances:
Suggests: R-unitizer
Suggests: R-knitr
Suggests: R-rmarkdown
BuildRequires: R-devel
BuildRequires: tex(latex)
BuildRequires: R-unitizer
BuildRequires: R-knitr
BuildRequires: R-rmarkdown
%description
Counterparts to R string manipulation functions that account for the
@ -31,9 +34,8 @@ effects of ANSI text formatting control sequences.
%prep
%setup -q -c -n %{packname}
pushd %{packname}
%patch0001 -p1
popd
# Remove useless executable bits.
find %{packname} -type f -executable -exec chmod -x '{}' \;
%build
@ -52,6 +54,7 @@ rm -f %{buildroot}%{rlibdir}/R.css
%files
%dir %{rlibdir}/%{packname}
%doc %{rlibdir}/%{packname}/doc
%doc %{rlibdir}/%{packname}/html
%{rlibdir}/%{packname}/DESCRIPTION
%doc %{rlibdir}/%{packname}/NEWS.md
@ -65,5 +68,8 @@ rm -f %{buildroot}%{rlibdir}/R.css
%changelog
* Sun Aug 19 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.3.0-1
- Update to latest version
* Tue Jul 24 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.2.3-1
- initial package for Fedora

View File

@ -1 +1 @@
SHA512 (fansi_0.2.3.tar.gz) = ce53de759e20e632e543950a52a7faeed377ab160f973b73546fe4587ce8642938ef5e33cf83d7585ea8e8b6087a9c6d8ad1ba6a48808f1effd21bf06615eef6
SHA512 (fansi_0.3.0.tar.gz) = 4769f80ad649bae681e0e87670fa5e415d39234424574a1da99aa43f6d7da225f9c2d187a8568a36812414a99d9742a279cca8c828b34d0ed94f58596769df5f