fixed build for clang

This commit is contained in:
2024-10-04 15:26:19 +03:00
parent 9f15a980af
commit 1140957dce
11 changed files with 10558 additions and 10691 deletions

View File

@@ -65,9 +65,16 @@
#define DOUBLEMARK 316
#define POINTSAT 317
extern char* xmalloc(int size);
extern void Message(char *s, int l);
extern void set_up_momentum(int value,int token);
extern void automata_driver(int value);
extern char* copys(char *);
#line 5 "annotate.y"
#include "macro.h"
#include <stdlib.h>
#include "compatible.h"
#ifdef SYS5
@@ -146,8 +153,8 @@ typedef union {
char AnnExTensionNumber[255]; /* to symbole right for the annotation */
static int Recog_My_Token();
static int look_up_specialfunction();
static unMYGETC();
static MYGETC();
static char unMYGETC(char c);
static char MYGETC();
static int map_assgn_op();
#ifndef YYLTYPE
@@ -623,6 +630,7 @@ while (0)
#define YYERRCODE 256
#ifndef YYPURE
int yylex_annotate();
#define YYLEX yylex_annotate()
#endif
@@ -677,7 +685,7 @@ static int yydebug; /* nonzero means print parse trace */
#ifdef __GNUC__
int yyparse_annotate(void);
#endif
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
#define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
#else /* not GNU C or C++ */
@@ -2258,7 +2266,7 @@ char *p;
register char *p2, *p1;
//extern char *malloc();
newbuf = (char*)malloc((unsigned)(newlength+1));
newbuf = (char*)malloc(newlength+1);
#ifdef __SPF
addToCollection(__LINE__, __FILE__,newbuf, 0);
#endif
@@ -2996,8 +3004,7 @@ look_up_annotate(st)
return (PTR_HASH) pt;
}
static
MYGETC()
static char MYGETC()
{
if (LENSTRINGTOPARSE <= PTTOSTRINGTOPARSE)
@@ -3013,9 +3020,7 @@ MYGETC()
return STRINGTOPARSE[ PTTOSTRINGTOPARSE-1];
}
static
unMYGETC(c)
char c;
static char unMYGETC(char c)
{
if (LENSTRINGTOPARSE <= PTTOSTRINGTOPARSE)
return EOF;
@@ -3086,10 +3091,10 @@ look_up_specialfunction(str)
return TRUE;
}
if (strcmp(specialfunction[i],"Dummy") == 0)
return NULL;
return 0;
}
return NULL;
return 0;
}

View File

@@ -71,5 +71,4 @@ typedef union {
#define DOUBLEMARK 316
#define POINTSAT 317
extern YYSTYPE yylval;

View File

@@ -15,7 +15,13 @@
#ifdef _NEEDALLOCAH_
# include <alloca.h>
#endif
extern char* xmalloc(int size);
extern void Message(char *s, int l);
extern void set_up_momentum(int value,int token);
extern void automata_driver(int value);
extern char* copys(char *);
#define ON 1
#define OFF 0
#define OTHER 2
@@ -182,8 +188,8 @@ extern POINTER newNode();
char AnnExTensionNumber[255]; /* to symbole right for the annotation */
static int Recog_My_Token();
static int look_up_specialfunction();
static unMYGETC();
static MYGETC();
static char unMYGETC(char c);
static char MYGETC();
static int map_assgn_op();
%}
@@ -1114,7 +1120,7 @@ char *p;
register char *p2, *p1;
extern char *malloc();
newbuf = malloc((unsigned)(newlength+1));
newbuf = malloc(newlength+1));
p2 = newbuf;
p1 = newbuf + newlength + 1;
@@ -1844,8 +1850,7 @@ look_up(st)
return (PTR_HASH) pt;
}
static
MYGETC()
static char MYGETC()
{
if (LENSTRINGTOPARSE <= PTTOSTRINGTOPARSE)
@@ -1861,9 +1866,7 @@ MYGETC()
return STRINGTOPARSE[ PTTOSTRINGTOPARSE-1];
}
static
unMYGETC(c)
char c;
static char unMYGETC(char c)
{
if (LENSTRINGTOPARSE <= PTTOSTRINGTOPARSE)
return EOF;
@@ -1931,10 +1934,10 @@ look_up_specialfunction(str)
return TRUE;
}
if (strcmp(specialfunction[i],"Dummy") == 0)
return NULL;
return 0;
}
return NULL;
return 0;
}

