Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:20
pie
0002-pie-replace-regexp-with-re.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0002-pie-replace-regexp-with-re.patch of Package pie
From ceea07620aa4124fa3c52afb5b9720c3a414579d Mon Sep 17 00:00:00 2001 From: Led <ledest@gmail.com> Date: Tue, 3 Mar 2015 13:15:17 +0200 Subject: [PATCH 2/2] pie: replace regexp with re --- apps/pie/src/cord_regexp.erl | 2 +- apps/pie/src/edit_file.erl | 4 ++-- apps/pie/src/edit_help.erl | 20 ++++++++++---------- apps/pie/src/edit_history.erl | 10 ++++------ 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/apps/pie/src/cord_regexp.erl b/apps/pie/src/cord_regexp.erl index 75c215b..a3f0689 100644 --- a/apps/pie/src/cord_regexp.erl +++ b/apps/pie/src/cord_regexp.erl @@ -258,7 +258,7 @@ same(Inp, REStr) -> forwards(Inp, REStr) == backwards(Inp, REStr). forwards(Inp, RE) -> - regexp:run(Inp, RE). + re:run(Inp, RE). backwards(Inp, REStr) -> {ok, RE} = re:compile(REStr), diff --git a/apps/pie/src/edit_file.erl b/apps/pie/src/edit_file.erl index 676132e..0342897 100644 --- a/apps/pie/src/edit_file.erl +++ b/apps/pie/src/edit_file.erl @@ -90,10 +90,10 @@ auto_set_mode(State) -> auto_set_mode(State, Filename, []) -> State; auto_set_mode(State, Filename, [{RE, {Mod, Fun}}|T]) -> - case regexp:run(Filename, RE) of + case re:run(Filename, RE) of nomatch -> auto_set_mode(State, Filename, T); - {match, _, _} -> + {match, _} -> Mod:Fun(State) end. diff --git a/apps/pie/src/edit_help.erl b/apps/pie/src/edit_help.erl index 23ba526..8c372bb 100644 --- a/apps/pie/src/edit_help.erl +++ b/apps/pie/src/edit_help.erl @@ -51,21 +51,21 @@ find_source(S0, Mod, Fun) -> end. guess_source_file(S0) -> - case regexp:sub(S0, "ebin", "src") of - {ok, S1, _} -> - case regexp:sub(S1, "beam", "erl") of - {ok, S2, _} -> + case re:replace(S0, "ebin", "src", [{return, list}]) of + S0 -> + error; + S1 -> + case re:replace(S1, "beam", "erl", [{return, list}]) of + S1 -> + error; + S2 -> case file:read_file_info(S2) of {ok, _} -> {ok, S2}; _ -> error - end; - _ -> - error - end; - _ -> - error + end + end end. %% ---------------------------------------------------------------------- diff --git a/apps/pie/src/edit_history.erl b/apps/pie/src/edit_history.erl index 098cd59..dd19bf9 100644 --- a/apps/pie/src/edit_history.erl +++ b/apps/pie/src/edit_history.erl @@ -81,7 +81,7 @@ search(State, BaseVar, RegionFn, Regexp) -> edit_buf:insert(Buf, Cmd, edit_buf:mark_pos(Buf, point)), State; {error, Err} -> - edit_util:status_msg(State, "Error: " ++ regexp:format_error(Err)); + edit_util:status_msg(State, "Error: " ++ io_lib:format("~p~n", [Err])); nomatch -> edit_util:status_msg(State, "Not found") end. @@ -112,13 +112,11 @@ trim_history(Hist) -> find_match([], Regexp) -> nomatch; find_match([H|T], Regexp) -> - case regexp:match(H, Regexp) of + case re:run(H, Regexp) of nomatch -> find_match(T, Regexp); - {match, _Start, _Length} -> - {match, H}; - {error, Err} -> - {error, Err} + {match, _} -> + {match, H} end. list_var(Base) -> Base. -- 2.1.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor