modp_b64_gen.c generates two identical char arrays
The following two lines generate two identical char arrays. https://github.com/client9/stringencoders/blob/e1448a9415f4ebf6f559c86718193ba067cbb99d/src/modp_b64_gen.c#L87 https://github.com/client9/stringencoders/blob/e1448a9415f4ebf6f559c86718193ba067cbb99d/src/modp_b64_gen.c#L92
One called e1 and the other e2.
I can't figure out what's the use two identical array literals.
They appear to be used only in the function modp_b64_encode which could work well with only one of them.
Is this deliberate? For what purpose?
char_array_to_c prints the passed in character array as a C program snippet.
If you build the library and open src/modp_b64_data.h you can see what the outputted C program snippets look like:
static const uint8_t e0[256] = {
'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C',
'C', 'C', 'D', 'D', 'D', 'D', 'E', 'E', 'E', 'E',
'F', 'F', 'F', 'F', 'G', 'G', 'G', 'G', 'H', 'H',
'H', 'H', 'I', 'I', 'I', 'I', 'J', 'J', 'J', 'J',
'K', 'K', 'K', 'K', 'L', 'L', 'L', 'L', 'M', 'M',
'M', 'M', 'N', 'N', 'N', 'N', 'O', 'O', 'O', 'O',
'P', 'P', 'P', 'P', 'Q', 'Q', 'Q', 'Q', 'R', 'R',
'R', 'R', 'S', 'S', 'S', 'S', 'T', 'T', 'T', 'T',
'U', 'U', 'U', 'U', 'V', 'V', 'V', 'V', 'W', 'W',
'W', 'W', 'X', 'X', 'X', 'X', 'Y', 'Y', 'Y', 'Y',
'Z', 'Z', 'Z', 'Z', 'a', 'a', 'a', 'a', 'b', 'b',
'b', 'b', 'c', 'c', 'c', 'c', 'd', 'd', 'd', 'd',
'e', 'e', 'e', 'e', 'f', 'f', 'f', 'f', 'g', 'g',
'g', 'g', 'h', 'h', 'h', 'h', 'i', 'i', 'i', 'i',
'j', 'j', 'j', 'j', 'k', 'k', 'k', 'k', 'l', 'l',
'l', 'l', 'm', 'm', 'm', 'm', 'n', 'n', 'n', 'n',
'o', 'o', 'o', 'o', 'p', 'p', 'p', 'p', 'q', 'q',
'q', 'q', 'r', 'r', 'r', 'r', 's', 's', 's', 's',
't', 't', 't', 't', 'u', 'u', 'u', 'u', 'v', 'v',
'v', 'v', 'w', 'w', 'w', 'w', 'x', 'x', 'x', 'x',
'y', 'y', 'y', 'y', 'z', 'z', 'z', 'z', '0', '0',
'0', '0', '1', '1', '1', '1', '2', '2', '2', '2',
'3', '3', '3', '3', '4', '4', '4', '4', '5', '5',
'5', '5', '6', '6', '6', '6', '7', '7', '7', '7',
'8', '8', '8', '8', '9', '9', '9', '9', '+', '+',
'+', '+', '/', '/', '/', '/'
};
...
The outputted arrays are then used in modp_b64.c to do interesting things. It is working as intended.
@baylesj, your comment is not related to my question.
The question is why are there two identical array literals being generated. One named e1 and the other named e2.