8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 20:43:03 +01:00

New gpre -b option to be used in the msvc build process. It enable to set the base directory for compile time db without using sed.

This commit is contained in:
brodsom 2003-07-02 12:57:41 +00:00
parent 665f10361f
commit 239c6deb30
7 changed files with 73 additions and 23 deletions

View File

@ -20,7 +20,7 @@
//
// All Rights Reserved.
// Contributor(s): ______________________________________.
// $Id: gpre.cpp,v 1.24 2003-04-02 12:07:10 brodsom Exp $
// $Id: gpre.cpp,v 1.25 2003-07-02 12:57:41 brodsom Exp $
// Revision 1.2 2000/11/16 15:54:29 fsg
// Added new switch -verbose to gpre that will dump
// parsed lines to stderr
@ -42,7 +42,7 @@
//
//____________________________________________________________
//
// $Id: gpre.cpp,v 1.24 2003-04-02 12:07:10 brodsom Exp $
// $Id: gpre.cpp,v 1.25 2003-07-02 12:57:41 brodsom Exp $
//
#define GPRE_MAIN
@ -99,7 +99,7 @@ extern "C" {
static BOOLEAN all_digits(char *);
static int arg_is_string(SLONG, TEXT **, TEXT *);
static SSHORT compare_ASCII7z(char *, char *);
static SLONG compile_module(SLONG);
static SLONG compile_module(SLONG,TEXT*);
static BOOLEAN file_rename(TEXT *, TEXT *, TEXT *);
#ifdef GPRE_FORTRAN
static void finish_based(ACT);
@ -108,7 +108,7 @@ static int get_char(IB_FILE *);
static BOOLEAN get_switches(int, TEXT **, IN_SW_TAB, SW_TAB, TEXT **);
static TOK get_token();
static int nextchar();
static SLONG pass1();
static SLONG pass1(TEXT*);
static void pass2(SLONG);
static void print_switches();
static void remember_label(TEXT *);
@ -357,7 +357,7 @@ int main(int argc, char* argv[])
// Call a subroutine to process the input line
//
TEXT* filename_array[3] = { 0 };
TEXT* filename_array[4] = { 0 };
if (!get_switches(argc, argv, gpre_in_sw_table, sw_table, filename_array)) {
CPR_exit(FINI_ERROR);
@ -367,6 +367,7 @@ int main(int argc, char* argv[])
out_file_name = filename_array[1];
TEXT* db_filename = filename_array[2];
TEXT* db_base_directory = filename_array[3];
if (!file_name) {
ib_fprintf(ib_stderr, "gpre: no source file named.\n");
@ -868,7 +869,7 @@ int main(int argc, char* argv[])
sw_databases = isc_databases;
try {
for (end_position = 0; end_position = compile_module(end_position);); // empty loop
for (end_position = 0; end_position = compile_module(end_position,filename_array[3]);); // empty loop
} // try
catch (const std::exception&) {} // fall through to the cleanup code
@ -1357,7 +1358,7 @@ static SSHORT compare_ASCII7z( char *str1, char *str2)
// Process a module and generate output.
//
static SLONG compile_module( SLONG start_position)
static SLONG compile_module( SLONG start_position, TEXT* base_directory)
{
SLONG end_position;
GPRE_REQ request;
@ -1397,7 +1398,7 @@ static SLONG compile_module( SLONG start_position)
// Take a first pass at the module
end_position = pass1();
end_position = pass1(base_directory);
// finish up any based_ons that got deferred
@ -1821,6 +1822,23 @@ static BOOLEAN get_switches(int argc,
file_array[2] = *++argv;
break;
case IN_SW_GPRE_BASE:
if (!arg_is_string
(--argc, argv,
"Command line syntax: -b requires database base directory:\n ")) return
FALSE;
file_array[3] = *++argv;
string = *argv;
if (*string == '=')
if (!arg_is_string
(--argc, argv,
"Command line syntax: -b requires database base directory:\n "))
return FALSE;
else
file_array[3] = *++argv;
break;
case IN_SW_GPRE_HANDLES:
if (!arg_is_string(
--argc,
@ -2313,7 +2331,7 @@ static int nextchar()
// for processing on pass 2.
//
static SLONG pass1()
static SLONG pass1(TEXT* base_directory)
{
ACT action;
SLONG start;
@ -2329,7 +2347,7 @@ static SLONG pass1()
while (token.tok_symbol)
{
start = token.tok_position;
if (action = PAR_action())
if (action = PAR_action(base_directory))
{
action->act_position = start;
if (!(action->act_flags & ACT_back_token)) {

View File

@ -19,7 +19,7 @@
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
* $Id: gpre.h,v 1.31 2003-02-27 16:55:56 brodsom Exp $
* $Id: gpre.h,v 1.32 2003-07-02 12:57:41 brodsom Exp $
* Revision 1.3 2000/11/27 09:26:13 fsg
* Fixed bugs in gpre to handle PYXIS forms
* and allow edit.e and fred.e to go through
@ -104,6 +104,7 @@ extern "C" {
#define ALLOC(size) MSC_alloc (size)
#define MAKE_CONTEXT(request) MSC_context (request)
#define COPY(from, length, to) MSC_copy (from, length, to)
#define COPY_CAT(from1, length1, from2, length2,to) MSC_copy_cat(from1, length1, from2, length2,to)
#define FREE(block) MSC_free (block)
#define MAKE_NODE(type, count) MSC_node (type, count)
#define POP(stack) MSC_pop (stack)

View File

@ -19,7 +19,7 @@
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
* $Id: gpreswi.h,v 1.7 2002-12-06 13:43:10 eku Exp $
* $Id: gpreswi.h,v 1.8 2003-07-02 12:57:41 brodsom Exp $
* Revision 1.2 2000/11/16 15:54:29 fsg
* Added new switch -verbose to gpre that will dump
* parsed lines to stderr
@ -88,6 +88,10 @@ enum gpre_cmd_switch
*/
IN_SW_GPRE_LANG_INTERNAL,
/* Added this to allow in builds to specify the compiletime database directory
* without the need to edit the epp source
*/
IN_SW_GPRE_BASE,
/* As mentioned above: This should always be one larger than the largest
switch value.
@ -161,5 +165,6 @@ static struct in_sw_tab_t gpre_in_sw_table[] =
{IN_SW_GPRE_ANSI , 0, "ANSI" , 0, 0, 0, FALSE, 0, 0, "\t\tgenerate ANSI85 compatible COBOL"},
#endif
{IN_SW_GPRE_Z , 0, "Z" , 0, 0, 0, FALSE, 0, 0, "\t\tprint software version"},
{IN_SW_GPRE_BASE , 0, "BASE" , 0, 0, 0, FALSE, 0, 0, "\t\tbase directory for compiletime DB"},
{IN_SW_GPRE_0 , 0, NULL , 0, 0, 0, FALSE, 0, 0, NULL}
};

View File

@ -25,10 +25,10 @@
//
//____________________________________________________________
//
// $Id: msc.cpp,v 1.5 2002-11-17 00:04:18 hippoman Exp $
// $Id: msc.cpp,v 1.6 2003-07-02 12:57:41 brodsom Exp $
//
//
//$Id: msc.cpp,v 1.5 2002-11-17 00:04:18 hippoman Exp $
//$Id: msc.cpp,v 1.6 2003-07-02 12:57:41 brodsom Exp $
//
// ***************************************************
@ -227,6 +227,25 @@ void MSC_copy( char *from, int length, char *to)
*to = 0;
}
//____________________________________________________________
//
// Copy two strings into another.
//
void MSC_copy_cat( char *from1, int length1, char *from2, int length2, char *to)
{
if (length1)
do
*to++ = *from1++;
while (--length1);
if (length2)
do
*to++ = *from2++;
while (--length2);
*to = 0;
}
//____________________________________________________________
//

View File

@ -36,6 +36,7 @@ extern UCHAR *MSC_alloc_permanent(int);
extern GPRE_NOD MSC_binary(NOD_T, GPRE_NOD, GPRE_NOD);
extern GPRE_CTX MSC_context(GPRE_REQ);
extern void MSC_copy(char *, int, char *);
extern void MSC_copy_cat(char *, int, char *, int,char *);
extern SYM MSC_find_symbol(SYM, enum sym_t);
extern void MSC_free(UCHAR *);
extern void MSC_free_request(GPRE_REQ);

View File

@ -20,7 +20,7 @@
//
// All Rights Reserved.
// Contributor(s): ______________________________________.
// $Id: par.cpp,v 1.18 2003-03-03 08:27:33 brodsom Exp $
// $Id: par.cpp,v 1.19 2003-07-02 12:57:41 brodsom Exp $
// Revision 1.2 2000/11/27 09:26:13 fsg
// Fixed bugs in gpre to handle PYXIS forms
// and allow edit.e and fred.e to go through
@ -37,7 +37,7 @@
//
//____________________________________________________________
//
// $Id: par.cpp,v 1.18 2003-03-03 08:27:33 brodsom Exp $
// $Id: par.cpp,v 1.19 2003-07-02 12:57:41 brodsom Exp $
//
#include "firebird.h"
@ -175,7 +175,7 @@ static GPRE_FLD flag_field;
// parse an action segment. If not, return NULL.
//
ACT PAR_action()
ACT PAR_action(TEXT* base_dir)
{
ACT action;
SYM symbol;
@ -253,7 +253,7 @@ ACT PAR_action()
return par_window_create();
#endif
case KW_DATABASE:
return PAR_database(FALSE);
return PAR_database(FALSE,base_dir);
#ifdef PYXIS
case KW_DELETE_WINDOW:
return par_window_delete();
@ -524,7 +524,7 @@ SSHORT PAR_blob_subtype(DBB dbb)
// an action block.
//
ACT PAR_database(USHORT sql)
ACT PAR_database(USHORT sql, TEXT* base_directory)
{
ACT action;
SYM symbol;
@ -559,8 +559,14 @@ ACT PAR_database(USHORT sql)
SYNTAX_ERROR("quoted file name");
if (QUOTED(token.tok_type)) {
db->dbb_filename = string = (TEXT *) ALLOC(token.tok_length + 1);
COPY(token.tok_string, token.tok_length, string);
if (base_directory){
db->dbb_filename = string = (TEXT *) ALLOC(token.tok_length + strlen(base_directory) + 1);
COPY_CAT(base_directory, strlen(base_directory),token.tok_string, token.tok_length, string);
}
else {
db->dbb_filename = string = (TEXT *) ALLOC(token.tok_length + 1);
COPY(token.tok_string, token.tok_length, string);
}
token.tok_length += 2;
}
else if (MATCH(KW_PASSWORD)) {

View File

@ -28,9 +28,9 @@
extern "C" {
#endif
extern ACT PAR_action(void);
extern ACT PAR_action(TEXT*);
extern SSHORT PAR_blob_subtype(DBB);
extern ACT PAR_database(USHORT);
extern ACT PAR_database(USHORT,TEXT*);
extern BOOLEAN PAR_end(void);
extern void PAR_error(TEXT *);
extern ACT PAR_event_init(USHORT);