Skip to content

Commit 998a4bc

Browse files
committed
fs: replace regexp with a compatible re2 backend
Signed-off-by: Anagh Kumar Baranwal <6824881+darthShadow@users.noreply.github.com>
1 parent eeca175 commit 998a4bc

File tree

8 files changed

+26
-12
lines changed

8 files changed

+26
-12
lines changed

.github/workflows/personal-build.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
platform: linux/amd64
3232
os: ubuntu-20.04
3333
go: '>=1.24.0-rc.1'
34-
gotags: 'cmount'
34+
gotags: 'cmount,re2_cgo'
3535
cgo: '1'
3636
build_flags: '-include "^linux/"'
3737
check: true
@@ -43,7 +43,7 @@ jobs:
4343
platform: linux/amd64
4444
os: ubuntu-22.04
4545
go: '>=1.24.0-rc.1'
46-
gotags: 'cmount'
46+
gotags: 'cmount,re2_cgo'
4747
cgo: '1'
4848
build_flags: '-include "^linux/"'
4949
check: true
@@ -55,7 +55,7 @@ jobs:
5555
platform: linux/amd64
5656
os: ubuntu-24.04
5757
go: '>=1.24.0-rc.1'
58-
gotags: 'cmount'
58+
gotags: 'cmount,re2_cgo'
5959
cgo: '1'
6060
build_flags: '-include "^linux/"'
6161
check: true
@@ -96,14 +96,14 @@ jobs:
9696
sudo apt-get update
9797
sudo apt-get upgrade -y
9898
sudo add-apt-repository -y ppa:git-core/ppa
99-
sudo apt-get install -y ca-certificates kmod software-properties-common
99+
sudo apt-get install -y build-essential ca-certificates kmod software-properties-common
100100
sudo apt-get update -y
101101
sudo apt-get upgrade -y
102102
sudo apt-get install -y git
103103
sudo git config --global --add safe.directory `pwd`
104104
sudo modprobe fuse
105105
sudo chmod 666 /dev/fuse
106-
sudo apt-get install -y fuse3 libfuse2 libfuse-dev libfuse3-3 libfuse3-dev rpm pkg-config git-annex upx git-annex-remote-rclone nfs-common
106+
sudo apt-get install -y fuse3 libfuse2 libfuse-dev libfuse3-3 libfuse3-dev libre2-dev rpm pkg-config git-annex upx git-annex-remote-rclone nfs-common
107107
sudo chown root:$USER /etc/fuse.conf
108108
if: matrix.os != 'macos-latest'
109109

@@ -118,7 +118,7 @@ jobs:
118118
brew update
119119
brew upgrade
120120
brew install --cask macfuse
121-
brew install git-annex git-annex-remote-rclone
121+
brew install git-annex git-annex-remote-rclone re2
122122
if: matrix.os == 'macos-latest'
123123

124124
- name: Set Environment Variables

