Browse Source

Create shared lib, cranked up compiler warnings

The configuration now builds a shared library and links FLEX libraries with
it.

Cranking up the compiler warnings to close to insane:
    - in  "static struct llist *lit()" fix a classic!
      single "&" where "&&" meant:
           inch=input();
        -  while(inch !=EOF & inch != ';' && inch != '\0') {
        +  while(inch !=EOF && inch != ';' && inch != '\0') {
    - removed unused variables
    - renamed shadowed variable/function parameter
    - fix function prototype/function not returning a value
      prototype:
        "char* <function>"
      implementation:
        no return statement at all!
master
haavee 3 years ago
parent
commit
33a0f2a739
  1. 16
      src/CMakeLists.txt
  2. 7
      src/vex.h
  3. 2
      src/vex.y
  4. 2
      src/vex.yy.l
  5. 20
      src/vex_get.c
  6. 62
      src/vex_util.c

16
src/CMakeLists.txt

@ -3,8 +3,7 @@ FLEX_TARGET(VexScanner vex.yy.l ${CMAKE_CURRENT_BINARY_DIR}/vex.yy.c)
ADD_FLEX_BISON_DEPENDENCY(VexScanner VexParser)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_library(vex
print_vex.c
add_library(vex SHARED
vex_get.c
vex_util.c
${BISON_VexParser_OUTPUTS}
@ -12,8 +11,21 @@ add_library(vex
)
set_property(TARGET vex PROPERTY POSITION_INDEPENDENT_CODE ON)
# 1. Currently flex generates vex.yy.c with a signed/unsigned comparision in so
# remove that warning :-(
# 2. The only way to make sure _GNU_SOURCE is NOT defined is to combine
# -D_GNU_SOURCE with an immediately following -U_GNU_SOURCE
target_compile_options(vex PUBLIC -D_GNU_SOURCE -U_GNU_SOURCE -W -Wall -Wextra -Werror
-pedantic -ansi -Wcast-qual -Wredundant-decls -Wfloat-equal -Wshadow -Wno-sign-compare)
# Compile towards POSIX standards
target_compile_definitions(vex PUBLIC _POSIX_C_SOURCE=200809L _XOPEN_SOURCE=700 __STDC_FORMAT_MACROS)
target_include_directories(vex PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_include_directories(vex PUBLIC ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(vex PUBLIC ${FLEX_LIBRARIES})
install(TARGETS vex DESTINATION lib)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/vex_parser.h

7
src/vex.h

@ -506,7 +506,6 @@ void print_lowl(struct llist *items);
void print_lowl_st(int statement, void *ptr);
void print_def_block(struct llist *items, void func());
//void print_external(struct external *this);
void print_external(struct external *);
void print_svalue(char *svalue);
@ -639,8 +638,8 @@ get_literal_def(struct vex *vex_in);
Llist *
find_literal(Llist *defs);
char *
get_all_literals(struct llist *literals, char *str[]);
void
get_all_literals(struct llist *literals, char const *str[]);
void *
get_a_literal(struct llist *literals, char **str);
@ -1173,5 +1172,3 @@ create_stream_def_list(char *str);
void *
create_test(struct llist *start, char *str);
extern FILE *fp;
extern char *filename;

2
src/vex.y

@ -1646,7 +1646,7 @@ value: T_NAME {$$=make_dvalue($1,NULL);}
;
%%
int yylex(YYSTYPE *, void *);
/*int yylex(YYSTYPE *, void *);*/
void yyerror(s)
char *s;

2
src/vex.yy.l

@ -311,7 +311,7 @@ static struct llist *lit()
/* skip to ';' */
inch=input();
while(inch !=EOF & inch != ';' && inch != '\0') {
while(inch !=EOF && inch != ';' && inch != '\0') {
if(inch == '\n')
lines++;
else if(NULL == strchr(" \t\r",inch))

20
src/vex_get.c

@ -71,7 +71,6 @@ get_scan_source(Llist *lowls_scan_in)
state=FALSE;
}
lstate:
lowls=find_lowl(lowls,T_SOURCE);
if(lowls==NULL)
goto ldone;
@ -631,7 +630,7 @@ get_station_lowl(char *station_in,
static Llist *refs;
static Llist *lowls;
Llist *qualifiers, *lowls_this;
Llist *lowls_this;
Llist *defs;
char *def;
@ -733,7 +732,6 @@ get_source_lowl(char *source_in, int statement_in, struct vex *vex_in)
Llist *lowls_this;
Llist *defs;
char *def;
static char *source;
static struct vex *vex;
@ -770,8 +768,6 @@ get_source_lowl(char *source_in, int statement_in, struct vex *vex_in)
lowls=((Def *)((Lowl *)defs->ptr)->item)->refs;
lstart:
lstate:
lowls=find_lowl(lowls,statement);
if(lowls==NULL)
@ -806,7 +802,7 @@ get_global_lowl(int statement_in,
static Llist *lowls;
Llist *defs;
Llist *qualifiers, *lowls_this;
Llist *lowls_this;
char *def;
static struct vex *vex;
@ -1027,11 +1023,9 @@ get_literal_lowl(char *source_in, struct vex *vex_in)
Llist *lowls_this;
Llist *defs;
char *def;
static char *source;
static struct vex *vex;
static int statement;
static int state=FALSE;
@ -1067,8 +1061,6 @@ get_literal_lowl(char *source_in, struct vex *vex_in)
lowls=((Def *)((Lowl *)defs->ptr)->item)->refs;
lstart:
lstate:
lowls=find_lowl(lowls,T_LITERAL);
if(lowls==NULL){
@ -1107,12 +1099,12 @@ get_a_literal(struct llist *literals, char **text)
return literals->next;
}
/*---------------------------------------------------------------------------*/
char *
get_all_literals(struct llist *literals, char *array[])
void
get_all_literals(struct llist *literals, char const *array[])
{
int i=0;
char *literal_header="start_literal";
char *literal_tail="end_literal";
char const *literal_header="start_literal";
char const *literal_tail="end_literal";
array[i]=literal_header;
i++;

62
src/vex_util.c

@ -380,12 +380,12 @@ struct vex_block *make_block(int block,struct llist *items)
return new;
}
struct vex *make_vex(struct llist *version, struct llist *blocks)
struct vex *make_vex(struct llist *version, struct llist *blocks_in)
{
NEWSTRUCT(new,vex);
new->version=version;
new->blocks=blocks;
new->blocks=blocks_in;
return new;
}
@ -1299,8 +1299,6 @@ static int
get_data_transfer_field(Data_transfer *data_transfer,int n,int *link,
int *name,char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1347,8 +1345,6 @@ static int
get_axis_type_field(Axis_type *axis_type,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1370,8 +1366,6 @@ static int
get_antenna_motion_field(Antenna_motion *antenna_motion,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1401,8 +1395,6 @@ static int
get_pointing_sector_field(Pointing_sector *pointing_sector,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1449,8 +1441,6 @@ static int
get_bbc_assign_field(Bbc_assign *bbc_assign,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1479,8 +1469,6 @@ static int
get_clock_early_field(Clock_early *clock_early,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1518,8 +1506,6 @@ static int
get_headstack_field(Headstack *headstack,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1547,8 +1533,6 @@ static int
get_tape_length_field(Tape_Length *tape_length,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1581,8 +1565,6 @@ static int
get_tape_motion_field(Tape_Motion *tape_motion,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1653,8 +1635,6 @@ static int
get_if_def_field(If_def *if_def,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1732,8 +1712,6 @@ static int
get_setup_always_field(Setup_always *setup_always,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1756,8 +1734,6 @@ static int
get_parity_check_field(Parity_check *parity_check,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1781,8 +1757,6 @@ static int
get_tape_prepass_field(Tape_prepass *tape_prepass,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1806,8 +1780,6 @@ static int
get_preob_cal_field(Preob_cal *preob_cal,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1834,8 +1806,6 @@ static int
get_midob_cal_field(Midob_cal *midob_cal,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1862,8 +1832,6 @@ static int
get_postob_cal_field(Postob_cal *postob_cal,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1925,8 +1893,6 @@ static int
get_site_position_field(Site_position *site_position,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1957,8 +1923,6 @@ static int
get_site_velocity_field(Site_velocity *site_velocity,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -1989,8 +1953,6 @@ static int
get_ocean_load_vert_field(Ocean_load_vert *ocean_load_vert,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -2016,8 +1978,6 @@ static int
get_ocean_load_horiz_field(Ocean_load_horiz *ocean_load_horiz,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -2043,8 +2003,6 @@ static int
get_source_model_field(Source_model *source_model,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -2099,8 +2057,6 @@ static int
get_vsn_field(Vsn *vsn,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -2299,8 +2255,6 @@ static int
get_vlba_frmtr_sys_trk_field(Vlba_frmtr_sys_trk *vlba_frmtr_sys_trk,int n,
int *link, int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -2336,8 +2290,6 @@ static int
get_s2_data_source_field(S2_data_source *s2_data_source,int n,int *link,
int *name, char **value, char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -2368,8 +2320,6 @@ static int
get_dvalue_field(Dvalue *dvalue,int n,int *link,int *name,char **value,
char **units)
{
int ierr;
*link=0;
*name=0;
*units=NULL;
@ -2414,8 +2364,6 @@ static int
get_svalue_field(char *svalue,int n,int *link,int *name, char **value,
char **units)
{
int ierr;
*link=0;
*name=1;
*units=NULL;
@ -2459,8 +2407,6 @@ static int
get_date_field(char *date,int n,int *link, int *name, char **value,
char **units)
{
int ierr;
*link=0;
*name=0;
*units=NULL;
@ -2481,8 +2427,6 @@ static int
get_time_field(char *time,int n,int *link, int *name, char **value,
char **units)
{
int ierr;
*link=0;
*name=0;
*units=NULL;
@ -2503,8 +2447,6 @@ static int
get_angle_field(char *angle,int n,int *link, int *name, char **value,
char **units)
{
int ierr;
*link=0;
*name=0;
*units=NULL;

Loading…
Cancel
Save