summaryrefslogtreecommitdiff
path: root/library/backend/vcc_yacc.cpp
authoreilers <eilers>2003-03-27 16:17:48 (UTC)
committer eilers <eilers>2003-03-27 16:17:48 (UTC)
commit390a5a0c332c8c6fb380c1ed4cd6adae3e544a08 (patch) (unidiff)
tree7ad6266be3d78d25ae061a0be067f82f8d666246 /library/backend/vcc_yacc.cpp
parentff43585778968407bb08473e45ddd1d942f8d8c8 (diff)
downloadopie-390a5a0c332c8c6fb380c1ed4cd6adae3e544a08.zip
opie-390a5a0c332c8c6fb380c1ed4cd6adae3e544a08.tar.gz
opie-390a5a0c332c8c6fb380c1ed4cd6adae3e544a08.tar.bz2
using releases from qtopia-free-1.6.0-snapshot-20030324 which fixes the
following bugs #776 and #490: Now, we could successfully parse vcards from palm 4 + 5 and quoted-printable encoded lines .. !
Diffstat (limited to 'library/backend/vcc_yacc.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/backend/vcc_yacc.cpp127
1 files changed, 73 insertions, 54 deletions
diff --git a/library/backend/vcc_yacc.cpp b/library/backend/vcc_yacc.cpp
index b2b0c14..5649522 100644
--- a/library/backend/vcc_yacc.cpp
+++ b/library/backend/vcc_yacc.cpp
@@ -155,13 +155,13 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable.
155#include <stdlib.h> 155#include <stdlib.h>
156#include <ctype.h> 156#include <ctype.h>
157 157
158/*#ifdef PALMTOPCENTER */ 158/*#ifdef PALMTOPCENTER */
159/*#include <qpe/vobject_p.h> */ 159/*#include <qpe/vobject_p.h> */
160/*#else */ 160/*#else */
161#include <qtopia/private/vobject_p.h> 161#include "vobject_p.h"
162/*#endif */ 162/*#endif */
163 163
164/**** Types, Constants ****/ 164/**** Types, Constants ****/
165 165
166 #define YYDEBUG 0/* 1 to compile in some debugging code */ 166 #define YYDEBUG 0/* 1 to compile in some debugging code */
167 #define MAXTOKEN 256/* maximum token (line) length */ 167 #define MAXTOKEN 256/* maximum token (line) length */
@@ -740,22 +740,28 @@ static void handleMoreRFC822LineBreak(int c) {
740 740
741static char* lexGet1Value() { 741static char* lexGet1Value() {
742 int c; 742 int c;
743 lexSkipWhite(); 743 lexSkipWhite();
744 c = lexLookahead(); 744 c = lexLookahead();
745 lexClearToken(); 745 lexClearToken();
746 while (c != EOF && c != ';') { 746 while (c != EOF && (c != ';' || !fieldedProp)) {
747 if (c == '\\' ) { 747 if (c == '\\' ) {
748 int a; 748 int a;
749 lexSkipLookahead(); 749 lexSkipLookahead();
750 a = lexLookahead(); 750 a = lexLookahead();
751 if ( a != ';' ) { 751 if ( a == ';' ) {
752 lexAppendc('\\');
753 } else {
754 lexAppendc( ';' ); 752 lexAppendc( ';' );
755 lexSkipLookahead(); 753 lexSkipLookahead();
754 } else if ( a == '\n' ) {
755 lexAppendc( '\n' );
756 lexSkipLookahead();
757 } else if ( a == '\\' ) {
758 lexAppendc( '\\' );
759 lexSkipLookahead();
760 } else {
761 lexAppendc('\\');
756 } 762 }
757 } else if (c == '\n') { 763 } else if (c == '\n') {
758 int a; 764 int a;
759 lexSkipLookahead(); 765 lexSkipLookahead();
760 a = lexLookahead(); 766 a = lexLookahead();
761 if (a == ' ' || a == '\t') { 767 if (a == ' ' || a == '\t') {
@@ -948,73 +954,84 @@ static int match_begin_end_name(int end) {
948 } 954 }
949 return 0; 955 return 0;
950 } 956 }
951 957
952static char* lexGetQuotedPrintable() 958static char* lexGetQuotedPrintable()
953 { 959 {
954 int cur; 960 int c;
955 961 lexSkipWhite();
962 c = lexLookahead();
956 lexClearToken(); 963 lexClearToken();
957 do { 964
958 cur = lexGetc(); 965 while (c != EOF && c != ';') {
959 switch (cur) { 966 if (c == '\n') {
960 case '=': { 967 // break, leave '\n' on remaining chars.
961 int c = 0;
962 int next[2];
963 int i;
964 for (i = 0; i < 2; i++) {
965 next[i] = lexGetc();
966 if (next[i] >= '0' && next[i] <= '9')
967 c = c * 16 + next[i] - '0';
968 else if (next[i] >= 'A' && next[i] <= 'F')
969 c = c * 16 + next[i] - 'A' + 10;
970 else
971 break; 968 break;
969 } else if (c == '=') {
970 int cur = 0;
971 int next;
972
973 lexSkipLookahead(); // skip '='
974 next = lexLookahead();
975
976 if (next == '\n') {
977 // skip and only skip the \n
978 lexSkipLookahead();
979 c = lexLookahead();
980 ++mime_lineNum; // aid in error reporting
981 continue;
982 } else if (next >= '0' && next <= '9') {
983 cur = next - '0';
984 } else if (next >= 'A' && next <= 'F') {
985 cur = next - 'A' + 10;
986 } else {
987 // we have been sent buggy stuff. doesn't matter
988 // what we do so long as we keep going.
989 // should probably spit an error here
990 lexSkipLookahead();
991 c = lexLookahead();
992 continue;
972 } 993 }
973 if (i == 0) { 994
974 /* single '=' follow by LINESEP is continuation sign? */ 995 lexSkipLookahead(); // skip A-Z0-9
975 if (next[0] == '\n') { 996 next = lexLookahead();
976 ++mime_lineNum; 997
977 } 998 cur = cur * 16;
978 else { 999 // this time really just expecting 0-9A-F
979 lexPushLookaheadc('='); 1000 if (next >= '0' && next <= '9') {
980 goto EndString; 1001 cur += next - '0';
981 } 1002 } else if (next >= 'A' && next <= 'F') {
1003 cur += next - 'A' + 10;
1004 } else {
1005 // we have been sent buggy stuff. doesn't matter
1006 // what we do so long as we keep going.
1007 // should probably spit an error here
1008 lexSkipLookahead();
1009 c = lexLookahead();
1010 continue;
982 } 1011 }
983 else if (i == 1) { 1012
984 lexPushLookaheadc(next[1]); 1013 // got a valid escaped =. append it.
985 lexPushLookaheadc(next[0]); 1014 lexSkipLookahead(); // skip second 0-9A-F
986 lexAppendc('='); 1015 lexAppendc(cur);
987 } else { 1016 } else {
988 lexAppendc(c); 1017 lexSkipLookahead(); // skip whatever we just read.
1018 lexAppendc(c); // and append it.
989 } 1019 }
990 break; 1020 c = lexLookahead();
991 } /* '=' */
992 case '\n': {
993 lexPushLookaheadc('\n');
994 goto EndString;
995 } 1021 }
996 case (int)EOF:
997 break;
998 default:
999 lexAppendc(cur);
1000 break;
1001 } /* switch */
1002 } while (cur != (int)EOF);
1003
1004EndString:
1005 lexAppendc(0); 1022 lexAppendc(0);
1006 return lexStr(); 1023 return c==EOF?0:lexStr();
1007 } /* LexQuotedPrintable */ 1024}
1008 1025
1009static int yylex() { 1026static int yylex() {
1010 1027
1011 int lexmode = LEXMODE(); 1028 int lexmode = LEXMODE();
1012 if (lexmode == L_VALUES) { 1029 if (lexmode == L_VALUES) {
1013 int c = lexGetc(); 1030 int c = lexGetc();
1014 if (c == ';') { 1031 if (c == ';' && fieldedProp) {
1015 DBG_(("db: SEMICOLON\n")); 1032 DBG_(("db: SEMICOLON\n"));
1016 lexPushLookaheadc(c); 1033 lexPushLookaheadc(c);
1017 handleMoreRFC822LineBreak(c); 1034 handleMoreRFC822LineBreak(c);
1018 lexSkipLookahead(); 1035 lexSkipLookahead();
1019 return SEMICOLON; 1036 return SEMICOLON;
1020 } 1037 }
@@ -1062,18 +1079,20 @@ static int yylex() {
1062 while (1) { 1079 while (1) {
1063 int c = lexGetc(); 1080 int c = lexGetc();
1064 switch(c) { 1081 switch(c) {
1065 case ':': { 1082 case ':': {
1066 /* consume all line separator(s) adjacent to each other */ 1083 /* consume all line separator(s) adjacent to each other */
1067 /* ignoring linesep immediately after colon. */ 1084 /* ignoring linesep immediately after colon. */
1085 /* I don't see this in the spec, and it breaks null values -- WA
1068 c = lexLookahead(); 1086 c = lexLookahead();
1069 while (strchr("\n",c)) { 1087 while (strchr("\n",c)) {
1070 lexSkipLookahead(); 1088 lexSkipLookahead();
1071 c = lexLookahead(); 1089 c = lexLookahead();
1072 ++mime_lineNum; 1090 ++mime_lineNum;
1073 } 1091 }
1092 */
1074 DBG_(("db: COLON\n")); 1093 DBG_(("db: COLON\n"));
1075 return COLON; 1094 return COLON;
1076 } 1095 }
1077 case ';': 1096 case ';':
1078 DBG_(("db: SEMICOLON\n")); 1097 DBG_(("db: SEMICOLON\n"));
1079 return SEMICOLON; 1098 return SEMICOLON;
@@ -1214,13 +1233,13 @@ void mime_error_(char *s)
1214 { 1233 {
1215 if (mimeErrorHandler) { 1234 if (mimeErrorHandler) {
1216 mimeErrorHandler(s); 1235 mimeErrorHandler(s);
1217 } 1236 }
1218 } 1237 }
1219 1238
1220#line 1221 "y.tab.c" 1239#line 1240 "y.tab.c"
1221#define YYABORT goto yyabort 1240#define YYABORT goto yyabort
1222#define YYREJECT goto yyabort 1241#define YYREJECT goto yyabort
1223#define YYACCEPT goto yyaccept 1242#define YYACCEPT goto yyaccept
1224#define YYERROR goto yyerrlab 1243#define YYERROR goto yyerrlab
1225int 1244int
1226#if defined(__STDC__) 1245#if defined(__STDC__)
@@ -1514,13 +1533,13 @@ case 45:
1514#line 376 "backend/vcc.y" 1533#line 376 "backend/vcc.y"
1515{ 1534{
1516 lexPopMode(0); 1535 lexPopMode(0);
1517 popVObject(); 1536 popVObject();
1518 } 1537 }
1519break; 1538break;
1520#line 1521 "y.tab.c" 1539#line 1540 "y.tab.c"
1521 } 1540 }
1522 yyssp -= yym; 1541 yyssp -= yym;
1523 yystate = *yyssp; 1542 yystate = *yyssp;
1524 yyvsp -= yym; 1543 yyvsp -= yym;
1525 yym = yylhs[yyn]; 1544 yym = yylhs[yyn];
1526 if (yystate == 0 && yym == 0) 1545 if (yystate == 0 && yym == 0)