Initial import (#1608215).
This commit is contained in:
parent
25fbeba1e0
commit
eb01f64dcf
|
@ -0,0 +1 @@
|
|||
/fansi_0.2.3.tar.gz
|
|
@ -0,0 +1,71 @@
|
|||
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
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
%global packname fansi
|
||||
%global rlibdir %{_libdir}/R/library
|
||||
|
||||
Name: R-%{packname}
|
||||
Version: 0.2.3
|
||||
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
|
||||
# LinkingTo:
|
||||
# Enhances:
|
||||
|
||||
Suggests: R-unitizer
|
||||
BuildRequires: R-devel
|
||||
BuildRequires: tex(latex)
|
||||
BuildRequires: R-unitizer
|
||||
|
||||
%description
|
||||
Counterparts to R string manipulation functions that account for the
|
||||
effects of ANSI text formatting control sequences.
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q -c -n %{packname}
|
||||
|
||||
pushd %{packname}
|
||||
%patch0001 -p1
|
||||
popd
|
||||
|
||||
|
||||
%build
|
||||
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}%{rlibdir}
|
||||
%{_bindir}/R CMD INSTALL -l %{buildroot}%{rlibdir} %{packname}
|
||||
test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so)
|
||||
rm -f %{buildroot}%{rlibdir}/R.css
|
||||
|
||||
|
||||
%check
|
||||
%{_bindir}/R CMD check %{packname}
|
||||
|
||||
|
||||
%files
|
||||
%dir %{rlibdir}/%{packname}
|
||||
%doc %{rlibdir}/%{packname}/html
|
||||
%{rlibdir}/%{packname}/DESCRIPTION
|
||||
%doc %{rlibdir}/%{packname}/NEWS.md
|
||||
%{rlibdir}/%{packname}/INDEX
|
||||
%{rlibdir}/%{packname}/NAMESPACE
|
||||
%{rlibdir}/%{packname}/Meta
|
||||
%{rlibdir}/%{packname}/R
|
||||
%{rlibdir}/%{packname}/help
|
||||
%dir %{rlibdir}/%{packname}/libs
|
||||
%{rlibdir}/%{packname}/libs/%{packname}.so
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Jul 24 2018 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.2.3-1
|
||||
- initial package for Fedora
|
Loading…
Reference in New Issue