cmd/help.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import (
44
"context"
55
"fmt"
66
"os"
7-
"regexp"
87
"sort"
98
"strings"
109

10+
regexp "github.com/wasilibs/go-re2"
11+
1112
"github.com/rclone/rclone/fs"
1213
"github.com/rclone/rclone/fs/config/configflags"
1314
"github.com/rclone/rclone/fs/config/flags"
@@ -222,7 +223,7 @@ Flags:
222223
223224
{{.Help}} (flag group {{.Name}}):
224225
{{.Flags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{end}}{{end}}{{if .HasHelpSubCommands}}
225-
226+
226227
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
227228
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}
228229

cmd/listremotes/listremotes.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import (
55
"encoding/json"
66
"fmt"
77
"os"
8-
"regexp"
98
"sort"
109
"strings"
1110

11+
regexp "github.com/wasilibs/go-re2"
12+
1213
"github.com/rclone/rclone/cmd"
1314
"github.com/rclone/rclone/fs"
1415
"github.com/rclone/rclone/fs/config"

fs/config/flags/flags.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ package flags
44

55
import (
66
"os"
7-
"regexp"
87
"strings"
98
"time"
109

10+
regexp "github.com/wasilibs/go-re2"
11+
1112
"github.com/rclone/rclone/fs"
1213
"github.com/spf13/pflag"
1314
)

fs/filter/glob.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ package filter
55
import (
66
"bytes"
77
"fmt"
8-
"regexp"
98
"strings"
109

10+
regexp "github.com/wasilibs/go-re2"
11+
1112
"github.com/rclone/rclone/fs"
1213
)
1314

fs/filter/rules.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import (
44
"bufio"
55
"fmt"
66
"os"
7-
"regexp"
87
"strings"
98

9+
regexp "github.com/wasilibs/go-re2"
10+
1011
"github.com/rclone/rclone/fs"
1112
)
1213

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ require (
7878
github.com/stretchr/testify v1.10.0
7979
github.com/t3rm1n4l/go-mega v0.0.0-20241213151442-a19cff0ec7b5
8080
github.com/unknwon/goconfig v1.0.0
81+
github.com/wasilibs/go-re2 v1.8.0
8182
github.com/willscott/go-nfs v0.0.3-0.20240425122109-91bc38957cc9
8283
github.com/winfsp/cgofuse v1.6.0
8384
github.com/xanzy/ssh-agent v0.3.3
@@ -213,8 +214,10 @@ require (
213214
github.com/shabbyrobe/gocovmerge v0.0.0-20230507112040-c3350d9342df // indirect
214215
github.com/sony/gobreaker v1.0.0 // indirect
215216
github.com/spacemonkeygo/monkit/v3 v3.0.24 // indirect
217+
github.com/tetratelabs/wazero v1.8.2 // indirect
216218
github.com/tklauser/go-sysconf v0.3.14 // indirect
217219
github.com/tklauser/numcpus v0.9.0 // indirect
220+
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 // indirect
218221
github.com/willscott/go-nfs-client v0.0.0-20240104095149-b44639837b00 // indirect
219222
github.com/yusufpapurcu/wmi v1.2.4 // indirect
220223
github.com/zeebo/errs v1.4.0 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf
603603
github.com/t3rm1n4l/go-mega v0.0.0-20241213151442-a19cff0ec7b5 h1:Sa+sR8aaAMFwxhXWENEnE6ZpqhZ9d7u1RT2722Rw6hc=
604604
github.com/t3rm1n4l/go-mega v0.0.0-20241213151442-a19cff0ec7b5/go.mod h1:UdZiFUFu6e2WjjtjxivwXWcwc1N/8zgbkBR9QNucUOY=
605605
github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502/go.mod h1:p9lPsd+cx33L3H9nNoecRRxPssFKUwwI50I3pZ0yT+8=
606+
github.com/tetratelabs/wazero v1.8.2 h1:yIgLR/b2bN31bjxwXHD8a3d+BogigR952csSDdLYEv4=
607+
github.com/tetratelabs/wazero v1.8.2/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
606608
github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU=
607609
github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY=
608610
github.com/tklauser/numcpus v0.9.0 h1:lmyCHtANi8aRUgkckBgoDk1nHCux3n2cgkJLXdQGPDo=
@@ -615,6 +617,10 @@ github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65E
615617
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
616618
github.com/unknwon/goconfig v1.0.0 h1:rS7O+CmUdli1T+oDm7fYj1MwqNWtEJfNj+FqcUHML8U=
617619
github.com/unknwon/goconfig v1.0.0/go.mod h1:qu2ZQ/wcC/if2u32263HTVC39PeOQRSmidQk3DuDFQ8=
620+
github.com/wasilibs/go-re2 v1.8.0 h1:6wpqZ31vdoJRSOM41bWEd1AbSmRe161yQkTzoihqwEg=
621+
github.com/wasilibs/go-re2 v1.8.0/go.mod h1:RjA3Y/yW6xFL8Iyz8f5sVhttLq5b5DRF8baZ7Sh+elk=
622+
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52 h1:OvLBa8SqJnZ6P+mjlzc2K7PM22rRUPE1x32G9DTPrC4=
623+
github.com/wasilibs/wazero-helpers v0.0.0-20240620070341-3dff1577cd52/go.mod h1:jMeV4Vpbi8osrE/pKUxRZkVaA0EX7NZN0A9/oRzgpgY=
618624
github.com/willscott/go-nfs v0.0.3-0.20240425122109-91bc38957cc9 h1:IGSoH2aBagQ9VI8ZwbjHYIslta5vXfczegV1B4y9KqY=
619625
github.com/willscott/go-nfs v0.0.3-0.20240425122109-91bc38957cc9/go.mod h1:Ql2ebUpEFm/a1CAY884di2XZkdcddfHZ6ONrAlhFev0=
620626
github.com/willscott/go-nfs-client v0.0.0-20240104095149-b44639837b00 h1:U0DnHRZFzoIV1oFEZczg5XyPut9yxk9jjtax/9Bxr/o=

0 commit comments

Comments
 (0)