You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2022/08/15 16:44:01 UTC
[GitHub] [couchdb-config] nickva commented on a diff in pull request #40: Remove leading/trailing whitespaces in config values
nickva commented on code in PR #40:
URL: https://github.com/apache/couchdb-config/pull/40#discussion_r945937157
##########
src/config_util.erl:
##########
@@ -72,3 +73,16 @@ fix_path_list(["."|Rest], Acc) ->
fix_path_list(Rest, Acc);
fix_path_list([Dir | Rest], Acc) ->
fix_path_list(Rest, [Dir | Acc]).
+
+% Remove leading and trailing ws from string
+% Implementation used from mochiweb_headers for speed
+% discussion https://github.com/mochi/mochiweb/pull/247
+trim_leading_and_trailing_ws(S) ->
+ trim_and_reverse(trim_and_reverse(S, false), false).
+
+trim_and_reverse([S | Rest], Reversed) when S=:=$ ; S=:=$\n; S=:=$\t ->
+ trim_and_reverse(Rest, Reversed);
+trim_and_reverse(V, false) ->
+ trim_and_reverse(lists:reverse(V), true);
+trim_and_reverse(V, true) ->
+ V.
Review Comment:
Since we're supporting Erlang 20+ could we use string:trim/1?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org