[rb-general] BUILD_PATH_PREFIX_MAP code examples and test cases
infinity0 at debian.org
Mon Jan 30 17:24:00 CET 2017
Code and test cases are now available here:
I made some minor changes on top of the proposal from last time; the mapping is now:
% -> %p
= -> %e
: -> %c
in other words, the first letter of the name of the symbol in English. (Yes it's English-centric, but so are programming languages in general.)
I'll next write up the English descriptions of the code, including what to do under various error conditions, why this was chosen, what circumstances you'd want to use this in, etc etc.
In the meantime people can feel free to review my C (I checked it through ASAN already) and/or submit PRs for other languages.
I made the change because one of the aims is to make decode() easy to implement both in C as well as higher-level languages. The previous mapping had one major issue:
% -> %%
= -> %+
: -> %;
This means that "the easy way" of doing it in C (single-pass left-to-right parsing) gives different results from "the easy way" of doing it in higher-level languages, for the string sequence "%%+". This is not a possible output of a good encoder; however I don't want to take chances and even "invalid" encodings should still be decoded in the same way by all implementations.
single-pass l2r : %%+ decodes to %+
.replace(%+, =).replace(%%, %): %%+ decodes to %=
.replace(%%, %).replace(%+, =): %%+ decodes to =
I couldn't think of a suitable symbol to map % to, so I then picked letters instead.
More information about the rb-general