From: Michael Wallner Date: Mon, 21 Dec 2020 12:02:22 +0000 (+0100) Subject: fix #96: LIB*_VERSION_HEX format X-Git-Tag: 1.1.0-beta1~14 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=4ca28fb6eb31ca8efb8f41ff764e9ef9177297f6;p=awesomized%2Flibmemcached fix #96: LIB*_VERSION_HEX format --- diff --git a/CMakeVersions.txt b/CMakeVersions.txt index dd2e7ed6..965c1106 100644 --- a/CMakeVersions.txt +++ b/CMakeVersions.txt @@ -1,15 +1,18 @@ function(to_hex HEX) + # mind you, not really hexadecimal, but just a decimal in hex notation, huh?! set(XNUMBER 0x) - set(XDIGITS 0 1 2 3 4 5 6 7 8 9 a b c d e f) foreach(DEC IN LISTS ARGN) - if(${DEC} GREATER 255) - message(WARNING "to_hex(HEX ${DEC}): decimal number out of uint8 range (>=256)") + while(1) + string(LENGTH "${DEC}" LEN) + if(LEN GREATER_EQUAL 3) + break() + endif() + string(CONCAT DEC "0" "${DEC}") + endwhile() + if(DEC GREATER 999) + message(WARNING "to_hex(HEX ${DEC}): decimal wider than 3 digits") endif() - math(EXPR HIDEC "${DEC} / 16") - math(EXPR LODEC "${DEC} % 16") - list(GET XDIGITS ${HIDEC} HIHEX) - list(GET XDIGITS ${LODEC} LOHEX) - string(APPEND XNUMBER ${HIHEX}${LOHEX}) + string(APPEND XNUMBER ${DEC}) endforeach() set(${HEX} ${XNUMBER} PARENT_SCOPE) endfunction()