View File

@@ -16,8 +16,15 @@
#include "vextern.h"
#include "annotate.tab.h"
extern void Message(char *s, int l);
void reset_semicoln_handler();
void reset();
int class_struct(int value);
int is_declare(int value);
int declare_symb(int value);
int block_like(int state);
int keep_original(int state);
int lastdecl_id; /* o if no main_type appeared */
int left_paren ;
@@ -484,8 +491,7 @@ int value ;
}
class_struct(value)
register int value ;
int class_struct(int value)
{
switch (value) {
case ENUM :
@@ -496,8 +502,7 @@ register int value ;
}
}
declare_symb(value)
register int value ;
int declare_symb(int value)
{
switch (value) {
case TYPENAME :
@@ -523,8 +528,7 @@ void reset()
/* put_line_queue(line_pos_1,line_pos_fname); */
}
block_like(state)
int state ;
int block_like(int state)
{
switch( state) {
@@ -541,9 +545,7 @@ int state ;
}
}
int
is_declare(value)
int value ;
int is_declare(int value)
{
switch (value) {
case TYPENAME:
@@ -594,8 +596,7 @@ void reset_semicoln_handler()
}
keep_original(state)
int state;
int keep_original(int state)
{
switch (state) {
case ELSE_EXPECTED_STATE:

View File

@@ -47,6 +47,7 @@ extern int PTTOSTRINGTOPARSE;
extern PTR_BFND ANNOTATIONSCOPE;
extern PTR_TYPE global_int_annotation;
extern char AnnExTensionNumber[];
extern int yyparse_annotate(void);
/* FORWARD DECLARATION */
int Get_Scope_Of_Annotation();
@@ -100,7 +101,7 @@ static char *Defined_Value_Str[MAX_ANNOTATION];
static int Defined_Value_Value[MAX_ANNOTATION];
/* Indicate if comment is an annotation */
Is_Annotation(str)
int Is_Annotation(str)
char *str;
{
@@ -122,7 +123,7 @@ char *str;
}
}
Is_Annotation_Cont(str)
int Is_Annotation_Cont(str)
char *str;
{
@@ -229,7 +230,7 @@ char *str;
/* basically go thrue the program and parse annotation, and set
if they are defined */
initAnnotation()
int initAnnotation()
{
PTR_CMNT cmnt;
PTR_BFND ptbif;

View File

@@ -1,284 +1,286 @@
/*********************************************************************/
/* pC++/Sage++ Copyright (C) 1993 */
/* Indiana University University of Oregon University of Rennes */
/*********************************************************************/
/*
* hash.c -- hash table routines
*/
#include <stdio.h>
#include "compatible.h"
#ifdef SYS5
#include <string.h>
#else
#include <strings.h>
#endif
#include "defs.h"
#include "symb.h"
#include "defines.h"
#include "bif.h"
#include "extern.h"
extern int parstate;
extern PTR_BFND cur_bfnd, pred_bfnd, global_bfnd;
extern PTR_TYPE vartype, global_default, impltype[];
extern void make_prog_header();
PTR_TYPE install_array();
PTR_LLND make_llnd();
PTR_SYMB make_symb();
char *chkalloc();
void free();
void errstr();
PTR_HASH hash_table[hashMax];
/*
* init_hash -- initialize the hash table
*/
void
init_hash()
{
register int i;
for (i = 0; i < hashMax; i++)
hash_table[i] = HSNULL;
}
/*
* Hash(string) -- compute hash value of string.
*/
int
hash(string)
register char *string;
{
register int i;
for (i = 0; *string;)
i += *string++;
return (i % hashMax);
}
/*
* look_up(string) -- lookup string in the hash table and
* install it if not there
*/
PTR_HASH
look_up(string, decl_type)
register char *string;
int decl_type;
{
int i;
register PTR_HASH entry;
PTR_BFND cur_scope(), p;
i = hash(string);
p = cur_scope();
for (entry = hash_table[i]; entry; entry = entry->next_entry) {
if (!strcmp(string, entry->ident) && (entry->id_attr)) {
if ((entry->id_attr->scope == p) ||
((entry->id_attr->variant==FUNCTION_NAME) &&
(p->variant==FUNC_HEDR) &&
(p->entry.Template.symbol==entry->id_attr)))
return (entry);
if (decl_type == SOFT) {
for (p=cur_scope(); NEW_SCOPE(p); p = p->control_parent) {
if (entry->id_attr->scope == p)
return (entry);
}
if (entry->id_attr->scope == p)
return (entry);
}
}
}
entry = (struct hash_entry *) chkalloc(sizeof(struct hash_entry));
entry->ident = copys(string);
entry->next_entry = hash_table[i];
hash_table[i] = entry;
return (entry);
}
PTR_HASH
correct_symtab(h, type)
PTR_HASH h;
int type;
{
int i;
PTR_HASH entry;
i = hash(h->ident);
for (entry = hash_table[i]; entry; entry = entry->next_entry) {
if (!strcmp(h->ident, entry->ident)
&& ( !(entry->id_attr)
||(entry->id_attr->variant==type))
&& (h != entry))
break;
}
if (!entry) return h;
if (hash_table[i] != h) {
fprintf (stderr, "Bug in correct_symtab\n");
return h;
}
hash_table[i] = hash_table[i]->next_entry;
#ifdef __SPF
removeFromCollection(h);
#endif
free((char *)h);
return hash_table[i];
}
/*
* Checks whether the "name" is installed and installs as a SOFT
* entry if not.
*/
PTR_LLND
check_and_install(h, d, ndim)
PTR_HASH h;
PTR_LLND d;
int ndim;
{
PTR_BFND cur_scope();
PTR_SYMB install_entry();
PTR_TYPE p = NULL;
PTR_SYMB s;
PTR_LLND r;
void set_type(), err();
/* Check if the variable is already declared */
if ((s = h->id_attr) && (s->scope == cur_scope()) && s->type) {
if (d && s->type->variant != T_ARRAY) {
p = install_array(d, s->type, ndim);
s->type = p;
}
}
else {
if (h->id_attr && h->id_attr->type)
p = h->id_attr->type;
else if (!undeftype)
p = impltype[*h->ident - 'a'];
else
err("Variable type unknown",327);
if (d)
p = install_array(d, p, ndim);
s = install_entry(h, SOFT);
set_type(s, p, LOCAL);
}
if (d) {
r = p->entry.ar_decl.ranges
= make_llnd(fi,ARRAY_REF, d, LLNULL, s);
}
else
r = make_llnd(fi,VAR_REF, LLNULL, LLNULL, s);
return make_llnd(fi,EXPR_LIST, r, LLNULL, SMNULL);
}
/*
* install_entry takes a pointer to a hash entry and
* makes another symbol table entry for the same id
*/
PTR_SYMB
install_entry(entry, decl_type)
PTR_HASH entry;
int decl_type;
{
register PTR_SYMB symb_ptr;
PTR_BFND cur_scope();
PTR_BFND p;
void err();
if (decl_type == HARD && entry->id_attr &&
entry->id_attr->scope != cur_scope())
entry = look_up(entry->ident, HARD);
if ((entry->id_attr) && ((entry->id_attr->scope == cur_scope()) ||
((entry->id_attr->variant==FUNCTION_NAME) &&
(entry->id_attr->scope->variant==FUNC_HEDR))))
{
if (entry->id_attr->decl == SOFT) {
entry->id_attr->decl = decl_type;
return(entry->id_attr);
}
if (decl_type == SOFT)
return(entry->id_attr);
/* else */
errstr("Redeclaration of identifier: %s",entry->id_attr->ident,328);
/*(void)fprintf(stderr, "id: %s\n", entry->id_attr->ident);*/
return (SMNULL);
}
symb_ptr = make_symb(fi,DEFAULT, entry->ident);
for (p=cur_scope();
NEW_SCOPE(p) && (decl_type==SOFT);
p = p->control_parent)
;
symb_ptr->scope = p;
symb_ptr->outer = entry->id_attr;
symb_ptr->parent = entry;
symb_ptr->decl = decl_type;
entry->id_attr = symb_ptr;
symb_ptr->id_list = SMNULL;
return (symb_ptr);
}
PTR_SYMB
get_proc_symbol(entry)
PTR_HASH entry;
{
register PTR_SYMB symb_ptr;
PTR_BFND cur_scope();
symb_ptr = make_symb(fi, PROCEDURE_NAME, entry->ident);
symb_ptr->scope = global_bfnd;
symb_ptr->outer = entry->id_attr;
symb_ptr->parent = entry;
entry->id_attr = symb_ptr;
return (symb_ptr);
}
/*
PTR_BFND
cur_scope()
{
register PTR_BFND p;
*/
/* Takes cares of main program unit begining without a PROGRAM
statement. After rewrite of statement processing has been done,
strengthen ( weaken? ) the test.
*/
/*
if ((pred_bfnd->variant == GLOBAL) && (parstate == OUTSIDE))
{
make_prog_header();
return (pred_bfnd);
}
for (p = pred_bfnd;
(p->variant != PROG_HEDR) &&
(p->variant != PROC_HEDR) &&
(p->variant != PROS_HEDR) &&
(p->variant != FUNC_HEDR) &&
(p->variant != BLOCK_DATA) &&
(p->variant != FORALL_NODE) &&
(p->variant != GLOBAL) &&
(p->variant != CDOALL_NODE) &&
(p->variant != SDOALL_NODE) &&
(p->variant != DOACROSS_NODE) &&
(p->variant != STRUCT_DECL);
p = p->control_parent);
;
return (p);
}
*/
/*********************************************************************/
/* pC++/Sage++ Copyright (C) 1993 */
/* Indiana University University of Oregon University of Rennes */
/*********************************************************************/
/*
* hash.c -- hash table routines
*/
#include <stdio.h>
#include "compatible.h"
#ifdef SYS5
#include <string.h>
#else
#include <strings.h>
#endif
#include "defs.h"
#include "symb.h"
#include "defines.h"
#include "bif.h"
#include "extern.h"
extern int parstate;
extern PTR_BFND cur_bfnd, pred_bfnd, global_bfnd;
extern PTR_TYPE vartype, global_default, impltype[];
extern void make_prog_header();
PTR_TYPE install_array();
PTR_LLND make_llnd();
PTR_SYMB make_symb();
char *chkalloc();
void free();
void errstr();
PTR_HASH hash_table[hashMax];
#ifdef __SPF
extern void removeFromCollection(void *pointer);
#endif
/*
* init_hash -- initialize the hash table
*/
void
init_hash()
{
register int i;
for (i = 0; i < hashMax; i++)
hash_table[i] = HSNULL;
}
/*
* Hash(string) -- compute hash value of string.
*/
int
hash(string)
register char *string;
{
register int i;
for (i = 0; *string;)
i += *string++;
return (i % hashMax);
}
/*
* look_up(string) -- lookup string in the hash table and
* install it if not there
*/
PTR_HASH
look_up(string, decl_type)
register char *string;
int decl_type;
{
int i;
register PTR_HASH entry;
PTR_BFND cur_scope(), p;
i = hash(string);
p = cur_scope();
for (entry = hash_table[i]; entry; entry = entry->next_entry) {
if (!strcmp(string, entry->ident) && (entry->id_attr)) {
if ((entry->id_attr->scope == p) ||
((entry->id_attr->variant==FUNCTION_NAME) &&
(p->variant==FUNC_HEDR) &&
(p->entry.Template.symbol==entry->id_attr)))
return (entry);
if (decl_type == SOFT) {
for (p=cur_scope(); NEW_SCOPE(p); p = p->control_parent) {
if (entry->id_attr->scope == p)
return (entry);
}
if (entry->id_attr->scope == p)
return (entry);
}
}
}
entry = (struct hash_entry *) chkalloc(sizeof(struct hash_entry));
entry->ident = copys(string);
entry->next_entry = hash_table[i];
hash_table[i] = entry;
return (entry);
}
PTR_HASH
correct_symtab(h, type)
PTR_HASH h;
int type;
{
int i;
PTR_HASH entry;
i = hash(h->ident);
for (entry = hash_table[i]; entry; entry = entry->next_entry) {
if (!strcmp(h->ident, entry->ident)
&& ( !(entry->id_attr)
||(entry->id_attr->variant==type))
&& (h != entry))
break;
}
if (!entry) return h;
if (hash_table[i] != h) {
fprintf (stderr, "Bug in correct_symtab\n");
return h;
}
hash_table[i] = hash_table[i]->next_entry;
#ifdef __SPF
removeFromCollection(h);
#endif
free((char *)h);
return hash_table[i];
}
/*
* Checks whether the "name" is installed and installs as a SOFT
* entry if not.
*/
PTR_LLND
check_and_install(h, d, ndim)
PTR_HASH h;
PTR_LLND d;
int ndim;
{
PTR_BFND cur_scope();
PTR_SYMB install_entry();
PTR_TYPE p = NULL;
PTR_SYMB s;
PTR_LLND r;
void set_type(), err();
/* Check if the variable is already declared */
if ((s = h->id_attr) && (s->scope == cur_scope()) && s->type) {
if (d && s->type->variant != T_ARRAY) {
p = install_array(d, s->type, ndim);
s->type = p;
}
}
else {
if (h->id_attr && h->id_attr->type)
p = h->id_attr->type;
else if (!undeftype)
p = impltype[*h->ident - 'a'];
else
err("Variable type unknown",327);
if (d)
p = install_array(d, p, ndim);
s = install_entry(h, SOFT);
set_type(s, p, LOCAL);
}
if (d) {
r = p->entry.ar_decl.ranges
= make_llnd(fi,ARRAY_REF, d, LLNULL, s);
}
else
r = make_llnd(fi,VAR_REF, LLNULL, LLNULL, s);
return make_llnd(fi,EXPR_LIST, r, LLNULL, SMNULL);
}
/*
* install_entry takes a pointer to a hash entry and
* makes another symbol table entry for the same id
*/
PTR_SYMB
install_entry(entry, decl_type)
PTR_HASH entry;
int decl_type;
{
register PTR_SYMB symb_ptr;
PTR_BFND cur_scope();
PTR_BFND p;
void err();
if (decl_type == HARD && entry->id_attr &&
entry->id_attr->scope != cur_scope())
entry = look_up(entry->ident, HARD);
if ((entry->id_attr) && ((entry->id_attr->scope == cur_scope()) ||
((entry->id_attr->variant==FUNCTION_NAME) &&
(entry->id_attr->scope->variant==FUNC_HEDR))))
{
if (entry->id_attr->decl == SOFT) {
entry->id_attr->decl = decl_type;
return(entry->id_attr);
}
if (decl_type == SOFT)
return(entry->id_attr);
/* else */
errstr("Redeclaration of identifier: %s",entry->id_attr->ident,328);
/*(void)fprintf(stderr, "id: %s\n", entry->id_attr->ident);*/
return (SMNULL);
}
symb_ptr = make_symb(fi,DEFAULT, entry->ident);
for (p=cur_scope();
NEW_SCOPE(p) && (decl_type==SOFT);
p = p->control_parent)
;
symb_ptr->scope = p;
symb_ptr->outer = entry->id_attr;
symb_ptr->parent = entry;
symb_ptr->decl = decl_type;
entry->id_attr = symb_ptr;
symb_ptr->id_list = SMNULL;
return (symb_ptr);
}
PTR_SYMB
get_proc_symbol(entry)
PTR_HASH entry;
{
register PTR_SYMB symb_ptr;
PTR_BFND cur_scope();
symb_ptr = make_symb(fi, PROCEDURE_NAME, entry->ident);
symb_ptr->scope = global_bfnd;
symb_ptr->outer = entry->id_attr;
symb_ptr->parent = entry;
entry->id_attr = symb_ptr;
return (symb_ptr);
}
/*
PTR_BFND
cur_scope()
{
register PTR_BFND p;
*/
/* Takes cares of main program unit begining without a PROGRAM
statement. After rewrite of statement processing has been done,
strengthen ( weaken? ) the test.
*/
/*
if ((pred_bfnd->variant == GLOBAL) && (parstate == OUTSIDE))
{
make_prog_header();
return (pred_bfnd);
}
for (p = pred_bfnd;
(p->variant != PROG_HEDR) &&
(p->variant != PROC_HEDR) &&
(p->variant != PROS_HEDR) &&
(p->variant != FUNC_HEDR) &&
(p->variant != BLOCK_DATA) &&
(p->variant != FORALL_NODE) &&
(p->variant != GLOBAL) &&
(p->variant != CDOALL_NODE) &&
(p->variant != SDOALL_NODE) &&
(p->variant != DOACROSS_NODE) &&
(p->variant != STRUCT_DECL);
p = p->control_parent);
;
return (p);
}
*/

File diff suppressed because it is too large Load Diff

View File

@@ -1,208 +1,212 @@
/*********************************************************************/
/* pC++/Sage++ Copyright (C) 1993 */
/* Indiana University University of Oregon University of Rennes */
/*********************************************************************/
/*
* misc.c
*
* Misellanious help routines
*/
#include "defs.h"
#include "defines.h"
#include <ctype.h>
#include "db.h"
#include <stdlib.h>
#include <string.h>
extern int blklevel;
extern void warn1();
extern PTR_BFND cur_scope();
PTR_LABEL make_label();
extern PTR_FILE fi;
void free();
extern PTR_CMNT comments;
extern PTR_FNAME cur_thread_file;
extern PTR_FNAME the_file;
extern int yylineno;
extern int mod_offset;
extern PTR_BFND last_bfnd;
extern PTR_BFND head_bfnd, last_bfnd;
extern PTR_LLND head_llnd;
extern PTR_SYMB head_symb;
extern PTR_TYPE head_type;
extern PTR_LABEL head_label;
/*
* eqn -- checks if first n characters of two strings are the same
*
* input:
* n - length to be checked
* a - string1
* b - string2
*
* output:
* YES if the first n characters are same. NO, otherwise.
*/
int
eqn(n, a, b)
register int n;
register unsigned char *a, *b;
{
while (--n >= 0)
if ((isupper(*a) ? tolower(*a++) : *a++) != *b++)
return (NO);
return (YES);
}
/*
* StringConcatenation -- concatenate strings
*/
char *StringConcatenation(char *s1, char*s2)
{
char *res = (char*)malloc(strlen(s1)+strlen(s2)+1);
res[0] = '\0';
strcat(res, s1);
strcat(res, s2);
return res;
}
/*
* convci - converts an ASCII string to binary
*
* input:
* n - length of the string
* s - the string to be converted
*
* output:
* the converted long value
*/
long
convci(n, s)
register int n;
register char *s;
{
register long sum;
sum = 0;
while (n-- > 0)
sum = 10 * sum + (*s++ - '0');
return (sum);
}
/*
* convic -- converts a long integer to ASCII string
*
* input:
* n - the number to be converted
*
* output:
* the converted string
*/
char *
convic(n)
long n;
{
static char s[20];
register char *t;
s[19] = '\0';
t = s + 19;
do {
*--t = '0' + n % 10;
n /= 10;
} while (n > 0);
return (t);
}
/*
* Get a BIF node
*/
PTR_BFND
get_bfnd(fid,node_type, symb_ptr, ll1, ll2, ll3)
PTR_FILE fid;
int node_type;
PTR_SYMB symb_ptr;
PTR_LLND ll1, ll2, ll3;
{
PTR_BFND new_bfnd, make_bfnd();
new_bfnd = make_bfnd(fid, node_type, symb_ptr, ll1, ll2, ll3);
new_bfnd->filename = the_file;
/*new_bfnd->filename = cur_thread_file;*/ /*podd 18.04.99*/
new_bfnd->entry.Template.cmnt_ptr = comments;
new_bfnd->entry.Template.bl_ptr1 = BLNULL;
new_bfnd->entry.Template.bl_ptr2 = BLNULL;
new_bfnd->g_line = yylineno;
new_bfnd->l_line = yylineno - mod_offset;
last_bfnd = new_bfnd;
return (new_bfnd);
}
void
release_nodes()
{
register PTR_BFND p1 = head_bfnd;
register PTR_LLND p2 = head_llnd;
register PTR_SYMB p3 = head_symb;
register PTR_TYPE p4 = head_type;
register PTR_LABEL p5 =head_label;
register PTR_BFND t1;
register PTR_LLND t2;
register PTR_SYMB t3;
register PTR_TYPE t4;
register PTR_LABEL t5;
while (p1) {
t1 = p1;
p1 = p1->thread;
#ifdef __SPF
removeFromCollection(t1);
#endif
free ((char *)t1);
}
while (p2) {
t2 = p2;
p2 = p2->thread;
#ifdef __SPF
removeFromCollection(t2);
#endif
free ((char *)t2);
}
while (p3) {
t3 = p3;
p3 = p3->thread;
#ifdef __SPF
removeFromCollection(t3);
#endif
free ((char *)t3);
}
while (p4) {
t4 = p4;
p4 = p4->thread;
#ifdef __SPF
removeFromCollection(t4);
#endif
free ((char *)t4);
}
while (p5) {
t5 = p5;
p5 = p5->next;
#ifdef __SPF
removeFromCollection(t5);
#endif
free ((char *)t5);
}
}
/*********************************************************************/
/* pC++/Sage++ Copyright (C) 1993 */
/* Indiana University University of Oregon University of Rennes */
/*********************************************************************/
/*
* misc.c
*
* Misellanious help routines
*/
#include "defs.h"
#include "defines.h"
#include <ctype.h>
#include "db.h"
#include <stdlib.h>
#include <string.h>
extern int blklevel;
extern void warn1();
extern PTR_BFND cur_scope();
PTR_LABEL make_label();
extern PTR_FILE fi;
void free();
extern PTR_CMNT comments;
extern PTR_FNAME cur_thread_file;
extern PTR_FNAME the_file;
extern int yylineno;
extern int mod_offset;
extern PTR_BFND last_bfnd;
extern PTR_BFND head_bfnd, last_bfnd;
extern PTR_LLND head_llnd;
extern PTR_SYMB head_symb;
extern PTR_TYPE head_type;
extern PTR_LABEL head_label;
#ifdef __SPF
extern void removeFromCollection(void *pointer);
#endif
/*
* eqn -- checks if first n characters of two strings are the same
*
* input:
* n - length to be checked
* a - string1
* b - string2
*
* output:
* YES if the first n characters are same. NO, otherwise.
*/
int
eqn(n, a, b)
register int n;
register unsigned char *a, *b;
{
while (--n >= 0)
if ((isupper(*a) ? tolower(*a++) : *a++) != *b++)
return (NO);
return (YES);
}
/*
* StringConcatenation -- concatenate strings
*/
char *StringConcatenation(char *s1, char*s2)
{
char *res = (char*)malloc(strlen(s1)+strlen(s2)+1);
res[0] = '\0';
strcat(res, s1);
strcat(res, s2);
return res;
}
/*
* convci - converts an ASCII string to binary
*
* input:
* n - length of the string
* s - the string to be converted
*
* output:
* the converted long value
*/
long
convci(n, s)
register int n;
register char *s;
{
register long sum;
sum = 0;
while (n-- > 0)
sum = 10 * sum + (*s++ - '0');
return (sum);
}
/*
* convic -- converts a long integer to ASCII string
*
* input:
* n - the number to be converted
*
* output:
* the converted string
*/
char *
convic(n)
long n;
{
static char s[20];
register char *t;
s[19] = '\0';
t = s + 19;
do {
*--t = '0' + n % 10;
n /= 10;
} while (n > 0);
return (t);
}
/*
* Get a BIF node
*/
PTR_BFND
get_bfnd(fid,node_type, symb_ptr, ll1, ll2, ll3)
PTR_FILE fid;
int node_type;
PTR_SYMB symb_ptr;
PTR_LLND ll1, ll2, ll3;
{
PTR_BFND new_bfnd, make_bfnd();
new_bfnd = make_bfnd(fid, node_type, symb_ptr, ll1, ll2, ll3);
new_bfnd->filename = the_file;
/*new_bfnd->filename = cur_thread_file;*/ /*podd 18.04.99*/
new_bfnd->entry.Template.cmnt_ptr = comments;
new_bfnd->entry.Template.bl_ptr1 = BLNULL;
new_bfnd->entry.Template.bl_ptr2 = BLNULL;
new_bfnd->g_line = yylineno;
new_bfnd->l_line = yylineno - mod_offset;
last_bfnd = new_bfnd;
return (new_bfnd);
}
void
release_nodes()
{
register PTR_BFND p1 = head_bfnd;
register PTR_LLND p2 = head_llnd;
register PTR_SYMB p3 = head_symb;
register PTR_TYPE p4 = head_type;
register PTR_LABEL p5 =head_label;
register PTR_BFND t1;
register PTR_LLND t2;
register PTR_SYMB t3;
register PTR_TYPE t4;
register PTR_LABEL t5;
while (p1) {
t1 = p1;
p1 = p1->thread;
#ifdef __SPF
removeFromCollection(t1);
#endif
free ((char *)t1);
}
while (p2) {
t2 = p2;
p2 = p2->thread;
#ifdef __SPF
removeFromCollection(t2);
#endif
free ((char *)t2);
}
while (p3) {
t3 = p3;
p3 = p3->thread;
#ifdef __SPF
removeFromCollection(t3);
#endif
free ((char *)t3);
}
while (p4) {
t4 = p4;
p4 = p4->thread;
#ifdef __SPF
removeFromCollection(t4);
#endif
free ((char *)t4);
}
while (p5) {
t5 = p5;
p5 = p5->next;
#ifdef __SPF
removeFromCollection(t5);
#endif
free ((char *)t5);
}
}

File diff suppressed because it is too large Load Diff