diff options
-rw-r--r-- | src/property/file.lisp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/property/file.lisp b/src/property/file.lisp index 2a3921f..2f88160 100644 --- a/src/property/file.lisp +++ b/src/property/file.lisp @@ -528,10 +528,19 @@ NO-SOURCE or \"PLACEHOLDER\", use the existing field value." ;; beginning with '/' so that all filesystems are available ;; before trying to mount to virtual targets like "swap". ;; (STRING< already sorts like this but be explicit about it.) + ;; + ;; Treat comments and blank lines as equal to any other line + ;; and use STABLE-SORT to try to keep comments close to lines + ;; they describe. (return - (sort (nconc accum (hash-table-values pending)) - (lambda (a b) - (or (and (char= #\/ (first-char a)) - (not (char= #\/ (first-char b)))) - (string< a b))) - :key (compose (curry #'nth target) #'words)))))))) + (stable-sort + (nconc accum (hash-table-values pending)) + (lambda (a b) + (and (plusp (length a)) (plusp (length b)) + (not (char= #\# (first-char a))) + (not (char= #\# (first-char b))) + (let ((a* (nth target (words a))) + (b* (nth target (words b)))) + (or (and (char= #\/ (first-char a*)) + (not (char= #\/ (first-char b*)))) + (string< a* b*)))))))))))) |