forked from JDimproved/JDim
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[IDEA] Regex: Implement named captures #59
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oniguruma利用時にregexのテストコードのビルドでposix regexと宣言が混ざりエラーが起きるようです https://github.com/ma8ma/JDim/pull/59/checks?check_run_id=3645171604
|
ma8ma
force-pushed
the
idea-regex-implement-named-capture
branch
from
September 25, 2021 07:53
6a19581
to
7067724
Compare
clang-5.0 のコンパイルエラーのまとめ
|
正規表現の名前付きキャプチャ機能をラッパークラスに実装します。 Glib Regexのみ有効でそれ以外の正規表現ライブラリでは名前を指定しても マッチしません。 合わせて `スレタイ検索時にアドレスとスレタイを取得する正規表現` (about:config) に名前付きキャプチャ対応を追加します。 また、互換性のためグループ番号は現状を維持します。 取得対象 | グループ番号 | キャプチャの名前 | 備考 --- | --- | --- | --- スレURL | 1 | url | 必須 スレタイトル | 2 | subject | 必須 レス数 | 3 | number | オプション
oniguruma と gtest の regex プロトタイプ宣言が衝突しエラーになるため APIのマクロをundefする
oniguruma と gtest の regex プロトタイプ宣言が衝突しコンパイルエラーに なるためテストはスキップします。
テストプログラムのビルドの条件コンパイルを修正し正しい条件で ビルドされるようにします。 https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Configuration-Headers.html
``` In file included from gtest_jdlib_jdregex.cpp:3:0: ../src/jdlib/jdregex.h:11:10: fatal error: config.h: No such file or directory #include "config.h" ^~~~~~~~~~ ```
clang 5.0はCWG DR1778[1]を実装していないためnoexcept指定のコンストラクタで コンパイルエラーが発生します。そのためコンパイラのバージョンをチェック してnoexceptを指定するように変更します。 [1]: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1286r2.html ``` In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/vector:67: /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:340:20: error: exception specification of '_Vector_impl' uses itself _Vector_impl _M_impl; ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:340:20: note: in instantiation of exception specification for '_Vector_impl' requested here /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/type_traits:1018:14: note: in instantiation of template class 'std::__is_nt_constructible_impl<true, std::allocator<std::__cxx11::basic_string<char> >>' requested here : public __is_nothrow_constructible_impl<_Tp>::type ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:132:6: note: in instantiation of template class 'std::is_nothrow_default_constructible<std::allocator<std::__cxx11::basic_string<char> > >' requested here is_nothrow_default_constructible<_Tp_alloc_type>::value) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:340:20: note: in instantiation of exception specification for '_Vector_impl' requested here _Vector_impl _M_impl; ^ In file included from ../src/article/articleadmin.cpp:16: ../src/article/../jdlib/jdregex.h:83:9: error: exception specification of explicitly defaulted default constructor does not match the calculated one Regex() noexcept = default; ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/type_traits:1018:14: note: in instantiation of template class 'std::__is_nt_constructible_impl<true, std::allocator<std::__cxx11::basic_string<char> >>' requested here : public __is_nothrow_constructible_impl<_Tp>::type ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:132:6: note: in instantiation of template class 'std::is_nothrow_default_constructible<std::allocator<std::__cxx11::basic_string<char> > >' requested here is_nothrow_default_constructible<_Tp_alloc_type>::value) ^ /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/stl_vector.h:340:20: note: in instantiation of exception specification for '_Vector_impl' requested here _Vector_impl _M_impl; ^ ```
clangで発生するコンパイルエラーの条件が不明のためnoexceptを外して試します。
noexcept指定をもとに戻しCIでテストするコンパイラを変更します。
ma8ma
force-pushed
the
idea-regex-implement-named-capture
branch
from
September 26, 2021 13:37
9c87fb7
to
fcfe874
Compare
4 tasks
テストの結果、現バージョン0.6.0でのマージを断念し動作環境が更新される0.7.0リリース以降に上流へマージしたいと思います。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
edit(2022-01-29): 上流にマージされました (JDimproved#904)
このPRはアイデア検証用でありマージしません。
正規表現の名前付きキャプチャ機能をラッパークラスに実装します。
Glib Regexのみ有効でそれ以外の正規表現ライブラリでは名前を指定してもマッチしません。
合わせて
スレタイ検索時にアドレスとスレタイを取得する正規表現
(about:config) に名前付きキャプチャ対応を追加します。また、互換性のためグループ番号は現状を維持します。
スレタイ検索の設定
スレタイ検索時にアドレスとスレタイを取得する正規表現
(about:config) はグループ番号のかわりに名前付きキャプチャを利用することができる。( v0.6.0+から追加、Glib Regexのみ )正規表現パターン中に名前が有れば名前付きキャプチャ、無ければグループ番号で対象を取得する。
url
subject
number
グループ番号は順序固定のため取得対象が番号順に並んでいないときは名前付きキャプチャを使うと分かりやすい。
(下の例はスレタイ、レス数、URLの順に並んでいるデータにマッチする)
^(?=[^\t\n]+\t[^\t\n]+\t([^\t\n]+))([^\t\n]+)\t([^\t\n]+)
^(?<subject>[^\t\n]+)\t(?<number>[^\t\n]+)\t(?<url>[^\t\n]+)
正規表現の構文はGlib公式など外部サイトを参照。
パッチの適応方法
git clone コマンドを使う方法 (一時的なcloneで使い捨てる)ブランチを削除したため利用できません
curl と patch コマンドを使う場合
※ git pullなどでmasterブランチを更新してから行うことを推奨します。
hub コマンドを使う場合