diff options
| -rw-r--r-- | src/Makefile.am | 4 | ||||
| -rw-r--r-- | src/calculer.c | 2 | ||||
| -rw-r--r-- | src/cli.c | 12 | ||||
| -rw-r--r-- | src/disp.c | 23 | ||||
| -rw-r--r-- | src/ray.c | 11 | ||||
| -rw-r--r-- | src/tui.c | 11 | 
6 files changed, 58 insertions, 5 deletions
| diff --git a/src/Makefile.am b/src/Makefile.am index d8f6457..3c4c982 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,9 @@ linenoise_lib.c:  endif # USE_READLINE_COND  else # DEBUG_COND -AM_CFLAGS += -DNDEBUG -Wno-unused-variable +AM_CFLAGS += -DNDEBUG +calculer_SOURCES += calc_data.c input.c cli.c tui.c ray.c +AM_LDFLAGS += -lncurses  if USE_READLINE_COND  AM_LDFLAGS += -lreadline diff --git a/src/calculer.c b/src/calculer.c index 705fb74..6bf8fbb 100644 --- a/src/calculer.c +++ b/src/calculer.c @@ -153,7 +153,7 @@ main(int argc, char *argv[])  	time_t now = time(NULL);  	struct tm *tm = localtime(&now);  	size_t bytes_written = strftime(logbuf, sizeof(logbuf), "%F\t", tm); -	assert(bytes_written); +	assert(bytes_written);	/* TODO: better handling */  	int opt;  	while ((opt = getopt(argc, argv, ":Vhl:m:M:i:")) != -1) @@ -29,6 +29,7 @@ void  cli_display_calc(int x, int y)  {  	printf("%d + %d = ", x, y); +	fflush(stdout);  }  int @@ -60,3 +61,14 @@ void cli_destroy(void) {}  void *cli_pre_reload(void) {return NULL;}  void cli_post_reload(void *) {}  #endif + +#ifdef NDEBUG +static struct disp __cli_disp = { +	.init = cli_init, +	.display_calc = cli_display_calc, +	.read_input = cli_read_input, +	.display_res = cli_display_res, +	.destroy = cli_destroy +}; +struct disp *cli_disp = &__cli_disp; +#endif @@ -25,6 +25,13 @@  #include "disp.h" +#ifdef NDEBUG +extern struct disp *cli_disp; +extern struct disp *tui_disp; +extern struct disp *ray_disp; +#endif + +#ifndef NDEBUG  static void *  load_generic_symbol(struct disp *disp, char *base_name)  { @@ -46,8 +53,9 @@ load_generic_symbol(struct disp *disp, char *base_name)  	return ptr;  } +#endif - +#ifndef NDEBUG  static void  load_symbols(struct disp *disp)  { @@ -72,6 +80,7 @@ load_symbols(struct disp *disp)  	printf("INFO: successfully loaded symbols from \"%s\"\n",  	       disp->so_path);  } +#endif  struct disp *  get_disp(char *disp_name) @@ -90,9 +99,15 @@ get_disp(char *disp_name)  	return disp;  #else -#  error "not available yet" -#endif +	if (strcmp(disp_name, "cli") == 0) +		return cli_disp; +	if (strcmp(disp_name, "tui") == 0) +		return tui_disp; +	if (strcmp(disp_name, "ray") == 0) +		return ray_disp; +  	return NULL; +#endif  }  void @@ -101,11 +116,13 @@ destroy_disp(struct disp *disp)  	if (disp->destroy)  		disp->destroy(); +#ifndef NDEBUG  	if (disp->dl_handle)  		dlclose(disp->dl_handle);  	free(disp->so_path);  	free(disp); +#endif  }  #ifndef NDEBUG @@ -292,3 +292,14 @@ ray_post_reload(void *state)  	TraceLog(LOG_INFO, "post-reload actions done");  }  #endif + +#ifdef NDEBUG +static struct disp __ray_disp = { +	.init = ray_init, +	.display_calc = ray_display_calc, +	.read_input = ray_read_input, +	.display_res = ray_display_res, +	.destroy = ray_destroy +}; +struct disp *ray_disp = &__ray_disp; +#endif @@ -171,3 +171,14 @@ tui_post_reload(void *state)  	redraw();  }  #endif + +#ifdef NDEBUG +static struct disp __tui_disp = { +	.init = tui_init, +	.display_calc = tui_display_calc, +	.read_input = tui_read_input, +	.display_res = tui_display_res, +	.destroy = tui_destroy +}; +struct disp *tui_disp = &__tui_disp; +#endif | 
