Skip to content

Commit

Permalink
Shorten manifest parsing code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
phst committed Oct 8, 2024
1 parent 7d138ff commit a944e73
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions elisp/runfiles/runfiles.el
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,12 @@ Return an object of type ‘elisp/runfiles/runfiles--manifest’."
;; Perform the same parsing as
;; https://github.com/bazelbuild/bazel/blob/6.4.0/tools/cpp/runfiles/runfiles_src.cc#L241.
(while (not (eobp))
(pcase (buffer-substring-no-properties
(line-beginning-position) (line-end-position))
((rx bol (let key (+ (not (any ?\n ?\s))))
?\s (let value (+ nonl)) eol)
(pcase (buffer-substring-no-properties (point) (line-end-position))
((rx bos (let key (+ (not (any ?\n ?\s))))
?\s (let value (* nonl)) eos)
;; Runfiles are always local, so quote them unconditionally.
(puthash key (concat "/:" value) manifest))
((rx bol (let key (+ (not (any ?\n ?\s)))) ?\s eol)
(puthash key :empty manifest))
(puthash key (if (string-empty-p value) :empty (concat "/:" value))
manifest))
(other (signal 'elisp/runfiles/syntax-error (list filename other))))
(forward-line)))
(elisp/runfiles/manifest--make filename manifest)))
Expand Down

0 comments on commit a944e73

Please sign in to comment.