fix misuse of snprintf, fix tags, use strtok_r

this was previously relying on undefined behavior- snprintf cannot read
and write to the same place. i'm not saying this patch makes this the
best c, i'm just saying it works as intended now.

additionally use reentrant strtok_r.
Merge pull request #3 from vine/master

fix misuse of snprintf, fix tags, use strtok_r