]> git.draconx.ca Git - gob-dx.git/blobdiff - src/checks.c
Release 0.93.4
[gob-dx.git] / src / checks.c
index d287341513dc34c21903e97b1b3558eed787cca9..726dad91957c50d354a4919e2372f3cac36d8e3a 100644 (file)
 
 #include "checks.h"
 
-void
+static void
 check_duplicate(Class *c, Node *node, char *id, int line_no)
 {
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                char *nid;
                int nline_no;
@@ -49,15 +49,15 @@ check_duplicate(Class *c, Node *node, char *id, int line_no)
                        nline_no = v->line_no;
                } else
                        continue;
-               if(n==node ||
-                  line_no>=nline_no ||
-                  strcmp(nid,id)!=0 ||
+               if(n == node ||
+                  line_no >= nline_no ||
+                  strcmp(nid, id) != 0 ||
                   n->type != node->type)
                        continue;
                s = g_strdup_printf("symbol '%s' redefined, "
                                    "first defined on line %d",
-                                   id,line_no);
-               print_error(FALSE,s,nline_no);
+                                   id, line_no);
+               print_error(FALSE, s, nline_no);
        }
 }
 
@@ -65,14 +65,14 @@ void
 check_duplicate_symbols(Class *c)
 {
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
-                       check_duplicate(c,n,m->id,m->line_no);
+                       check_duplicate(c, n, m->id, m->line_no);
                } else if(n->type == VARIABLE_NODE) {
                        Variable *v = (Variable *)n;
-                       check_duplicate(c,n,v->id,v->line_no);
+                       check_duplicate(c, n, v->id, v->line_no);
                }
        }
 }
@@ -81,14 +81,14 @@ void
 check_bad_symbols(Class *c)
 {
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
                        if((m->method == SIGNAL_LAST_METHOD ||
                            m->method == SIGNAL_FIRST_METHOD ||
                            m->method == VIRTUAL_METHOD) &&
-                          strcmp(m->id,"__parent__")==0) {
+                          strcmp(m->id, "__parent__")==0) {
                                char *s;
                                s = g_strdup_printf("'%s' not allowed as an "
                                                    "identifier of signal "
@@ -99,33 +99,32 @@ check_bad_symbols(Class *c)
                        }
                        if(m->method != INIT_METHOD &&
                           m->method != CLASS_INIT_METHOD &&
-                          (strcmp(m->id,"init")==0 ||
-                           strcmp(m->id,"class_init")==0)) {
+                          (strcmp(m->id, "init")==0 ||
+                           strcmp(m->id, "class_init")==0)) {
                                print_error(FALSE,"init, or class_init not "
                                            "allowed as an "
                                            "identifier of non-"
-                                           "constructor methods",m->line_no);
+                                           "constructor methods", m->line_no);
                        }
                } else if(n->type == VARIABLE_NODE) {
                        Variable *v = (Variable *)n;
-                       if(strcmp(v->id,"_priv")==0 ||
-                          strcmp(v->id,"__parent__")==0) {
+                       if(strcmp(v->id, "_priv")==0 ||
+                          strcmp(v->id, "__parent__")==0) {
                                char *s;
                                s = g_strdup_printf("'%s' not allowed as a "
-                                                   "data member name",v->id);
-                               print_error(FALSE,s,v->line_no);
+                                                   "data member name", v->id);
+                               print_error(FALSE, s, v->line_no);
                                g_free(s);
                        }
                }
        }
 }
 
-
-void
-check_duplicate_named(Class *c,Node *node,char *id, int line_no)
+static void
+check_duplicate_named(Class *c, Node *node, char *id, int line_no)
 {
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                char *nid;
                int nline_no;
@@ -160,7 +159,7 @@ void
 check_duplicate_signals_args(Class *c)
 {
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
@@ -178,7 +177,7 @@ void
 check_public_new(Class *c)
 {
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
@@ -197,7 +196,7 @@ void
 check_vararg(Class *c)
 {
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
@@ -221,7 +220,7 @@ void
 check_firstarg(Class *c)
 {
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
@@ -244,7 +243,7 @@ void
 check_nonvoidempty(Class *c)
 {
        GList *li;
-       for(li=c->nodes; li; li=g_list_next(li)) {
+       for(li = c->nodes; li != NULL; li = g_list_next(li)) {
                Node *n = li->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
@@ -273,7 +272,7 @@ void
 check_signal_args(Class *c)
 {
        GList *li;
-       for(li=c->nodes; li; li=g_list_next(li)) {
+       for(li = c->nodes; li != NULL; li = g_list_next(li)) {
                Node *n = li->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
@@ -300,7 +299,7 @@ void
 check_argument_types(Class *c)
 {
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == ARGUMENT_NODE) {
                        Argument *a = (Argument *)n;
@@ -324,7 +323,7 @@ count_signals(Class *c)
 {
        int num = 0;
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
@@ -341,8 +340,7 @@ count_arguments(Class *c)
 {
        int num = 0;
        GList *li;
-
-       for(li=c->nodes;li;li=g_list_next(li)) {
+       for(li = c->nodes; li != NULL; li = g_list_next(li)) {
                Node *n = li->data;
                if(n->type == ARGUMENT_NODE)
                        num ++;
@@ -355,7 +353,7 @@ count_overrides(Class *c)
 {
        int num = 0;
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
@@ -371,7 +369,7 @@ count_privates(Class *c)
 {
        int num = 0;
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == VARIABLE_NODE) {
                        Variable *v = (Variable *)n;
@@ -387,7 +385,7 @@ count_protecteds(Class *c)
 {
        int num = 0;
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == METHOD_NODE) {
                        Method *m = (Method *)n;
@@ -403,7 +401,7 @@ count_destructors(Class *c)
 {
        int num = 0;
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == VARIABLE_NODE) {
                        Variable *v = (Variable *)n;
@@ -419,7 +417,7 @@ count_initializers(Class *c)
 {
        int num = 0;
        GList *l;
-       for(l=c->nodes;l;l=g_list_next(l)) {
+       for(l = c->nodes; l != NULL; l = g_list_next(l)) {
                Node *n = l->data;
                if(n->type == VARIABLE_NODE) {
                        Variable *v = (Variable *)n;