8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 18:43:02 +01:00

Partial fix for CORE-6157: Firebird.pas : avoid use of awk and grep to build target

This commit is contained in:
AlexPeshkoff 2020-04-10 16:19:09 +03:00
parent e44446e855
commit 2d8ebe0395
4 changed files with 104 additions and 19042 deletions

View File

@ -105,21 +105,42 @@ IDL_ROOT=$(SRC_ROOT)/include/firebird
IDL_FILE=$(IDL_ROOT)/FirebirdInterface.idl
API_H_FILE=$(IDL_ROOT)/IdlFbInterfaces.h
API_PAS_FILE=$(SRC_ROOT)/include/gen/Firebird.pas
PAS_ROOT=$(SRC_ROOT)/misc/pascal
MISC=$(SRC_ROOT)/misc
PAS_ROOT=$(MISC)/pascal
PASCAL_SOURCES=$(wildcard $(PAS_ROOT)/*)
TMP_FUNCS=$(TMP_ROOT)/func.pas
XPB_CONSTS=$(SRC_ROOT)/include/firebird/impl/consts_pub.h
ERR_CONSTS=$(ROOT)/lang_helpers/gds_codes.pas
RPL_AWK=$(GEN_ROOT)/def_awk
RPL_AWK_SRC=$(MISC)/def_awk.c
RPL_GREP=$(GEN_ROOT)/isc_grep
RPL_GREP_SRC=$(MISC)/isc_grep.c
updateCloopInterfaces : $(API_H_FILE) $(API_PAS_FILE)
$(API_H_FILE): $(IDL_FILE)
$(CLOOP) $< c++ $@ IDL_FB_INTERFACES_H Firebird I
$(TMP_FUNCS): $(PASCAL_SOURCES) $(XPB_CONSTS) $(ERR_CONSTS)
cat $(PAS_ROOT)/fb_get_master_interface.pas >$(TMP_FUNCS)
awk -f $(PAS_ROOT)/Pascal.Constants.awk <$(XPB_CONSTS) >>$(TMP_FUNCS)
grep '[[:space:]]isc_' $(ERR_CONSTS) >>$(TMP_FUNCS)
#
# This way firebird.pas can be created not using own mini-utilities.
# They were added to be able to build on windows, this code is left for reference.
#
#$(TMP_FUNCS): $(PASCAL_SOURCES) $(XPB_CONSTS) $(ERR_CONSTS)
# cat $(PAS_ROOT)/fb_get_master_interface.pas >$(TMP_FUNCS)
# awk -f $(PAS_ROOT)/Pascal.Constants.awk <$(XPB_CONSTS) >>$(TMP_FUNCS)
# grep '[[:space:]]isc_' $(ERR_CONSTS) >>$(TMP_FUNCS)
#
$(RPL_AWK): $(RPL_AWK_SRC)
$(CC) -o $@ $^
$(RPL_GREP): $(RPL_GREP_SRC)
$(CC) -o $@ $^
$(TMP_FUNCS): $(PASCAL_SOURCES) $(XPB_CONSTS) $(ERR_CONSTS) $(RPL_AWK) $(RPL_GREP)
cp $(PAS_ROOT)/fb_get_master_interface.pas $(TMP_FUNCS)
$(RPL_AWK) <$(XPB_CONSTS) >>$(TMP_FUNCS)
$(RPL_GREP) <$(ERR_CONSTS) >>$(TMP_FUNCS)
$(API_PAS_FILE): $(IDL_FILE) $(PASCAL_SOURCES) $(TMP_FUNCS)
$(CLOOP) $(IDL_FILE) pascal $@ Firebird --uses SysUtils \
@ -709,7 +730,9 @@ clean_vers:
$(RM) *.vers
clean_misc:
$(RM) ods.txt odstest* security.tmp test.header.txt $(API_PAS_FILE)
$(RM) security.tmp test.header.txt
$(RM) $(API_PAS_FILE) $(API_H_FILE) $(TMP_FUNCS) $(RPL_AWK) $(RPL_GREP)
ifeq ($(EDITLINE_FLG),Y)
ifeq ($(STD_EDITLINE),false)

File diff suppressed because it is too large Load Diff

55
src/misc/def_awk.c Normal file
View File

@ -0,0 +1,55 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main()
{
char s[1024];
while (fgets(s, sizeof(s), stdin))
{
char* toks[3];
int n;
char* p = s;
/* get paranoid */
s[sizeof(s) - 1] = 0;
/* parse string to tokens */
toks[2] = NULL;
for (n = 0; n < 3; ++n)
{
toks[n] = strtok(p, " \t\n\r");
p = NULL;
if (!toks[n])
break;
}
/* skip empty & incomplete */
if (! toks[2])
continue;
/* skip unknown statements */
if (strcmp(toks[0], "#define") != 0)
continue;
/* skip unknown constants */
for (p = toks[2]; *p; ++p)
{
if (isdigit(*p))
break;
}
if (!*p)
continue;
/* output correct constant */
if (*toks[2] == '-')
printf("\t%s = %s;\n", toks[1], toks[2]);
else if (strncmp(toks[2], "0x", 2) == 0)
printf("\t%s = $%s;\n", toks[1], toks[2] + 2);
else
printf("\t%s = byte(%s);\n", toks[1], toks[2]);
}
return 0;
}

20
src/misc/isc_grep.c Normal file
View File

@ -0,0 +1,20 @@
#include <string.h>
#include <ctype.h>
#include <stdio.h>
int main()
{
char s[1024];
while (fgets(s, sizeof(s), stdin))
{
s[sizeof(s) - 1] = 0;
char* p = s;
while (isspace(*p))
++p;
if (strncmp(p, "isc_", 4) == 0)
fputs(s, stdout);
}
return 0;
}