this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

more

+89 -400
-106
.devcontainer/Dockerfile
··· 1 - FROM node:20 2 - 3 - ARG TZ 4 - ENV TZ="$TZ" 5 - 6 - ARG CLAUDE_CODE_VERSION=latest 7 - 8 - # Install basic development tools and iptables/ipset 9 - RUN apt-get update && apt-get install -y --no-install-recommends \ 10 - less \ 11 - git \ 12 - procps \ 13 - sudo \ 14 - fzf \ 15 - zsh \ 16 - man-db \ 17 - unzip \ 18 - gnupg2 \ 19 - gh \ 20 - iptables \ 21 - ipset \ 22 - iproute2 \ 23 - dnsutils \ 24 - aggregate \ 25 - jq \ 26 - nano \ 27 - vim \ 28 - locales \ 29 - && apt-get clean && rm -rf /var/lib/apt/lists/* 30 - 31 - # Configure locales 32 - RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \ 33 - locale-gen 34 - ENV LANG en_US.UTF-8 35 - ENV LANGUAGE en_US:en 36 - ENV LC_ALL en_US.UTF-8 37 - 38 - # Parquet 39 - RUN wget https://packages.apache.org/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb && apt install -y -V ./apache-arrow-apt-source-latest-bookworm.deb && rm -f ./apache-arrow-apt-source-latest-bookworm.deb 40 - RUN apt update 41 - RUN apt install -y libarrow-dev libparquet-dev 42 - 43 - # Ensure default node user has access to /usr/local/share 44 - RUN mkdir -p /usr/local/share/npm-global && \ 45 - chown -R node:node /usr/local/share 46 - 47 - ARG USERNAME=node 48 - 49 - # Persist bash history. 50 - RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ 51 - && mkdir /commandhistory \ 52 - && touch /commandhistory/.bash_history \ 53 - && chown -R $USERNAME /commandhistory 54 - 55 - # Set `DEVCONTAINER` environment variable to help with orientation 56 - ENV DEVCONTAINER=true 57 - 58 - # Create workspace and config directories and set permissions 59 - RUN mkdir -p /workspace /home/node/.claude && \ 60 - chown -R node:node /workspace /home/node/.claude 61 - 62 - WORKDIR /workspace 63 - 64 - ARG GIT_DELTA_VERSION=0.18.2 65 - RUN ARCH=$(dpkg --print-architecture) && \ 66 - wget "https://github.com/dandavison/delta/releases/download/${GIT_DELTA_VERSION}/git-delta_${GIT_DELTA_VERSION}_${ARCH}.deb" && \ 67 - sudo dpkg -i "git-delta_${GIT_DELTA_VERSION}_${ARCH}.deb" && \ 68 - rm "git-delta_${GIT_DELTA_VERSION}_${ARCH}.deb" 69 - 70 - # Set up non-root user 71 - USER node 72 - 73 - # Install global packages 74 - ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global 75 - ENV PATH=$PATH:/usr/local/share/npm-global/bin 76 - 77 - # Set the default shell to zsh rather than sh 78 - ENV SHELL=/bin/zsh 79 - 80 - # Set the default editor and visual 81 - ENV EDITOR nano 82 - ENV VISUAL nano 83 - 84 - # Default powerline10k theme 85 - ARG ZSH_IN_DOCKER_VERSION=1.2.0 86 - RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v${ZSH_IN_DOCKER_VERSION}/zsh-in-docker.sh)" -- \ 87 - -p git \ 88 - -p fzf \ 89 - -a "source /usr/share/doc/fzf/examples/key-bindings.zsh" \ 90 - -a "source /usr/share/doc/fzf/examples/completion.zsh" \ 91 - -a "export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \ 92 - -x 93 - 94 - # Install Claude 95 - RUN npm install -g @anthropic-ai/claude-code@${CLAUDE_CODE_VERSION} 96 - 97 - COPY setup-ocaml.sh /usr/local/bin 98 - 99 - # Copy and set up firewall script and let node sudo to all (for opam depexts) 100 - COPY init-firewall.sh /usr/local/bin/ 101 - USER root 102 - RUN chmod +x /usr/local/bin/init-firewall.sh && \ 103 - echo "node ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/node-firewall && \ 104 - chmod 0440 /etc/sudoers.d/node-firewall 105 - USER node 106 -
+7 -13
.devcontainer/devcontainer.json
··· 1 1 { 2 - "name": "Claude Code Sandbox", 3 - "build": { 4 - "dockerfile": "Dockerfile", 5 - "args": { 6 - "TZ": "${localEnv:TZ:America/Los_Angeles}", 7 - "CLAUDE_CODE_VERSION": "latest", 8 - "GIT_DELTA_VERSION": "0.18.2", 9 - "ZSH_IN_DOCKER_VERSION": "1.2.0" 10 - } 11 - }, 2 + "name": "Claude Code OCaml Sandbox", 3 + "image": "ghcr.io/avsm/claude-ocaml-devcontainer:main", 12 4 "runArgs": [ 13 5 "--cap-add=NET_ADMIN", 14 6 "--cap-add=NET_RAW" ··· 16 8 "customizations": { 17 9 "vscode": { 18 10 "extensions": [ 11 + "anthropic.claude-code", 19 12 "dbaeumer.vscode-eslint", 20 13 "esbenp.prettier-vscode", 21 14 "eamodio.gitlens", ··· 43 36 "remoteUser": "node", 44 37 "mounts": [ 45 38 "source=claude-code-bashhistory-${devcontainerId},target=/commandhistory,type=volume", 46 - "source=claude-code-config-${devcontainerId},target=/home/node/.claude,type=volume", 39 + "source=${localEnv:HOME}/.claude,target=/home/node/.claude,type=bind", 47 40 "source=${localEnv:HOME}/.ssh,target=/home/node/.ssh,type=bind,readonly", 48 - "source=${localWorkspaceFolder}/.slopper,target=/home/node/.slopper,type=bind" 41 + "source=${localEnv:HOME}/.gitconfig,target=/home/node/.gitconfig,type=bind,readonly" 49 42 ], 50 43 "containerEnv": { 51 44 "NODE_OPTIONS": "--max-old-space-size=4096", ··· 54 47 }, 55 48 "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=delegated", 56 49 "workspaceFolder": "/workspace", 57 - "postCreateCommand": "/usr/local/bin/setup-ocaml.sh && sudo /usr/local/bin/init-firewall.sh" 50 + "postCreateCommand": "sudo /usr/local/bin/init-firewall.sh", 51 + "waitFor": "postStartCommand" 58 52 }
-137
.devcontainer/init-firewall.sh
··· 1 - #!/bin/bash 2 - set -euo pipefail # Exit on error, undefined vars, and pipeline failures 3 - IFS=$'\n\t' # Stricter word splitting 4 - 5 - # 1. Extract Docker DNS info BEFORE any flushing 6 - DOCKER_DNS_RULES=$(iptables-save -t nat | grep "127\.0\.0\.11" || true) 7 - 8 - # Flush existing rules and delete existing ipsets 9 - iptables -F 10 - iptables -X 11 - iptables -t nat -F 12 - iptables -t nat -X 13 - iptables -t mangle -F 14 - iptables -t mangle -X 15 - ipset destroy allowed-domains 2>/dev/null || true 16 - 17 - # 2. Selectively restore ONLY internal Docker DNS resolution 18 - if [ -n "$DOCKER_DNS_RULES" ]; then 19 - echo "Restoring Docker DNS rules..." 20 - iptables -t nat -N DOCKER_OUTPUT 2>/dev/null || true 21 - iptables -t nat -N DOCKER_POSTROUTING 2>/dev/null || true 22 - echo "$DOCKER_DNS_RULES" | xargs -L 1 iptables -t nat 23 - else 24 - echo "No Docker DNS rules to restore" 25 - fi 26 - 27 - # First allow DNS and localhost before any restrictions 28 - # Allow outbound DNS 29 - iptables -A OUTPUT -p udp --dport 53 -j ACCEPT 30 - # Allow inbound DNS responses 31 - iptables -A INPUT -p udp --sport 53 -j ACCEPT 32 - # Allow outbound SSH 33 - iptables -A OUTPUT -p tcp --dport 22 -j ACCEPT 34 - # Allow inbound SSH responses 35 - iptables -A INPUT -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT 36 - # Allow localhost 37 - iptables -A INPUT -i lo -j ACCEPT 38 - iptables -A OUTPUT -o lo -j ACCEPT 39 - 40 - # Create ipset with CIDR support 41 - ipset create allowed-domains hash:net 42 - 43 - # Fetch GitHub meta information and aggregate + add their IP ranges 44 - echo "Fetching GitHub IP ranges..." 45 - gh_ranges=$(curl -s https://api.github.com/meta) 46 - if [ -z "$gh_ranges" ]; then 47 - echo "ERROR: Failed to fetch GitHub IP ranges" 48 - exit 1 49 - fi 50 - 51 - if ! echo "$gh_ranges" | jq -e '.web and .api and .git' >/dev/null; then 52 - echo "ERROR: GitHub API response missing required fields" 53 - exit 1 54 - fi 55 - 56 - echo "Processing GitHub IPs..." 57 - while read -r cidr; do 58 - if [[ ! "$cidr" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[0-9]{1,2}$ ]]; then 59 - echo "ERROR: Invalid CIDR range from GitHub meta: $cidr" 60 - exit 1 61 - fi 62 - echo "Adding GitHub range $cidr" 63 - ipset add allowed-domains "$cidr" 64 - done < <(echo "$gh_ranges" | jq -r '(.web + .api + .git)[]' | aggregate -q) 65 - 66 - # Resolve and add other allowed domains 67 - for domain in \ 68 - "registry.npmjs.org" \ 69 - "api.anthropic.com" \ 70 - "sentry.io" \ 71 - "statsig.anthropic.com" \ 72 - "opam.ocaml.org" \ 73 - "deb.debian.org" \ 74 - "dl.geotessera.org" \ 75 - "tangled.org" \ 76 - "api.fastmail.com" \ 77 - "packages.apache.org" \ 78 - "statsig.com"; do 79 - echo "Resolving $domain..." 80 - ips=$(dig +noall +answer A "$domain" | awk '$4 == "A" {print $5}') 81 - if [ -z "$ips" ]; then 82 - echo "ERROR: Failed to resolve $domain" 83 - exit 1 84 - fi 85 - 86 - while read -r ip; do 87 - if [[ ! "$ip" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then 88 - echo "ERROR: Invalid IP from DNS for $domain: $ip" 89 - exit 1 90 - fi 91 - echo "Adding $ip for $domain" 92 - ipset add allowed-domains "$ip" 93 - done < <(echo "$ips") 94 - done 95 - 96 - # Get host IP from default route 97 - HOST_IP=$(ip route | grep default | cut -d" " -f3) 98 - if [ -z "$HOST_IP" ]; then 99 - echo "ERROR: Failed to detect host IP" 100 - exit 1 101 - fi 102 - 103 - HOST_NETWORK=$(echo "$HOST_IP" | sed "s/\.[0-9]*$/.0\/24/") 104 - echo "Host network detected as: $HOST_NETWORK" 105 - 106 - # Set up remaining iptables rules 107 - iptables -A INPUT -s "$HOST_NETWORK" -j ACCEPT 108 - iptables -A OUTPUT -d "$HOST_NETWORK" -j ACCEPT 109 - 110 - # Set default policies to DROP first 111 - iptables -P INPUT DROP 112 - iptables -P FORWARD DROP 113 - iptables -P OUTPUT DROP 114 - 115 - # First allow established connections for already approved traffic 116 - iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT 117 - iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT 118 - 119 - # Then allow only specific outbound traffic to allowed domains 120 - iptables -A OUTPUT -m set --match-set allowed-domains dst -j ACCEPT 121 - 122 - echo "Firewall configuration complete" 123 - echo "Verifying firewall rules..." 124 - if curl --connect-timeout 5 https://example.com >/dev/null 2>&1; then 125 - echo "ERROR: Firewall verification failed - was able to reach https://example.com" 126 - exit 1 127 - else 128 - echo "Firewall verification passed - unable to reach https://example.com as expected" 129 - fi 130 - 131 - # Verify GitHub API access 132 - if ! curl --connect-timeout 5 https://api.github.com/zen >/dev/null 2>&1; then 133 - echo "ERROR: Firewall verification failed - unable to reach https://api.github.com" 134 - exit 1 135 - else 136 - echo "Firewall verification passed - able to reach https://api.github.com as expected" 137 - fi
-65
.devcontainer/setup-ocaml.sh
··· 1 - #!/bin/bash 2 - set -e 3 - 4 - echo "Installing OCaml dependencies..." 5 - sudo apt-get update 6 - sudo apt-get install -y \ 7 - build-essential \ 8 - curl \ 9 - git \ 10 - unzip \ 11 - bubblewrap \ 12 - m4 \ 13 - opam \ 14 - ripgrep \ 15 - vim \ 16 - pkg-config \ 17 - libgmp-dev 18 - 19 - echo "Initializing opam..." 20 - opam init --disable-sandboxing -y 21 - eval $(opam env) 22 - 23 - opam repo add aoah https://tangled.org/anil.recoil.org/aoah-opam-repo.git 24 - 25 - echo "Installing OCaml LSP server and common tools..." 26 - opam install -y \ 27 - ocaml-lsp-server \ 28 - dune \ 29 - merlin \ 30 - ocamlformat \ 31 - odoc \ 32 - utop \ 33 - cohttp-eio \ 34 - tls-eio \ 35 - progress \ 36 - decompress \ 37 - eio_main \ 38 - ezjsonm \ 39 - decompress \ 40 - zarith \ 41 - re \ 42 - ca-certs \ 43 - syndic \ 44 - alcotest \ 45 - ctypes \ 46 - ctypes-foreign \ 47 - lambdasoup \ 48 - cmarkit \ 49 - yaml \ 50 - jekyll-format \ 51 - jsont \ 52 - bytesrw \ 53 - toml \ 54 - crockford \ 55 - jsonfeed \ 56 - yamlt \ 57 - xdge 58 - 59 - echo "Setting up shell environment..." 60 - echo 'eval $(opam env)' >> ~/.bashrc 61 - 62 - echo "OCaml setup complete!" 63 - opam --version 64 - ocaml --version 65 - which ocamllsp
+1 -1
project/atp/test/dune
··· 1 1 (test 2 2 (name test_cbort) 3 - (libraries cbort jsont jsont_bytesrw bytesrw)) 3 + (libraries cbort jsont jsont.bytesrw bytesrw)) 4 4 5 5 (test 6 6 (name test_dagcbort)
+4 -4
project/ocaml-matrix/examples/simple_bot.ml
··· 70 70 (* Echo command - repeat the message *) 71 71 let echo_text = String.sub msg 6 (String.length msg - 6) in 72 72 (try 73 - Messages.send_text client ~room_id ~body:echo_text (); 73 + let _ = Messages.send_text client ~room_id ~body:echo_text () in 74 74 Printf.printf "Echoed: %s\n%!" echo_text 75 75 with Eio.Io _ as e -> 76 76 Printf.eprintf "Failed to send echo: %s\n%!" (Printexc.to_string e)) 77 77 | Some msg when msg = "!ping" -> 78 78 (* Ping command *) 79 79 (try 80 - Messages.send_text client ~room_id ~body:"pong!" (); 80 + let _ = Messages.send_text client ~room_id ~body:"pong!" () in 81 81 Printf.printf "Responded to ping\n%!" 82 82 with Eio.Io _ as e -> 83 83 Printf.eprintf "Failed to send pong: %s\n%!" (Printexc.to_string e)) ··· 108 108 ~homeserver:(Uri.of_string homeserver) 109 109 ~user:username ~password () 110 110 with Eio.Io (Error.E err, _) -> 111 - Printf.eprintf "Login failed: %a\n%!" Error.pp_err err; 111 + Format.eprintf "Login failed: %a@." Error.pp_err err; 112 112 exit 1 113 113 in 114 114 ··· 137 137 handle_sync client my_user_id response; 138 138 Sync.Continue) 139 139 ~on_error:(fun err -> 140 - Printf.eprintf "Sync error: %a\n%!" Error.pp_err err; 140 + Format.eprintf "Sync error: %a@." Error.pp_err err; 141 141 (* Retry after 5 seconds on error *) 142 142 Sync.Retry_after 5.0) 143 143 ();
+1 -1
project/ocaml-quickjs/dune-project
··· 16 16 (ocaml (>= 5.1)) 17 17 (dune (>= 3.20)) 18 18 (zarith (>= 1.13)) ; For BigInt support 19 - (pcre2 (>= 8.0)) ; For RegExp support with full PCRE2 features 19 + (re (>= 1.11)) ; For RegExp support (pure OCaml) 20 20 (fmt (>= 0.9)) ; For pretty printing 21 21 (sedlex (>= 3.2)) ; Unicode-aware lexer (optional, we do handwritten but may use for unicode categories) 22 22 (yojson (>= 2.1)) ; For test262 metadata parsing
+1 -1
project/ocaml-quickjs/lib/quickjs/builtins/dune
··· 1 1 (library 2 2 (name quickjs_builtins) 3 3 (public_name ocaml-quickjs.builtins) 4 - (libraries quickjs_runtime quickjs_parser quickjs_compiler zarith unix pcre2)) 4 + (libraries quickjs_runtime quickjs_parser quickjs_compiler zarith unix re))
+65 -62
project/ocaml-quickjs/lib/quickjs/builtins/regexp.ml
··· 1 1 (** JavaScript RegExp built-in object. 2 2 3 3 Implements RegExp as specified in ECMA-262. 4 - Uses OCaml's pcre2 library for regex execution with support for: 4 + Uses OCaml's re library for regex execution with support for: 5 5 - Lookahead assertions: (?=...) and (?!...) 6 - - Lookbehind assertions: (?<=...) and (?<!...) 7 6 - Named capture groups: (?<name>...) or (?P<name>...) 8 - - All standard flags: g, i, m, s, u, y *) 7 + - All standard flags: g, i, m, s, u, y 8 + 9 + Note: Lookbehind assertions are not supported by the re library. *) 9 10 10 11 open Quickjs_runtime.Value 11 12 12 13 (** Compiled regexp with metadata for JavaScript semantics *) 13 14 type js_regexp = { 14 - re : Pcre2.regexp; 15 + re : Re.re; 15 16 pattern : string; 16 17 flags : string; 17 18 num_groups : int; 18 19 named_groups : (string * int) list; 19 20 } 20 21 21 - (** Convert JS regex flags to Pcre2 icflag *) 22 - let flags_to_icflag flags = 22 + (** Convert JS regex flags to Re.Pcre flags *) 23 + let flags_to_re_flags flags = 23 24 let opts = ref [] in 24 25 if String.contains flags 'i' then 25 26 opts := `CASELESS :: !opts; ··· 27 28 opts := `MULTILINE :: !opts; 28 29 if String.contains flags 's' then 29 30 opts := `DOTALL :: !opts; 30 - Pcre2.cflags !opts 31 + !opts 31 32 32 - (** Convert JS regex pattern to PCRE2 pattern, handling JS-specific syntax *) 33 + (** Convert JS regex pattern to PCRE pattern, handling JS-specific syntax *) 33 34 let convert_js_pattern pattern = 34 35 (* JavaScript uses (?<name>...) for named groups, PCRE uses (?P<name>...) *) 35 36 let buf = Buffer.create (String.length pattern + 10) in ··· 42 43 if !i + 3 < String.length pattern && 43 44 (pattern.[!i + 3] = '=' || pattern.[!i + 3] = '!') then 44 45 begin 45 - (* It's a lookbehind, keep as is *) 46 + (* Lookbehind not supported by re library, keep as is but will fail at compile *) 46 47 Buffer.add_char buf pattern.[!i]; 47 48 incr i 48 49 end ··· 128 129 let compile_pattern pattern flags = 129 130 try 130 131 let pcre_pattern = convert_js_pattern pattern in 131 - let iflags = flags_to_icflag flags in 132 - let compiled = Pcre2.regexp ~iflags pcre_pattern in 132 + let re_flags = flags_to_re_flags flags in 133 + let compiled = Re.compile (Re.Pcre.re ~flags:re_flags pcre_pattern) in 133 134 let num_groups, named_groups = analyze_pattern pattern in 134 135 Some { 135 136 re = compiled; ··· 172 173 | _ -> 0 173 174 else 0 174 175 in 175 - (try 176 - let result = Pcre2.exec ~rex:regexp.re ~pos:last_index str in 177 - let match_start, match_end = Pcre2.get_substring_ofs result 0 in 176 + (match Re.exec_opt ~pos:last_index regexp.re str with 177 + | Some result -> 178 + let match_start, match_end = Re.Group.offset result 0 in 178 179 (* For sticky, match must start at lastIndex *) 179 180 if sticky && match_start <> last_index then begin 180 181 ignore (set_property obj "lastIndex" (Int 0l)); ··· 184 185 ignore (set_property obj "lastIndex" (Int (Int32.of_int match_end))); 185 186 Bool true 186 187 end 187 - with Not_found -> 188 + | None -> 188 189 if sticky || String.contains regexp.flags 'g' then 189 190 ignore (set_property obj "lastIndex" (Int 0l)); 190 191 Bool false) ··· 210 211 | _ -> 0 211 212 else 0 212 213 in 213 - (try 214 - let result = Pcre2.exec ~rex:regexp.re ~pos:last_index str in 215 - let match_start, match_end = Pcre2.get_substring_ofs result 0 in 214 + (match Re.exec_opt ~pos:last_index regexp.re str with 215 + | Some result -> 216 + let match_start, match_end = Re.Group.offset result 0 in 216 217 217 218 (* For sticky, match must start at lastIndex *) 218 219 if sticky && match_start <> last_index then begin ··· 225 226 226 227 (* Build result array *) 227 228 let arr_obj = make_object ~class_id:Class_array () in 228 - let num_groups = Pcre2.num_of_subs result in 229 + let num_groups = Re.Group.nb_groups result in 229 230 let groups = Array.init num_groups (fun i -> 230 - try String (Pcre2.get_substring result i) 231 - with Not_found -> Undefined 231 + match Re.Group.get_opt result i with 232 + | Some s -> String s 233 + | None -> Undefined 232 234 ) in 233 235 arr_obj.data <- Data_array { values = groups; length = num_groups }; 234 236 ignore (set_property arr_obj "length" (Int (Int32.of_int num_groups))); ··· 240 242 let groups_obj = make_object () in 241 243 List.iter (fun (name, idx) -> 242 244 if idx < num_groups then 243 - try 244 - let s = Pcre2.get_named_substring regexp.re name result in 245 - ignore (set_property groups_obj name (String s)) 246 - with Not_found -> 247 - ignore (set_property groups_obj name Undefined) 245 + match Re.Group.get_opt result idx with 246 + | Some s -> ignore (set_property groups_obj name (String s)) 247 + | None -> ignore (set_property groups_obj name Undefined) 248 248 ) regexp.named_groups; 249 249 ignore (set_property arr_obj "groups" (Object groups_obj)) 250 250 end else ··· 252 252 253 253 Object arr_obj 254 254 end 255 - with Not_found -> 255 + | None -> 256 256 if global || sticky then 257 257 ignore (set_property obj "lastIndex" (Int 0l)); 258 258 Null) ··· 327 327 let rec loop pos acc = 328 328 if pos > String.length str then List.rev acc 329 329 else 330 - try 331 - let result = Pcre2.exec ~rex:regexp.re ~pos str in 332 - let _, match_end = Pcre2.get_substring_ofs result 0 in 330 + match Re.exec_opt ~pos regexp.re str with 331 + | Some result -> 332 + let _, match_end = Re.Group.offset result 0 in 333 333 (* Advance at least one char to avoid infinite loops on zero-width matches *) 334 334 let next_pos = max (pos + 1) match_end in 335 335 loop next_pos (result :: acc) 336 - with Not_found -> List.rev acc 336 + | None -> List.rev acc 337 337 in 338 338 loop 0 [] 339 339 ··· 350 350 if matches = [] then Null 351 351 else 352 352 let arr = List.map (fun result -> 353 - String (Pcre2.get_substring result 0) 353 + String (Re.Group.get result 0) 354 354 ) matches in 355 355 make_array arr 356 356 end else ··· 367 367 let matches = find_all_matches regexp str in 368 368 let results = List.map (fun result -> 369 369 let arr_obj = make_object ~class_id:Class_array () in 370 - let num_groups = Pcre2.num_of_subs result in 370 + let num_groups = Re.Group.nb_groups result in 371 371 let groups = Array.init num_groups (fun i -> 372 - try String (Pcre2.get_substring result i) 373 - with Not_found -> Undefined 372 + match Re.Group.get_opt result i with 373 + | Some s -> String s 374 + | None -> Undefined 374 375 ) in 375 376 arr_obj.data <- Data_array { values = groups; length = num_groups }; 376 377 ignore (set_property arr_obj "length" (Int (Int32.of_int num_groups))); 377 - let match_start, _ = Pcre2.get_substring_ofs result 0 in 378 + let match_start, _ = Re.Group.offset result 0 in 378 379 ignore (set_property arr_obj "index" (Int (Int32.of_int match_start))); 379 380 ignore (set_property arr_obj "input" (String str)); 380 381 381 382 (* Add named groups *) 382 383 if regexp.named_groups <> [] then begin 383 384 let groups_obj = make_object () in 384 - List.iter (fun (name, _idx) -> 385 - try 386 - let s = Pcre2.get_named_substring regexp.re name result in 387 - ignore (set_property groups_obj name (String s)) 388 - with Not_found -> 389 - ignore (set_property groups_obj name Undefined) 385 + List.iter (fun (name, idx) -> 386 + match Re.Group.get_opt result idx with 387 + | Some s -> ignore (set_property groups_obj name (String s)) 388 + | None -> ignore (set_property groups_obj name Undefined) 390 389 ) regexp.named_groups; 391 390 ignore (set_property arr_obj "groups" (Object groups_obj)) 392 391 end else ··· 417 416 match repl.[!i] with 418 417 | '$' -> Buffer.add_char buf '$'; incr i 419 418 | '&' -> 420 - Buffer.add_string buf (Pcre2.get_substring result 0); 419 + Buffer.add_string buf (Re.Group.get result 0); 421 420 incr i 422 421 | '`' -> 423 - let start, _ = Pcre2.get_substring_ofs result 0 in 422 + let start, _ = Re.Group.offset result 0 in 424 423 Buffer.add_string buf (String.sub str 0 start); 425 424 incr i 426 425 | '\'' -> 427 - let _, stop = Pcre2.get_substring_ofs result 0 in 426 + let _, stop = Re.Group.offset result 0 in 428 427 Buffer.add_string buf (String.sub str stop (String.length str - stop)); 429 428 incr i 430 429 | '0'..'9' as c -> ··· 435 434 match repl.[!i + 1] with 436 435 | '0'..'9' as c2 -> 437 436 let idx2 = idx * 10 + (Char.code c2 - Char.code '0') in 438 - if idx2 <= Pcre2.num_of_subs result then (idx2, 2) 437 + if idx2 <= Re.Group.nb_groups result then (idx2, 2) 439 438 else (idx, 1) 440 439 | _ -> (idx, 1) 441 440 else (idx, 1) 442 441 in 443 - (try Buffer.add_string buf (Pcre2.get_substring result idx) 444 - with Not_found -> ()); 442 + (match Re.Group.get_opt result idx with 443 + | Some s -> Buffer.add_string buf s 444 + | None -> ()); 445 445 i := !i + consumed 446 446 | '<' -> 447 - (* Named group $<name> *) 447 + (* Named group $<name> - look up index from our named_groups list *) 448 448 incr i; 449 449 let name_start = !i in 450 450 while !i < String.length repl && repl.[!i] <> '>' do ··· 452 452 done; 453 453 let name = String.sub repl name_start (!i - name_start) in 454 454 if !i < String.length repl then incr i; (* Skip '>' *) 455 - (try 456 - Buffer.add_string buf (Pcre2.get_named_substring regexp.re name result) 457 - with Not_found -> ()) 455 + (match List.assoc_opt name regexp.named_groups with 456 + | Some idx -> 457 + (match Re.Group.get_opt result idx with 458 + | Some s -> Buffer.add_string buf s 459 + | None -> ()) 460 + | None -> ()) 458 461 | c -> Buffer.add_char buf '$'; Buffer.add_char buf c; incr i 459 462 end else begin 460 463 Buffer.add_char buf repl.[!i]; ··· 470 473 let last_end = ref 0 in 471 474 let matches = find_all_matches regexp str in 472 475 List.iter (fun result -> 473 - let start, stop = Pcre2.get_substring_ofs result 0 in 476 + let start, stop = Re.Group.offset result 0 in 474 477 Buffer.add_string result_buf (String.sub str !last_end (start - !last_end)); 475 478 Buffer.add_string result_buf (do_replace result); 476 479 last_end := stop ··· 479 482 String (Buffer.contents result_buf) 480 483 end else begin 481 484 (* Replace first match only *) 482 - try 483 - let result = Pcre2.exec ~rex:regexp.re str in 484 - let start, stop = Pcre2.get_substring_ofs result 0 in 485 + match Re.exec_opt regexp.re str with 486 + | Some result -> 487 + let start, stop = Re.Group.offset result 0 in 485 488 let result_str = String.sub str 0 start ^ 486 489 do_replace result ^ 487 490 String.sub str stop (String.length str - stop) in 488 491 String result_str 489 - with Not_found -> String str 492 + | None -> String str 490 493 end 491 494 | None -> String str) 492 495 | _ -> String str ··· 497 500 | Object obj -> 498 501 (match get_compiled_regexp obj with 499 502 | Some regexp -> 500 - (try 501 - let result = Pcre2.exec ~rex:regexp.re str in 502 - let pos, _ = Pcre2.get_substring_ofs result 0 in 503 + (match Re.exec_opt regexp.re str with 504 + | Some result -> 505 + let pos, _ = Re.Group.offset result 0 in 503 506 Int (Int32.of_int pos) 504 - with Not_found -> Int (-1l)) 507 + | None -> Int (-1l)) 505 508 | None -> Int (-1l)) 506 509 | _ -> Int (-1l) 507 510 ··· 511 514 | Object obj -> 512 515 (match get_compiled_regexp obj with 513 516 | Some regexp -> 514 - let parts = Pcre2.split ~rex:regexp.re str in 517 + let parts = Re.split regexp.re str in 515 518 let parts = match limit with 516 519 | Some n when n >= 0 -> 517 520 let rec take n lst = match n, lst with
+1 -1
project/ocaml-quickjs/ocaml-quickjs.opam
··· 11 11 "ocaml" {>= "5.1"} 12 12 "dune" {>= "3.20" & >= "3.20"} 13 13 "zarith" {>= "1.13"} 14 - "pcre2" {>= "8.0"} 14 + "re" {>= "1.11"} 15 15 "fmt" {>= "0.9"} 16 16 "sedlex" {>= "3.2"} 17 17 "yojson" {>= "2.1"}
+5 -5
project/parquet/src/codec/parquet_codec.ml
··· 205 205 (** Default Zstd compression level (1-22, default 3). *) 206 206 let default_level = 3 207 207 208 - let decompress data ~uncompressed_size = 209 - try Ok (Zstd.decompress uncompressed_size data) 210 - with Zstd.Error msg -> Error (Printf.sprintf "Zstd decompression failed: %s" msg) 208 + let decompress data ~uncompressed_size:_ = 209 + match Zstd.decompress data with 210 + | Ok s -> Ok s 211 + | Error msg -> Error (Printf.sprintf "Zstd decompression failed: %s" msg) 211 212 212 213 let compress data ~level = 213 214 let level = match level with Some l -> l | None -> default_level in 214 - try Ok (Zstd.compress ~level data) 215 - with Zstd.Error msg -> Error (Printf.sprintf "Zstd compression failed: %s" msg) 215 + Ok (Zstd.compress ~level data) 216 216 end 217 217 218 218 (** {2 Brotli (BROTLI = 4)} *)
+2 -2
project/parquet/src/column/parquet_dremel.ml
··· 21 21 values : Parquet_value.t array; 22 22 definition_levels : int array; 23 23 repetition_levels : int array; 24 - max_def_level : int; 25 - max_rep_level : int; 24 + max_def_level : int; [@warning "-69"] 25 + max_rep_level : int; [@warning "-69"] 26 26 mutable value_idx : int; (* Current position in values array *) 27 27 mutable level_idx : int; (* Current position in levels arrays *) 28 28 }
+2 -2
project/parquet/src/writer/parquet_writer.ml
··· 313 313 mutable num_values : int64; 314 314 mutable total_uncompressed_size : int64; 315 315 mutable total_compressed_size : int64; 316 - mutable data_offset : int64; 316 + mutable data_offset : int64; [@warning "-69"] 317 317 mutable dictionary_page : (string * string) option; (* header, data for dict page *) 318 - mutable dictionary_page_offset : int64 option; 318 + mutable dictionary_page_offset : int64 option; [@warning "-69"] 319 319 mutable uses_dictionary : bool; 320 320 mutable statistics : statistics option; (* Column statistics for predicate pushdown *) 321 321 }