summaryrefslogtreecommitdiff
path: root/gnu/packages/regex.scm
blob: 7a222c76d58ddc3d06ef74c30c00211071b8bd53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 John Darrington
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Jelle Licht <jlicht@fsfe.org>
;;; Copyright © 2016, 2018, 2019, 2020, 2022 Marius Bakke <marius@gnu.org>
;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
;;; Copyright © 2024 Zheng Junjie <873216071@qq.com>
;;; Copyright © 2025 Ashish SHUKLA <ashish.is@lostca.se>
;;; Copyright © 2026 gemmaro <gemmaro.dev@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (gnu packages regex)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix gexp)
  #:use-module (guix build-system gnu)
  #:use-module (guix build-system cmake)
  #:use-module (guix utils)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages check)
  #:use-module (gnu packages cpp)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages python)
  #:use-module (gnu packages ruby))

(define-public onigmo
  (package
    (name "onigmo")
    (version "6.2.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
              (url "https://github.com/k-takata/Onigmo")
              (commit (string-append "Onigmo-" version))))
       (file-name (git-file-name name version))
       (sha256
        (base32 "0m6z61w8b4y8yk63sj9q8jm8a2v4ncrx258k96bn71nmji7rjnq3"))))
    (build-system gnu-build-system)
    (arguments
     (list
      #:test-target "pytest"))
    (native-inputs (list autoconf automake libtool ruby python))
    (home-page "https://github.com/k-takata/Onigmo")
    (synopsis "Regular expression library forked from Oniguruma")
    (description
     "Onigmo is a regular expression library forked from Oniguruma.  It
focuses on supporting new expressions.")
    (license license:bsd-2)))

(define-public oniguruma
  (package
    (name "oniguruma")
    (version "6.9.10")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
              (url "https://github.com/kkos/oniguruma")
              (commit (string-append "v" version))))
       (file-name
        (git-file-name name version))
       (sha256
        (base32 "0lp5ix2ky40ijzp1nsrxrlglvqrmik402n48f7v8siqd3isdbxzs"))))
    (build-system gnu-build-system)
    (arguments
     (list
      #:configure-flags #~(list "--disable-static")))
    (native-inputs
     (list autoconf
           automake
           libtool))
    (home-page "https://github.com/kkos/oniguruma")
    (synopsis "Regular expression library")
    (description
     "Oniguruma is a regular expressions library.  The special characteristic
of this library is that different character encoding for every regular
expression object can be specified.")
    (license license:bsd-2)))

(define-public re2
   (package
     (name "re2")
     (version "2022-12-01")
     (home-page "https://github.com/google/re2")
     (source (origin
               (method git-fetch)
               (uri (git-reference (url home-page) (commit version)))
               (file-name (git-file-name name version))
               (sha256
                (base32
                 "0g627a5ppyarhf2ph4gyzj89pwbkwfjfajgljzkmjafjmdyxfqs6"))))
     (build-system gnu-build-system)
     (arguments
      (list #:test-target "test"
            ;; There is no configure step, but the Makefile respects a prefix.
            #:make-flags #~(list (string-append "prefix=" #$output)
                                 (string-append "CXX=" #$(cxx-for-target)))
            #:phases
            #~(modify-phases %standard-phases
                (delete 'configure)
                (add-after 'install 'delete-static-library
                  (lambda _
                    ;; No make target for shared-only; delete the static version.
                    (delete-file (string-append #$output "/lib/libre2.a")))))))
     (synopsis "Fast, safe, thread-friendly regular expression engine")
     (description "RE2 is a fast, safe, thread-friendly alternative to
backtracking regular expression engines like those used in PCRE, Perl and
Python.  It is a C++ library.")
     (license license:bsd-3)))

(define-public re2-next
  (package
    (inherit re2)
    (name "re2")
    (version "2024-07-02")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/google/re2")
                    (commit version)))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "11q0kz8b3y5ysn58fr62yhib520f9l3grbn8gxr8x5s9k700vq11"))))
    (build-system cmake-build-system)
    (arguments (list #:tests? (not (%current-target-system))
                     #:configure-flags #~(list "-DBUILD_SHARED_LIBS=ON"
                                               ;; "-DRE2_USE_ICU=ON"
                                               #$@(if (not (%current-target-system))
                                                      #~("-DRE2_BUILD_TESTING=ON")
                                                      #~()))))
    (native-inputs (list googlebenchmark googletest))
    (propagated-inputs (list abseil-cpp))))

(define-public tre
  (package
    (name "tre")
    (version "0.9.0")
    (source (origin
              (method git-fetch)
              (uri (git-reference
                    (url "https://github.com/laurikari/tre")
                    (commit (string-append "v" version))))
              (file-name (git-file-name name version))
              (sha256
               (base32
                "1zy91a0jfc5galvd7xrvkn17i3wfiwnv9ikys4qiyjgy7fmk5vz4"))))
    (build-system gnu-build-system)
    (arguments
     `(#:phases
       (modify-phases %standard-phases
         (replace 'bootstrap
           (lambda _
             (invoke "autoreconf" "-vif")))
         (add-before 'check 'install-locales
           (lambda _
             ;; The tests require the availability of the
             ;; 'en_US.ISO-8859-1' locale.
             (setenv "LOCPATH" (getcwd))
             (invoke "localedef" "--no-archive"
                     "--prefix" (getcwd) "-i" "en_US"
                     "-f" "ISO-8859-1" "./en_US.ISO-8859-1"))))))
    (native-inputs
     (list autoconf
           automake
           gettext-minimal ;for autopoint
           libtool))
    (synopsis "Approximate regex matching library and agrep utility")
    (description "Superset of the POSIX regex API, enabling approximate
matching.  Also ships a version of the agrep utility which behaves similar to
grep but features inexact matching.")
    (home-page "https://laurikari.net/tre")
    (license license:bsd-2)))