2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
gbc_form.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
|
|
|
|
2009-08-17 12:41:51 +02: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
|
|
|
|
2009-08-17 12:41:51 +02: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
|
|
|
|
2009-08-17 12:41:51 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#define __GBC_FORM_C
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "gb_common.h"
|
|
|
|
#include "gb_error.h"
|
|
|
|
#include "gb_limit.h"
|
|
|
|
#include "gb_file.h"
|
|
|
|
#include "gb_str.h"
|
|
|
|
#include "gbc_compile.h"
|
2009-01-04 19:55:25 +01:00
|
|
|
#include "gbc_chown.h"
|
2007-12-30 17:41:49 +01:00
|
|
|
#include "gbc_form.h"
|
|
|
|
|
|
|
|
/*#define DEBUG*/
|
|
|
|
|
2010-12-05 21:17:24 +01:00
|
|
|
static char *_source;
|
2007-12-30 17:41:49 +01:00
|
|
|
static const char *_current;
|
|
|
|
|
|
|
|
static FORM_PARENT form_parent[MAX_FORM_PARENT];
|
2008-01-06 19:49:23 +01:00
|
|
|
static int form_parent_level;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-01-04 19:55:25 +01:00
|
|
|
static bool _no_trim = FALSE;
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-03-18 14:14:17 +01:00
|
|
|
void FORM_print_len(const char *buffer, int len)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
if (JOB->verbose)
|
|
|
|
printf("%.*s", len, buffer);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-01-04 19:55:25 +01:00
|
|
|
BUFFER_add(&JOB->source, buffer, len);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-18 14:14:17 +01:00
|
|
|
void FORM_print(const char *buffer)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
if (JOB->verbose)
|
|
|
|
printf("%s", buffer);
|
2010-06-24 03:14:12 +02:00
|
|
|
|
2009-01-04 19:55:25 +01:00
|
|
|
BUFFER_add(&JOB->source, buffer, strlen(buffer));
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-18 14:14:17 +01:00
|
|
|
void FORM_print_char(char c)
|
|
|
|
{
|
|
|
|
if (JOB->verbose)
|
|
|
|
putchar(c);
|
|
|
|
|
|
|
|
BUFFER_add_char(&JOB->source, c);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
static void print_fmt(const char *before, const char *word, int len, const char *after)
|
|
|
|
{
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print(before);
|
|
|
|
FORM_print_len(word, len);
|
|
|
|
FORM_print(after);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2011-10-09 12:00:33 +02:00
|
|
|
|
|
|
|
static void print_var(const char *before, const char *word, int len, const char *after)
|
|
|
|
{
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print(before);
|
2011-10-09 12:00:33 +02:00
|
|
|
if (!word)
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print("Me");
|
2011-10-09 12:00:33 +02:00
|
|
|
else
|
|
|
|
{
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print("{");
|
|
|
|
FORM_print_len(word, len);
|
|
|
|
FORM_print("}");
|
2011-10-09 12:00:33 +02:00
|
|
|
}
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print(after);
|
2011-10-09 12:00:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-08 21:57:50 +02:00
|
|
|
static bool read_line(const char **str, int *len)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2010-05-22 20:02:34 +02:00
|
|
|
const char *start, *end;
|
2009-01-04 19:55:25 +01:00
|
|
|
unsigned char car;
|
2010-05-22 20:02:34 +02:00
|
|
|
int l;
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
if (_no_trim)
|
|
|
|
{
|
|
|
|
car = *_current;
|
|
|
|
if (!car)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
car = *_current;
|
|
|
|
if (!car)
|
|
|
|
return TRUE;
|
|
|
|
if (car > ' ')
|
|
|
|
break;
|
|
|
|
|
|
|
|
_current++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-22 20:02:34 +02:00
|
|
|
start = _current;
|
2009-01-04 19:55:25 +01:00
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
car = *_current++;
|
2010-05-22 20:02:34 +02:00
|
|
|
if (car == '\n') // || car =='\r' || !car)
|
2009-01-04 19:55:25 +01:00
|
|
|
break;
|
2010-05-22 20:02:34 +02:00
|
|
|
//if (car > ' ')
|
|
|
|
// nospace = _current;
|
|
|
|
}
|
|
|
|
|
|
|
|
end = _current;
|
|
|
|
l = (int)(end - start);
|
|
|
|
|
|
|
|
while (l > 0 && (uchar)end[-1] <= ' ')
|
|
|
|
{
|
|
|
|
end--;
|
|
|
|
l--;
|
2009-01-04 19:55:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
*str = start;
|
2010-05-22 20:02:34 +02:00
|
|
|
*len = l;
|
2009-01-04 19:55:25 +01:00
|
|
|
return FALSE;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
static char *get_word(const char **str, int *len)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
char car;
|
|
|
|
const char *pos;
|
|
|
|
|
|
|
|
*len = 0;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
car = **str;
|
|
|
|
if (car == '\n')
|
|
|
|
return NULL;
|
|
|
|
if (!isspace(car))
|
|
|
|
break;
|
|
|
|
(*str)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = *str;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
car = **str;
|
|
|
|
if (isspace(car))
|
|
|
|
break;
|
|
|
|
(*str)++;
|
|
|
|
(*len)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (char *)pos;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
static void parent_enter(const char *str, int len)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
if (form_parent_level >= MAX_FORM_PARENT)
|
|
|
|
THROW("&1: too many nested containers", JOB->form);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-01-04 19:55:25 +01:00
|
|
|
form_parent[form_parent_level].name = (char *)str;
|
|
|
|
form_parent[form_parent_level].len = len;
|
|
|
|
form_parent_level++;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void parent_leave(void)
|
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
if (form_parent_level == 0)
|
|
|
|
THROW("&1: syntax error", JOB->form);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2009-01-04 19:55:25 +01:00
|
|
|
form_parent_level--;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
static void parent_get(char **str, int *len, int add)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
if (form_parent_level < add)
|
|
|
|
{
|
|
|
|
*str = NULL;
|
|
|
|
*len = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-10-09 12:00:33 +02:00
|
|
|
FORM_PARENT *fp = &form_parent[form_parent_level - add];
|
|
|
|
*str = fp->name;
|
|
|
|
*len = fp->len;
|
2009-01-04 19:55:25 +01:00
|
|
|
}
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
static void get_container(char **str, int *len)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
parent_get(str, len, 2);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2008-01-06 19:49:23 +01:00
|
|
|
static void get_current(char **str, int *len)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
parent_get(str, len, 1);
|
|
|
|
}
|
|
|
|
|
2011-03-29 02:24:15 +02:00
|
|
|
static void save_action(bool delete)
|
2009-01-04 19:55:25 +01:00
|
|
|
{
|
|
|
|
FILE *file;
|
|
|
|
const char *path;
|
|
|
|
char *name;
|
|
|
|
const char *line;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
path = FILE_cat(FILE_get_dir(COMP_project), ".action", NULL);
|
2009-11-22 20:18:38 +01:00
|
|
|
mkdir(path, 0777);
|
2009-11-22 20:16:39 +01:00
|
|
|
FILE_set_owner(path, COMP_project);
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
name = STR_copy(FILE_set_ext(FILE_get_name(JOB->form), "action"));
|
|
|
|
path = FILE_cat(FILE_get_dir(COMP_project), ".action", name, NULL);
|
|
|
|
|
2011-03-29 02:24:15 +02:00
|
|
|
if (delete)
|
2009-01-04 19:55:25 +01:00
|
|
|
{
|
2011-03-29 02:24:15 +02:00
|
|
|
if (FILE_exist(path))
|
|
|
|
{
|
|
|
|
if (JOB->verbose)
|
2011-04-22 18:52:59 +02:00
|
|
|
printf("Deleting action file %s\n", path);
|
2011-03-29 02:24:15 +02:00
|
|
|
|
|
|
|
FILE_unlink(path);
|
|
|
|
}
|
2009-01-04 19:55:25 +01:00
|
|
|
}
|
2011-03-29 02:24:15 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (JOB->verbose)
|
2011-04-22 18:52:59 +02:00
|
|
|
printf("Writing action file %s\n", path);
|
2009-01-04 19:55:25 +01:00
|
|
|
|
2011-03-29 02:24:15 +02:00
|
|
|
file = fopen(path, "w");
|
|
|
|
if (!file)
|
|
|
|
THROW("Cannot create action file: &1", path);
|
|
|
|
|
|
|
|
fputs("# Gambas Action File 3.0\n", file);
|
|
|
|
|
|
|
|
_no_trim = TRUE;
|
|
|
|
while (!read_line(&line, &len))
|
|
|
|
{
|
|
|
|
fwrite(line, sizeof(char), len, file);
|
|
|
|
putc('\n', file);
|
|
|
|
}
|
|
|
|
_no_trim = FALSE;
|
|
|
|
|
|
|
|
if (fclose(file))
|
|
|
|
THROW("Cannot create action file: &1", path);
|
|
|
|
|
|
|
|
FILE_set_owner(path, COMP_project);
|
|
|
|
}
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
STR_free(name);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2012-01-28 10:55:55 +01:00
|
|
|
char *FORM_get_file_family(const char *file, const FORM_FAMILY **family)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
char *form;
|
2012-01-28 10:55:55 +01:00
|
|
|
const FORM_FAMILY *p;
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
if (strcmp(FILE_get_ext(file), "class"))
|
|
|
|
return NULL;
|
|
|
|
|
2010-03-11 11:59:53 +01:00
|
|
|
p = COMP_form_families;
|
|
|
|
|
2012-01-28 10:55:55 +01:00
|
|
|
while (p->ext)
|
2009-01-04 19:55:25 +01:00
|
|
|
{
|
2012-01-28 10:55:55 +01:00
|
|
|
form = STR_copy(FILE_set_ext(file, p->ext));
|
2010-03-11 11:59:53 +01:00
|
|
|
if (FILE_exist(form))
|
|
|
|
break;
|
2009-01-04 19:55:25 +01:00
|
|
|
STR_free(form);
|
2010-03-11 11:59:53 +01:00
|
|
|
form = NULL;
|
|
|
|
p++;
|
2009-01-04 19:55:25 +01:00
|
|
|
}
|
2010-03-11 11:59:53 +01:00
|
|
|
|
2012-01-28 10:55:55 +01:00
|
|
|
if (form) *family= p;
|
2010-03-11 11:59:53 +01:00
|
|
|
return form;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
2012-03-18 14:14:17 +01:00
|
|
|
/*
|
2009-07-08 21:57:50 +02:00
|
|
|
static bool FORM_init(void)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
BUFFER_create(&_source);
|
|
|
|
BUFFER_load_file(&_source, JOB->form);
|
|
|
|
BUFFER_add(&_source, "\n\0", 2);
|
|
|
|
_current = _source;
|
|
|
|
return FALSE;
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void FORM_exit(void)
|
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
BUFFER_delete(&_source);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
2012-03-18 14:14:17 +01:00
|
|
|
*/
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-03-18 14:14:17 +01:00
|
|
|
void FORM_do(char *source, bool ctrl_public)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
2009-01-04 19:55:25 +01:00
|
|
|
const char *line;
|
|
|
|
char *word;
|
|
|
|
char *win = NULL;
|
|
|
|
char *twin = NULL;
|
|
|
|
|
2011-10-16 21:24:01 +02:00
|
|
|
int len, len_twin;
|
2009-01-04 19:55:25 +01:00
|
|
|
const char *pos_rewind;
|
|
|
|
bool virtual;
|
2009-09-17 22:58:27 +02:00
|
|
|
bool public;
|
2011-03-29 02:24:15 +02:00
|
|
|
bool action;
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
if (JOB->form == NULL)
|
|
|
|
return;
|
|
|
|
|
2012-03-18 14:14:17 +01:00
|
|
|
_source = source;
|
|
|
|
_current = _source;
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
/* version */
|
|
|
|
|
|
|
|
if (read_line(&line, &len))
|
|
|
|
goto _ERROR;
|
|
|
|
|
|
|
|
if (strncasecmp(line, "# Gambas Form File 3.0", len))
|
|
|
|
THROW("Bad form file version");
|
|
|
|
|
|
|
|
pos_rewind = _current;
|
|
|
|
form_parent_level = 0;
|
|
|
|
|
2012-03-18 14:14:17 +01:00
|
|
|
//FORM_print("@SECTION\n");
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
while (!read_line(&line, &len))
|
|
|
|
{
|
|
|
|
if (len == 0 || *line == '#' || *line == '\'')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (*line == '{')
|
|
|
|
{
|
|
|
|
form_parent_level++;
|
|
|
|
line++;
|
|
|
|
|
|
|
|
word = get_word(&line, &len);
|
|
|
|
if (word == NULL)
|
|
|
|
goto _ERROR;
|
|
|
|
|
|
|
|
if (win != NULL)
|
|
|
|
{
|
2009-09-17 22:58:27 +02:00
|
|
|
if (word[0] == '!')
|
|
|
|
{
|
|
|
|
word++;
|
|
|
|
len--;
|
|
|
|
public = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
public = FALSE;
|
|
|
|
|
|
|
|
if (ctrl_public || public)
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print("Public");
|
2009-01-04 19:55:25 +01:00
|
|
|
else
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print("Private");
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
//print_fmt(" {%.*s} ", len, word);
|
|
|
|
print_fmt(" {", word, len, "} ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (win == NULL)
|
|
|
|
{
|
|
|
|
win = word;
|
|
|
|
}
|
|
|
|
|
|
|
|
word = get_word(&line, &len);
|
|
|
|
if (word == NULL)
|
|
|
|
goto _ERROR;
|
|
|
|
|
|
|
|
if (twin != NULL)
|
|
|
|
{
|
|
|
|
if (*word == '#')
|
|
|
|
{
|
|
|
|
word++;
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
//print_fmt("AS %.*s\n", len, word);
|
2011-10-09 12:00:33 +02:00
|
|
|
print_fmt("As ", word, len, "\n");
|
2009-01-04 19:55:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (twin == NULL)
|
|
|
|
{
|
|
|
|
twin = word;
|
|
|
|
len_twin = len;
|
|
|
|
|
|
|
|
//print_fmt("INHERITS %.*s\n\n", len_twin, twin);
|
2011-10-09 12:00:33 +02:00
|
|
|
print_fmt("Inherits ", twin, len_twin, "\n\n");
|
2009-01-04 19:55:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*line == '}')
|
|
|
|
{
|
|
|
|
form_parent_level--;
|
|
|
|
if (form_parent_level <= 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print("\nPublic Sub {$load}()\n\n");
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
_current = pos_rewind;
|
|
|
|
form_parent_level = 0;
|
|
|
|
|
|
|
|
while (!read_line(&line, &len))
|
|
|
|
{
|
|
|
|
if (len == 0 || *line == '#' || *line == '\'')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (*line == '{')
|
|
|
|
{
|
|
|
|
line++;
|
|
|
|
|
|
|
|
word = get_word(&line, &len);
|
|
|
|
if (word == NULL)
|
|
|
|
goto _ERROR;
|
|
|
|
|
|
|
|
if (form_parent_level == 0)
|
|
|
|
{
|
2011-10-09 12:00:33 +02:00
|
|
|
parent_enter(NULL, 0);
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print(" With Me\n");
|
2009-01-04 19:55:25 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//print_fmt(" {%.*s} = NEW ", len, word);
|
2009-09-17 22:58:27 +02:00
|
|
|
if (word[0] == '!')
|
|
|
|
{
|
|
|
|
word++;
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
|
2011-10-09 12:00:33 +02:00
|
|
|
print_fmt(" {", word, len, "} = New ");
|
2009-01-04 19:55:25 +01:00
|
|
|
parent_enter(word, len);
|
|
|
|
|
|
|
|
word = get_word(&line, &len);
|
|
|
|
if (word == NULL)
|
|
|
|
goto _ERROR;
|
|
|
|
|
|
|
|
if (*word == '#')
|
|
|
|
{
|
|
|
|
virtual = TRUE;
|
|
|
|
word++;
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
virtual = FALSE;
|
|
|
|
|
|
|
|
//print_fmt("%.*s", len, word);
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print_len(word, len);
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
if (!virtual)
|
|
|
|
{
|
|
|
|
get_container(&word, &len);
|
2011-10-09 12:00:33 +02:00
|
|
|
print_var("(", word, len, ")");
|
2009-01-04 19:55:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
word = get_word(&line, &len);
|
|
|
|
if (word == NULL)
|
|
|
|
get_current(&word, &len);
|
|
|
|
|
|
|
|
//print_fmt(" AS \"%.*s\"\n", len, word);
|
2011-10-09 12:00:33 +02:00
|
|
|
print_fmt(" As \"", word, len, "\"\n");
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
get_current(&word, &len);
|
2011-10-09 12:00:33 +02:00
|
|
|
print_var(" With ", word, len, "\n");
|
2009-01-04 19:55:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (*line == '}')
|
|
|
|
{
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print(" End With\n");
|
2009-01-04 19:55:25 +01:00
|
|
|
parent_leave();
|
|
|
|
if (form_parent_level == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*get_current(&word, &len_word);*/
|
2012-03-18 14:14:17 +01:00
|
|
|
/*FORM_print(" %.*s", len_word, word);*/
|
|
|
|
FORM_print(" .");
|
|
|
|
FORM_print_len(line, len);
|
|
|
|
FORM_print("\n");
|
2009-01-04 19:55:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (form_parent_level > 0)
|
|
|
|
goto _ERROR;
|
|
|
|
|
2012-03-18 14:14:17 +01:00
|
|
|
FORM_print("\nEnd\n\n");
|
2009-01-04 19:55:25 +01:00
|
|
|
|
2011-03-29 02:24:15 +02:00
|
|
|
// Create or delete the action file if needed
|
|
|
|
|
|
|
|
action = FALSE;
|
2009-01-04 19:55:25 +01:00
|
|
|
|
|
|
|
while (!read_line(&line, &len))
|
|
|
|
{
|
|
|
|
if (!strncasecmp(line, "# Gambas Action File 3.0", len))
|
|
|
|
{
|
2011-03-29 02:24:15 +02:00
|
|
|
save_action(FALSE);
|
|
|
|
action = TRUE;
|
2009-01-04 19:55:25 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-29 02:24:15 +02:00
|
|
|
if (!action)
|
|
|
|
save_action(TRUE);
|
|
|
|
|
2009-01-04 19:55:25 +01:00
|
|
|
return;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
_ERROR:
|
|
|
|
|
2009-01-04 19:55:25 +01:00
|
|
|
THROW("&1: syntax error in form file", JOB->form);
|
2007-12-30 17:41:49 +01:00
|
|
|
}
|
|
|
|
|