OpenCOBOL 1.1pre-rel
Functions | Variables
error.c File Reference
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "cobc.h"
#include "tree.h"
Include dependency graph for error.c:

Go to the source code of this file.

Functions

static void print_error (char *file, int line, const char *prefix, const char *fmt, va_list ap)
char * check_filler_name (char *name)
void cb_warning (const char *fmt,...)
void cb_error (const char *fmt,...)
void cb_warning_x (cb_tree x, const char *fmt,...)
void cb_error_x (cb_tree x, const char *fmt,...)
int cb_verify (const enum cb_support tag, const char *feature)
void redefinition_error (cb_tree x)
void redefinition_warning (cb_tree x, cb_tree y)
void undefined_error (cb_tree x)
void ambiguous_error (cb_tree x)
void group_error (cb_tree x, const char *clause)
void level_redundant_error (cb_tree x, const char *clause)
void level_require_error (cb_tree x, const char *clause)
void level_except_error (cb_tree x, const char *clause)

Variables

static char * errnamebuff = NULL

Function Documentation

void ambiguous_error ( cb_tree  x)

Definition at line 197 of file error.c.

{
        struct cb_word  *w;
        struct cb_field *p;
        struct cb_label *l2;
        cb_tree         l;
        cb_tree         y;

        w = CB_REFERENCE (x)->word;
        if (w->error == 0) {
                if (!errnamebuff) {
                        errnamebuff = cobc_malloc (COB_NORMAL_BUFF);
                }
                /* display error on the first time */
                snprintf (errnamebuff, COB_NORMAL_MAX, "'%s'", CB_NAME (x));
                for (l = CB_REFERENCE (x)->chain; l; l = CB_REFERENCE (l)->chain) {
                        strcat (errnamebuff, " in '");
                        strcat (errnamebuff, CB_NAME (l));
                        strcat (errnamebuff, "'");
                }
                cb_error_x (x, _("%s ambiguous; need qualification"), errnamebuff);
                w->error = 1;

                /* display all fields with the same name */
                for (l = w->items; l; l = CB_CHAIN (l)) {
                        y = CB_VALUE (l);
                        snprintf (errnamebuff, COB_NORMAL_MAX, "'%s' ", w->name);
                        switch (CB_TREE_TAG (y)) {
                        case CB_TAG_FIELD:
                                for (p = CB_FIELD (y)->parent; p; p = p->parent) {
                                        strcat (errnamebuff, "in '");
                                        strcat (errnamebuff, p->name);
                                        strcat (errnamebuff, "' ");
                                }
                                break;
                        case CB_TAG_LABEL:
                                l2 = CB_LABEL (y);
                                if (l2->section) {
                                        strcat (errnamebuff, "in '");
                                        strcat (errnamebuff, (const char *)(l2->section->name));
                                        strcat (errnamebuff, "' ");
                                }
                                break;
                        default:
                                break;
                        }
                        strcat (errnamebuff, _("defined here"));
                        cb_error_x (y, errnamebuff);
                }
        }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_error ( const char *  fmt,
  ... 
)

Definition at line 85 of file error.c.

{
        va_list ap;

        va_start (ap, fmt);
        print_error (NULL, 0, "Error: ", fmt, ap);
        va_end (ap);

        errorcount++;

}

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_error_x ( cb_tree  x,
const char *  fmt,
  ... 
)

Definition at line 110 of file error.c.

{
        va_list ap;

        va_start (ap, fmt);
        print_error ((char *)(x->source_file), x->source_line, "Error: ", fmt, ap);
        va_end (ap);

        errorcount++;
}

Here is the call graph for this function:

int cb_verify ( const enum cb_support  tag,
const char *  feature 
)

Definition at line 122 of file error.c.

{
        switch (tag) {
        case CB_OK:
                return 1;
        case CB_WARNING:
                return 1;
        case CB_ARCHAIC:
                if (cb_warn_archaic) {
                        cb_warning (_("%s is archaic in %s"), feature, cb_config_name);
                }
                return 1;
        case CB_OBSOLETE:
                if (cb_warn_obsolete) {
                        cb_warning (_("%s is obsolete in %s"), feature, cb_config_name);
                }
                return 1;
        case CB_SKIP:
                return 0;
        case CB_IGNORE:
                cb_warning (_("%s ignored"), feature);
                return 0;
        case CB_ERROR:
                return 0;
        case CB_UNCONFORMABLE:
                cb_error (_("%s does not conform to %s"), feature, cb_config_name);
                return 0;
        }
        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_warning ( const char *  fmt,
  ... 
)

Definition at line 73 of file error.c.

{
        va_list ap;

        va_start (ap, fmt);
        print_error (NULL, 0, "Warning: ", fmt, ap);
        va_end (ap);

        warningcount++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cb_warning_x ( cb_tree  x,
const char *  fmt,
  ... 
)

Definition at line 98 of file error.c.

{
        va_list ap;

        va_start (ap, fmt);
        print_error ((char *)(x->source_file), x->source_line, "Warning: ", fmt, ap);
        va_end (ap);

        warningcount++;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* check_filler_name ( char *  name)

Definition at line 64 of file error.c.

{
        if (!memcmp (name, "WORK$", 5)) {
                name = (char *)"FILLER";
        }
        return name;
}

Here is the caller graph for this function:

void group_error ( cb_tree  x,
const char *  clause 
)

Definition at line 250 of file error.c.

{
        cb_error_x (x, _("Group item '%s' cannot have %s clause"), check_filler_name (cb_name (x)), clause);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void level_except_error ( cb_tree  x,
const char *  clause 
)

Definition at line 270 of file error.c.

{
        cb_error_x (x, _("Level %02d item '%s' cannot have other than %s clause"),
                    cb_field (x)->level, check_filler_name (cb_name (x)), clause);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void level_redundant_error ( cb_tree  x,
const char *  clause 
)

Definition at line 256 of file error.c.

{
        cb_error_x (x, _("Level %02d item '%s' cannot have %s clause"),
                    cb_field (x)->level, check_filler_name (cb_name (x)), clause);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void level_require_error ( cb_tree  x,
const char *  clause 
)

Definition at line 263 of file error.c.

{
        cb_error_x (x, _("Level %02d item '%s' requires %s clause"),
                    cb_field (x)->level, check_filler_name (cb_name (x)), clause);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void print_error ( char *  file,
int  line,
const char *  prefix,
const char *  fmt,
va_list  ap 
) [static]

Definition at line 34 of file error.c.

{
        static struct cb_label *last_section = NULL;
        static struct cb_label *last_paragraph = NULL;

        file = file ? file : cb_source_file;
        line = line ? line : cb_source_line;

        /* print the paragraph or section name */
        if (current_section != last_section || current_paragraph != last_paragraph) {
                if (current_paragraph &&
                    strcmp ((const char *)(current_paragraph->name), "MAIN PARAGRAPH")) {
                        fprintf (stderr, _("%s: In paragraph '%s':\n"),
                                 file, current_paragraph->name);
                } else if (current_section &&
                           strcmp ((const char *)(current_section->name), "MAIN SECTION")) {
                                fprintf (stderr, _("%s: In section '%s':\n"),
                                        file, current_section->name);
                }
                last_section = current_section;
                last_paragraph = current_paragraph;
        }

        /* print the error */
        fprintf (stderr, "%s:%d: %s", file, line, prefix);
        vfprintf (stderr, fmt, ap);
        fputs ("\n", stderr);
}

Here is the caller graph for this function:

void redefinition_error ( cb_tree  x)

Definition at line 154 of file error.c.

{
        struct cb_word  *w;

        w = CB_REFERENCE (x)->word;
        cb_error_x (x, _("Redefinition of '%s'"), w->name);
        cb_error_x (CB_VALUE (w->items), _("'%s' previously defined here"), w->name);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void redefinition_warning ( cb_tree  x,
cb_tree  y 
)

Definition at line 164 of file error.c.

{
        struct cb_word  *w;

        w = CB_REFERENCE (x)->word;
        cb_warning_x (x, _("Redefinition of '%s'"), w->name);
        if (y) {
                cb_warning_x (y, _("'%s' previously defined here"), w->name);
        } else {
                cb_warning_x (CB_VALUE (w->items), _("'%s' previously defined here"), w->name);
        }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void undefined_error ( cb_tree  x)

Definition at line 178 of file error.c.

{
        struct cb_reference     *r;
        cb_tree                 c;

        if (!errnamebuff) {
                errnamebuff = cobc_malloc (COB_NORMAL_BUFF);
        }
        r = CB_REFERENCE (x);
        snprintf (errnamebuff, COB_NORMAL_MAX, "'%s'", CB_NAME (x));
        for (c = r->chain; c; c = CB_REFERENCE (c)->chain) {
                strcat (errnamebuff, " in '");
                strcat (errnamebuff, CB_NAME (c));
                strcat (errnamebuff, "'");
        }
        cb_error_x (x, _("%s undefined"), errnamebuff);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char* errnamebuff = NULL [static]

Definition at line 31 of file error.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines