Skip to content

Commit

Permalink
f0004
Browse files Browse the repository at this point in the history
  • Loading branch information
adesutherland committed Mar 1, 2020
1 parent 89c2b2d commit 6cecc96
Show file tree
Hide file tree
Showing 35 changed files with 429 additions and 352 deletions.
11 changes: 2 additions & 9 deletions bintree.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,10 @@
*
*/

#ifndef __BINTREE_H__
#define __BINTREE_H__

#include "lstring.h"

#ifdef __BINTREE_C__
# define EXTERN
#else
# define EXTERN extern
#endif
#ifndef __BINTREE_H__
#define __BINTREE_H__

#define BALANCE_START 7
#define BALANCE_INC 8
Expand Down Expand Up @@ -59,5 +53,4 @@ void __CDECL BinDel( BinTree *tree, PLstr name,
void __CDECL BinPrint( PBinLeaf leaf );
void __CDECL BinBalance( BinTree *tree );

#undef EXTERN
#endif
11 changes: 8 additions & 3 deletions bmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ typedef struct tmemory_st {
byte data[sizeof(void*)];
} Memory;

static Memory *mem_head = NULL;
static long total_mem = 0L;
#include "context.h"
#define mem_head ((Memory*)(currentContext->bmem_mem_head))
#define total_mem (currentContext->bmem_total_mem)

void mem_list(void);

Expand Down Expand Up @@ -242,7 +243,11 @@ mem_list(void)
mem_print(count++,mem);
mem = mem->prev;
if (++y==15) {
if (getchar()=='q') exit(0);
if (getchar()=='q')
{
PopContext();
exit(0);
}
y = 0;
}
}
Expand Down
67 changes: 0 additions & 67 deletions bstr.h

This file was deleted.

3 changes: 0 additions & 3 deletions builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@
# include <winfunc.h>
#endif

/* ------------- External variables ------------ */
extern Lstr stemvaluenotfound; /* from variable.c */

/* -------------------------------------------------------------- */
/* ADDRESS() */
/* -------------------------------------------------------------- */
Expand Down
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
BREXX CMS Change LOG
====================


F0004 - Make Re-entrant
F0006 - Fix error reading the REXX file actually being interpreted
Fix when program file not found the extra "STAT" Error message
F0003 - Fix Issue 1 (SAY - Trailing junk)
Expand Down
10 changes: 6 additions & 4 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "trace.h"
#include "compile.h"
#include "nextsymb.h"
#include "context.h"

/*
//
Expand All @@ -93,16 +94,16 @@ void __CDECL C_template( void );
TBltFunc* __CDECL C_isBuiltin( PLstr );

/* --- static Variables --- */
static int str_interpreted; /* is it a string interpreted */
static int checked_semicolon; /* if instruction has checked the semicolon likeIF */
#define str_interpreted (currentContext->compile_str_interpreted) /* is it a string interpreted */
#define checked_semicolon (currentContext->compile_checked_semicolon) /* if instruction has checked the semicolon likeIF */
#define Loop (currentContext->compile_Loop)

typedef struct loop_st {
size_t Citerate;
size_t Cleave;
int noofvars;
PLstr ctrlvar;
} LoopCtrl;
static DQueue Loop;

/* ------------ local prototypes ------------ */
static bool C_instr(bool);
Expand Down Expand Up @@ -135,7 +136,8 @@ static void C_trace(void);
static void C_upper(void);

/* ---------------------------------------------------------- */
static
/* because ths is const we shall keep it really global */
static const
struct sort_list_st {
char *name;
void (*func)(void);
Expand Down
27 changes: 3 additions & 24 deletions compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,15 @@
*
*/

#ifndef __COMPILE_H__
#define __COMPILE_H__

#ifndef WIN
# include "bmem.h"
#endif
#include "lstring.h"
#include "bintree.h"
#include "nextsymb.h"

#ifdef __COMPILE_C__
# define EXTERN
#else
# define EXTERN extern
#endif
#ifndef __COMPILE_H__
#define __COMPILE_H__

/* ----------- local defines --------------- */
#define UNKNOWN_LABEL 0xFFFF
Expand Down Expand Up @@ -64,21 +58,7 @@ typedef struct tfunction {
} RxFunc;

/* ------------ Global Variables ------------ */
/* --- Compile Variables --- */
EXTERN RxFile *CompileRxFile; /* Rexx file pointer */
EXTERN byte *CompileCodePtr; /* code pointer */
EXTERN PLstr CompileCode; /* code space */
#ifndef ALIGN
EXTERN word CompileCodeLen; /* code length */
#else
EXTERN dword CompileCodeLen; /* code length */
#endif

EXTERN Clause *CompileClause; /* compile clauses */
EXTERN int CompileCurClause; /* current clause */
EXTERN int CompileClauseItems; /* maximum clause len */

EXTERN int CompileNesting; /* current nesting */
#include "context.h"

/* --------------- rexx options ----------------- */
enum options_type {
Expand Down Expand Up @@ -232,5 +212,4 @@ void *_Add2Lits( PLstr lit, int hasdot );
void __CDECL _mustbe( enum symboltype sym, int err, int subno);
PBinLeaf _AddLabel( int type, size_t position );

#undef EXTERN
#endif
2 changes: 1 addition & 1 deletion config.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Modified for VM/370 CMS and GCC by Robert O'Hara, July 2010. */

/* The one version to rule them all! */
#define CMS_VERSION "F0006"
#define CMS_VERSION "F0004"

#include "rxmvs.h"

Expand Down
47 changes: 47 additions & 0 deletions context.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Global Variable Context - for reentrancy */
#define __CONTEXT_C__

#include <stdio.h>
#include <stdlib.h>
#include "context.h"

void PopContext()
{
Context *oldContext;
/* printf("PopContext()\n"); */
if (currentContext) {
oldContext = currentContext;
currentContext = oldContext->previous;
free(oldContext);
}
else printf("currentContext is null\n");
}

void PushContext()
{
/* printf("PushContext()\n"); */
Context *newContext = malloc(sizeof(Context));
newContext->previous = currentContext;
currentContext = newContext;

/* bmem.c */
currentContext->bmem_mem_head = NULL;
currentContext->bmem_total_mem = 0L;

/* lstring.h */
currentContext->lstring_lLastScannedNumber=0.0;
#ifdef __CMS__
currentContext->lstring_lNumericDigits = 9;
#else
currentContext->lstring_lNumericDigits = LMAXNUMERICDIGITS;
#endif

/* ltime.c */
currentContext->ltime_elapsed=0.0;

/* rexxfunc.c */
currentContext->rexxfunc_ExtraFuncs = NULL;

}

#undef __CONTEXT_C__
Loading

0 comments on commit 6cecc96

Please sign in to comment.