From 0896db1904ff75c73a279721cdb1f2759e19ab3b Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Wed, 8 Oct 2014 20:24:53 +0200 Subject: Add implementation of droplast/1. lists:droplast/1 is new as of R17. --- src/index.erl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/index.erl b/src/index.erl index 5fd468b..9b0be81 100644 --- a/src/index.erl +++ b/src/index.erl @@ -56,10 +56,15 @@ truncate(Basepath, Index) -> addlast(Basepath, Entry) -> add(Basepath, last, Entry). +%% From lib/stdlib/src/lists.erl. For supporting < R17. +-spec droplast(nonempty_list()) -> list(). +droplast([_T]) -> []; +droplast([H|T]) -> [H|droplast(T)]. + decodedata(EntryText) when length(EntryText) == ?ENTRYSIZEINFILE -> case [lists:last(EntryText)] of "\n" -> - hex:hexstr_to_bin(lists:droplast(EntryText)); + hex:hexstr_to_bin(droplast(EntryText)); _ -> util:exit_with_error(badformat, readindex, "Index line not ending with linefeed") -- cgit v1.1