Nikos Mavrogiannopoulos wrote: > On 01/30/2012 10:29 PM, Jim Meyering wrote: > >> Hi Nikos, >> Have you considered pre-filtering the data you pass to the base64-decoding >> function? We considered what you're proposing when adding the >> --ignore-garbage option to the command-line base64 program: > > Could also be done, but since the code to remove newlines was there, I > thought it is simpler to augment it to remove common garbage.
I am reluctant to make this low-level decoding function ignore anything else. Even for newlines, I hesitated, because an inserted newline might represent corruption for some application, but the newline-filtering code is mostly optional. However, with your proposed change, an application that previously allowed newlines, would now have to allow insertion of arbitrarily many " \t\r" bytes as well. Then there's the slightly higher cost of filtering out those three new bytes in an inner loop. If there's a noticeable performance hit, it would not be welcome in an application that already knows or guarantees those added bytes are not present. This part would affect all users, not just those that enable newline-filtering. I think it's better if you preprocess the input. An added benefit: if your set of ignorable bytes changes, you can change it without worrying about gnulib's constraints.