X-Git-Url: https://git.m6w6.name/?p=m6w6%2Flibmemcached;a=blobdiff_plain;f=CMakeVersions.txt;h=965c1106dce5204d9f72630eaeb762dcba829e41;hp=dd2e7ed6404eea934f0cdf8a4a027847caa9eb4a;hb=4ca28fb6eb31ca8efb8f41ff764e9ef9177297f6;hpb=802aeb5f48ba7ca9e2ea22c73dfd57ace949f09c 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()