diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2023-03-16 13:18:41 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2023-03-16 19:05:09 -0700 |
commit | 4143535ae5eb9385a86240e152be873cc4348e03 (patch) | |
tree | 13cf54b103ef4d8a4540dc87aad7998797cb41e0 /src/property/disk.lisp | |
parent | a2f0f9376e110d6c930b0cd3cf533c7fd3b7b917 (diff) | |
download | consfigurator-4143535ae5eb9385a86240e152be873cc4348e03.tar.gz |
add regexp trailing option to attempt to parse matches as numbers
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/disk.lisp')
-rw-r--r-- | src/property/disk.lisp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/property/disk.lisp b/src/property/disk.lisp index 53203aa..08d1dcf 100644 --- a/src/property/disk.lisp +++ b/src/property/disk.lisp @@ -1207,16 +1207,14 @@ Currently only handling of LVM logical volumes is implemented." (defun parse-volume-size (volume-size-specification) (if (stringp volume-size-specification) - (multiple-value-bind (match groups) - (re:scan-to-strings #?/\A([0-9]+)([MGT])?\z/ volume-size-specification) - (unless match - (simple-program-error - "~A is not a valid volume size." volume-size-specification)) - (* (parse-integer (elt groups 0)) - (eswitch ((elt groups 1) :test #'string=) - ("M" 1) - ("G" 1024) - ("T" 1048576)))) + (aif (#~/\A(\d+)([MGT])?\z/p volume-size-specification) + (* (elt it 0) + (eswitch ((elt it 1) :test #'string=) + ("M" 1) + ("G" 1024) + ("T" 1048576))) + (simple-program-error "~A is not a valid volume size." + volume-size-specification)) volume-size-specification)) (defmacro volumes (&body volume-specifications) |