author | zautrix <zautrix> | 2004-10-25 15:27:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-25 15:27:39 (UTC) |
commit | 03ca6830a9e6742b8873aee04d77b3e094b65d30 (patch) (unidiff) | |
tree | 170ab278ffeb371aae783815101f64275cd30c53 /libkcal/versit | |
parent | 62e92aa86b6281b4e4c2a2bdb57f3ceb5a87f4e3 (diff) | |
download | kdepimpi-03ca6830a9e6742b8873aee04d77b3e094b65d30.zip kdepimpi-03ca6830a9e6742b8873aee04d77b3e094b65d30.tar.gz kdepimpi-03ca6830a9e6742b8873aee04d77b3e094b65d30.tar.bz2 |
fix of vcal crash
-rw-r--r-- | libkcal/versit/vcc.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libkcal/versit/vcc.c b/libkcal/versit/vcc.c index 9be752d..5413813 100644 --- a/libkcal/versit/vcc.c +++ b/libkcal/versit/vcc.c | |||
@@ -1253,1025 +1253,1026 @@ case 46: | |||
1253 | { | 1253 | { |
1254 | lexPopMode(0); | 1254 | lexPopMode(0); |
1255 | popVObject(); | 1255 | popVObject(); |
1256 | } | 1256 | } |
1257 | break; | 1257 | break; |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | #line 705 "/usr/share/bison/bison.simple" | 1260 | #line 705 "/usr/share/bison/bison.simple" |
1261 | 1261 | ||
1262 | 1262 | ||
1263 | yyvsp -= yylen; | 1263 | yyvsp -= yylen; |
1264 | yyssp -= yylen; | 1264 | yyssp -= yylen; |
1265 | #if YYLSP_NEEDED | 1265 | #if YYLSP_NEEDED |
1266 | yylsp -= yylen; | 1266 | yylsp -= yylen; |
1267 | #endif | 1267 | #endif |
1268 | 1268 | ||
1269 | #if YYDEBUG | 1269 | #if YYDEBUG |
1270 | if (yydebug) | 1270 | if (yydebug) |
1271 | { | 1271 | { |
1272 | short *yyssp1 = yyss - 1; | 1272 | short *yyssp1 = yyss - 1; |
1273 | YYFPRINTF (stderr, "state stack now"); | 1273 | YYFPRINTF (stderr, "state stack now"); |
1274 | while (yyssp1 != yyssp) | 1274 | while (yyssp1 != yyssp) |
1275 | YYFPRINTF (stderr, " %d", *++yyssp1); | 1275 | YYFPRINTF (stderr, " %d", *++yyssp1); |
1276 | YYFPRINTF (stderr, "\n"); | 1276 | YYFPRINTF (stderr, "\n"); |
1277 | } | 1277 | } |
1278 | #endif | 1278 | #endif |
1279 | 1279 | ||
1280 | *++yyvsp = yyval; | 1280 | *++yyvsp = yyval; |
1281 | #if YYLSP_NEEDED | 1281 | #if YYLSP_NEEDED |
1282 | *++yylsp = yyloc; | 1282 | *++yylsp = yyloc; |
1283 | #endif | 1283 | #endif |
1284 | 1284 | ||
1285 | /* Now `shift' the result of the reduction. Determine what state | 1285 | /* Now `shift' the result of the reduction. Determine what state |
1286 | that goes to, based on the state we popped back to and the rule | 1286 | that goes to, based on the state we popped back to and the rule |
1287 | number reduced by. */ | 1287 | number reduced by. */ |
1288 | 1288 | ||
1289 | yyn = yyr1[yyn]; | 1289 | yyn = yyr1[yyn]; |
1290 | 1290 | ||
1291 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; | 1291 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; |
1292 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) | 1292 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) |
1293 | yystate = yytable[yystate]; | 1293 | yystate = yytable[yystate]; |
1294 | else | 1294 | else |
1295 | yystate = yydefgoto[yyn - YYNTBASE]; | 1295 | yystate = yydefgoto[yyn - YYNTBASE]; |
1296 | 1296 | ||
1297 | goto yynewstate; | 1297 | goto yynewstate; |
1298 | 1298 | ||
1299 | 1299 | ||
1300 | /*------------------------------------. | 1300 | /*------------------------------------. |
1301 | | yyerrlab -- here on detecting error | | 1301 | | yyerrlab -- here on detecting error | |
1302 | `------------------------------------*/ | 1302 | `------------------------------------*/ |
1303 | yyerrlab: | 1303 | yyerrlab: |
1304 | /* If not already recovering from an error, report this error. */ | 1304 | /* If not already recovering from an error, report this error. */ |
1305 | if (!yyerrstatus) | 1305 | if (!yyerrstatus) |
1306 | { | 1306 | { |
1307 | ++yynerrs; | 1307 | ++yynerrs; |
1308 | 1308 | ||
1309 | #ifdef YYERROR_VERBOSE | 1309 | #ifdef YYERROR_VERBOSE |
1310 | yyn = yypact[yystate]; | 1310 | yyn = yypact[yystate]; |
1311 | 1311 | ||
1312 | if (yyn > YYFLAG && yyn < YYLAST) | 1312 | if (yyn > YYFLAG && yyn < YYLAST) |
1313 | { | 1313 | { |
1314 | YYSIZE_T yysize = 0; | 1314 | YYSIZE_T yysize = 0; |
1315 | char *yymsg; | 1315 | char *yymsg; |
1316 | int yyx, yycount; | 1316 | int yyx, yycount; |
1317 | 1317 | ||
1318 | yycount = 0; | 1318 | yycount = 0; |
1319 | /* Start YYX at -YYN if negative to avoid negative indexes in | 1319 | /* Start YYX at -YYN if negative to avoid negative indexes in |
1320 | YYCHECK. */ | 1320 | YYCHECK. */ |
1321 | for (yyx = yyn < 0 ? -yyn : 0; | 1321 | for (yyx = yyn < 0 ? -yyn : 0; |
1322 | yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) | 1322 | yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) |
1323 | if (yycheck[yyx + yyn] == yyx) | 1323 | if (yycheck[yyx + yyn] == yyx) |
1324 | yysize += yystrlen (yytname[yyx]) + 15, yycount++; | 1324 | yysize += yystrlen (yytname[yyx]) + 15, yycount++; |
1325 | yysize += yystrlen ("parse error, unexpected ") + 1; | 1325 | yysize += yystrlen ("parse error, unexpected ") + 1; |
1326 | yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); | 1326 | yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); |
1327 | yymsg = (char *) YYSTACK_ALLOC (yysize); | 1327 | yymsg = (char *) YYSTACK_ALLOC (yysize); |
1328 | if (yymsg != 0) | 1328 | if (yymsg != 0) |
1329 | { | 1329 | { |
1330 | char *yyp = yystpcpy (yymsg, "parse error, unexpected "); | 1330 | char *yyp = yystpcpy (yymsg, "parse error, unexpected "); |
1331 | yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); | 1331 | yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); |
1332 | 1332 | ||
1333 | if (yycount < 5) | 1333 | if (yycount < 5) |
1334 | { | 1334 | { |
1335 | yycount = 0; | 1335 | yycount = 0; |
1336 | for (yyx = yyn < 0 ? -yyn : 0; | 1336 | for (yyx = yyn < 0 ? -yyn : 0; |
1337 | yyx < (int) (sizeof (yytname) / sizeof (char *)); | 1337 | yyx < (int) (sizeof (yytname) / sizeof (char *)); |
1338 | yyx++) | 1338 | yyx++) |
1339 | if (yycheck[yyx + yyn] == yyx) | 1339 | if (yycheck[yyx + yyn] == yyx) |
1340 | { | 1340 | { |
1341 | const char *yyq = ! yycount ? ", expecting " : " or "; | 1341 | const char *yyq = ! yycount ? ", expecting " : " or "; |
1342 | yyp = yystpcpy (yyp, yyq); | 1342 | yyp = yystpcpy (yyp, yyq); |
1343 | yyp = yystpcpy (yyp, yytname[yyx]); | 1343 | yyp = yystpcpy (yyp, yytname[yyx]); |
1344 | yycount++; | 1344 | yycount++; |
1345 | } | 1345 | } |
1346 | } | 1346 | } |
1347 | yyerror (yymsg); | 1347 | yyerror (yymsg); |
1348 | YYSTACK_FREE (yymsg); | 1348 | YYSTACK_FREE (yymsg); |
1349 | } | 1349 | } |
1350 | else | 1350 | else |
1351 | yyerror ("parse error; also virtual memory exhausted"); | 1351 | yyerror ("parse error; also virtual memory exhausted"); |
1352 | } | 1352 | } |
1353 | else | 1353 | else |
1354 | #endif /* defined (YYERROR_VERBOSE) */ | 1354 | #endif /* defined (YYERROR_VERBOSE) */ |
1355 | yyerror ("parse error"); | 1355 | yyerror ("parse error"); |
1356 | } | 1356 | } |
1357 | goto yyerrlab1; | 1357 | goto yyerrlab1; |
1358 | 1358 | ||
1359 | 1359 | ||
1360 | /*--------------------------------------------------. | 1360 | /*--------------------------------------------------. |
1361 | | yyerrlab1 -- error raised explicitly by an action | | 1361 | | yyerrlab1 -- error raised explicitly by an action | |
1362 | `--------------------------------------------------*/ | 1362 | `--------------------------------------------------*/ |
1363 | yyerrlab1: | 1363 | yyerrlab1: |
1364 | if (yyerrstatus == 3) | 1364 | if (yyerrstatus == 3) |
1365 | { | 1365 | { |
1366 | /* If just tried and failed to reuse lookahead token after an | 1366 | /* If just tried and failed to reuse lookahead token after an |
1367 | error, discard it. */ | 1367 | error, discard it. */ |
1368 | 1368 | ||
1369 | /* return failure if at end of input */ | 1369 | /* return failure if at end of input */ |
1370 | if (yychar == YYEOF) | 1370 | if (yychar == YYEOF) |
1371 | YYABORT; | 1371 | YYABORT; |
1372 | YYDPRINTF ((stderr, "Discarding token %d (%s).\n", | 1372 | YYDPRINTF ((stderr, "Discarding token %d (%s).\n", |
1373 | yychar, yytname[yychar1])); | 1373 | yychar, yytname[yychar1])); |
1374 | yychar = YYEMPTY; | 1374 | yychar = YYEMPTY; |
1375 | } | 1375 | } |
1376 | 1376 | ||
1377 | /* Else will try to reuse lookahead token after shifting the error | 1377 | /* Else will try to reuse lookahead token after shifting the error |
1378 | token. */ | 1378 | token. */ |
1379 | 1379 | ||
1380 | yyerrstatus = 3; /* Each real token shifted decrements this */ | 1380 | yyerrstatus = 3; /* Each real token shifted decrements this */ |
1381 | 1381 | ||
1382 | goto yyerrhandle; | 1382 | goto yyerrhandle; |
1383 | 1383 | ||
1384 | 1384 | ||
1385 | /*-------------------------------------------------------------------. | 1385 | /*-------------------------------------------------------------------. |
1386 | | yyerrdefault -- current state does not do anything special for the | | 1386 | | yyerrdefault -- current state does not do anything special for the | |
1387 | | error token. | | 1387 | | error token. | |
1388 | `-------------------------------------------------------------------*/ | 1388 | `-------------------------------------------------------------------*/ |
1389 | yyerrdefault: | 1389 | yyerrdefault: |
1390 | #if 0 | 1390 | #if 0 |
1391 | /* This is wrong; only states that explicitly want error tokens | 1391 | /* This is wrong; only states that explicitly want error tokens |
1392 | should shift them. */ | 1392 | should shift them. */ |
1393 | 1393 | ||
1394 | /* If its default is to accept any token, ok. Otherwise pop it. */ | 1394 | /* If its default is to accept any token, ok. Otherwise pop it. */ |
1395 | yyn = yydefact[yystate]; | 1395 | yyn = yydefact[yystate]; |
1396 | if (yyn) | 1396 | if (yyn) |
1397 | goto yydefault; | 1397 | goto yydefault; |
1398 | #endif | 1398 | #endif |
1399 | 1399 | ||
1400 | 1400 | ||
1401 | /*---------------------------------------------------------------. | 1401 | /*---------------------------------------------------------------. |
1402 | | yyerrpop -- pop the current state because it cannot handle the | | 1402 | | yyerrpop -- pop the current state because it cannot handle the | |
1403 | | error token | | 1403 | | error token | |
1404 | `---------------------------------------------------------------*/ | 1404 | `---------------------------------------------------------------*/ |
1405 | yyerrpop: | 1405 | yyerrpop: |
1406 | if (yyssp == yyss) | 1406 | if (yyssp == yyss) |
1407 | YYABORT; | 1407 | YYABORT; |
1408 | yyvsp--; | 1408 | yyvsp--; |
1409 | yystate = *--yyssp; | 1409 | yystate = *--yyssp; |
1410 | #if YYLSP_NEEDED | 1410 | #if YYLSP_NEEDED |
1411 | yylsp--; | 1411 | yylsp--; |
1412 | #endif | 1412 | #endif |
1413 | 1413 | ||
1414 | #if YYDEBUG | 1414 | #if YYDEBUG |
1415 | if (yydebug) | 1415 | if (yydebug) |
1416 | { | 1416 | { |
1417 | short *yyssp1 = yyss - 1; | 1417 | short *yyssp1 = yyss - 1; |
1418 | YYFPRINTF (stderr, "Error: state stack now"); | 1418 | YYFPRINTF (stderr, "Error: state stack now"); |
1419 | while (yyssp1 != yyssp) | 1419 | while (yyssp1 != yyssp) |
1420 | YYFPRINTF (stderr, " %d", *++yyssp1); | 1420 | YYFPRINTF (stderr, " %d", *++yyssp1); |
1421 | YYFPRINTF (stderr, "\n"); | 1421 | YYFPRINTF (stderr, "\n"); |
1422 | } | 1422 | } |
1423 | #endif | 1423 | #endif |
1424 | 1424 | ||
1425 | /*--------------. | 1425 | /*--------------. |
1426 | | yyerrhandle. | | 1426 | | yyerrhandle. | |
1427 | `--------------*/ | 1427 | `--------------*/ |
1428 | yyerrhandle: | 1428 | yyerrhandle: |
1429 | yyn = yypact[yystate]; | 1429 | yyn = yypact[yystate]; |
1430 | if (yyn == YYFLAG) | 1430 | if (yyn == YYFLAG) |
1431 | goto yyerrdefault; | 1431 | goto yyerrdefault; |
1432 | 1432 | ||
1433 | yyn += YYTERROR; | 1433 | yyn += YYTERROR; |
1434 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) | 1434 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) |
1435 | goto yyerrdefault; | 1435 | goto yyerrdefault; |
1436 | 1436 | ||
1437 | yyn = yytable[yyn]; | 1437 | yyn = yytable[yyn]; |
1438 | if (yyn < 0) | 1438 | if (yyn < 0) |
1439 | { | 1439 | { |
1440 | if (yyn == YYFLAG) | 1440 | if (yyn == YYFLAG) |
1441 | goto yyerrpop; | 1441 | goto yyerrpop; |
1442 | yyn = -yyn; | 1442 | yyn = -yyn; |
1443 | goto yyreduce; | 1443 | goto yyreduce; |
1444 | } | 1444 | } |
1445 | else if (yyn == 0) | 1445 | else if (yyn == 0) |
1446 | goto yyerrpop; | 1446 | goto yyerrpop; |
1447 | 1447 | ||
1448 | if (yyn == YYFINAL) | 1448 | if (yyn == YYFINAL) |
1449 | YYACCEPT; | 1449 | YYACCEPT; |
1450 | 1450 | ||
1451 | YYDPRINTF ((stderr, "Shifting error token, ")); | 1451 | YYDPRINTF ((stderr, "Shifting error token, ")); |
1452 | 1452 | ||
1453 | *++yyvsp = yylval; | 1453 | *++yyvsp = yylval; |
1454 | #if YYLSP_NEEDED | 1454 | #if YYLSP_NEEDED |
1455 | *++yylsp = yylloc; | 1455 | *++yylsp = yylloc; |
1456 | #endif | 1456 | #endif |
1457 | 1457 | ||
1458 | yystate = yyn; | 1458 | yystate = yyn; |
1459 | goto yynewstate; | 1459 | goto yynewstate; |
1460 | 1460 | ||
1461 | 1461 | ||
1462 | /*-------------------------------------. | 1462 | /*-------------------------------------. |
1463 | | yyacceptlab -- YYACCEPT comes here. | | 1463 | | yyacceptlab -- YYACCEPT comes here. | |
1464 | `-------------------------------------*/ | 1464 | `-------------------------------------*/ |
1465 | yyacceptlab: | 1465 | yyacceptlab: |
1466 | yyresult = 0; | 1466 | yyresult = 0; |
1467 | goto yyreturn; | 1467 | goto yyreturn; |
1468 | 1468 | ||
1469 | /*-----------------------------------. | 1469 | /*-----------------------------------. |
1470 | | yyabortlab -- YYABORT comes here. | | 1470 | | yyabortlab -- YYABORT comes here. | |
1471 | `-----------------------------------*/ | 1471 | `-----------------------------------*/ |
1472 | yyabortlab: | 1472 | yyabortlab: |
1473 | yyresult = 1; | 1473 | yyresult = 1; |
1474 | goto yyreturn; | 1474 | goto yyreturn; |
1475 | 1475 | ||
1476 | /*---------------------------------------------. | 1476 | /*---------------------------------------------. |
1477 | | yyoverflowab -- parser overflow comes here. | | 1477 | | yyoverflowab -- parser overflow comes here. | |
1478 | `---------------------------------------------*/ | 1478 | `---------------------------------------------*/ |
1479 | yyoverflowlab: | 1479 | yyoverflowlab: |
1480 | yyerror ("parser stack overflow"); | 1480 | yyerror ("parser stack overflow"); |
1481 | yyresult = 2; | 1481 | yyresult = 2; |
1482 | /* Fall through. */ | 1482 | /* Fall through. */ |
1483 | 1483 | ||
1484 | yyreturn: | 1484 | yyreturn: |
1485 | #ifndef yyoverflow | 1485 | #ifndef yyoverflow |
1486 | if (yyss != yyssa) | 1486 | if (yyss != yyssa) |
1487 | YYSTACK_FREE (yyss); | 1487 | YYSTACK_FREE (yyss); |
1488 | #endif | 1488 | #endif |
1489 | return yyresult; | 1489 | return yyresult; |
1490 | } | 1490 | } |
1491 | #line 373 "vcc.y" | 1491 | #line 373 "vcc.y" |
1492 | 1492 | ||
1493 | static int pushVObject(const char *prop) | 1493 | static int pushVObject(const char *prop) |
1494 | { | 1494 | { |
1495 | VObject *newObj; | 1495 | VObject *newObj; |
1496 | if (ObjStackTop == MAXLEVEL) | 1496 | if (ObjStackTop == MAXLEVEL) |
1497 | return FALSE; | 1497 | return FALSE; |
1498 | 1498 | ||
1499 | ObjStack[++ObjStackTop] = curObj; | 1499 | ObjStack[++ObjStackTop] = curObj; |
1500 | 1500 | ||
1501 | if (curObj) { | 1501 | if (curObj) { |
1502 | newObj = addProp(curObj,prop); | 1502 | newObj = addProp(curObj,prop); |
1503 | curObj = newObj; | 1503 | curObj = newObj; |
1504 | } | 1504 | } |
1505 | else | 1505 | else |
1506 | curObj = newVObject(prop); | 1506 | curObj = newVObject(prop); |
1507 | 1507 | ||
1508 | return TRUE; | 1508 | return TRUE; |
1509 | } | 1509 | } |
1510 | 1510 | ||
1511 | 1511 | ||
1512 | /* This pops the recently built vCard off the stack and returns it. */ | 1512 | /* This pops the recently built vCard off the stack and returns it. */ |
1513 | static VObject* popVObject() | 1513 | static VObject* popVObject() |
1514 | { | 1514 | { |
1515 | VObject *oldObj; | 1515 | VObject *oldObj; |
1516 | if (ObjStackTop < 0) { | 1516 | if (ObjStackTop < 0) { |
1517 | yyerror("pop on empty Object Stack\n"); | 1517 | yyerror("pop on empty Object Stack\n"); |
1518 | return 0; | 1518 | return 0; |
1519 | } | 1519 | } |
1520 | oldObj = curObj; | 1520 | oldObj = curObj; |
1521 | curObj = ObjStack[ObjStackTop--]; | 1521 | curObj = ObjStack[ObjStackTop--]; |
1522 | 1522 | ||
1523 | return oldObj; | 1523 | return oldObj; |
1524 | } | 1524 | } |
1525 | 1525 | ||
1526 | 1526 | ||
1527 | static void enterValues(const char *value) | 1527 | static void enterValues(const char *value) |
1528 | { | 1528 | { |
1529 | if (fieldedProp && *fieldedProp) { | 1529 | if (fieldedProp && *fieldedProp) { |
1530 | if (value) { | 1530 | if (value) { |
1531 | addPropValue(curProp,*fieldedProp,value); | 1531 | addPropValue(curProp,*fieldedProp,value); |
1532 | } | 1532 | } |
1533 | /* else this field is empty, advance to next field */ | 1533 | /* else this field is empty, advance to next field */ |
1534 | fieldedProp++; | 1534 | fieldedProp++; |
1535 | } | 1535 | } |
1536 | else { | 1536 | else { |
1537 | if (value) { | 1537 | if (value) { |
1538 | char *p1, *p2; | 1538 | char *p1, *p2; |
1539 | wchar_t *p3; | 1539 | wchar_t *p3; |
1540 | int i; | 1540 | int i; |
1541 | 1541 | ||
1542 | /* If the property already has a string value, we append this one, | 1542 | /* If the property already has a string value, we append this one, |
1543 | using ';' to separate the values. */ | 1543 | using ';' to separate the values. */ |
1544 | if (vObjectUStringZValue(curProp)) { | 1544 | if (vObjectUStringZValue(curProp)) { |
1545 | p1 = fakeCString(vObjectUStringZValue(curProp)); | 1545 | p1 = fakeCString(vObjectUStringZValue(curProp)); |
1546 | p2 = malloc((strlen(p1)+strlen(value)+1)); | 1546 | p2 = malloc((strlen(p1)+strlen(value)+1)); |
1547 | strcpy(p2, p1); | 1547 | strcpy(p2, p1); |
1548 | deleteStr(p1); | 1548 | deleteStr(p1); |
1549 | 1549 | ||
1550 | i = strlen(p2); | 1550 | i = strlen(p2); |
1551 | p2[i] = ';'; | 1551 | p2[i] = ';'; |
1552 | p2[i+1] = '\0'; | 1552 | p2[i+1] = '\0'; |
1553 | p2 = strcat(p2, value); | 1553 | p2 = strcat(p2, value); |
1554 | p3 = (wchar_t *) vObjectUStringZValue(curProp); | 1554 | p3 = (wchar_t *) vObjectUStringZValue(curProp); |
1555 | free(p3); | 1555 | free(p3); |
1556 | setVObjectUStringZValue_(curProp,fakeUnicode(p2,0)); | 1556 | setVObjectUStringZValue_(curProp,fakeUnicode(p2,0)); |
1557 | deleteStr(p2); | 1557 | deleteStr(p2); |
1558 | } else { | 1558 | } else { |
1559 | setVObjectUStringZValue_(curProp,fakeUnicode(value,0)); | 1559 | setVObjectUStringZValue_(curProp,fakeUnicode(value,0)); |
1560 | } | 1560 | } |
1561 | } | 1561 | } |
1562 | } | 1562 | } |
1563 | deleteStr(value); | 1563 | deleteStr(value); |
1564 | } | 1564 | } |
1565 | 1565 | ||
1566 | static void enterProps(const char *s) | 1566 | static void enterProps(const char *s) |
1567 | { | 1567 | { |
1568 | curProp = addGroup(curObj,s); | 1568 | curProp = addGroup(curObj,s); |
1569 | deleteStr(s); | 1569 | deleteStr(s); |
1570 | } | 1570 | } |
1571 | 1571 | ||
1572 | static void enterAttr(const char *s1, const char *s2) | 1572 | static void enterAttr(const char *s1, const char *s2) |
1573 | { | 1573 | { |
1574 | const char *p1, *p2; | 1574 | const char *p1, *p2; |
1575 | p1 = lookupProp_(s1); | 1575 | p1 = lookupProp_(s1); |
1576 | if (s2) { | 1576 | if (s2) { |
1577 | VObject *a; | 1577 | VObject *a; |
1578 | p2 = lookupProp_(s2); | 1578 | p2 = lookupProp_(s2); |
1579 | a = addProp(curProp,p1); | 1579 | a = addProp(curProp,p1); |
1580 | setVObjectStringZValue(a,p2); | 1580 | setVObjectStringZValue(a,p2); |
1581 | } | 1581 | } |
1582 | else | 1582 | else |
1583 | addProp(curProp,p1); | 1583 | addProp(curProp,p1); |
1584 | if (stricmp(p1,VCBase64Prop) == 0 || (s2 && stricmp(p2,VCBase64Prop)==0)) | 1584 | if (stricmp(p1,VCBase64Prop) == 0 || (s2 && stricmp(p2,VCBase64Prop)==0)) |
1585 | lexPushMode(L_BASE64); | 1585 | lexPushMode(L_BASE64); |
1586 | else if (stricmp(p1,VCQuotedPrintableProp) == 0 | 1586 | else if (stricmp(p1,VCQuotedPrintableProp) == 0 |
1587 | || (s2 && stricmp(p2,VCQuotedPrintableProp)==0)) | 1587 | || (s2 && stricmp(p2,VCQuotedPrintableProp)==0)) |
1588 | lexPushMode(L_QUOTED_PRINTABLE); | 1588 | lexPushMode(L_QUOTED_PRINTABLE); |
1589 | deleteStr(s1); deleteStr(s2); | 1589 | deleteStr(s1); deleteStr(s2); |
1590 | } | 1590 | } |
1591 | 1591 | ||
1592 | 1592 | ||
1593 | #define MAX_LEX_LOOKAHEAD_0 32 | 1593 | #define MAX_LEX_LOOKAHEAD_0 32 |
1594 | #define MAX_LEX_LOOKAHEAD 64 | 1594 | #define MAX_LEX_LOOKAHEAD 64 |
1595 | #define MAX_LEX_MODE_STACK_SIZE 10 | 1595 | #define MAX_LEX_MODE_STACK_SIZE 10 |
1596 | #define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop]) | 1596 | #define LEXMODE() (lexBuf.lexModeStack[lexBuf.lexModeStackTop]) |
1597 | 1597 | ||
1598 | struct LexBuf { | 1598 | struct LexBuf { |
1599 | /* input */ | 1599 | /* input */ |
1600 | #ifdef INCLUDEMFC | 1600 | #ifdef INCLUDEMFC |
1601 | CFile *inputFile; | 1601 | CFile *inputFile; |
1602 | #else | 1602 | #else |
1603 | FILE *inputFile; | 1603 | FILE *inputFile; |
1604 | #endif | 1604 | #endif |
1605 | char *inputString; | 1605 | char *inputString; |
1606 | unsigned long curPos; | 1606 | unsigned long curPos; |
1607 | unsigned long inputLen; | 1607 | unsigned long inputLen; |
1608 | /* lookahead buffer */ | 1608 | /* lookahead buffer */ |
1609 | /* -- lookahead buffer is short instead of char so that EOF | 1609 | /* -- lookahead buffer is short instead of char so that EOF |
1610 | / can be represented correctly. | 1610 | / can be represented correctly. |
1611 | */ | 1611 | */ |
1612 | unsigned long len; | 1612 | unsigned long len; |
1613 | short buf[MAX_LEX_LOOKAHEAD]; | 1613 | short buf[MAX_LEX_LOOKAHEAD]; |
1614 | unsigned long getPtr; | 1614 | unsigned long getPtr; |
1615 | /* context stack */ | 1615 | /* context stack */ |
1616 | unsigned long lexModeStackTop; | 1616 | unsigned long lexModeStackTop; |
1617 | enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE]; | 1617 | enum LexMode lexModeStack[MAX_LEX_MODE_STACK_SIZE]; |
1618 | /* token buffer */ | 1618 | /* token buffer */ |
1619 | unsigned long maxToken; | 1619 | unsigned long maxToken; |
1620 | char *strs; | 1620 | char *strs; |
1621 | unsigned long strsLen; | 1621 | unsigned long strsLen; |
1622 | } lexBuf; | 1622 | } lexBuf; |
1623 | 1623 | ||
1624 | static void lexPushMode(enum LexMode mode) | 1624 | static void lexPushMode(enum LexMode mode) |
1625 | { | 1625 | { |
1626 | if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1)) | 1626 | if (lexBuf.lexModeStackTop == (MAX_LEX_MODE_STACK_SIZE-1)) |
1627 | yyerror("lexical context stack overflow"); | 1627 | yyerror("lexical context stack overflow"); |
1628 | else { | 1628 | else { |
1629 | lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode; | 1629 | lexBuf.lexModeStack[++lexBuf.lexModeStackTop] = mode; |
1630 | } | 1630 | } |
1631 | } | 1631 | } |
1632 | 1632 | ||
1633 | static void lexPopMode(int top) | 1633 | static void lexPopMode(int top) |
1634 | { | 1634 | { |
1635 | /* special case of pop for ease of error recovery -- this | 1635 | /* special case of pop for ease of error recovery -- this |
1636 | version will never underflow */ | 1636 | version will never underflow */ |
1637 | if (top) | 1637 | if (top) |
1638 | lexBuf.lexModeStackTop = 0; | 1638 | lexBuf.lexModeStackTop = 0; |
1639 | else | 1639 | else |
1640 | if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--; | 1640 | if (lexBuf.lexModeStackTop > 0) lexBuf.lexModeStackTop--; |
1641 | } | 1641 | } |
1642 | 1642 | ||
1643 | static int lexWithinMode(enum LexMode mode) { | 1643 | static int lexWithinMode(enum LexMode mode) { |
1644 | unsigned long i; | 1644 | unsigned long i; |
1645 | for (i=0;i<lexBuf.lexModeStackTop;i++) | 1645 | for (i=0;i<lexBuf.lexModeStackTop;i++) |
1646 | if (mode == lexBuf.lexModeStack[i]) return 1; | 1646 | if (mode == lexBuf.lexModeStack[i]) return 1; |
1647 | return 0; | 1647 | return 0; |
1648 | } | 1648 | } |
1649 | 1649 | ||
1650 | static char lexGetc_() | 1650 | static char lexGetc_() |
1651 | { | 1651 | { |
1652 | /* get next char from input, no buffering. */ | 1652 | /* get next char from input, no buffering. */ |
1653 | if (lexBuf.curPos == lexBuf.inputLen) | 1653 | if (lexBuf.curPos == lexBuf.inputLen) |
1654 | return EOF; | 1654 | return EOF; |
1655 | else if (lexBuf.inputString) | 1655 | else if (lexBuf.inputString) |
1656 | return *(lexBuf.inputString + lexBuf.curPos++); | 1656 | return *(lexBuf.inputString + lexBuf.curPos++); |
1657 | else { | 1657 | else { |
1658 | #ifdef INCLUDEMFC | 1658 | #ifdef INCLUDEMFC |
1659 | char result; | 1659 | char result; |
1660 | return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF; | 1660 | return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF; |
1661 | #else | 1661 | #else |
1662 | return fgetc(lexBuf.inputFile); | 1662 | return fgetc(lexBuf.inputFile); |
1663 | #endif | 1663 | #endif |
1664 | } | 1664 | } |
1665 | } | 1665 | } |
1666 | 1666 | ||
1667 | static int lexGeta() | 1667 | static int lexGeta() |
1668 | { | 1668 | { |
1669 | ++lexBuf.len; | 1669 | ++lexBuf.len; |
1670 | return (lexBuf.buf[lexBuf.getPtr] = lexGetc_()); | 1670 | return (lexBuf.buf[lexBuf.getPtr] = lexGetc_()); |
1671 | } | 1671 | } |
1672 | 1672 | ||
1673 | static int lexGeta_(int i) | 1673 | static int lexGeta_(int i) |
1674 | { | 1674 | { |
1675 | ++lexBuf.len; | 1675 | ++lexBuf.len; |
1676 | return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_()); | 1676 | return (lexBuf.buf[(lexBuf.getPtr+i)%MAX_LEX_LOOKAHEAD] = lexGetc_()); |
1677 | } | 1677 | } |
1678 | 1678 | ||
1679 | static void lexSkipLookahead() { | 1679 | static void lexSkipLookahead() { |
1680 | if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { | 1680 | if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { |
1681 | /* don't skip EOF. */ | 1681 | /* don't skip EOF. */ |
1682 | lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; | 1682 | lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; |
1683 | lexBuf.len--; | 1683 | lexBuf.len--; |
1684 | } | 1684 | } |
1685 | } | 1685 | } |
1686 | 1686 | ||
1687 | static int lexLookahead() { | 1687 | static int lexLookahead() { |
1688 | int c = (lexBuf.len)? | 1688 | int c = (lexBuf.len)? |
1689 | lexBuf.buf[lexBuf.getPtr]: | 1689 | lexBuf.buf[lexBuf.getPtr]: |
1690 | lexGeta(); | 1690 | lexGeta(); |
1691 | /* do the \r\n -> \n or \r -> \n translation here */ | 1691 | /* do the \r\n -> \n or \r -> \n translation here */ |
1692 | if (c == '\r') { | 1692 | if (c == '\r') { |
1693 | int a = (lexBuf.len>1)? | 1693 | int a = (lexBuf.len>1)? |
1694 | lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]: | 1694 | lexBuf.buf[(lexBuf.getPtr+1)%MAX_LEX_LOOKAHEAD]: |
1695 | lexGeta_(1); | 1695 | lexGeta_(1); |
1696 | if (a == '\n') { | 1696 | if (a == '\n') { |
1697 | lexSkipLookahead(); | 1697 | lexSkipLookahead(); |
1698 | } | 1698 | } |
1699 | lexBuf.buf[lexBuf.getPtr] = c = '\n'; | 1699 | lexBuf.buf[lexBuf.getPtr] = c = '\n'; |
1700 | } | 1700 | } |
1701 | else if (c == '\n') { | 1701 | else if (c == '\n') { |
1702 | int a = (lexBuf.len>1)? | 1702 | int a = (lexBuf.len>1)? |
1703 | lexBuf.buf[lexBuf.getPtr+1]: | 1703 | lexBuf.buf[lexBuf.getPtr+1]: |
1704 | lexGeta_(1); | 1704 | lexGeta_(1); |
1705 | if (a == '\r') { | 1705 | if (a == '\r') { |
1706 | lexSkipLookahead(); | 1706 | lexSkipLookahead(); |
1707 | } | 1707 | } |
1708 | lexBuf.buf[lexBuf.getPtr] = '\n'; | 1708 | lexBuf.buf[lexBuf.getPtr] = '\n'; |
1709 | } | 1709 | } |
1710 | return c; | 1710 | return c; |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | static int lexGetc() { | 1713 | static int lexGetc() { |
1714 | int c = lexLookahead(); | 1714 | int c = lexLookahead(); |
1715 | if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { | 1715 | if (lexBuf.len > 0 && lexBuf.buf[lexBuf.getPtr]!=EOF) { |
1716 | /* EOF will remain in lookahead buffer */ | 1716 | /* EOF will remain in lookahead buffer */ |
1717 | lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; | 1717 | lexBuf.getPtr = (lexBuf.getPtr + 1) % MAX_LEX_LOOKAHEAD; |
1718 | lexBuf.len--; | 1718 | lexBuf.len--; |
1719 | } | 1719 | } |
1720 | return c; | 1720 | return c; |
1721 | } | 1721 | } |
1722 | 1722 | ||
1723 | static void lexSkipLookaheadWord() { | 1723 | static void lexSkipLookaheadWord() { |
1724 | if (lexBuf.strsLen <= lexBuf.len) { | 1724 | if (lexBuf.strsLen <= lexBuf.len) { |
1725 | lexBuf.len -= lexBuf.strsLen; | 1725 | lexBuf.len -= lexBuf.strsLen; |
1726 | lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD; | 1726 | lexBuf.getPtr = (lexBuf.getPtr + lexBuf.strsLen) % MAX_LEX_LOOKAHEAD; |
1727 | } | 1727 | } |
1728 | } | 1728 | } |
1729 | 1729 | ||
1730 | static void lexClearToken() | 1730 | static void lexClearToken() |
1731 | { | 1731 | { |
1732 | lexBuf.strsLen = 0; | 1732 | lexBuf.strsLen = 0; |
1733 | } | 1733 | } |
1734 | 1734 | ||
1735 | static void lexAppendc(int c) | 1735 | static void lexAppendc(int c) |
1736 | { | 1736 | { |
1737 | lexBuf.strs[lexBuf.strsLen] = c; | 1737 | lexBuf.strs[lexBuf.strsLen] = c; |
1738 | /* append up to zero termination */ | 1738 | /* append up to zero termination */ |
1739 | if (c == 0) return; | 1739 | if (c == 0) return; |
1740 | lexBuf.strsLen++; | 1740 | lexBuf.strsLen++; |
1741 | if (lexBuf.strsLen > lexBuf.maxToken) { | 1741 | if (lexBuf.strsLen > lexBuf.maxToken) { |
1742 | /* double the token string size */ | 1742 | /* double the token string size */ |
1743 | lexBuf.maxToken <<= 1; | 1743 | lexBuf.maxToken <<= 1; |
1744 | lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken); | 1744 | lexBuf.strs = (char*) realloc(lexBuf.strs,(size_t)lexBuf.maxToken); |
1745 | } | 1745 | } |
1746 | } | 1746 | } |
1747 | 1747 | ||
1748 | static char* lexStr() { | 1748 | static char* lexStr() { |
1749 | return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1); | 1749 | return dupStr(lexBuf.strs,(size_t)lexBuf.strsLen+1); |
1750 | } | 1750 | } |
1751 | 1751 | ||
1752 | static void lexSkipWhite() { | 1752 | static void lexSkipWhite() { |
1753 | int c = lexLookahead(); | 1753 | int c = lexLookahead(); |
1754 | while (c == ' ' || c == '\t') { | 1754 | while (c == ' ' || c == '\t') { |
1755 | lexSkipLookahead(); | 1755 | lexSkipLookahead(); |
1756 | c = lexLookahead(); | 1756 | c = lexLookahead(); |
1757 | } | 1757 | } |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | static char* lexGetWord() { | 1760 | static char* lexGetWord() { |
1761 | int c; | 1761 | int c; |
1762 | lexSkipWhite(); | 1762 | lexSkipWhite(); |
1763 | lexClearToken(); | 1763 | lexClearToken(); |
1764 | c = lexLookahead(); | 1764 | c = lexLookahead(); |
1765 | while (c != EOF && !strchr("\t\n ;:=",c)) { | 1765 | // LR while (c != EOF && !strchr("\t\n ;:=",c)) { |
1766 | while (c != EOF && !strchr("\t\n;:=",c)) { | ||
1766 | lexAppendc(c); | 1767 | lexAppendc(c); |
1767 | lexSkipLookahead(); | 1768 | lexSkipLookahead(); |
1768 | c = lexLookahead(); | 1769 | c = lexLookahead(); |
1769 | } | 1770 | } |
1770 | lexAppendc(0); | 1771 | lexAppendc(0); |
1771 | return lexStr(); | 1772 | return lexStr(); |
1772 | } | 1773 | } |
1773 | 1774 | ||
1774 | static void lexPushLookaheadc(int c) { | 1775 | static void lexPushLookaheadc(int c) { |
1775 | int putptr; | 1776 | int putptr; |
1776 | /* can't putback EOF, because it never leaves lookahead buffer */ | 1777 | /* can't putback EOF, because it never leaves lookahead buffer */ |
1777 | if (c == EOF) return; | 1778 | if (c == EOF) return; |
1778 | putptr = (int)lexBuf.getPtr - 1; | 1779 | putptr = (int)lexBuf.getPtr - 1; |
1779 | if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; | 1780 | if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; |
1780 | lexBuf.getPtr = putptr; | 1781 | lexBuf.getPtr = putptr; |
1781 | lexBuf.buf[putptr] = c; | 1782 | lexBuf.buf[putptr] = c; |
1782 | lexBuf.len += 1; | 1783 | lexBuf.len += 1; |
1783 | } | 1784 | } |
1784 | 1785 | ||
1785 | static char* lexLookaheadWord() { | 1786 | static char* lexLookaheadWord() { |
1786 | /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0 | 1787 | /* this function can lookahead word with max size of MAX_LEX_LOOKAHEAD_0 |
1787 | / and thing bigger than that will stop the lookahead and return 0; | 1788 | / and thing bigger than that will stop the lookahead and return 0; |
1788 | / leading white spaces are not recoverable. | 1789 | / leading white spaces are not recoverable. |
1789 | */ | 1790 | */ |
1790 | int c; | 1791 | int c; |
1791 | int len = 0; | 1792 | int len = 0; |
1792 | int curgetptr = 0; | 1793 | int curgetptr = 0; |
1793 | lexSkipWhite(); | 1794 | lexSkipWhite(); |
1794 | lexClearToken(); | 1795 | lexClearToken(); |
1795 | curgetptr = (int)lexBuf.getPtr;/* remember! */ | 1796 | curgetptr = (int)lexBuf.getPtr;/* remember! */ |
1796 | while (len < (MAX_LEX_LOOKAHEAD_0)) { | 1797 | while (len < (MAX_LEX_LOOKAHEAD_0)) { |
1797 | c = lexGetc(); | 1798 | c = lexGetc(); |
1798 | len++; | 1799 | len++; |
1799 | if (c == EOF || strchr("\t\n ;:=", c)) { | 1800 | if (c == EOF || strchr("\t\n ;:=", c)) { |
1800 | lexAppendc(0); | 1801 | lexAppendc(0); |
1801 | /* restore lookahead buf. */ | 1802 | /* restore lookahead buf. */ |
1802 | lexBuf.len += len; | 1803 | lexBuf.len += len; |
1803 | lexBuf.getPtr = curgetptr; | 1804 | lexBuf.getPtr = curgetptr; |
1804 | return lexStr(); | 1805 | return lexStr(); |
1805 | } | 1806 | } |
1806 | else | 1807 | else |
1807 | lexAppendc(c); | 1808 | lexAppendc(c); |
1808 | } | 1809 | } |
1809 | lexBuf.len += len;/* char that has been moved to lookahead buffer */ | 1810 | lexBuf.len += len;/* char that has been moved to lookahead buffer */ |
1810 | lexBuf.getPtr = curgetptr; | 1811 | lexBuf.getPtr = curgetptr; |
1811 | return 0; | 1812 | return 0; |
1812 | } | 1813 | } |
1813 | 1814 | ||
1814 | #ifdef _SUPPORT_LINE_FOLDING | 1815 | #ifdef _SUPPORT_LINE_FOLDING |
1815 | static void handleMoreRFC822LineBreak(int c) { | 1816 | static void handleMoreRFC822LineBreak(int c) { |
1816 | /* suport RFC 822 line break in cases like | 1817 | /* suport RFC 822 line break in cases like |
1817 | *ADR: foo; | 1818 | *ADR: foo; |
1818 | * morefoo; | 1819 | * morefoo; |
1819 | * more foo; | 1820 | * more foo; |
1820 | */ | 1821 | */ |
1821 | if (c == ';') { | 1822 | if (c == ';') { |
1822 | int a; | 1823 | int a; |
1823 | lexSkipLookahead(); | 1824 | lexSkipLookahead(); |
1824 | /* skip white spaces */ | 1825 | /* skip white spaces */ |
1825 | a = lexLookahead(); | 1826 | a = lexLookahead(); |
1826 | while (a == ' ' || a == '\t') { | 1827 | while (a == ' ' || a == '\t') { |
1827 | lexSkipLookahead(); | 1828 | lexSkipLookahead(); |
1828 | a = lexLookahead(); | 1829 | a = lexLookahead(); |
1829 | } | 1830 | } |
1830 | if (a == '\n') { | 1831 | if (a == '\n') { |
1831 | lexSkipLookahead(); | 1832 | lexSkipLookahead(); |
1832 | a = lexLookahead(); | 1833 | a = lexLookahead(); |
1833 | if (a == ' ' || a == '\t') { | 1834 | if (a == ' ' || a == '\t') { |
1834 | /* continuation, throw away all the \n and spaces read so | 1835 | /* continuation, throw away all the \n and spaces read so |
1835 | * far | 1836 | * far |
1836 | */ | 1837 | */ |
1837 | lexSkipWhite(); | 1838 | lexSkipWhite(); |
1838 | lexPushLookaheadc(';'); | 1839 | lexPushLookaheadc(';'); |
1839 | } | 1840 | } |
1840 | else { | 1841 | else { |
1841 | lexPushLookaheadc('\n'); | 1842 | lexPushLookaheadc('\n'); |
1842 | lexPushLookaheadc(';'); | 1843 | lexPushLookaheadc(';'); |
1843 | } | 1844 | } |
1844 | } | 1845 | } |
1845 | else { | 1846 | else { |
1846 | lexPushLookaheadc(';'); | 1847 | lexPushLookaheadc(';'); |
1847 | } | 1848 | } |
1848 | } | 1849 | } |
1849 | } | 1850 | } |
1850 | 1851 | ||
1851 | static char* lexGet1Value() { | 1852 | static char* lexGet1Value() { |
1852 | int c; | 1853 | int c; |
1853 | lexSkipWhite(); | 1854 | lexSkipWhite(); |
1854 | c = lexLookahead(); | 1855 | c = lexLookahead(); |
1855 | lexClearToken(); | 1856 | lexClearToken(); |
1856 | while (c != EOF && c != ';') { | 1857 | while (c != EOF && c != ';') { |
1857 | if (c == '\n') { | 1858 | if (c == '\n') { |
1858 | int a; | 1859 | int a; |
1859 | lexSkipLookahead(); | 1860 | lexSkipLookahead(); |
1860 | a = lexLookahead(); | 1861 | a = lexLookahead(); |
1861 | if (a == ' ' || a == '\t') { | 1862 | if (a == ' ' || a == '\t') { |
1862 | lexAppendc(' '); | 1863 | lexAppendc(' '); |
1863 | lexSkipLookahead(); | 1864 | lexSkipLookahead(); |
1864 | } | 1865 | } |
1865 | else { | 1866 | else { |
1866 | lexPushLookaheadc('\n'); | 1867 | lexPushLookaheadc('\n'); |
1867 | break; | 1868 | break; |
1868 | } | 1869 | } |
1869 | } | 1870 | } |
1870 | else { | 1871 | else { |
1871 | lexAppendc(c); | 1872 | lexAppendc(c); |
1872 | lexSkipLookahead(); | 1873 | lexSkipLookahead(); |
1873 | } | 1874 | } |
1874 | c = lexLookahead(); | 1875 | c = lexLookahead(); |
1875 | } | 1876 | } |
1876 | lexAppendc(0); | 1877 | lexAppendc(0); |
1877 | handleMoreRFC822LineBreak(c); | 1878 | handleMoreRFC822LineBreak(c); |
1878 | return c==EOF?0:lexStr(); | 1879 | return c==EOF?0:lexStr(); |
1879 | } | 1880 | } |
1880 | #endif | 1881 | #endif |
1881 | 1882 | ||
1882 | 1883 | ||
1883 | static int match_begin_name(int end) { | 1884 | static int match_begin_name(int end) { |
1884 | char *n = lexLookaheadWord(); | 1885 | char *n = lexLookaheadWord(); |
1885 | int token = ID; | 1886 | int token = ID; |
1886 | if (n) { | 1887 | if (n) { |
1887 | if (!stricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD; | 1888 | if (!stricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD; |
1888 | else if (!stricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL; | 1889 | else if (!stricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL; |
1889 | else if (!stricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT; | 1890 | else if (!stricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT; |
1890 | else if (!stricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO; | 1891 | else if (!stricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO; |
1891 | deleteStr(n); | 1892 | deleteStr(n); |
1892 | return token; | 1893 | return token; |
1893 | } | 1894 | } |
1894 | return 0; | 1895 | return 0; |
1895 | } | 1896 | } |
1896 | 1897 | ||
1897 | 1898 | ||
1898 | #ifdef INCLUDEMFC | 1899 | #ifdef INCLUDEMFC |
1899 | void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile) | 1900 | void initLex(const char *inputstring, unsigned long inputlen, CFile *inputfile) |
1900 | #else | 1901 | #else |
1901 | void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) | 1902 | void initLex(const char *inputstring, unsigned long inputlen, FILE *inputfile) |
1902 | #endif | 1903 | #endif |
1903 | { | 1904 | { |
1904 | /* initialize lex mode stack */ | 1905 | /* initialize lex mode stack */ |
1905 | lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL; | 1906 | lexBuf.lexModeStack[lexBuf.lexModeStackTop=0] = L_NORMAL; |
1906 | 1907 | ||
1907 | /* iniatialize lex buffer. */ | 1908 | /* iniatialize lex buffer. */ |
1908 | lexBuf.inputString = (char*) inputstring; | 1909 | lexBuf.inputString = (char*) inputstring; |
1909 | lexBuf.inputLen = inputlen; | 1910 | lexBuf.inputLen = inputlen; |
1910 | lexBuf.curPos = 0; | 1911 | lexBuf.curPos = 0; |
1911 | lexBuf.inputFile = inputfile; | 1912 | lexBuf.inputFile = inputfile; |
1912 | 1913 | ||
1913 | lexBuf.len = 0; | 1914 | lexBuf.len = 0; |
1914 | lexBuf.getPtr = 0; | 1915 | lexBuf.getPtr = 0; |
1915 | 1916 | ||
1916 | lexBuf.maxToken = MAXTOKEN; | 1917 | lexBuf.maxToken = MAXTOKEN; |
1917 | lexBuf.strs = (char*)malloc(MAXTOKEN); | 1918 | lexBuf.strs = (char*)malloc(MAXTOKEN); |
1918 | lexBuf.strsLen = 0; | 1919 | lexBuf.strsLen = 0; |
1919 | 1920 | ||
1920 | } | 1921 | } |
1921 | 1922 | ||
1922 | static void finiLex() { | 1923 | static void finiLex() { |
1923 | free(lexBuf.strs); | 1924 | free(lexBuf.strs); |
1924 | } | 1925 | } |
1925 | 1926 | ||
1926 | 1927 | ||
1927 | /* This parses and converts the base64 format for binary encoding into | 1928 | /* This parses and converts the base64 format for binary encoding into |
1928 | * a decoded buffer (allocated with new). See RFC 1521. | 1929 | * a decoded buffer (allocated with new). See RFC 1521. |
1929 | */ | 1930 | */ |
1930 | static char * lexGetDataFromBase64() | 1931 | static char * lexGetDataFromBase64() |
1931 | { | 1932 | { |
1932 | unsigned long bytesLen = 0, bytesMax = 0; | 1933 | unsigned long bytesLen = 0, bytesMax = 0; |
1933 | int quadIx = 0, pad = 0; | 1934 | int quadIx = 0, pad = 0; |
1934 | unsigned long trip = 0; | 1935 | unsigned long trip = 0; |
1935 | unsigned char b; | 1936 | unsigned char b; |
1936 | int c; | 1937 | int c; |
1937 | unsigned char *bytes = NULL; | 1938 | unsigned char *bytes = NULL; |
1938 | unsigned char *oldBytes = NULL; | 1939 | unsigned char *oldBytes = NULL; |
1939 | 1940 | ||
1940 | DBG_(("db: lexGetDataFromBase64\n")); | 1941 | DBG_(("db: lexGetDataFromBase64\n")); |
1941 | while (1) { | 1942 | while (1) { |
1942 | c = lexGetc(); | 1943 | c = lexGetc(); |
1943 | if (c == '\n') { | 1944 | if (c == '\n') { |
1944 | ++mime_lineNum; | 1945 | ++mime_lineNum; |
1945 | if (lexLookahead() == '\n') { | 1946 | if (lexLookahead() == '\n') { |
1946 | /* a '\n' character by itself means end of data */ | 1947 | /* a '\n' character by itself means end of data */ |
1947 | break; | 1948 | break; |
1948 | } | 1949 | } |
1949 | else continue; /* ignore '\n' */ | 1950 | else continue; /* ignore '\n' */ |
1950 | } | 1951 | } |
1951 | else { | 1952 | else { |
1952 | if ((c >= 'A') && (c <= 'Z')) | 1953 | if ((c >= 'A') && (c <= 'Z')) |
1953 | b = (unsigned char)(c - 'A'); | 1954 | b = (unsigned char)(c - 'A'); |
1954 | else if ((c >= 'a') && (c <= 'z')) | 1955 | else if ((c >= 'a') && (c <= 'z')) |
1955 | b = (unsigned char)(c - 'a') + 26; | 1956 | b = (unsigned char)(c - 'a') + 26; |
1956 | else if ((c >= '0') && (c <= '9')) | 1957 | else if ((c >= '0') && (c <= '9')) |
1957 | b = (unsigned char)(c - '0') + 52; | 1958 | b = (unsigned char)(c - '0') + 52; |
1958 | else if (c == '+') | 1959 | else if (c == '+') |
1959 | b = 62; | 1960 | b = 62; |
1960 | else if (c == '/') | 1961 | else if (c == '/') |
1961 | b = 63; | 1962 | b = 63; |
1962 | else if (c == '=') { | 1963 | else if (c == '=') { |
1963 | b = 0; | 1964 | b = 0; |
1964 | pad++; | 1965 | pad++; |
1965 | } else if ((c == ' ') || (c == '\t')) { | 1966 | } else if ((c == ' ') || (c == '\t')) { |
1966 | continue; | 1967 | continue; |
1967 | } else { /* error condition */ | 1968 | } else { /* error condition */ |
1968 | if (bytes) free(bytes); | 1969 | if (bytes) free(bytes); |
1969 | else if (oldBytes) free(oldBytes); | 1970 | else if (oldBytes) free(oldBytes); |
1970 | /* error recovery: skip until 2 adjacent newlines. */ | 1971 | /* error recovery: skip until 2 adjacent newlines. */ |
1971 | DBG_(("db: invalid character 0x%x '%c'\n", c,c)); | 1972 | DBG_(("db: invalid character 0x%x '%c'\n", c,c)); |
1972 | if (c != EOF) { | 1973 | if (c != EOF) { |
1973 | c = lexGetc(); | 1974 | c = lexGetc(); |
1974 | while (c != EOF) { | 1975 | while (c != EOF) { |
1975 | if (c == '\n' && lexLookahead() == '\n') { | 1976 | if (c == '\n' && lexLookahead() == '\n') { |
1976 | ++mime_lineNum; | 1977 | ++mime_lineNum; |
1977 | break; | 1978 | break; |
1978 | } | 1979 | } |
1979 | c = lexGetc(); | 1980 | c = lexGetc(); |
1980 | } | 1981 | } |
1981 | } | 1982 | } |
1982 | return NULL; | 1983 | return NULL; |
1983 | } | 1984 | } |
1984 | trip = (trip << 6) | b; | 1985 | trip = (trip << 6) | b; |
1985 | if (++quadIx == 4) { | 1986 | if (++quadIx == 4) { |
1986 | unsigned char outBytes[3]; | 1987 | unsigned char outBytes[3]; |
1987 | int numOut; | 1988 | int numOut; |
1988 | int i; | 1989 | int i; |
1989 | for (i = 0; i < 3; i++) { | 1990 | for (i = 0; i < 3; i++) { |
1990 | outBytes[2-i] = (unsigned char)(trip & 0xFF); | 1991 | outBytes[2-i] = (unsigned char)(trip & 0xFF); |
1991 | trip >>= 8; | 1992 | trip >>= 8; |
1992 | } | 1993 | } |
1993 | numOut = 3 - pad; | 1994 | numOut = 3 - pad; |
1994 | if (bytesLen + numOut > bytesMax) { | 1995 | if (bytesLen + numOut > bytesMax) { |
1995 | if (!bytes) { | 1996 | if (!bytes) { |
1996 | bytesMax = 1024; | 1997 | bytesMax = 1024; |
1997 | bytes = (unsigned char*)malloc((size_t)bytesMax); | 1998 | bytes = (unsigned char*)malloc((size_t)bytesMax); |
1998 | } | 1999 | } |
1999 | else { | 2000 | else { |
2000 | bytesMax <<= 2; | 2001 | bytesMax <<= 2; |
2001 | oldBytes = bytes; | 2002 | oldBytes = bytes; |
2002 | bytes = (unsigned char*)realloc(bytes,(size_t)bytesMax); | 2003 | bytes = (unsigned char*)realloc(bytes,(size_t)bytesMax); |
2003 | } | 2004 | } |
2004 | if (bytes == 0) { | 2005 | if (bytes == 0) { |
2005 | mime_error("out of memory while processing BASE64 data\n"); | 2006 | mime_error("out of memory while processing BASE64 data\n"); |
2006 | } | 2007 | } |
2007 | } | 2008 | } |
2008 | if (bytes) { | 2009 | if (bytes) { |
2009 | memcpy(bytes + bytesLen, outBytes, numOut); | 2010 | memcpy(bytes + bytesLen, outBytes, numOut); |
2010 | bytesLen += numOut; | 2011 | bytesLen += numOut; |
2011 | } | 2012 | } |
2012 | trip = 0; | 2013 | trip = 0; |
2013 | quadIx = 0; | 2014 | quadIx = 0; |
2014 | } | 2015 | } |
2015 | } | 2016 | } |
2016 | } /* while */ | 2017 | } /* while */ |
2017 | DBG_(("db: bytesLen = %d\n", bytesLen)); | 2018 | DBG_(("db: bytesLen = %d\n", bytesLen)); |
2018 | /* kludge: all this won't be necessary if we have tree form | 2019 | /* kludge: all this won't be necessary if we have tree form |
2019 | representation */ | 2020 | representation */ |
2020 | if (bytes) { | 2021 | if (bytes) { |
2021 | setValueWithSize(curProp,bytes,(unsigned int)bytesLen); | 2022 | setValueWithSize(curProp,bytes,(unsigned int)bytesLen); |
2022 | free(bytes); | 2023 | free(bytes); |
2023 | } | 2024 | } |
2024 | else if (oldBytes) { | 2025 | else if (oldBytes) { |
2025 | setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen); | 2026 | setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen); |
2026 | free(oldBytes); | 2027 | free(oldBytes); |
2027 | } | 2028 | } |
2028 | return 0; | 2029 | return 0; |
2029 | } | 2030 | } |
2030 | 2031 | ||
2031 | static int match_begin_end_name(int end) { | 2032 | static int match_begin_end_name(int end) { |
2032 | int token; | 2033 | int token; |
2033 | lexSkipWhite(); | 2034 | lexSkipWhite(); |
2034 | if (lexLookahead() != ':') return ID; | 2035 | if (lexLookahead() != ':') return ID; |
2035 | lexSkipLookahead(); | 2036 | lexSkipLookahead(); |
2036 | lexSkipWhite(); | 2037 | lexSkipWhite(); |
2037 | token = match_begin_name(end); | 2038 | token = match_begin_name(end); |
2038 | if (token == ID) { | 2039 | if (token == ID) { |
2039 | lexPushLookaheadc(':'); | 2040 | lexPushLookaheadc(':'); |
2040 | DBG_(("db: ID '%s'\n", yylval.str)); | 2041 | DBG_(("db: ID '%s'\n", yylval.str)); |
2041 | return ID; | 2042 | return ID; |
2042 | } | 2043 | } |
2043 | else if (token != 0) { | 2044 | else if (token != 0) { |
2044 | lexSkipLookaheadWord(); | 2045 | lexSkipLookaheadWord(); |
2045 | deleteStr(yylval.str); | 2046 | deleteStr(yylval.str); |
2046 | DBG_(("db: begin/end %d\n", token)); | 2047 | DBG_(("db: begin/end %d\n", token)); |
2047 | return token; | 2048 | return token; |
2048 | } | 2049 | } |
2049 | return 0; | 2050 | return 0; |
2050 | } | 2051 | } |
2051 | 2052 | ||
2052 | static char* lexGetQuotedPrintable() | 2053 | static char* lexGetQuotedPrintable() |
2053 | { | 2054 | { |
2054 | char cur; | 2055 | char cur; |
2055 | 2056 | ||
2056 | lexClearToken(); | 2057 | lexClearToken(); |
2057 | do { | 2058 | do { |
2058 | cur = lexGetc(); | 2059 | cur = lexGetc(); |
2059 | switch (cur) { | 2060 | switch (cur) { |
2060 | case '=': { | 2061 | case '=': { |
2061 | int c = 0; | 2062 | int c = 0; |
2062 | int next[2]; | 2063 | int next[2]; |
2063 | int i; | 2064 | int i; |
2064 | for (i = 0; i < 2; i++) { | 2065 | for (i = 0; i < 2; i++) { |
2065 | next[i] = lexGetc(); | 2066 | next[i] = lexGetc(); |
2066 | if (next[i] >= '0' && next[i] <= '9') | 2067 | if (next[i] >= '0' && next[i] <= '9') |
2067 | c = c * 16 + next[i] - '0'; | 2068 | c = c * 16 + next[i] - '0'; |
2068 | else if (next[i] >= 'A' && next[i] <= 'F') | 2069 | else if (next[i] >= 'A' && next[i] <= 'F') |
2069 | c = c * 16 + next[i] - 'A' + 10; | 2070 | c = c * 16 + next[i] - 'A' + 10; |
2070 | else | 2071 | else |
2071 | break; | 2072 | break; |
2072 | } | 2073 | } |
2073 | if (i == 0) { | 2074 | if (i == 0) { |
2074 | /* single '=' follow by LINESEP is continuation sign? */ | 2075 | /* single '=' follow by LINESEP is continuation sign? */ |
2075 | if (next[0] == '\n') { | 2076 | if (next[0] == '\n') { |
2076 | ++mime_lineNum; | 2077 | ++mime_lineNum; |
2077 | } | 2078 | } |
2078 | else { | 2079 | else { |
2079 | lexPushLookaheadc('='); | 2080 | lexPushLookaheadc('='); |
2080 | goto EndString; | 2081 | goto EndString; |
2081 | } | 2082 | } |
2082 | } | 2083 | } |
2083 | else if (i == 1) { | 2084 | else if (i == 1) { |
2084 | lexPushLookaheadc(next[1]); | 2085 | lexPushLookaheadc(next[1]); |
2085 | lexPushLookaheadc(next[0]); | 2086 | lexPushLookaheadc(next[0]); |
2086 | lexAppendc('='); | 2087 | lexAppendc('='); |
2087 | } else { | 2088 | } else { |
2088 | lexAppendc(c); | 2089 | lexAppendc(c); |
2089 | } | 2090 | } |
2090 | break; | 2091 | break; |
2091 | } /* '=' */ | 2092 | } /* '=' */ |
2092 | case '\n': { | 2093 | case '\n': { |
2093 | lexPushLookaheadc('\n'); | 2094 | lexPushLookaheadc('\n'); |
2094 | goto EndString; | 2095 | goto EndString; |
2095 | } | 2096 | } |
2096 | case (char)EOF: | 2097 | case (char)EOF: |
2097 | break; | 2098 | break; |
2098 | default: | 2099 | default: |
2099 | lexAppendc(cur); | 2100 | lexAppendc(cur); |
2100 | break; | 2101 | break; |
2101 | } /* switch */ | 2102 | } /* switch */ |
2102 | } while (cur != (char)EOF); | 2103 | } while (cur != (char)EOF); |
2103 | 2104 | ||
2104 | EndString: | 2105 | EndString: |
2105 | lexAppendc(0); | 2106 | lexAppendc(0); |
2106 | return lexStr(); | 2107 | return lexStr(); |
2107 | } /* LexQuotedPrintable */ | 2108 | } /* LexQuotedPrintable */ |
2108 | 2109 | ||
2109 | int yylex() { | 2110 | int yylex() { |
2110 | 2111 | ||
2111 | int lexmode = LEXMODE(); | 2112 | int lexmode = LEXMODE(); |
2112 | if (lexmode == L_VALUES) { | 2113 | if (lexmode == L_VALUES) { |
2113 | int c = lexGetc(); | 2114 | int c = lexGetc(); |
2114 | if (c == ';') { | 2115 | if (c == ';') { |
2115 | DBG_(("db: SEMICOLON\n")); | 2116 | DBG_(("db: SEMICOLON\n")); |
2116 | lexPushLookaheadc(c); | 2117 | lexPushLookaheadc(c); |
2117 | #ifdef _SUPPORT_LINE_FOLDING | 2118 | #ifdef _SUPPORT_LINE_FOLDING |
2118 | handleMoreRFC822LineBreak(c); | 2119 | handleMoreRFC822LineBreak(c); |
2119 | #endif | 2120 | #endif |
2120 | lexSkipLookahead(); | 2121 | lexSkipLookahead(); |
2121 | return SEMICOLON; | 2122 | return SEMICOLON; |
2122 | } | 2123 | } |
2123 | else if (strchr("\n",c)) { | 2124 | else if (strchr("\n",c)) { |
2124 | ++mime_lineNum; | 2125 | ++mime_lineNum; |
2125 | /* consume all line separator(s) adjacent to each other */ | 2126 | /* consume all line separator(s) adjacent to each other */ |
2126 | c = lexLookahead(); | 2127 | c = lexLookahead(); |
2127 | while (strchr("\n",c)) { | 2128 | while (strchr("\n",c)) { |
2128 | lexSkipLookahead(); | 2129 | lexSkipLookahead(); |
2129 | c = lexLookahead(); | 2130 | c = lexLookahead(); |
2130 | ++mime_lineNum; | 2131 | ++mime_lineNum; |
2131 | } | 2132 | } |
2132 | DBG_(("db: LINESEP\n")); | 2133 | DBG_(("db: LINESEP\n")); |
2133 | return LINESEP; | 2134 | return LINESEP; |
2134 | } | 2135 | } |
2135 | else { | 2136 | else { |
2136 | char *p = 0; | 2137 | char *p = 0; |
2137 | lexPushLookaheadc(c); | 2138 | lexPushLookaheadc(c); |
2138 | if (lexWithinMode(L_BASE64)) { | 2139 | if (lexWithinMode(L_BASE64)) { |
2139 | /* get each char and convert to bin on the fly... */ | 2140 | /* get each char and convert to bin on the fly... */ |
2140 | p = lexGetDataFromBase64(); | 2141 | p = lexGetDataFromBase64(); |
2141 | yylval.str = p; | 2142 | yylval.str = p; |
2142 | return STRING; | 2143 | return STRING; |
2143 | } | 2144 | } |
2144 | else if (lexWithinMode(L_QUOTED_PRINTABLE)) { | 2145 | else if (lexWithinMode(L_QUOTED_PRINTABLE)) { |
2145 | p = lexGetQuotedPrintable(); | 2146 | p = lexGetQuotedPrintable(); |
2146 | } | 2147 | } |
2147 | else { | 2148 | else { |
2148 | #ifdef _SUPPORT_LINE_FOLDING | 2149 | #ifdef _SUPPORT_LINE_FOLDING |
2149 | p = lexGet1Value(); | 2150 | p = lexGet1Value(); |
2150 | #else | 2151 | #else |
2151 | p = lexGetStrUntil(";\n"); | 2152 | p = lexGetStrUntil(";\n"); |
2152 | #endif | 2153 | #endif |
2153 | } | 2154 | } |
2154 | if (p) { | 2155 | if (p) { |
2155 | DBG_(("db: STRING: '%s'\n", p)); | 2156 | DBG_(("db: STRING: '%s'\n", p)); |
2156 | yylval.str = p; | 2157 | yylval.str = p; |
2157 | return STRING; | 2158 | return STRING; |
2158 | } | 2159 | } |
2159 | else return 0; | 2160 | else return 0; |
2160 | } | 2161 | } |
2161 | } | 2162 | } |
2162 | else { | 2163 | else { |
2163 | /* normal mode */ | 2164 | /* normal mode */ |
2164 | while (1) { | 2165 | while (1) { |
2165 | int c = lexGetc(); | 2166 | int c = lexGetc(); |
2166 | switch(c) { | 2167 | switch(c) { |
2167 | case ':': { | 2168 | case ':': { |
2168 | /* consume all line separator(s) adjacent to each other */ | 2169 | /* consume all line separator(s) adjacent to each other */ |
2169 | /* ignoring linesep immediately after colon. */ | 2170 | /* ignoring linesep immediately after colon. */ |
2170 | /* c = lexLookahead(); | 2171 | /* c = lexLookahead(); |
2171 | while (strchr("\n",c)) { | 2172 | while (strchr("\n",c)) { |
2172 | lexSkipLookahead(); | 2173 | lexSkipLookahead(); |
2173 | c = lexLookahead(); | 2174 | c = lexLookahead(); |
2174 | ++mime_lineNum; | 2175 | ++mime_lineNum; |
2175 | }*/ | 2176 | }*/ |
2176 | DBG_(("db: COLON\n")); | 2177 | DBG_(("db: COLON\n")); |
2177 | return COLON; | 2178 | return COLON; |
2178 | } | 2179 | } |
2179 | case ';': | 2180 | case ';': |
2180 | DBG_(("db: SEMICOLON\n")); | 2181 | DBG_(("db: SEMICOLON\n")); |
2181 | return SEMICOLON; | 2182 | return SEMICOLON; |
2182 | case '=': | 2183 | case '=': |
2183 | DBG_(("db: EQ\n")); | 2184 | DBG_(("db: EQ\n")); |
2184 | return EQ; | 2185 | return EQ; |
2185 | /* ignore whitespace in this mode */ | 2186 | /* ignore whitespace in this mode */ |
2186 | case '\t': | 2187 | case '\t': |
2187 | case ' ': continue; | 2188 | case ' ': continue; |
2188 | case '\n': { | 2189 | case '\n': { |
2189 | ++mime_lineNum; | 2190 | ++mime_lineNum; |
2190 | continue; | 2191 | continue; |
2191 | } | 2192 | } |
2192 | case EOF: return 0; | 2193 | case EOF: return 0; |
2193 | break; | 2194 | break; |
2194 | default: { | 2195 | default: { |
2195 | lexPushLookaheadc(c); | 2196 | lexPushLookaheadc(c); |
2196 | if (isalpha(c)) { | 2197 | if (isalpha(c)) { |
2197 | char *t = lexGetWord(); | 2198 | char *t = lexGetWord(); |
2198 | yylval.str = t; | 2199 | yylval.str = t; |
2199 | if (!stricmp(t, "begin")) { | 2200 | if (!stricmp(t, "begin")) { |
2200 | return match_begin_end_name(0); | 2201 | return match_begin_end_name(0); |
2201 | } | 2202 | } |
2202 | else if (!stricmp(t,"end")) { | 2203 | else if (!stricmp(t,"end")) { |
2203 | return match_begin_end_name(1); | 2204 | return match_begin_end_name(1); |
2204 | } | 2205 | } |
2205 | else { | 2206 | else { |
2206 | DBG_(("db: ID '%s'\n", t)); | 2207 | DBG_(("db: ID '%s'\n", t)); |
2207 | return ID; | 2208 | return ID; |
2208 | } | 2209 | } |
2209 | } | 2210 | } |
2210 | else { | 2211 | else { |
2211 | /* unknow token */ | 2212 | /* unknow token */ |
2212 | return 0; | 2213 | return 0; |
2213 | } | 2214 | } |
2214 | break; | 2215 | break; |
2215 | } | 2216 | } |
2216 | } | 2217 | } |
2217 | } | 2218 | } |
2218 | } | 2219 | } |
2219 | return 0; | 2220 | return 0; |
2220 | } | 2221 | } |
2221 | 2222 | ||
2222 | 2223 | ||
2223 | /***************************************************************************/ | 2224 | /***************************************************************************/ |
2224 | /*** Public Functions ****/ | 2225 | /*** Public Functions ****/ |
2225 | /***************************************************************************/ | 2226 | /***************************************************************************/ |
2226 | 2227 | ||
2227 | static VObject* Parse_MIMEHelper() | 2228 | static VObject* Parse_MIMEHelper() |
2228 | { | 2229 | { |
2229 | ObjStackTop = -1; | 2230 | ObjStackTop = -1; |
2230 | mime_numErrors = 0; | 2231 | mime_numErrors = 0; |
2231 | mime_lineNum = 1; | 2232 | mime_lineNum = 1; |
2232 | vObjList = 0; | 2233 | vObjList = 0; |
2233 | curObj = 0; | 2234 | curObj = 0; |
2234 | 2235 | ||
2235 | if (yyparse() != 0) | 2236 | if (yyparse() != 0) |
2236 | return 0; | 2237 | return 0; |
2237 | 2238 | ||
2238 | finiLex(); | 2239 | finiLex(); |
2239 | return vObjList; | 2240 | return vObjList; |
2240 | } | 2241 | } |
2241 | 2242 | ||
2242 | DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len) | 2243 | DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len) |
2243 | { | 2244 | { |
2244 | initLex(input, len, 0); | 2245 | initLex(input, len, 0); |
2245 | return Parse_MIMEHelper(); | 2246 | return Parse_MIMEHelper(); |
2246 | } | 2247 | } |
2247 | 2248 | ||
2248 | 2249 | ||
2249 | #if INCLUDEMFC | 2250 | #if INCLUDEMFC |
2250 | 2251 | ||
2251 | DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file) | 2252 | DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file) |
2252 | { | 2253 | { |
2253 | unsigned long startPos; | 2254 | unsigned long startPos; |
2254 | VObject *result; | 2255 | VObject *result; |
2255 | 2256 | ||
2256 | initLex(0,-1,file); | 2257 | initLex(0,-1,file); |
2257 | startPos = file->GetPosition(); | 2258 | startPos = file->GetPosition(); |
2258 | if (!(result = Parse_MIMEHelper())) | 2259 | if (!(result = Parse_MIMEHelper())) |
2259 | file->Seek(startPos, CFile::begin); | 2260 | file->Seek(startPos, CFile::begin); |
2260 | return result; | 2261 | return result; |
2261 | } | 2262 | } |
2262 | 2263 | ||
2263 | #else | 2264 | #else |
2264 | 2265 | ||
2265 | VObject* Parse_MIME_FromFile(FILE *file) | 2266 | VObject* Parse_MIME_FromFile(FILE *file) |
2266 | { | 2267 | { |
2267 | VObject *result; | 2268 | VObject *result; |
2268 | long startPos; | 2269 | long startPos; |
2269 | 2270 | ||
2270 | initLex(0,(unsigned long)-1,file); | 2271 | initLex(0,(unsigned long)-1,file); |
2271 | startPos = ftell(file); | 2272 | startPos = ftell(file); |
2272 | if (!(result = Parse_MIMEHelper())) { | 2273 | if (!(result = Parse_MIMEHelper())) { |
2273 | fseek(file,startPos,SEEK_SET); | 2274 | fseek(file,startPos,SEEK_SET); |
2274 | } | 2275 | } |
2275 | return result; | 2276 | return result; |
2276 | } | 2277 | } |
2277 | 2278 | ||