summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandmarti1424 <andmarti@gmail.com>2017-12-02 11:01:28 -0300
committerandmarti1424 <andmarti@gmail.com>2017-12-02 11:01:28 -0300
commit9369750bad0eb8098ce06f42b4dc814e9001d54e (patch)
treec6535ae9c6c62ae706929067c667675ae1a889ac
parentd2a63fcf08a266a5af956d6baa3284cd65f515d6 (diff)
Prevent some warnings during build
-rw-r--r--src/color.c36
-rw-r--r--src/conf.c6
-rw-r--r--src/dep_graph.c14
-rw-r--r--src/lua.c2
-rw-r--r--src/main.c28
-rwxr-xr-xsrc/utils/dictionary.c3
6 files changed, 47 insertions, 42 deletions
diff --git a/src/color.c b/src/color.c
index 6ce0920..5cf62fe 100644
--- a/src/color.c
+++ b/src/color.c
@@ -258,9 +258,10 @@ void chg_color(char * str) {
if (str[strlen(str)-1]=='"') del_char(str, strlen(str)-1);
parse_str(d, str);
+ char * cl;
// Validate we got enough keys to change a color
- if (get(d, "fg") == '\0' || get(d, "bg") == '\0' || get(d, "type") == '\0') {
+ if ( (((cl = get(d, "fg")) != NULL) && cl[0] == '\0') || (((cl = get(d, "bg")) != NULL) && cl[0] == '\0') || (((cl = get(d, "type")) != NULL) && cl[0] == '\0')) {
sc_error("Color definition incomplete");
destroy_dictionary(d);
return;
@@ -283,12 +284,12 @@ void chg_color(char * str) {
int type = atoi(get(d_colors_param, get(d, "type")));
ucolors[ type ].fg = atoi(get(d_colors_param, get(d, "fg")));
ucolors[ type ].bg = atoi(get(d_colors_param, get(d, "bg")));
- if (get(d, "bold") != '\0') ucolors[ type ].bold = atoi(get(d, "bold"));
- if (get(d, "dim") != '\0') ucolors[ type ].dim = atoi(get(d, "dim"));
- if (get(d, "reverse") != '\0') ucolors[ type ].reverse = atoi(get(d, "reverse"));
- if (get(d, "standout") != '\0') ucolors[ type ].standout = atoi(get(d, "standout"));
- if (get(d, "blink") != '\0') ucolors[ type ].blink = atoi(get(d, "blink"));
- if (get(d, "underline") != '\0') ucolors[ type ].underline = atoi(get(d, "underline"));
+ if (((cl = get(d, "bold")) != NULL) && cl[0] != '\0') ucolors[ type ].bold = atoi(get(d, "bold"));
+ if (((cl = get(d, "dim")) != NULL) && cl[0] != '\0') ucolors[ type ].dim = atoi(get(d, "dim"));
+ if (((cl = get(d, "reverse")) != NULL) && cl[0] != '\0') ucolors[ type ].reverse = atoi(get(d, "reverse"));
+ if (((cl = get(d, "standout")) != NULL) && cl[0] != '\0') ucolors[ type ].standout = atoi(get(d, "standout"));
+ if (((cl = get(d, "blink")) != NULL) && cl[0] != '\0') ucolors[ type ].blink = atoi(get(d, "blink"));
+ if (((cl = get(d, "underline")) != NULL) && cl[0] != '\0') ucolors[ type ].underline = atoi(get(d, "underline"));
// clean temp variable
destroy_dictionary(d);
@@ -331,11 +332,12 @@ void color_cell(int r, int c, int rf, int cf, char * str) {
if (str[strlen(str)-1]=='"') del_char(str, strlen(str)-1);
parse_str(d, str);
+ char * cl;
// Validations
if (
- ((get(d, "fg") != '\0' && get(d_colors_param, get(d, "fg")) == NULL) ||
- (get(d, "bg") != '\0' && get(d_colors_param, get(d, "bg")) == NULL))) {
+ ((cl = get(d, "fg")) != NULL && cl[0] != '\0' && get(d_colors_param, get(d, "fg")) == NULL) ||
+ ((cl = get(d, "bg")) != NULL && cl[0] != '\0' && get(d_colors_param, get(d, "bg")) == NULL)) {
sc_error("One of the values specified is wrong. Please check the values of type, fg and bg.");
destroy_dictionary(d);
return;
@@ -371,18 +373,18 @@ void color_cell(int r, int c, int rf, int cf, char * str) {
n->ucolor->blink = 0;
}
- if (get(d, "bg") != '\0')
+ if ((cl = get(d, "bg")) != NULL && cl[0] != '\0')
n->ucolor->bg = atoi(get(d_colors_param, get(d, "bg")));
- if (get(d, "fg") != '\0')
+ if ((cl = get(d, "fg")) != NULL && cl[0] != '\0')
n->ucolor->fg = atoi(get(d_colors_param, get(d, "fg")));
- if (get(d, "bold") != '\0') n->ucolor->bold = atoi(get(d, "bold"));
- if (get(d, "dim") != '\0') n->ucolor->dim = atoi(get(d, "dim"));
- if (get(d, "reverse") != '\0') n->ucolor->reverse = atoi(get(d, "reverse"));
- if (get(d, "standout") != '\0') n->ucolor->standout = atoi(get(d, "standout"));
- if (get(d, "blink") != '\0') n->ucolor->blink = atoi(get(d, "blink"));
- if (get(d, "underline") != '\0') n->ucolor->underline = atoi(get(d, "underline"));
+ if ((cl = get(d, "bold")) != NULL && cl[0] != '\0') n->ucolor->bold = atoi(get(d, "bold"));
+ if ((cl = get(d, "dim") ) != NULL && cl[0] != '\0') n->ucolor->dim = atoi(get(d, "dim"));
+ if ((cl = get(d, "reverse")) != NULL && cl[0] != '\0') n->ucolor->reverse = atoi(get(d, "reverse"));
+ if ((cl = get(d, "standout")) != NULL && cl[0] != '\0') n->ucolor->standout = atoi(get(d, "standout"));
+ if ((cl = get(d, "blink")) != NULL && cl[0] != '\0') n->ucolor->blink = atoi(get(d, "blink"));
+ if ((cl = get(d, "underline")) != NULL && cl[0] != '\0') n->ucolor->underline = atoi(get(d, "underline"));
if (! loading) {
#ifdef UNDO
diff --git a/src/conf.c b/src/conf.c
index 1d89a9d..056329e 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -156,8 +156,8 @@ char * get_conf_values(char * salida) {
char * get_conf_value(char * key) {
char * val = get(user_conf_d, key);
- if ( val != '\0' )
- return val;
- else
+ if ( val == NULL || *(&val[0]) == '\0')
return get(predefined_conf_d, key);
+ else
+ return val;
}
diff --git a/src/dep_graph.c b/src/dep_graph.c
index cc30814..fe245b6 100644
--- a/src/dep_graph.c
+++ b/src/dep_graph.c
@@ -517,6 +517,7 @@ int All_vertexs_of_edges_visited(struct edgeTag * e) {
* \return none
*/
void EvalBottomUp() {
+ /*
struct ent * p;
vertexT * temp = graph->vertices;
@@ -545,14 +546,15 @@ void EvalBottomUp() {
temp = temp->next;
- /*
- if (temp == NULL && evaluated) { //end of cycle. if evaluated a vertex in this loop, loop again
- //sc_debug("recycle");
- evaluated = 0;
- temp = graph->vertices;
- } else if (temp == NULL) return;*/
+ //
+ //if (temp == NULL && evaluated) { //end of cycle. if evaluated a vertex in this loop, loop again
+ // //sc_debug("recycle");
+ // evaluated = 0;
+ // temp = graph->vertices;
+ //} else if (temp == NULL) return;
}
//sc_debug("fin eval");
+ */
}
diff --git a/src/lua.c b/src/lua.c
index fd2aad3..fd54bb5 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -281,7 +281,7 @@ int l_query (lua_State *L) {
ret = ui_query(val);
//sc_debug("return of query:%s.\n", ret);
- if (ret == '\0') {
+ if (ret != NULL && ret[0] == '\0') {
free(ret);
return 0;
}
diff --git a/src/main.c b/src/main.c
index 2e1bb31..31fa98b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -202,11 +202,11 @@ int main (int argc, char ** argv) {
read_argv(argc, argv);
// check if version is in argv. if so, show version and quit
- if (atoi(get_conf_value("version"))) // atoi converts string to an int
+ if (atoi((char *) get_conf_value("version"))) // atoi converts string to an int
show_version_and_quit();
// create command line history structure
- if (! atoi(get_conf_value("nocurses"))) {
+ if (! atoi((char *) get_conf_value("nocurses"))) {
#ifdef HISTORY_FILE
commandline_history = (struct history *) create_history(':');
load_history(commandline_history, ':'); // load the command history file
@@ -225,7 +225,7 @@ int main (int argc, char ** argv) {
// initiate NCURSES if that is what is wanted
- if (! atoi(get_conf_value("nocurses")))
+ if (! atoi((char *) get_conf_value("nocurses")))
ui_start_screen();
#ifdef USECOLORS
@@ -253,7 +253,7 @@ int main (int argc, char ** argv) {
return exit_app(-1);
}
- if (! atoi(get_conf_value("nocurses"))) { // WE MUST STOP SCREEN!
+ if (! atoi((char *) get_conf_value("nocurses"))) { // WE MUST STOP SCREEN!
ui_stop_screen();
// if output is set, nocurses should always be 1 !
@@ -286,7 +286,7 @@ int main (int argc, char ** argv) {
// initiate ui
FILE * f;
- if ( ! atoi(get_conf_value("nocurses"))) {
+ if ( ! atoi((char *) get_conf_value("nocurses"))) {
// we show welcome screen if no spreadsheet was passed to SC-IM
// and no input was sent throw pipeline
if ( ! curfile[0] && ! wcslen(stdin_buffer)) {
@@ -304,7 +304,7 @@ int main (int argc, char ** argv) {
}
// handle input from keyboard
- if (! atoi(get_conf_value("nocurses")))
+ if (! atoi((char *) get_conf_value("nocurses")))
buffer = (struct block *) create_buf(); // this should only take place if curses ui
wchar_t nocurses_buffer[BUFFERSIZE];
@@ -317,7 +317,7 @@ int main (int argc, char ** argv) {
lastbackup_tv = (struct timeval) {0};
#endif
- while ( ! shall_quit && ! atoi(get_conf_value("quit_afterload"))) {
+ while ( ! shall_quit && ! atoi((char *) get_conf_value("quit_afterload"))) {
// save current time for runtime timer
gettimeofday(&current_tv, NULL);
@@ -325,7 +325,7 @@ int main (int argc, char ** argv) {
handle_backup();
// if we are in ncurses
- if (! atoi(get_conf_value("nocurses"))) {
+ if (! atoi((char *) get_conf_value("nocurses"))) {
handle_input(buffer);
// if we are not in ncurses
@@ -338,7 +338,7 @@ int main (int argc, char ** argv) {
shall_quit=2 means :q! */
if (shall_quit == 1 && modcheck()) shall_quit = 0;
}
- if (atoi(get_conf_value("nocurses")) && f != NULL) fclose(f);
+ if (atoi((char *) get_conf_value("nocurses")) && f != NULL) fclose(f);
return shall_quit == -1 ? exit_app(-1) : exit_app(0);
}
@@ -459,7 +459,7 @@ void delete_structures() {
int exit_app(int status) {
// free history
- if (! atoi(get_conf_value("nocurses"))) {
+ if (! atoi((char *) get_conf_value("nocurses"))) {
#ifdef HISTORY_FILE
if (! save_history(commandline_history, "w")) sc_error("Could not save commandline history");
@@ -492,11 +492,11 @@ int exit_app(int status) {
erase_buf(buffer);
// stop CURSES screen
- if (! atoi(get_conf_value("nocurses")))
+ if (! atoi((char *) (get_conf_value("nocurses"))))
ui_stop_screen();
// close fdoutput
- if (get_conf_value("output") != '\0' && fdoutput != NULL) {
+ if (get_conf_value("output") != NULL && get_conf_value("output")[0] != '\0' && fdoutput != NULL) {
fclose(fdoutput);
}
@@ -559,7 +559,7 @@ void load_sc() {
if (c) sprintf(word + strlen(word), " ");
sprintf(word + strlen(word), "%s", p.we_wordv[c]);
}
- if (strlen(word) && ! readfile(word, 0) && ! atoi(get_conf_value("nocurses"))) {
+ if (strlen(word) && ! readfile(word, 0) && ! atoi((char *) get_conf_value("nocurses"))) {
sc_info("New file: \"%s\"", word); // file passed to scim executable does not exists
}
wordfree(&p);
@@ -657,7 +657,7 @@ void sig_cont() {
*/
void sig_int() {
- if ( ! atoi(get_conf_value("debug")))
+ if ( ! atoi((char *) get_conf_value("debug")))
sc_error("Got SIGINT. Press «:q<Enter>» to quit SC-IM");
else
shall_quit = 2;
diff --git a/src/utils/dictionary.c b/src/utils/dictionary.c
index cba7ae3..a488c9c 100755
--- a/src/utils/dictionary.c
+++ b/src/utils/dictionary.c
@@ -76,6 +76,7 @@ void put(struct dictionary * d, char * k, char * v) {
//if ( ! strlen (k) ) return;
struct nlist * nl;
+ char * cl;
// Insert the first element
if (d->list == NULL) {
@@ -91,7 +92,7 @@ void put(struct dictionary * d, char * k, char * v) {
// Duplicated keys are not allowed.
// If an existent key is inserted, the value is overwritten.
- } else if ( get(d, k) != '\0' ) {
+ } else if ( (cl = get(d, k)) != NULL && cl[0] != '\0' ) {
nl = get_nl(d, k);
free(nl->val);