summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiliana Marie Prikler <liliana.prikler@gmail.com>2025-05-28 14:04:57 +0200
committerLiliana Marie Prikler <liliana.prikler@gmail.com>2025-06-06 22:39:02 +0200
commitb32a47f26c8ea6b7cb7ade944f0251cb59b87178 (patch)
tree959bb66609fdc07d824ebcc7066fc5573c271fae
parenteb5ae31d17a7924202ba78621c6e696e7f3d5c81 (diff)
gnu: Add scn.
* gnu/packages/patches/scn-fast-float-compat.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it here. * gnu/packages/cpp.scm (scn): New variable.
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/cpp.scm28
-rw-r--r--gnu/packages/patches/scn-fast-float-compat.patch48
3 files changed, 77 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 70673be2623..a84c96b991b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2045,6 +2045,7 @@ dist_patch_DATA = \
2045 %D%/packages/patches/quodlibet-fix-mtime-tests.patch \ 2045 %D%/packages/patches/quodlibet-fix-mtime-tests.patch \
2046 %D%/packages/patches/qucs-s-qucsator-rf-search.patch \ 2046 %D%/packages/patches/qucs-s-qucsator-rf-search.patch \
2047 %D%/packages/patches/qxlsx-fix-include-directory.patch \ 2047 %D%/packages/patches/qxlsx-fix-include-directory.patch \
2048 %D%/packages/patches/scn-fast-float-compat.patch \
2048 %D%/packages/patches/sdcc-disable-non-free-code.patch \ 2049 %D%/packages/patches/sdcc-disable-non-free-code.patch \
2049 %D%/packages/patches/sdl-pango-api_additions.patch \ 2050 %D%/packages/patches/sdl-pango-api_additions.patch \
2050 %D%/packages/patches/sdl-pango-blit_overflow.patch \ 2051 %D%/packages/patches/sdl-pango-blit_overflow.patch \
diff --git a/gnu/packages/cpp.scm b/gnu/packages/cpp.scm
index 39596bd54f4..461070c5202 100644
--- a/gnu/packages/cpp.scm
+++ b/gnu/packages/cpp.scm
@@ -1719,6 +1719,34 @@ code and retrieving their output.")
1719 (home-page "https://github.com/DaanDeMeyer/reproc") 1719 (home-page "https://github.com/DaanDeMeyer/reproc")
1720 (license license:expat))) 1720 (license license:expat)))
1721 1721
1722(define-public scn
1723 (package
1724 (name "scn")
1725 (version "4.0.1")
1726 (source (origin
1727 (method git-fetch)
1728 (uri (git-reference
1729 (url "https://github.com/eliaskosunen/scnlib")
1730 (commit (string-append "v" version))))
1731 (file-name (git-file-name name version))
1732 (patches (search-patches "scn-fast-float-compat.patch"))
1733 (sha256
1734 (base32 "0lnb9r004y75n4s4pd3k58cdcjpcylhdgr5phwja713g3dd40im8"))))
1735 (build-system cmake-build-system)
1736 (arguments
1737 (list #:configure-flags #~(list "-DSCN_USE_EXTERNAL_GTEST=yes"
1738 "-DSCN_USE_EXTERNAL_BENCHMARK=yes"
1739 "-DSCN_USE_EXTERNAL_FAST_FLOAT=yes"
1740 "-DBUILD_SHARED_LIBS=yes")))
1741 (propagated-inputs (list fast-float))
1742 (native-inputs (list googletest googlebenchmark))
1743 (home-page "https://scnlib.dev/")
1744 (synopsis "Type-safe text parsing library")
1745 (description "@code{scn} is a text parsing library for C++. It can
1746be used as a safe alternative to @code{scanf} or as a fast alternative to
1747@code{IOStreams}, analogous to @code{fmt}.")
1748 (license license:asl2.0)))
1749
1722(define-public sobjectizer 1750(define-public sobjectizer
1723 (package 1751 (package
1724 (name "sobjectizer") 1752 (name "sobjectizer")
diff --git a/gnu/packages/patches/scn-fast-float-compat.patch b/gnu/packages/patches/scn-fast-float-compat.patch
new file mode 100644
index 00000000000..27c18a3ac8e
--- /dev/null
+++ b/gnu/packages/patches/scn-fast-float-compat.patch
@@ -0,0 +1,48 @@
1From 144a590f6c7861101579069e89dfb1db0ddfec25 Mon Sep 17 00:00:00 2001
2From: Elias Kosunen <elias.kosunen@gmail.com>
3Date: Wed, 21 May 2025 23:59:59 +0300
4Subject: [PATCH] Fix incompatibility with newer fast_float
5
6---
7 benchmark/runtime/float/repeated.cpp | 1 -
8 benchmark/runtime/float/single.cpp | 1 -
9 src/scn/impl.cpp | 6 ++++--
10 3 files changed, 4 insertions(+), 4 deletions(-)
11
12diff --git a/benchmark/runtime/float/repeated.cpp b/benchmark/runtime/float/repeated.cpp
13index 0aa0c39a..8a4de0a1 100644
14--- a/benchmark/runtime/float/repeated.cpp
15+++ b/benchmark/runtime/float/repeated.cpp
16@@ -210,4 +210,3 @@ static void scan_float_repeated_fastfloat(benchmark::State& state)
17 }
18 BENCHMARK_TEMPLATE(scan_float_repeated_fastfloat, float);
19 BENCHMARK_TEMPLATE(scan_float_repeated_fastfloat, double);
20-BENCHMARK_TEMPLATE(scan_float_repeated_fastfloat, long double);
21diff --git a/benchmark/runtime/float/single.cpp b/benchmark/runtime/float/single.cpp
22index e06cd138..6819621b 100644
23--- a/benchmark/runtime/float/single.cpp
24+++ b/benchmark/runtime/float/single.cpp
25@@ -185,4 +185,3 @@ static void scan_float_single_fastfloat(benchmark::State& state)
26 }
27 BENCHMARK_TEMPLATE(scan_float_single_fastfloat, float);
28 BENCHMARK_TEMPLATE(scan_float_single_fastfloat, double);
29-BENCHMARK_TEMPLATE(scan_float_single_fastfloat, long double);
30diff --git a/src/scn/impl.cpp b/src/scn/impl.cpp
31index a36117d8..1e38f1f4 100644
32--- a/src/scn/impl.cpp
33+++ b/src/scn/impl.cpp
34@@ -723,10 +723,12 @@ struct fast_float_impl_base : impl_base {
35 {
36 unsigned format_flags{};
37 if ((m_options & float_reader_base::allow_fixed) != 0) {
38- format_flags |= fast_float::fixed;
39+ format_flags |=
40+ static_cast<unsigned>(fast_float::chars_format::fixed);
41 }
42 if ((m_options & float_reader_base::allow_scientific) != 0) {
43- format_flags |= fast_float::scientific;
44+ format_flags |=
45+ static_cast<unsigned>(fast_float::chars_format::scientific);
46 }
47
48 return static_cast<fast_float::chars_format>(format_flags); \ No newline at end of file