diff options
author | Linus Nordberg <linus@nordberg.se> | 2014-10-08 20:24:53 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordberg.se> | 2014-10-08 20:24:53 +0200 |
commit | 0896db1904ff75c73a279721cdb1f2759e19ab3b (patch) | |
tree | 683aba0f861c6f46cd1903182864c195c2af150f /src/index.erl | |
parent | 9d2ef27d1427ef1c61c497c272a74506d651771a (diff) |
Add implementation of droplast/1.
lists:droplast/1 is new as of R17.
Diffstat (limited to 'src/index.erl')
-rw-r--r-- | src/index.erl | 7 |
1 files changed, 6 insertions, 1 deletions
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") |