-rw-r--r-- | library/backend/vcc.y | 103 |
1 files changed, 56 insertions, 47 deletions
diff --git a/library/backend/vcc.y b/library/backend/vcc.y index e326a64..5bcf0cb 100644 --- a/library/backend/vcc.y +++ b/library/backend/vcc.y | |||
@@ -518,5 +518,5 @@ static int lexWithinMode(enum LexMode mode) { | |||
518 | } | 518 | } |
519 | 519 | ||
520 | static char lexGetc_() | 520 | static int lexGetc_() |
521 | { | 521 | { |
522 | /* get next char from input, no buffering. */ | 522 | /* get next char from input, no buffering. */ |
@@ -932,58 +932,67 @@ static int match_begin_end_name(int end) { | |||
932 | static char* lexGetQuotedPrintable() | 932 | static char* lexGetQuotedPrintable() |
933 | { | 933 | { |
934 | char cur; | 934 | int c; |
935 | 935 | lexSkipWhite(); | |
936 | c = lexLookahead(); | ||
936 | lexClearToken(); | 937 | lexClearToken(); |
937 | do { | 938 | |
938 | cur = lexGetc(); | 939 | while (c != EOF && c != ';') { |
939 | switch (cur) { | 940 | if (c == '\n') { |
940 | case '=': { | 941 | // break, leave '\n' on remaining chars. |
941 | int c = 0; | ||
942 | int next[2]; | ||
943 | int i; | ||
944 | for (i = 0; i < 2; i++) { | ||
945 | next[i] = lexGetc(); | ||
946 | if (next[i] >= '0' && next[i] <= '9') | ||
947 | c = c * 16 + next[i] - '0'; | ||
948 | else if (next[i] >= 'A' && next[i] <= 'F') | ||
949 | c = c * 16 + next[i] - 'A' + 10; | ||
950 | else | ||
951 | break; | 942 | break; |
943 | } else if (c == '=') { | ||
944 | int cur = 0; | ||
945 | int next; | ||
946 | |||
947 | lexSkipLookahead(); // skip '=' | ||
948 | next = lexLookahead(); | ||
949 | |||
950 | if (next == '\n') { | ||
951 | // skip and only skip the \n | ||
952 | lexSkipLookahead(); | ||
953 | c = lexLookahead(); | ||
954 | ++mime_lineNum; // aid in error reporting | ||
955 | continue; | ||
956 | } else if (next >= '0' && next <= '9') { | ||
957 | cur = next - '0'; | ||
958 | } else if (next >= 'A' && next <= 'F') { | ||
959 | cur = next - 'A' + 10; | ||
960 | } else { | ||
961 | // we have been sent buggy stuff. doesn't matter | ||
962 | // what we do so long as we keep going. | ||
963 | // should probably spit an error here | ||
964 | c = lexLookahead(); | ||
965 | continue; | ||
952 | } | 966 | } |
953 | if (i == 0) { | 967 | |
954 | /* single '=' follow by LINESEP is continuation sign? */ | 968 | lexSkipLookahead(); // skip A-Z0-9 |
955 | if (next[0] == '\n') { | 969 | next = lexLookahead(); |
956 | ++mime_lineNum; | 970 | |
957 | } | 971 | cur = cur * 16; |
958 | else { | 972 | // this time really just expecting 0-9A-F |
959 | lexPushLookaheadc('='); | 973 | if (next >= '0' && next <= '9') { |
960 | goto EndString; | 974 | cur += next - '0'; |
961 | } | 975 | } else if (next >= 'A' && next <= 'F') { |
976 | cur += next - 'A' + 10; | ||
977 | } else { | ||
978 | // we have been sent buggy stuff. doesn't matter | ||
979 | // what we do so long as we keep going. | ||
980 | // should probably spit an error here | ||
981 | c = lexLookahead(); | ||
982 | continue; | ||
962 | } | 983 | } |
963 | else if (i == 1) { | 984 | |
964 | lexPushLookaheadc(next[1]); | 985 | // got a valid escaped =. append it. |
965 | lexPushLookaheadc(next[0]); | 986 | lexSkipLookahead(); // skip second 0-9A-F |
966 | lexAppendc('='); | 987 | lexAppendc(cur); |
967 | } else { | 988 | } else { |
968 | lexAppendc(c); | 989 | lexSkipLookahead(); // skip whatever we just read. |
990 | lexAppendc(c); // and append it. | ||
969 | } | 991 | } |
970 | break; | 992 | c = lexLookahead(); |
971 | } /* '=' */ | ||
972 | case '\n': { | ||
973 | lexPushLookaheadc('\n'); | ||
974 | goto EndString; | ||
975 | } | 993 | } |
976 | case (char)EOF: | ||
977 | break; | ||
978 | default: | ||
979 | lexAppendc(cur); | ||
980 | break; | ||
981 | } /* switch */ | ||
982 | } while (cur != (char)EOF); | ||
983 | |||
984 | EndString: | ||
985 | lexAppendc(0); | 994 | lexAppendc(0); |
986 | return lexStr(); | 995 | return c==EOF?0:lexStr(); |
987 | } /* LexQuotedPrintable */ | 996 | } |
988 | 997 | ||
989 | static int yylex() { | 998 | static int yylex() { |