Skip to content

Commit

Permalink
Merge pull request #65 from tridactyl/remove_pcre
Browse files Browse the repository at this point in the history
Fix #64: swap PCRE for nim-regex
  • Loading branch information
bovine3dom authored Apr 7, 2023
2 parents 62f19db + de63e22 commit a993286
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions compile_and_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ chmod +x native_main
cp native_main ~/.local/share/tridactyl/native_main
time printf '%c\0\0\0{"cmd": "run", "command": "echo $PATH"}' 39 | ./native_main
time printf '%c\0\0\0{"cmd": "version"}' 39 | ./native_main
# time printf '%c\0\0\0{"cmd": "read", "file": "$HOME/test"}' 39 | ./native_main
# time printf '%c\0\0\0{"cmd": "version"}' 39 | ~/.local/share/tridactyl/native_main.py # approx 100ms
# time printf '%c\0\0\0{"cmd": "run", "command": "echo $PATH"}' 39 | ~/.local/share/tridactyl/native_main.py # approx 100ms
7 changes: 5 additions & 2 deletions src/native_main.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import streams
import os
import strutils
import posix
import re
import regex
import base64

# Third party stuff
Expand Down Expand Up @@ -115,7 +115,10 @@ proc expandVars(path: string): string =
name, value, tail: string
(first, last) = (0, 0)
while true:
(first, last) = findBounds(result, re"\$(\w+|\{[^}]*\})", first)
var bounds_slices = findAllBounds(result, re"\$(\w+|\{[^}]*\})", first)
if bounds_slices.len == 0:
break
(first, last) = (bounds_slices[0].a, bounds_slices[0].b)
if first < 0 or last < first:
break
name = result[first + 1 .. last]
Expand Down
1 change: 1 addition & 0 deletions tridactyl_native.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ bin = @["native_main"]

requires "nim >= 1.2.0"
requires "tempfile >= 0.1.0"
requires "regex >= 0.20.2"

0 comments on commit a993286

Please sign in to comment.