-/* Semantically identical to ADVANCE_INPUT above, only no >255
- checking is needed for decoding -- checking is covered by IS_BASE64
- below. */
-#define ADVANCE_INPUT(c, stream) \
- (ec = Lstream_get_emchar (stream), \
- ec == -1 ? 0 : (c = (Bufbyte)ec, 1))
-
-/* Get next character from the stream, but ignore it if it's
- whitespace. ENDP is set to 1 if EOF is hit. */
-#define ADVANCE_INPUT_IGNORE_WHITESPACE(c, endp, stream) do { \
- endp = 0; \
- do { \
- if (!ADVANCE_INPUT (c, stream)) \
- endp = 1; \
- } while (!endp && (c == ' ' || c == '\t' || c == '\r' || c == '\n' \
- || c == '\f' || c == '\v')); \
-} while (0)
-
-#define STORE_BYTE(pos, val) do { \
+/* Get next character from the stream, except that non-base64
+ characters are ignored. This is in accordance with rfc2045. EC
+ should be an Emchar, so that it can hold -1 as the value for EOF. */
+#define ADVANCE_INPUT_IGNORE_NONBASE64(ec, stream, streampos) do { \
+ ec = Lstream_get_emchar (stream); \
+ ++streampos; \
+ /* IS_BASE64 may not be called with negative arguments so check for \
+ EOF first. */ \
+ if (ec < 0 || IS_BASE64 (ec) || ec == '=') \
+ break; \
+} while (1)
+
+#define STORE_BYTE(pos, val, ccnt) do { \