strscan 3.0.1 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/COPYING +56 -0
- data/LICENSE.txt +22 -0
- data/ext/strscan/extconf.rb +7 -3
- data/ext/strscan/strscan.c +61 -8
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0451e93aa90b5c3384fd0c026e22709b673cf06f172d737c3e7b4ba347a0026
|
4
|
+
data.tar.gz: 2772b7377b8c885632e0b0fe2132f9b0ae143c4dfc25a2806a59fe3ef917eb59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 119a3269f50a35ace7e62c1f8e7d817ae70fe3e40a724385a7891d355ab62b7f7cac46689b62ff7d0267db524b4621c3b15f90f5bb0f2a359b11d70d4eaaf477
|
7
|
+
data.tar.gz: f9439f76c7b1b6f866afbfa7c064ce0ad0f4a5f3582ef773a7da2fab2d15c2cf36e578661e0330268a649bf1fdf03843c306ce295f0ebc3ed5cddee5f4b15aed
|
data/COPYING
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
StringScanner is copyrighted free software by Minero Aoki.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file LICENSE.txt), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b. use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c. give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d. make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a. distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c. give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d. make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (C) 1999-2006 Minero Aoki. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions
|
5
|
+
are met:
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
16
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
17
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
18
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
19
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
20
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
21
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
22
|
+
SUCH DAMAGE.
|
data/ext/strscan/extconf.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'mkmf'
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
if RUBY_ENGINE == 'ruby'
|
4
|
+
$INCFLAGS << " -I$(top_srcdir)" if $extmk
|
5
|
+
have_func("onig_region_memsize", "ruby.h")
|
6
|
+
create_makefile 'strscan'
|
7
|
+
else
|
8
|
+
File.write('Makefile', dummy_makefile("").join)
|
9
|
+
end
|
data/ext/strscan/strscan.c
CHANGED
@@ -22,7 +22,7 @@ extern size_t onig_region_memsize(const struct re_registers *regs);
|
|
22
22
|
|
23
23
|
#include <stdbool.h>
|
24
24
|
|
25
|
-
#define STRSCAN_VERSION "3.0.
|
25
|
+
#define STRSCAN_VERSION "3.0.6"
|
26
26
|
|
27
27
|
/* =======================================================================
|
28
28
|
Data Type Definitions
|
@@ -435,11 +435,11 @@ strscan_get_pos(VALUE self)
|
|
435
435
|
*
|
436
436
|
* In short, it's a 0-based index into the string.
|
437
437
|
*
|
438
|
-
* s = StringScanner.new("
|
439
|
-
* s.charpos
|
440
|
-
* s.scan_until(
|
441
|
-
* s.pos
|
442
|
-
* s.charpos
|
438
|
+
* s = StringScanner.new("abc\u00e4def\u00f6ghi")
|
439
|
+
* s.charpos # -> 0
|
440
|
+
* s.scan_until(/\u00e4/) # -> "abc\u00E4"
|
441
|
+
* s.pos # -> 5
|
442
|
+
* s.charpos # -> 4
|
443
443
|
*/
|
444
444
|
static VALUE
|
445
445
|
strscan_get_charpos(VALUE self)
|
@@ -1038,8 +1038,9 @@ strscan_empty_p(VALUE self)
|
|
1038
1038
|
* This method is obsolete; use #eos? instead.
|
1039
1039
|
*
|
1040
1040
|
* s = StringScanner.new('test string')
|
1041
|
-
*
|
1042
|
-
* s.
|
1041
|
+
* # These two are opposites
|
1042
|
+
* s.eos? # => false
|
1043
|
+
* s.rest? # => true
|
1043
1044
|
*/
|
1044
1045
|
static VALUE
|
1045
1046
|
strscan_rest_p(VALUE self)
|
@@ -1458,6 +1459,54 @@ strscan_fixed_anchor_p(VALUE self)
|
|
1458
1459
|
return p->fixed_anchor_p ? Qtrue : Qfalse;
|
1459
1460
|
}
|
1460
1461
|
|
1462
|
+
typedef struct {
|
1463
|
+
VALUE self;
|
1464
|
+
VALUE captures;
|
1465
|
+
} named_captures_data;
|
1466
|
+
|
1467
|
+
static int
|
1468
|
+
named_captures_iter(const OnigUChar *name,
|
1469
|
+
const OnigUChar *name_end,
|
1470
|
+
int back_num,
|
1471
|
+
int *back_refs,
|
1472
|
+
OnigRegex regex,
|
1473
|
+
void *arg)
|
1474
|
+
{
|
1475
|
+
named_captures_data *data = arg;
|
1476
|
+
|
1477
|
+
VALUE key = rb_str_new((const char *)name, name_end - name);
|
1478
|
+
VALUE value = RUBY_Qnil;
|
1479
|
+
int i;
|
1480
|
+
for (i = 0; i < back_num; i++) {
|
1481
|
+
value = strscan_aref(data->self, INT2NUM(back_refs[i]));
|
1482
|
+
}
|
1483
|
+
rb_hash_aset(data->captures, key, value);
|
1484
|
+
return 0;
|
1485
|
+
}
|
1486
|
+
|
1487
|
+
/*
|
1488
|
+
* call-seq:
|
1489
|
+
* scanner.named_captures -> hash
|
1490
|
+
*
|
1491
|
+
* Returns a hash of string variables matching the regular expression.
|
1492
|
+
*
|
1493
|
+
* scan = StringScanner.new('foobarbaz')
|
1494
|
+
* scan.match?(/(?<f>foo)(?<r>bar)(?<z>baz)/)
|
1495
|
+
* scan.named_captures # -> {"f"=>"foo", "r"=>"bar", "z"=>"baz"}
|
1496
|
+
*/
|
1497
|
+
static VALUE
|
1498
|
+
strscan_named_captures(VALUE self)
|
1499
|
+
{
|
1500
|
+
struct strscanner *p;
|
1501
|
+
GET_SCANNER(self, p);
|
1502
|
+
named_captures_data data;
|
1503
|
+
data.self = self;
|
1504
|
+
data.captures = rb_hash_new();
|
1505
|
+
onig_foreach_name(RREGEXP_PTR(p->regex), named_captures_iter, &data);
|
1506
|
+
|
1507
|
+
return data.captures;
|
1508
|
+
}
|
1509
|
+
|
1461
1510
|
/* =======================================================================
|
1462
1511
|
Ruby Interface
|
1463
1512
|
======================================================================= */
|
@@ -1468,6 +1517,8 @@ strscan_fixed_anchor_p(VALUE self)
|
|
1468
1517
|
* StringScanner provides for lexical scanning operations on a String. Here is
|
1469
1518
|
* an example of its usage:
|
1470
1519
|
*
|
1520
|
+
* require 'strscan'
|
1521
|
+
*
|
1471
1522
|
* s = StringScanner.new('This is an example string')
|
1472
1523
|
* s.eos? # -> false
|
1473
1524
|
*
|
@@ -1650,4 +1701,6 @@ Init_strscan(void)
|
|
1650
1701
|
rb_define_method(StringScanner, "inspect", strscan_inspect, 0);
|
1651
1702
|
|
1652
1703
|
rb_define_method(StringScanner, "fixed_anchor?", strscan_fixed_anchor_p, 0);
|
1704
|
+
|
1705
|
+
rb_define_method(StringScanner, "named_captures", strscan_named_captures, 0);
|
1653
1706
|
}
|
metadata
CHANGED
@@ -1,25 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strscan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minero Aoki
|
8
8
|
- Sutou Kouhei
|
9
|
+
- Charles Oliver Nutter
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2023-02-08 00:00:00.000000000 Z
|
13
14
|
dependencies: []
|
14
15
|
description: Provides lexical scanning operations on a String.
|
15
16
|
email:
|
16
17
|
-
|
17
18
|
- kou@cozmixng.org
|
19
|
+
- headius@headius.com
|
18
20
|
executables: []
|
19
21
|
extensions:
|
20
22
|
- ext/strscan/extconf.rb
|
21
23
|
extra_rdoc_files: []
|
22
24
|
files:
|
25
|
+
- COPYING
|
26
|
+
- LICENSE.txt
|
23
27
|
- ext/strscan/extconf.rb
|
24
28
|
- ext/strscan/strscan.c
|
25
29
|
homepage: https://github.com/ruby/strscan
|
@@ -42,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '0'
|
44
48
|
requirements: []
|
45
|
-
rubygems_version: 3.3.
|
49
|
+
rubygems_version: 3.3.26
|
46
50
|
signing_key:
|
47
51
|
specification_version: 4
|
48
52
|
summary: Provides lexical scanning operations on a String.
|