# HG changeset patch # User Franz Glasner # Date 1729442292 -7200 # Node ID c14c7b5b5fea0303a1d60b4b8a8b92ed3bfaf7be # Parent ab6298596d7386d6715945ba5a6b049e0ca7dd08 farray.sh: Make parsing of storage pointers stricter; disallow "octal" numbers. While there: add unittests for storage pointers. diff -r ab6298596d73 -r c14c7b5b5fea share/local-bsdtools/farray.sh --- a/share/local-bsdtools/farray.sh Sun Oct 20 16:33:20 2024 +0200 +++ b/share/local-bsdtools/farray.sh Sun Oct 20 18:38:12 2024 +0200 @@ -206,6 +206,12 @@ '') # empty is not allowed return 1;; + 0) + # a single 0 is allowed + return 0;; + 0*) + # other "octal" numbers of having a leading zero are not allowed + return 1;; *[!0123456789]*) # non-decimal return 1;; diff -r ab6298596d73 -r c14c7b5b5fea tests/farray-misc.t --- a/tests/farray-misc.t Sun Oct 20 16:33:20 2024 +0200 +++ b/tests/farray-misc.t Sun Oct 20 18:38:12 2024 +0200 @@ -43,6 +43,8 @@ [1] $ _farr_is_decimal_number '0x1' [1] + $ _farr_is_decimal_number '/' + [1] $ _farr_is_decimal_number *12345678901234567890 [1] $ _farr_is_decimal_number 0x0123456789abcdef @@ -103,3 +105,46 @@ $ ( _farr_make_index _res 0 0x1 ) ERROR: given length is not a valid decimal number [70] + + +Storage Pointer Checks +====================== + +No empty (null) values + + $ _farr_is_valid_storage_ptr '' + [1] + +The NULL pointer (aka s single 0 character) is allowed + + $ _farr_is_valid_storage_ptr 0 + +Non-decimal charactesr are not allowed + + $ _farr_is_valid_storage_ptr f12345 + [1] + + $ _farr_is_valid_storage_ptr a + [1] + + $ _farr_is_valid_storage_ptr '/' + [1] + +"Octal" numbers are not allowed + + $ _farr_is_valid_storage_ptr 01 + [1] + +Some valid numbers + + $ _farr_is_valid_storage_ptr 1 + $ _farr_is_valid_storage_ptr 2 + $ _farr_is_valid_storage_ptr 3 + $ _farr_is_valid_storage_ptr 4 + $ _farr_is_valid_storage_ptr 5 + $ _farr_is_valid_storage_ptr 6 + $ _farr_is_valid_storage_ptr 7 + $ _farr_is_valid_storage_ptr 8 + $ _farr_is_valid_storage_ptr 9 + + $ _farr_is_valid_storage_ptr 12345678901234567890