Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 761:c14c7b5b5fea
farray.sh: Make parsing of storage pointers stricter; disallow "octal" numbers.
While there: add unittests for storage pointers.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 20 Oct 2024 18:38:12 +0200 |
| parents | ab6298596d73 |
| children | b72c111e1b76 |
| files | share/local-bsdtools/farray.sh tests/farray-misc.t |
| diffstat | 2 files changed, 51 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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;;
--- 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
