diff options
Diffstat (limited to 'src/libicalss/icalssyacc.y')
-rw-r--r-- | src/libicalss/icalssyacc.y | 155 |
1 files changed, 67 insertions, 88 deletions
diff --git a/src/libicalss/icalssyacc.y b/src/libicalss/icalssyacc.y index ae40f119..6d38adcb 100644 --- a/src/libicalss/icalssyacc.y +++ b/src/libicalss/icalssyacc.y @@ -3,18 +3,9 @@ /* FILE: icalssyacc.y */ /* CREATOR: eric 08 Aug 2000 */ /* */ -/* (C) COPYRIGHT 2000, Eric Busboom <eric@civicknowledge.com> */ +/* SPDX-FileCopyrightText: 2000, Eric Busboom <eric@civicknowledge.com> */ /* */ -/* This program is free software; you can redistribute it and/or modify */ -/* it under the terms of either: */ -/* */ -/* The LGPL as published by the Free Software Foundation, version */ -/* 2.1, available at: https://www.gnu.org/licenses/lgpl-2.1.html */ -/* */ -/* Or: */ -/* */ -/* The Mozilla Public License Version 2.0. You may obtain a copy of */ -/* the License at https://www.mozilla.org/MPL/ */ +/* SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0 */ /* */ /* The Original Code is eric. The Initial Developer of the Original */ /* Code is Eric Busboom */ @@ -36,13 +27,14 @@ extern struct icalgauge_impl *icalss_yy_gauge; #define yyerror sserror -void sserror(char *s); +void sserror(const char *s); +int yylex(void); -static void ssyacc_add_where(struct icalgauge_impl* impl, char* prop, - icalgaugecompare compare , char* value); -static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1); -static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1); -static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l); +static void ssyacc_add_where(struct icalgauge_impl *impl, char *prop, + icalgaugecompare compare, const char *value); +static void ssyacc_add_select(struct icalgauge_impl *impl, char *str1); +static void ssyacc_add_from(struct icalgauge_impl *impl, char *str1); +static void set_logic(struct icalgauge_impl *impl, icalgaugelogic l); /* Don't know why I need this.... */ @@ -58,7 +50,6 @@ int sslex(void); char* v_string; } - %token <v_string> STRING %token SELECT FROM WHERE COMMA QUOTE EQUALS NOTEQUALS LESS GREATER LESSEQUALS %token GREATEREQUALS AND OR EOL END IS NOT SQLNULL @@ -102,22 +93,21 @@ where_list: | where_list OR where_clause {set_logic(icalss_yy_gauge,ICALGAUGELOGIC_OR);} ; - %% -static void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, - icalgaugecompare compare , char* value_str) +static void ssyacc_add_where(struct icalgauge_impl *impl, char *str1, + icalgaugecompare compare, const char *value_str) { - struct icalgauge_where *where; - char *compstr, *propstr, *c, *s,*l; + char *compstr, *propstr, *c, *l; + const char *s; - if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; + if ((where = malloc(sizeof(struct icalgauge_where))) == 0) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return; } - memset(where,0,sizeof(struct icalgauge_where)); + memset(where, 0, sizeof(struct icalgauge_where)); where->logic = ICALGAUGELOGIC_NONE; where->compare = ICALGAUGECOMPARE_NONE; where->comp = ICAL_NO_COMPONENT; @@ -125,71 +115,64 @@ static void ssyacc_add_where(struct icalgauge_impl* impl, char* str1, /* remove enclosing quotes */ s = value_str; - if(*s == '\''){ - s++; + if (*s == '\'') { + s++; } - l = s+strlen(s)-1; - if(*l == '\''){ - *l=0; + l = (char *)(s + strlen(s) - 1); + if (*l == '\'') { + *l = 0; } where->value = strdup(s); /* Is there a period in str1 ? If so, the string specified both a */ /* component and a property */ - if( (c = strrchr(str1,'.')) != 0){ - compstr = str1; - propstr = c+1; - *c = '\0'; + if ((c = strrchr(str1, '.')) != 0 ) { + compstr = str1; + propstr = c + 1; + *c = '\0'; } else { - compstr = 0; - propstr = str1; + compstr = 0; + propstr = str1; } - /* Handle the case where a component was specified */ - if(compstr != 0){ - where->comp = icalenum_string_to_component_kind(compstr); + if (compstr != 0) { + where->comp = icalenum_string_to_component_kind(compstr); } else { - where->comp = ICAL_NO_COMPONENT; + where->comp = ICAL_NO_COMPONENT; } - where->prop = icalenum_string_to_property_kind(propstr); - where->compare = compare; - - if(where->value == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - free(where->value); - return; + if (where->value == 0) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + free(where->value); + return; } - pvl_push(impl->where,where); + pvl_push(impl->where, where); } -static void set_logic(struct icalgauge_impl* impl,icalgaugelogic l) +static void set_logic(struct icalgauge_impl *impl, icalgaugelogic l) { pvl_elem e = pvl_tail(impl->where); struct icalgauge_where *where = pvl_data(e); where->logic = l; - } - - -static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1) +static void ssyacc_add_select(struct icalgauge_impl *impl, char *str1) { char *c, *compstr, *propstr; struct icalgauge_where *where; /* Uses only the prop and comp fields of the where structure */ - if ( (where = malloc(sizeof(struct icalgauge_where))) ==0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; + if ((where = malloc(sizeof(struct icalgauge_where))) == 0) { + icalerror_set_errno(ICAL_NEWFAILED_ERROR); + return; } - memset(where,0,sizeof(struct icalgauge_where)); + memset(where, 0, sizeof(struct icalgauge_where)); where->logic = ICALGAUGELOGIC_NONE; where->compare = ICALGAUGECOMPARE_NONE; where->comp = ICAL_NO_COMPONENT; @@ -197,57 +180,53 @@ static void ssyacc_add_select(struct icalgauge_impl* impl, char* str1) /* Is there a period in str1 ? If so, the string specified both a */ /* component and a property */ - if( (c = strrchr(str1,'.')) != 0){ - compstr = str1; - propstr = c+1; - *c = '\0'; + if ((c = strrchr(str1, '.')) != 0) { + compstr = str1; + propstr = c + 1; + *c = '\0'; } else { - compstr = 0; - propstr = str1; + compstr = 0; + propstr = str1; } - /* Handle the case where a component was specified */ - if(compstr != 0){ - where->comp = icalenum_string_to_component_kind(compstr); + if (compstr != 0) { + where->comp = icalenum_string_to_component_kind(compstr); } else { - where->comp = ICAL_NO_COMPONENT; + where->comp = ICAL_NO_COMPONENT; } - /* If the property was '*', then accept all properties */ - if(strcmp("*",propstr) == 0) { - where->prop = ICAL_ANY_PROPERTY; + if (strcmp("*", propstr) == 0) { + where->prop = ICAL_ANY_PROPERTY; } else { - where->prop = icalenum_string_to_property_kind(propstr); + where->prop = icalenum_string_to_property_kind(propstr); } - - if(where->prop == ICAL_NO_PROPERTY){ - free(where); - icalerror_set_errno(ICAL_BADARG_ERROR); - return; + if (where->prop == ICAL_NO_PROPERTY) { + free(where); + icalerror_set_errno(ICAL_BADARG_ERROR); + return; } - pvl_push(impl->select,where); + pvl_push(impl->select, where); } -static void ssyacc_add_from(struct icalgauge_impl* impl, char* str1) +static void ssyacc_add_from(struct icalgauge_impl *impl, char *str1) { icalcomponent_kind ckind; ckind = icalenum_string_to_component_kind(str1); - if(ckind == ICAL_NO_COMPONENT){ - assert(0); + if (ckind == ICAL_NO_COMPONENT) { + assert(0); } - pvl_push(impl->from,(void*)ckind); - + pvl_push(impl->from, (void*)ckind); } - -void sserror(char *s){ - fprintf(stderr,"Parse error \'%s\'\n", s); - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); +void sserror(const char *s) +{ + fprintf(stderr,"Parse error \'%s\'\n", s); + icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); } |