2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
gbc_compile.c
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
(c) 2000-2012 Benoît Minisini <gambas@users.sourceforge.net>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __GBC_COMPILE_C
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "gb_common.h"
|
|
|
|
#include "gb_error.h"
|
|
|
|
#include "gb_str.h"
|
|
|
|
#include "gb_file.h"
|
|
|
|
#include "gb_component.h"
|
|
|
|
|
|
|
|
#include "gbc_compile.h"
|
|
|
|
#include "gb_reserved.h"
|
|
|
|
#include "gbc_read.h"
|
|
|
|
#include "gbc_trans.h"
|
|
|
|
#include "gbc_header.h"
|
|
|
|
#include "gb_code.h"
|
|
|
|
#include "gbc_output.h"
|
|
|
|
#include "gbc_form.h"
|
2008-05-11 20:07:16 +02:00
|
|
|
#include "gbc_chown.h"
|
2010-04-25 12:46:57 +02:00
|
|
|
#include "gb_arch.h"
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
/*#define DEBUG*/
|
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
char *COMP_root = NULL;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
char *COMP_project;
|
2010-05-03 12:19:13 +02:00
|
|
|
char *COMP_project_name;
|
2008-01-06 19:49:23 +01:00
|
|
|
char *COMP_info_path;
|
2010-05-22 20:02:34 +02:00
|
|
|
static char *COMP_classes = NULL;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
COMPILE COMP_current;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-01-28 10:55:55 +01:00
|
|
|
const FORM_FAMILY COMP_form_families[] =
|
|
|
|
{
|
|
|
|
{ "form", FORM_NORMAL },
|
|
|
|
{ "report", FORM_NORMAL },
|
|
|
|
{ "webpage", FORM_WEBPAGE },
|
|
|
|
{ NULL }
|
|
|
|
};
|
2010-03-11 11:59:53 +01:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
static bool read_line(FILE *f, char *dir, int max)
|
|
|
|
{
|
2010-04-25 12:46:57 +02:00
|
|
|
char *p;
|
|
|
|
int c;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
p = dir;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
max--;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
c = fgetc(f);
|
|
|
|
if (c == EOF)
|
|
|
|
return TRUE;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
if (c == '\n' || max == 0)
|
|
|
|
{
|
|
|
|
*p = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
*p++ = (char)c;
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
static void add_memory_list(char *p, int size)
|
|
|
|
{
|
|
|
|
char *pe = p + size;
|
|
|
|
char *p2;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
if (p >= pe)
|
|
|
|
break;
|
|
|
|
|
|
|
|
p2 = p;
|
|
|
|
while (p2 < pe && *p2 != '\n')
|
|
|
|
p2++;
|
|
|
|
|
|
|
|
if (p2 >= pe)
|
|
|
|
break;
|
|
|
|
|
|
|
|
len = p2 - p;
|
|
|
|
if (len > 2 && p[len - 1] == '?')
|
|
|
|
len--;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-22 20:02:34 +02:00
|
|
|
COMPILE_add_class(p, len);
|
2010-04-25 12:46:57 +02:00
|
|
|
|
|
|
|
p = p2 + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void add_file_list(FILE *fi)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2010-04-25 12:46:57 +02:00
|
|
|
char line[256];
|
|
|
|
int len;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
if (read_line(fi, line, sizeof(line)))
|
|
|
|
break;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
len = strlen(line);
|
|
|
|
if (len > 2 && line[len - 1] == '?')
|
|
|
|
len--;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-05-22 20:02:34 +02:00
|
|
|
COMPILE_add_class(line, len);
|
2010-04-25 12:46:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void add_library_list_file(const char *path)
|
|
|
|
{
|
|
|
|
ARCH *arch;
|
|
|
|
ARCH_FIND find;
|
|
|
|
|
|
|
|
if (FILE_exist(path))
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2010-04-25 12:46:57 +02:00
|
|
|
arch = ARCH_open(path);
|
|
|
|
|
|
|
|
if (!ARCH_find(arch, ".list", 0, &find))
|
|
|
|
add_memory_list(&arch->addr[find.pos], find.len);
|
|
|
|
|
|
|
|
ARCH_close(arch);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
2010-04-25 12:46:57 +02:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
static void add_component_list_file(char *name)
|
|
|
|
{
|
|
|
|
char *path;
|
|
|
|
FILE *fi;
|
|
|
|
|
|
|
|
path = (char *)FILE_cat(COMP_info_path, name, NULL);
|
|
|
|
strcat(path, ".list");
|
|
|
|
fi = fopen(path, "r");
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
if (!fi)
|
|
|
|
{
|
2010-05-03 12:19:13 +02:00
|
|
|
// Do not raise an error if a component self-reference is not found
|
|
|
|
if (strcmp(name, COMP_project_name))
|
2010-04-25 12:46:57 +02:00
|
|
|
//fprintf(stderr, "warning: cannot read component list file: %s.list\n", name);
|
|
|
|
THROW("Component not found: &1", name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_file_list(fi);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
fclose(fi);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
|
2008-04-17 12:18:25 +02:00
|
|
|
static void startup_print(FILE *fs, const char *key, const char *def)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
2010-04-25 12:46:57 +02:00
|
|
|
char line[256];
|
|
|
|
int len = strlen(key);
|
|
|
|
bool print = FALSE;
|
2008-04-17 12:18:25 +02:00
|
|
|
|
|
|
|
fp = fopen(COMP_project, "r");
|
|
|
|
if (!fp)
|
|
|
|
return;
|
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
if (read_line(fp, line, sizeof(line)))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (strncmp(line, key, len) == 0)
|
|
|
|
{
|
|
|
|
fprintf(fs, "%s\n", &line[len]);
|
|
|
|
print = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
if (!print && def)
|
|
|
|
fprintf(fs, "%s\n", def);
|
2008-04-17 12:18:25 +02:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
void COMPILE_init(void)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2010-04-25 12:46:57 +02:00
|
|
|
const char *root;
|
|
|
|
FILE *fp;
|
|
|
|
char line[256];
|
|
|
|
//DIR *dir;
|
|
|
|
//struct dirent *dirent;
|
|
|
|
const char *name;
|
|
|
|
//struct passwd *info;
|
|
|
|
FILE *fs;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
RESERVED_init();
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
if (COMP_root)
|
|
|
|
root = COMP_root;
|
|
|
|
else
|
2010-04-25 12:46:57 +02:00
|
|
|
root = FILE_get_dir(FILE_get_dir(FILE_find_gambas()));
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
// Component directory
|
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
COMP_info_path = STR_copy(FILE_cat(root, "share/gambas" GAMBAS_VERSION_STRING "/info", NULL));
|
|
|
|
|
2010-05-03 12:19:13 +02:00
|
|
|
// Project name
|
|
|
|
|
|
|
|
COMP_project_name = STR_copy(FILE_get_name(FILE_get_dir(COMP_project)));
|
|
|
|
|
|
|
|
// Project classes
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
BUFFER_create(&COMP_classes);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
add_component_list_file("gb");
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
fp = fopen(COMP_project, "r");
|
|
|
|
if (!fp)
|
|
|
|
THROW(E_OPEN, COMP_project);
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
if (read_line(fp, line, sizeof(line)))
|
|
|
|
break;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
/*printf("%s\n", line);*/
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
if (strncmp(line, "Component=", 10) == 0)
|
|
|
|
add_component_list_file(&line[10]);
|
|
|
|
else if (strncmp(line, "Library=", 8) == 0)
|
|
|
|
add_library_list_file(&line[8]);
|
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
fclose(fp);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2008-05-11 20:07:16 +02:00
|
|
|
name = FILE_cat(FILE_get_dir(COMP_project), ".startup", NULL);
|
2010-04-25 12:46:57 +02:00
|
|
|
fs = fopen(name, "w");
|
|
|
|
if (!fs)
|
|
|
|
THROW("Cannot create .startup file");
|
2008-04-17 12:18:25 +02:00
|
|
|
|
|
|
|
startup_print(fs, "Startup=", "");
|
|
|
|
startup_print(fs, "Title=", "");
|
|
|
|
startup_print(fs, "Stack=", "0");
|
|
|
|
startup_print(fs, "StackTrace=", "0");
|
|
|
|
startup_print(fs, "Version=", "");
|
|
|
|
fputc('\n', fs);
|
|
|
|
startup_print(fs, "Component=", NULL);
|
2010-04-25 12:46:57 +02:00
|
|
|
startup_print(fs, "Library=", NULL);
|
2008-04-17 12:18:25 +02:00
|
|
|
fputc('\n', fs);
|
|
|
|
|
|
|
|
if (fclose(fs))
|
2010-04-25 12:46:57 +02:00
|
|
|
THROW("Cannot create .startup file");
|
|
|
|
|
|
|
|
FILE_set_owner(name, COMP_project);
|
2008-04-17 12:18:25 +02:00
|
|
|
|
2008-09-01 02:48:01 +02:00
|
|
|
// Adds a separator to make the difference between classes from components
|
|
|
|
// (they must be searched in the global symbol table) and classes from the
|
|
|
|
// project (they must be searched in the project symbol table)
|
|
|
|
|
2010-05-22 20:02:34 +02:00
|
|
|
COMPILE_add_class("-", 1);
|
2009-07-03 22:15:26 +02:00
|
|
|
|
|
|
|
/*
|
2010-04-25 12:46:57 +02:00
|
|
|
dir = opendir(FILE_get_dir(COMP_project));
|
|
|
|
if (dir)
|
|
|
|
{
|
|
|
|
while ((dirent = readdir(dir)) != NULL)
|
|
|
|
{
|
|
|
|
name = dirent->d_name;
|
|
|
|
if (*name == '.')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((strcasecmp(FILE_get_ext(name), "module") == 0)
|
|
|
|
|| (strcasecmp(FILE_get_ext(name), "class") == 0))
|
|
|
|
{
|
|
|
|
name = FILE_get_basename(name);
|
|
|
|
BUFFER_add(&COMP_classes, name, strlen(name));
|
|
|
|
BUFFER_add(&COMP_classes, "\n", 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir(dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
BUFFER_add(&COMP_classes, "\n", 1);
|
2009-07-03 22:15:26 +02:00
|
|
|
*/
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-19 22:55:16 +01:00
|
|
|
void COMPILE_begin(const char *file, bool trans, bool debug)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2010-04-25 12:46:57 +02:00
|
|
|
struct stat info;
|
|
|
|
off_t size;
|
|
|
|
|
|
|
|
CLEAR(JOB);
|
|
|
|
|
|
|
|
JOB->name = STR_copy(file);
|
2012-12-19 22:55:16 +01:00
|
|
|
JOB->debug = debug;
|
2012-01-28 10:55:55 +01:00
|
|
|
JOB->form = FORM_get_file_family(JOB->name, &JOB->family);
|
2010-04-25 12:46:57 +02:00
|
|
|
JOB->output = OUTPUT_get_file(JOB->name);
|
|
|
|
|
|
|
|
if (trans)
|
|
|
|
{
|
|
|
|
JOB->trans = TRUE;
|
|
|
|
JOB->tname = OUTPUT_get_trans_file(JOB->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
BUFFER_create(&JOB->source);
|
|
|
|
CLASS_create(&JOB->class);
|
|
|
|
|
|
|
|
JOB->default_library = NO_SYMBOL;
|
|
|
|
|
|
|
|
size = 0;
|
|
|
|
|
|
|
|
if (stat(JOB->name, &info))
|
2012-09-04 09:29:39 +02:00
|
|
|
ERROR_warning("cannot stat file: %s", JOB->name);
|
2010-04-25 12:46:57 +02:00
|
|
|
else
|
|
|
|
size += info.st_size;
|
|
|
|
|
|
|
|
if (JOB->form)
|
|
|
|
{
|
|
|
|
if (stat(JOB->form, &info))
|
2012-09-04 09:29:39 +02:00
|
|
|
ERROR_warning("cannot stat file: %s", JOB->form);
|
2010-04-25 12:46:57 +02:00
|
|
|
else
|
|
|
|
size += info.st_size * 2;
|
|
|
|
}
|
|
|
|
|
2013-03-30 00:33:01 +01:00
|
|
|
ALLOC(&JOB->pattern, sizeof(PATTERN) * (16 + size));
|
2010-04-25 12:46:57 +02:00
|
|
|
JOB->pattern_count = 0;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
void COMPILE_load(void)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2011-04-16 15:25:46 +02:00
|
|
|
if (BUFFER_load_file(&JOB->source, JOB->name))
|
|
|
|
THROW("Cannot load source file: &1", strerror(errno));
|
|
|
|
|
2011-04-22 18:52:59 +02:00
|
|
|
//BUFFER_add(&JOB->source, "\n", 1);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
void COMPILE_end(void)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2010-04-25 12:46:57 +02:00
|
|
|
CLASS_delete(&JOB->class);
|
|
|
|
BUFFER_delete(&JOB->source);
|
2013-03-30 00:33:01 +01:00
|
|
|
FREE(&JOB->pattern);
|
2010-04-25 12:46:57 +02:00
|
|
|
|
2012-11-10 01:19:53 +01:00
|
|
|
if (JOB->help)
|
|
|
|
ARRAY_delete(&JOB->help);
|
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
STR_free(JOB->name);
|
|
|
|
STR_free(JOB->form);
|
|
|
|
STR_free(JOB->output);
|
|
|
|
if (JOB->trans)
|
|
|
|
STR_free(JOB->tname);
|
2012-11-10 01:19:53 +01:00
|
|
|
if (JOB->help)
|
|
|
|
STR_free(JOB->hname);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2010-04-25 12:46:57 +02:00
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
void COMPILE_exit(void)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2010-04-25 12:46:57 +02:00
|
|
|
RESERVED_exit();
|
|
|
|
BUFFER_delete(&COMP_classes);
|
2010-05-03 12:19:13 +02:00
|
|
|
STR_free(COMP_project_name);
|
2010-04-25 12:46:57 +02:00
|
|
|
STR_free(COMP_project);
|
|
|
|
STR_free(COMP_info_path);
|
|
|
|
STR_free(COMP_root);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
2008-05-11 20:07:16 +02:00
|
|
|
|
2010-05-22 20:02:34 +02:00
|
|
|
void COMPILE_add_class(const char *name, int len)
|
2010-05-21 01:23:39 +02:00
|
|
|
{
|
2010-05-22 20:02:34 +02:00
|
|
|
unsigned char clen = len;
|
2010-05-21 01:23:39 +02:00
|
|
|
|
2010-05-22 20:02:34 +02:00
|
|
|
if (clen != len)
|
|
|
|
ERROR_panic("Class name is too long");
|
2010-05-21 01:23:39 +02:00
|
|
|
|
2010-05-22 20:02:34 +02:00
|
|
|
BUFFER_add(&COMP_classes, &clen, 1);
|
|
|
|
BUFFER_add(&COMP_classes, name, len);
|
2010-05-21 01:23:39 +02:00
|
|
|
}
|
|
|
|
|
2010-05-22 20:02:34 +02:00
|
|
|
void COMPILE_end_class(void)
|
2010-05-21 01:23:39 +02:00
|
|
|
{
|
2010-05-22 20:02:34 +02:00
|
|
|
unsigned char clen = 0;
|
|
|
|
BUFFER_add(&COMP_classes, &clen, 1);
|
|
|
|
}
|
2010-05-21 01:23:39 +02:00
|
|
|
|
2010-05-22 20:02:34 +02:00
|
|
|
void COMPILE_enum_class(char **name, int *len)
|
|
|
|
{
|
|
|
|
char *p = *name;
|
|
|
|
|
|
|
|
if (!p)
|
|
|
|
p = COMP_classes;
|
|
|
|
else
|
|
|
|
p += p[-1];
|
|
|
|
|
|
|
|
*len = *p;
|
|
|
|
*name = p + 1;
|
2010-05-21 01:23:39 +02:00
|
|
|
}
|
2012-09-04 09:29:39 +02:00
|
|
|
|
|
|
|
void COMPILE_print(int type, int line, const char *msg, ...)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
va_list args;
|
|
|
|
const char *arg[4];
|
|
|
|
bool col;
|
|
|
|
|
2012-10-02 22:31:06 +02:00
|
|
|
if (!JOB->warnings && type == MSG_WARNING)
|
2012-09-04 09:29:39 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
va_start(args, msg);
|
|
|
|
|
|
|
|
if (line < 0)
|
|
|
|
{
|
|
|
|
line = JOB->line;
|
|
|
|
col = JOB->column;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
col = FALSE;
|
|
|
|
|
|
|
|
if (JOB->name)
|
|
|
|
{
|
|
|
|
const char *name = FILE_get_name(JOB->name);
|
|
|
|
if (line)
|
|
|
|
{
|
|
|
|
if (line > JOB->max_line && JOB->form)
|
|
|
|
{
|
|
|
|
name = FILE_get_name(JOB->form);
|
|
|
|
fprintf(stderr, "%s:%d: ", name, line - FORM_FIRST_LINE + 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (col)
|
|
|
|
fprintf(stderr, "%s:%d:%d: ", name, line, READ_get_column());
|
|
|
|
else
|
|
|
|
fprintf(stderr, "%s:%d: ", name, line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf(stderr, "%s: ", name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf(stderr, "gbc: ");
|
|
|
|
|
|
|
|
fprintf(stderr, "%s: ", type ? "warning" : "error");
|
|
|
|
|
|
|
|
if (msg)
|
|
|
|
{
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
arg[i] = va_arg(args, const char *);
|
|
|
|
|
|
|
|
ERROR_define(msg, arg);
|
|
|
|
fputs(ERROR_info.msg, stderr);
|
|
|
|
putc('\n', stderr);
|
|
|
|
}
|
2013-01-06 17:13:31 +01:00
|
|
|
|
|
|
|
va_end(args);
|
2012-09-04 09:29:39 +02:00
|
|
|
}
|
|
|
|
|