Skip to content

Commit

Permalink
Merge pull request #94 from djs55/stringext
Browse files Browse the repository at this point in the history
Remove the rest of stringext
  • Loading branch information
djs55 authored Jul 18, 2016
2 parents fd0a82b + cccc227 commit 37a7357
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v0.7.3 (2016-07-18)

* remove the remaining uses of stringext (in the CLI example)

## v0.7.2 (2016-07-15)

* fix more dependency issues in the META file

## v0.7.1 (2016-07-15)

* switch to topkg
Expand Down
2 changes: 1 addition & 1 deletion src/_tags
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<*.*>: package(stringext), package(result), package(fmt), package(lambda-term)
<*.*>: package(astring), package(result), package(fmt), package(lambda-term)
<*.*>: package(cstruct), package(cstruct.lwt)
<*.*>: package(lwt)
<*.*>: package(cmdliner, logs.fmt)
Expand Down
19 changes: 10 additions & 9 deletions src/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
open Protocol_9p
open Infix
open Lwt
open Astring

let project_url = "http://github.com/mirage/ocaml-9p"
let version = "%%VERSION%%"
Expand All @@ -39,11 +40,11 @@ let finally f g =
Lwt.fail e)

let parse_address address =
match Stringext.split ~on:':' ~max:2 address with
| [ proto; address ] -> proto, address
| _ -> address, "5640"
match String.cut ~sep:":" address with
| Some (proto, address) -> proto, address
| None -> address, "5640"

let parse_path x = Stringext.split x ~on:'/'
let parse_path x = String.cuts x ~sep:"/"

let with_client address username f =
let proto, address = parse_address address in
Expand Down Expand Up @@ -160,7 +161,7 @@ let print_stats stats =
let rows = Array.of_list (List.map row_of_stat stats) in
let padto n x =
let extra = max 0 (n - (String.length x)) in
x ^ (String.make extra ' ') in
x ^ (String.v extra (fun _ -> ' ')) in
Array.iter (fun row ->
Array.iteri (fun i txt ->
let column = Array.map (fun row -> row.(i)) rows in
Expand Down Expand Up @@ -200,7 +201,7 @@ class read_line ~term ~history ~state = object(self)
initializer
let open React in
let open LTerm_text in
self#set_prompt (S.const (eval [ S (Printf.sprintf "9P %s> " (String.concat "/" !cwd)) ]))
self#set_prompt (S.const (eval [ S (Printf.sprintf "9P %s> " (String.concat ~sep:"/" !cwd)) ]))
end

let shell debug address username =
Expand All @@ -209,7 +210,7 @@ let shell debug address username =
with_client address username
(fun t ->
let execute_command x =
match Stringext.split ~on:' ' x with
match String.cuts ~sep:" " x with
| [ "ls" ] ->
begin
Client.readdir t !cwd >>= function
Expand All @@ -221,7 +222,7 @@ let shell debug address username =
return ()
end
| [ "cd"; dir ] ->
let dir' = Stringext.split ~on:'/' dir in
let dir' = String.cuts ~sep:"/" dir in
let newdir =
if dir <> "" && dir.[0] = '/' then dir'
else if dir = "." then !cwd
Expand Down Expand Up @@ -273,7 +274,7 @@ let shell debug address username =
>>= fun () ->
return ()
| "write" :: file :: rest ->
let data = String.concat " " rest in
let data = String.concat ~sep:" " rest in
let buf = Cstruct.create (String.length data) in
Cstruct.blit_from_string data 0 buf 0 (Cstruct.len buf);
begin
Expand Down

0 comments on commit 37a7357

Please sign in to comment.