From 4143535ae5eb9385a86240e152be873cc4348e03 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 16 Mar 2023 13:18:41 -0700 Subject: add regexp trailing option to attempt to parse matches as numbers Signed-off-by: Sean Whitton --- src/property/disk.lisp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/property/disk.lisp') 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) -- cgit v1.2.3