Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
olifer
0001-remove-parselib-bstring-dependency.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-remove-parselib-bstring-dependency.patch of Package olifer
From 529d04d92b940c76a6019a2fb6381ad10abda048 Mon Sep 17 00:00:00 2001 From: Led <ledest@gmail.com> Date: Sun, 19 Nov 2017 22:54:44 +0200 Subject: [PATCH 1/8] remove parselib/bstring dependency --- Makefile | 3 +-- src/rules/olifer_modifiers.erl | 33 +++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 0b78300..c775280 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,9 @@ PROJECT = olifer -DEPS = jsx parselib +DEPS = jsx TEST_DEPS = LIVR dep_jsx = git https://github.com/talentdeficit/jsx.git v2.6.2 -dep_parselib = git https://github.com/erlangbureau/parselib.git v2.1.0 dep_LIVR = git https://github.com/koorchik/LIVR master TEST_DIR = test diff --git a/src/rules/olifer_modifiers.erl b/src/rules/olifer_modifiers.erl index e60f09b..7894916 100644 --- a/src/rules/olifer_modifiers.erl +++ b/src/rules/olifer_modifiers.erl @@ -15,17 +15,24 @@ %% API trim(Value, [], _) when is_binary(Value) -> - {filter, bstring:trim(Value)}; + L = left_space_skip(Value, 0), + {filter, binary:part(Value, L, right_space_skip(Value, 0) - L)}; trim(Value, [], _) -> {filter, Value}. to_lc(Value, [], _) when is_binary(Value) -> - {filter, bstring:to_lower(Value)}; + {filter, <<<<if + B >= $A, B =< $Z -> B + ($a - $A); + true -> B + end>> || <<B>> <= Value>>}; to_lc(Value, [], _) -> {filter, Value}. to_uc(Value, [], _) when is_binary(Value) -> - {filter, bstring:to_upper(Value)}; + {filter, <<<<if + B >= $a, B =< $z -> B - ($a - $A); + true -> B + end>> || <<B>> <= Value>>}; to_uc(Value, [], _) -> {filter, Value}. @@ -57,9 +64,8 @@ default(Value, _Default, _AllData) -> %% INTERNAL remove_impl(Value, <<>>) -> {filter, Value}; -remove_impl(Value, <<First:1/binary, Rest/binary>>) -> - NewValueList = bstring:split_global(Value, First), - remove_impl(binary:list_to_bin(NewValueList), Rest). +remove_impl(Value, <<First, Rest/binary>>) -> + remove_impl(<<<<B>> || <<B>> <= Value, B =/= First>>, Rest). leave_only_impl(<<>>, _, Acc) -> {filter, Acc}; @@ -68,3 +74,18 @@ leave_only_impl(<<First:1/binary, Rest/binary>>, Pattern, Acc) -> nomatch -> leave_only_impl(Rest, Pattern, Acc); _ -> leave_only_impl(Rest, Pattern, <<Acc/binary, First/binary>>) end. + +left_space_skip(Value, I) -> + case byte_size(Value) =/= I andalso binary:at(Value, I) of + C when C =:= $\t; C =:= $\n; C =:= $\r; C =:= $\s -> left_space_skip(Value, I + 1); + _ -> I + end. + +right_space_skip(Value, I) -> + case byte_size(Value) of + I -> I; + S -> case binary:at(Value, S - I - 1) of + C when C =:= $\t; C =:= $\n; C =:= $\r; C =:= $\s -> right_space_skip(Value, I + 1); + _ -> S - I + end + end. -- 2.15.0
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