summaryrefslogtreecommitdiff
path: root/library/backend/vcc.y
Unidiff
Diffstat (limited to 'library/backend/vcc.y') (more/less context) (show whitespace changes)
-rw-r--r--library/backend/vcc.y25
1 files changed, 12 insertions, 13 deletions
diff --git a/library/backend/vcc.y b/library/backend/vcc.y
index 4c79368..bec2955 100644
--- a/library/backend/vcc.y
+++ b/library/backend/vcc.y
@@ -432,25 +432,25 @@ static void enterValues(const char *value)
432 } 432 }
433 deleteStr(value); 433 deleteStr(value);
434 } 434 }
435 435
436static void enterProps(const char *s) 436static void enterProps(const char *s)
437 { 437 {
438 curProp = addGroup(curObj,s); 438 curProp = addGroup(curObj,s);
439 deleteStr(s); 439 deleteStr(s);
440 } 440 }
441 441
442static void enterAttr(const char *s1, const char *s2) 442static void enterAttr(const char *s1, const char *s2)
443 { 443 {
444 const char *p1, *p2; 444 const char *p1, *p2=0;
445 p1 = lookupProp_(s1); 445 p1 = lookupProp_(s1);
446 if (s2) { 446 if (s2) {
447 VObject *a; 447 VObject *a;
448 p2 = lookupProp_(s2); 448 p2 = lookupProp_(s2);
449 a = addProp(curProp,p1); 449 a = addProp(curProp,p1);
450 setVObjectStringZValue(a,p2); 450 setVObjectStringZValue(a,p2);
451 } 451 }
452 else 452 else
453 addProp(curProp,p1); 453 addProp(curProp,p1);
454 if (qstricmp(p1,VCBase64Prop) == 0 || (s2 && qstricmp(p2,VCBase64Prop)==0)) 454 if (qstricmp(p1,VCBase64Prop) == 0 || (s2 && qstricmp(p2,VCBase64Prop)==0))
455 lexPushMode(L_BASE64); 455 lexPushMode(L_BASE64);
456 else if (qstricmp(p1,VCQuotedPrintableProp) == 0 456 else if (qstricmp(p1,VCQuotedPrintableProp) == 0
@@ -804,77 +804,79 @@ void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile)
804 804
805 } 805 }
806 806
807static void finiLex() { 807static void finiLex() {
808 free(lexBuf.strs); 808 free(lexBuf.strs);
809 } 809 }
810 810
811 811
812/*-----------------------------------*/ 812/*-----------------------------------*/
813/* This parses and converts the base64 format for binary encoding into 813/* This parses and converts the base64 format for binary encoding into
814 * a decoded buffer (allocated with new). See RFC 1521. 814 * a decoded buffer (allocated with new). See RFC 1521.
815 */ 815 */
816static char * lexGetDataFromBase64() 816static int lexGetDataFromBase64()
817 { 817 {
818 unsigned long bytesLen = 0, bytesMax = 0; 818 unsigned long bytesLen = 0, bytesMax = 0;
819 int quadIx = 0, pad = 0; 819 int quadIx = 0, pad = 0;
820 unsigned long trip = 0; 820 unsigned long trip = 0;
821 unsigned char b; 821 unsigned char b;
822 int c; 822 int c;
823 unsigned char *bytes = NULL; 823 unsigned char *bytes = NULL;
824 unsigned char *oldBytes = NULL; 824 unsigned char *oldBytes = NULL;
825 825
826 DBG_(("db: lexGetDataFromBase64\n")); 826 DBG_(("db: lexGetDataFromBase64\n"));
827 while (1) { 827 while (1) {
828 c = lexGetc(); 828 c = lexGetc();
829 lexSkipWhite();
829 if (c == '\n') { 830 if (c == '\n') {
830 ++mime_lineNum; 831 ++mime_lineNum;
831 if (lexLookahead() == '\n') { 832 if (lexLookahead() == '\n') {
832 /* a '\n' character by itself means end of data */ 833 /* a '\n' character by itself means end of data */
833 break; 834 break;
834 } 835 }
835 else continue; /* ignore '\n' */ 836 else continue; /* ignore '\n' */
836 } 837 }
837 else { 838 else {
838 if ((c >= 'A') && (c <= 'Z')) 839 if ((c >= 'A') && (c <= 'Z'))
839 b = (unsigned char)(c - 'A'); 840 b = (unsigned char)(c - 'A');
840 else if ((c >= 'a') && (c <= 'z')) 841 else if ((c >= 'a') && (c <= 'z'))
841 b = (unsigned char)(c - 'a') + 26; 842 b = (unsigned char)(c - 'a') + 26;
842 else if ((c >= '0') && (c <= '9')) 843 else if ((c >= '0') && (c <= '9'))
843 b = (unsigned char)(c - '0') + 52; 844 b = (unsigned char)(c - '0') + 52;
844 else if (c == '+') 845 else if (c == '+')
845 b = 62; 846 b = 62;
846 else if (c == '/') 847 else if (c == '/')
847 b = 63; 848 b = 63;
848 else if (c == '=') { 849 else if (c == '=') {
849 b = 0; 850 b = 0;
850 pad++; 851 pad++;
851 } else if ((c == ' ') || (c == '\t')) {
852 continue;
853 } else { /* error condition */ 852 } else { /* error condition */
854 if (bytes) free(bytes); 853 if (bytes) free(bytes);
855 else if (oldBytes) free(oldBytes); 854 else if (oldBytes) free(oldBytes);
856 // error recovery: skip until 2 adjacent newlines. 855 // error recovery: skip until 2 adjacent newlines.
857 DBG_(("db: invalid character 0x%x '%c'\n", c,c)); 856 DBG_(("db: invalid character 0x%x '%c'\n", c,c));
858 if (c != EOF) { 857 if (c != EOF) {
859 c = lexGetc(); 858 c = lexGetc();
860 while (c != EOF) { 859 while (c != EOF) {
861 if (c == '\n' && lexLookahead() == '\n') { 860 if (c == '\n') {
861 lexSkipWhite();
862 if(lexLookahead() == '\n') {
862 ++mime_lineNum; 863 ++mime_lineNum;
863 break; 864 break;
864 } 865 }
866 }
865 c = lexGetc(); 867 c = lexGetc();
866 } 868 }
867 } 869 }
868 return NULL; 870 return c != EOF;
869 } 871 }
870 trip = (trip << 6) | b; 872 trip = (trip << 6) | b;
871 if (++quadIx == 4) { 873 if (++quadIx == 4) {
872 unsigned char outBytes[3]; 874 unsigned char outBytes[3];
873 int numOut; 875 int numOut;
874 int i; 876 int i;
875 for (i = 0; i < 3; i++) { 877 for (i = 0; i < 3; i++) {
876 outBytes[2-i] = (unsigned char)(trip & 0xFF); 878 outBytes[2-i] = (unsigned char)(trip & 0xFF);
877 trip >>= 8; 879 trip >>= 8;
878 } 880 }
879 numOut = 3 - pad; 881 numOut = 3 - pad;
880 if (bytesLen + numOut > bytesMax) { 882 if (bytesLen + numOut > bytesMax) {
@@ -902,25 +904,25 @@ static char * lexGetDataFromBase64()
902 } /* while */ 904 } /* while */
903 DBG_(("db: bytesLen = %d\n", bytesLen)); 905 DBG_(("db: bytesLen = %d\n", bytesLen));
904 /* kludge: all this won't be necessary if we have tree form 906 /* kludge: all this won't be necessary if we have tree form
905 representation */ 907 representation */
906 if (bytes) { 908 if (bytes) {
907 setValueWithSize(curProp,bytes,(unsigned int)bytesLen); 909 setValueWithSize(curProp,bytes,(unsigned int)bytesLen);
908 free(bytes); 910 free(bytes);
909 } 911 }
910 else if (oldBytes) { 912 else if (oldBytes) {
911 setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen); 913 setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen);
912 free(oldBytes); 914 free(oldBytes);
913 } 915 }
914 return 0; 916 return bytesLen;
915 } 917 }
916 918
917static int match_begin_end_name(int end) { 919static int match_begin_end_name(int end) {
918 int token; 920 int token;
919 lexSkipWhite(); 921 lexSkipWhite();
920 if (lexLookahead() != ':') return ID; 922 if (lexLookahead() != ':') return ID;
921 lexSkipLookahead(); 923 lexSkipLookahead();
922 lexSkipWhite(); 924 lexSkipWhite();
923 token = match_begin_name(end); 925 token = match_begin_name(end);
924 if (token == ID) { 926 if (token == ID) {
925 lexPushLookaheadc(':'); 927 lexPushLookaheadc(':');
926 DBG_(("db: ID '%s'\n", yylval.str)); 928 DBG_(("db: ID '%s'\n", yylval.str));
@@ -933,25 +935,25 @@ static int match_begin_end_name(int end) {
933 return token; 935 return token;
934 } 936 }
935 return 0; 937 return 0;
936 } 938 }
937 939
938static char* lexGetQuotedPrintable() 940static char* lexGetQuotedPrintable()
939{ 941{
940 int c; 942 int c;
941 lexSkipWhite(); 943 lexSkipWhite();
942 c = lexLookahead(); 944 c = lexLookahead();
943 lexClearToken(); 945 lexClearToken();
944 946
945 while (c != EOF && c != ';') { 947 while (c != EOF && (c != ';' || !fieldedProp)) {
946 if (c == '\n') { 948 if (c == '\n') {
947 // break, leave '\n' on remaining chars. 949 // break, leave '\n' on remaining chars.
948 break; 950 break;
949 } else if (c == '=') { 951 } else if (c == '=') {
950 int cur = 0; 952 int cur = 0;
951 int next; 953 int next;
952 954
953 lexSkipLookahead(); // skip '=' 955 lexSkipLookahead(); // skip '='
954 next = lexLookahead(); 956 next = lexLookahead();
955 957
956 if (next == '\n') { 958 if (next == '\n') {
957 // skip and only skip the \n 959 // skip and only skip the \n
@@ -1023,29 +1025,26 @@ static int yylex() {
1023 lexSkipLookahead(); 1025 lexSkipLookahead();
1024 c = lexLookahead(); 1026 c = lexLookahead();
1025 ++mime_lineNum; 1027 ++mime_lineNum;
1026 } 1028 }
1027 DBG_(("db: LINESEP\n")); 1029 DBG_(("db: LINESEP\n"));
1028 return LINESEP; 1030 return LINESEP;
1029 } 1031 }
1030 else { 1032 else {
1031 char *p = 0; 1033 char *p = 0;
1032 lexPushLookaheadc(c); 1034 lexPushLookaheadc(c);
1033 if (lexWithinMode(L_BASE64)) { 1035 if (lexWithinMode(L_BASE64)) {
1034 /* get each char and convert to bin on the fly... */ 1036 /* get each char and convert to bin on the fly... */
1035 p = lexGetDataFromBase64(); 1037 yylval.str = NULL;
1036 #if 0 1038 return lexGetDataFromBase64() ? STRING : 0;
1037 yylval.str = p;
1038 return STRING;
1039 #endif
1040 } 1039 }
1041 else if (lexWithinMode(L_QUOTED_PRINTABLE)) { 1040 else if (lexWithinMode(L_QUOTED_PRINTABLE)) {
1042 p = lexGetQuotedPrintable(); 1041 p = lexGetQuotedPrintable();
1043 } 1042 }
1044 else { 1043 else {
1045#ifdef _SUPPORT_LINE_FOLDING 1044#ifdef _SUPPORT_LINE_FOLDING
1046 p = lexGet1Value(); 1045 p = lexGet1Value();
1047#else 1046#else
1048 p = lexGetStrUntil(";\n"); 1047 p = lexGetStrUntil(";\n");
1049#endif 1048#endif
1050 } 1049 }
1051 if (p) { 1050 if (p) {