3

I would like to implement a macro for calculating hashes of C-strings, and first thing, which I need, is getting codes of characters in string.

My idea is use the builtin macro index with string, which includes all of 256 ascii characters, and the target character as the second argument. The my first problem is how to safely encode this ascii string.

I'm totally newbie in GNU M4, maybe there is more simple way to do this.

Kayo
  • 179
  • 8
  • The second idea is use iteration over 0..255 and comparing target character with result of `format(%c, index)`, but I assume that is too slow way. – Kayo Dec 13 '15 at 17:14
  • 2
    What about using `esyscmd` to execute a command like `md5sum` which computes a hash code? Of course, it won't be quite so simple, but it's got to be simpler than computing the hash code in m4. Otherwise, see http://stackoverflow.com/questions/12907684/using-m4-to-convert-a-string-to-ascii-codepoints – rici Dec 15 '15 at 04:41

0 Answers0