diff options
author | Ludovic Courtès <ludo@gnu.org> | 2018-05-18 22:20:33 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2018-05-19 00:14:52 +0200 |
commit | 263c9941a1e523b360ca9f42d1ed6b11e6e6e285 (patch) | |
tree | 8fcb7e85667a28fcd33d68cea06173ccb134261e /gnu | |
parent | a48d34504181e2f14cef3a5514d2319e60453a79 (diff) | |
download | guix-263c9941a1e523b360ca9f42d1ed6b11e6e6e285.tar guix-263c9941a1e523b360ca9f42d1ed6b11e6e6e285.tar.gz |
uuid: 'uuid' returns #f when 'string->uuid' returns #f.
* gnu/system/uuid.scm (uuid): When STR is not a literal, return #f when
'string->uuid' returns #f.
* tests/uuid.scm ("uuid, dynamic value"): New test.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/system/uuid.scm | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gnu/system/uuid.scm b/gnu/system/uuid.scm index 73695ddeb8..f13960c3e9 100644 --- a/gnu/system/uuid.scm +++ b/gnu/system/uuid.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2017 Danny Milosavljevic <dannym@scratchpost.org> ;;; ;;; This file is part of GNU Guix. @@ -251,7 +251,8 @@ corresponding bytevector; otherwise return #f." (define-syntax uuid (lambda (s) - "Return the UUID object corresponding to the given UUID representation." + "Return the UUID object corresponding to the given UUID representation or +#f if the string could not be parsed." (syntax-case s (quote) ((_ str (quote type)) (and (string? (syntax->datum #'str)) @@ -266,9 +267,11 @@ corresponding bytevector; otherwise return #f." (string? (syntax->datum #'str)) #'(uuid str 'dce)) ((_ str) - #'(make-uuid 'dce (string->uuid str 'dce))) + #'(let ((bv (string->uuid str 'dce))) + (and bv (make-uuid 'dce bv)))) ((_ str type) - #'(make-uuid type (string->uuid str type)))))) + #'(let ((bv (string->uuid str type))) + (and bv (make-uuid type bv))))))) (define uuid->string ;; Convert the given bytevector or UUID object, to the corresponding UUID |