diff options
Diffstat (limited to 'src/libicalvcal/vcc.y')
-rw-r--r-- | src/libicalvcal/vcc.y | 113 |
1 files changed, 43 insertions, 70 deletions
diff --git a/src/libicalvcal/vcc.y b/src/libicalvcal/vcc.y index 9643e562..b4c81760 100644 --- a/src/libicalvcal/vcc.y +++ b/src/libicalvcal/vcc.y @@ -1,36 +1,10 @@ %{ /*************************************************************************** -(C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International +SPDX-FileCopyrightText: 1996 Apple Computer, Inc., AT&T Corp., International Business Machines Corporation and Siemens Rolm Communications Inc. -For purposes of this license notice, the term Licensors shall mean, -collectively, Apple Computer, Inc., AT&T Corp., International -Business Machines Corporation and Siemens Rolm Communications Inc. -The term Licensor shall mean any of the Licensors. - -Subject to acceptance of the following conditions, permission is hereby -granted by Licensors without the need for written agreement and without -license or royalty fees, to use, copy, modify and distribute this -software for any purpose. - -The above copyright notice and the following four paragraphs must be -reproduced in all copies of this software and any software including -this software. - -THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE -ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR -MODIFICATIONS. - -IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, -INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT -OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. - -EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. +SPDX-License-Identifier: LicenseRef-APPLEMIT The software is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the government are subject to restrictions set forth in @@ -113,9 +87,10 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. #endif #endif -#include <string.h> -#include <stdio.h> -#include <stdlib.h> +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + #include <ctype.h> #include "vcc.h" @@ -143,14 +118,13 @@ extern "C" { #endif extern void Parse_Debug(const char *s); - static void yyerror(char *s); + static void yyerror(const char *s); #if defined(__CPLUSPLUS__) }; #endif int yylex(void); -int yyparse(void); enum LexMode { L_NORMAL, @@ -185,7 +159,7 @@ static void enterAttr(const char *s1, const char *s2); static void enterProps(const char *s); static void enterValues(const char *value); static void finiLex(void); -static void mime_error_(char *s); +static void mime_error_(const char *s); static VObject* Parse_MIMEHelper(void); static VObject* popVObject(void); static int pushVObject(const char *prop); @@ -205,7 +179,6 @@ static int pushVObject(const char *prop); EQ COLON DOT SEMICOLON SPACE HTAB LINESEP NEWLINE BEGIN_VCARD END_VCARD BEGIN_VCAL END_VCAL BEGIN_VEVENT END_VEVENT BEGIN_VTODO END_VTODO - ID /* * NEWLINE is the token that would occur outside a vCard, @@ -351,7 +324,7 @@ eventitem: END_VEVENT { lexPopMode(0); - popVObject(); + (void)popVObject(); } | BEGIN_VEVENT { @@ -361,7 +334,7 @@ eventitem: END_VEVENT { lexPopMode(0); - popVObject(); + (void)popVObject(); } ; @@ -375,7 +348,7 @@ todoitem: END_VTODO { lexPopMode(0); - popVObject(); + (void)popVObject(); } | BEGIN_VTODO { @@ -385,7 +358,7 @@ todoitem: END_VTODO { lexPopMode(0); - popVObject(); + (void)popVObject(); } ; @@ -428,7 +401,7 @@ static void enterValues(const char *value) { if (fieldedProp && *fieldedProp) { if (value) { - addPropValue(curProp,*fieldedProp,value); + (void) addPropValue(curProp,*fieldedProp,value); } /* else this field is empty, advance to next field */ fieldedProp++; @@ -437,7 +410,7 @@ static void enterValues(const char *value) if (value) { char *p1, *p2; wchar_t *p3; - int i; + size_t i; /* If the property already has a string value, we append this one, using ';' to separate the values. */ @@ -450,7 +423,7 @@ static void enterValues(const char *value) p3 = (wchar_t *) vObjectUStringZValue(curProp); free(p3); setVObjectUStringZValue_(curProp,fakeUnicode(p2,0)); - deleteStr(p2); + free(p2); } else { setVObjectUStringZValue_(curProp,fakeUnicode(value,0)); } @@ -476,11 +449,11 @@ static void enterAttr(const char *s1, const char *s2) setVObjectStringZValue(a,p2); } else - addProp(curProp,p1); - if (stricmp(p1,VCBase64Prop) == 0 || (s2 && stricmp(p2,VCBase64Prop)==0)) + (void)addProp(curProp,p1); + if (strcasecmp(p1,VCBase64Prop) == 0 || (p2 && strcasecmp(p2,VCBase64Prop)==0)) lexPushMode(L_BASE64); - else if (stricmp(p1,VCQuotedPrintableProp) == 0 - || (s2 && stricmp(p2,VCQuotedPrintableProp)==0)) + else if (strcasecmp(p1,VCQuotedPrintableProp) == 0 + || (p2 && strcasecmp(p2,VCQuotedPrintableProp)==0)) lexPushMode(L_QUOTED_PRINTABLE); deleteStr(s1); deleteStr(s2); } @@ -555,7 +528,7 @@ static char lexGetc_() char result; return lexBuf.inputFile->Read(&result, 1) == 1 ? result : EOF; #else - return fgetc(lexBuf.inputFile); + return (char)fgetc(lexBuf.inputFile); #endif } } @@ -673,7 +646,7 @@ static void lexPushLookaheadc(int c) { if (((char) c) == ((char) EOF)) return; putptr = (int)lexBuf.getPtr - 1; if (putptr < 0) putptr += MAX_LEX_LOOKAHEAD; - lexBuf.getPtr = putptr; + lexBuf.getPtr = (unsigned long)putptr; lexBuf.buf[putptr] = c; lexBuf.len += 1; } @@ -696,14 +669,14 @@ static char* lexLookaheadWord() { lexAppendc(0); /* restore lookahead buf. */ lexBuf.len += len; - lexBuf.getPtr = curgetptr; + lexBuf.getPtr = (unsigned long)curgetptr; return lexStr(); } else lexAppendc(c); } lexBuf.len += len; /* char that has been moved to lookahead buffer */ - lexBuf.getPtr = curgetptr; + lexBuf.getPtr = (unsigned long)curgetptr; return 0; } @@ -780,10 +753,10 @@ static int match_begin_name(int end) { char *n = lexLookaheadWord(); int token = ID; if (n) { - if (!stricmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD; - else if (!stricmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL; - else if (!stricmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT; - else if (!stricmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO; + if (!strcasecmp(n,"vcard")) token = end?END_VCARD:BEGIN_VCARD; + else if (!strcasecmp(n,"vcalendar")) token = end?END_VCAL:BEGIN_VCAL; + else if (!strcasecmp(n,"vevent")) token = end?END_VEVENT:BEGIN_VEVENT; + else if (!strcasecmp(n,"vtodo")) token = end?END_VTODO:BEGIN_VTODO; deleteStr(n); return token; } @@ -829,7 +802,7 @@ static void finiLex() { */ static char * lexGetDataFromBase64() { - unsigned long bytesLen = 0, bytesMax = 0; + size_t bytesLen = 0, bytesMax = 0; int quadIx = 0, pad = 0; unsigned long trip = 0; unsigned char b; @@ -884,13 +857,13 @@ static char * lexGetDataFromBase64() trip = (trip << 6) | b; if (++quadIx == 4) { unsigned char outBytes[3]; - int numOut; + size_t numOut; int i; for (i = 0; i < 3; i++) { outBytes[2-i] = (unsigned char)(trip & 0xFF); trip >>= 8; } - numOut = 3 - pad; + numOut = (size_t)(3 - pad); if (bytesLen + numOut > bytesMax) { if (!bytes) { bytesMax = 1024; @@ -914,15 +887,15 @@ static char * lexGetDataFromBase64() } } } /* while */ - DBG_(("db: bytesLen = %d\n", bytesLen)); + DBG_(("db: bytesLen = %lu\n", (unsigned long)bytesLen)); /* kludge: all this won't be necessary if we have tree form representation */ if (bytes) { - setValueWithSize(curProp,bytes,(unsigned int)bytesLen); + (void)setValueWithSize(curProp,bytes,(unsigned int)bytesLen); free(bytes); } else if (oldBytes) { - setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen); + (void)setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen); free(oldBytes); } return 0; @@ -1072,7 +1045,7 @@ int yylex() { lexSkipLookahead(); c = lexLookahead(); ++mime_lineNum; - } + } DBG_(("db: COLON\n")); return COLON; } @@ -1096,10 +1069,10 @@ int yylex() { if (isalpha(c)) { char *t = lexGetWord(); yylval.str = t; - if (!stricmp(t, "begin")) { + if (!strcasecmp(t, "begin")) { return match_begin_end_name(0); } - else if (!stricmp(t,"end")) { + else if (!strcasecmp(t,"end")) { return match_begin_end_name(1); } else { @@ -1142,7 +1115,7 @@ static VObject* Parse_MIMEHelper() return vObjList; } -DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len) +VObject* Parse_MIME(const char *input, unsigned long len) { initLex(input, len, 0); return Parse_MIMEHelper(); @@ -1151,7 +1124,7 @@ DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len) #ifdef INCLUDEMFC -DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file) +VObject* Parse_MIME_FromFile(CFile *file) { unsigned long startPos; VObject *result; @@ -1174,12 +1147,12 @@ VObject* Parse_MIME_FromFile(FILE *file) startPos = ftell(file); if (!(result = Parse_MIMEHelper())) { if (startPos >= 0) - fseek(file,startPos,SEEK_SET); + (void)fseek(file,startPos,SEEK_SET); } return result; } -DLLEXPORT(VObject*) Parse_MIME_FromFileName(const char *fname) +VObject* Parse_MIME_FromFileName(const char *fname) { FILE *fp = fopen(fname,"r"); if (fp) { @@ -1200,12 +1173,12 @@ DLLEXPORT(VObject*) Parse_MIME_FromFileName(const char *fname) static MimeErrorHandler mimeErrorHandler; -DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler me) +void registerMimeErrorHandler(MimeErrorHandler me) { mimeErrorHandler = me; } -static void mime_error(char *s) +static void mime_error(const char *s) { char msg[256]; if (mimeErrorHandler) { @@ -1214,7 +1187,7 @@ static void mime_error(char *s) } } -static void mime_error_(char *s) +static void mime_error_(const char *s) { if (mimeErrorHandler) { mimeErrorHandler(s); |