Skip to content

Commit 7df6d10

Browse files
committed
Trim trailing whitespace parsing cabal.project
Fixes #2252
1 parent 93f0d48 commit 7df6d10

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/cabal-project-parser.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ let
4646
let
4747
# Look for a new attribute name
4848
pair = builtins.match "([^ :]*): *(.*)" s;
49+
trim = x: let m = builtins.match "(.*[^ \t])[ \t]*" x;
50+
in pkgs.lib.optionalString (m != null) (builtins.head m);
4951

5052
# Function to build the next parse state when the attribute name is known
5153
nextState = name: value: {
@@ -62,7 +64,7 @@ let
6264
if pair != null
6365
then
6466
# First line of a new attribute
65-
nextState (builtins.head pair) (builtins.elemAt pair 1)
67+
nextState (builtins.head pair) (trim (builtins.elemAt pair 1))
6668
else
6769
if name != null
6870
then nextState name s # Append another line to the current attribute

0 commit comments

Comments
 (0)