Skip to content

Commit

Permalink
F0035
Browse files Browse the repository at this point in the history
  • Loading branch information
adesutherland committed Dec 13, 2020
1 parent 77d6526 commit e586daa
Show file tree
Hide file tree
Showing 26 changed files with 481 additions and 309 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set(CMAKE_C_STANDARD 90)

include_directories(.)

add_definitions(-D__CMS__)

add_executable(CMS_370_BREXX
abbrev.c
abs.c
Expand Down
43 changes: 25 additions & 18 deletions address.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
#include <stdlib.h>

#ifdef __CMS__

#include <cmssys.h>

#endif

#include "lstring.h"
Expand Down Expand Up @@ -276,24 +278,29 @@ RxExecuteCmd(PLstr cmd, PLstr env) {
#if defined(__CMS__)
int how;

LASCIIZ(* env);
/*
if (!Lcmp(env, "CMS")) how = CMS_CONSOLE;
else how = CMS_COMMAND;
(context->rexxrxReturnCode) = CMScommand(LSTR(* cmd), how); // execute the command
*/
(context->rexxrxReturnCode) = __HOSTCM(cmd, env);

RxSetSpecialVar(RCVAR,(context->rexxrxReturnCode)); // set the returncode variable
if (((context->rexxrxReturnCode) < 0) && !((context->rexx_proc)[(context->rexx_rx_proc)].trace & off_trace)) { // do the right thing for tracing
if ((context->rexx_proc)[(context->rexx_rx_proc)].trace & (error_trace | normal_trace)) {
TraceCurline(NULL,TRUE);
fprintf(STDERR," +++ RC(%d) +++\n",(context->rexxrxReturnCode));
if ((context->rexx_proc)[(context->rexx_rx_proc)].interactive_trace)
TraceInteractive(FALSE);
}
if ((context->rexx_proc)[(context->rexx_rx_proc)].condition & SC_ERROR)
RxSignalCondition(SC_ERROR);
LASCIIZ(*env);
/*
if (!Lcmp(env, "CMS")) how = CMS_CONSOLE;
else how = CMS_COMMAND;
(context->rexxrxReturnCode) = CMScommand(LSTR(* cmd), how); // execute the command
*/
(context->rexxrxReturnCode) = __HOSTCM(cmd, env);

RxSetSpecialVar(RCVAR,
(context->rexxrxReturnCode)); // set the returncode variable
if (((context->rexxrxReturnCode) < 0) &&
!((context->rexx_proc)[(context->rexx_rx_proc)].trace &
off_trace)) { // do the right thing for tracing
if ((context->rexx_proc)[(context->rexx_rx_proc)].trace &
(error_trace | normal_trace)) {
TraceCurline(NULL, TRUE);
fprintf(STDERR, " +++ RC(%d) +++\n",
(context->rexxrxReturnCode));
if ((context->rexx_proc)[(context->rexx_rx_proc)].interactive_trace)
TraceInteractive(FALSE);
}
if ((context->rexx_proc)[(context->rexx_rx_proc)].condition & SC_ERROR)
RxSignalCondition(SC_ERROR);
}
#elif defined(__MVS__)
(context->rexxrxReturnCode) = system(LSTR(* cmd));
Expand Down
3 changes: 2 additions & 1 deletion bmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ mem_chk(void) {
int i = 0;
Context *context = (Context *) CMSGetPG();

for (mem = ((Memory *) (context->bmem_mem_head)); mem; mem = mem->prev, i++) {
for (mem = ((Memory *) (context->bmem_mem_head)); mem;
mem = mem->prev, i++) {
if (mem->magic != MAGIC) {
fprintf(STDERR, "PREFIX Magic number doesn't match! ID=%d\n", i);
mem_print(i, mem);
Expand Down
70 changes: 35 additions & 35 deletions builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,19 @@ R_O(const int func) {
break;

#ifndef __CMS__
case f_desbuf:
items = 0;
while (1) {
items += StackQueued();
if ((context->rexxrxStackList).items > 1)
DeleteStack();
else {
DQFlush(DQPEEK(&(context->rexxrxStackList)), _Lfree);
break;
case f_desbuf:
items = 0;
while (1) {
items += StackQueued();
if ((context->rexxrxStackList).items > 1)
DeleteStack();
else {
DQFlush(DQPEEK(&(context->rexxrxStackList)), _Lfree);
break;
}
}
}
Licpy(ARGR, items);
break;
Licpy(ARGR, items);
break;
#endif

case f_digits:
Expand All @@ -144,10 +144,10 @@ R_O(const int func) {
break;

#ifndef __CMS__
case f_makebuf:
CreateStack();
Licpy(ARGR, (context->rexxrxStackList).items);
break;
case f_makebuf:
CreateStack();
Licpy(ARGR, (context->rexxrxStackList).items);
break;
#endif

#ifdef WIN
Expand Down Expand Up @@ -235,7 +235,7 @@ R_C(const int func) {

case f_queued:
#if defined(__CMS__) || defined(__MVS) /* dw start */
Licpy(ARGR,StackQueued());
Licpy(ARGR, StackQueued());
break;
#else
if (exist(1)) {
Expand Down Expand Up @@ -915,24 +915,24 @@ R_sourceline() {
} /* R_sourceline */

#ifdef __CMS__

void __CDECL
VM_O(int func)
{
Context *context = (Context*)CMSGetPG();
switch (func){
case f_cmsflag:
if (ARGN!=1) (context->lstring_Lerror)(ERR_INCORRECT_CALL,0);
L2STR(ARG1);
CMSFLAG(ARGR,ARG1);
break;
case f_cmsline:
CMSLINE(ARGR);
break;
case f_cmsuser:
CMSUSER(ARGR);
break;
default:
fprintf(stderr, "unknown function %d in VM_O" , func);
}
VM_O(int func) {
Context *context = (Context *) CMSGetPG();
switch (func) {
case f_cmsflag:
if (ARGN != 1) (context->lstring_Lerror)(ERR_INCORRECT_CALL, 0);
L2STR(ARG1);
CMSFLAG(ARGR, ARG1);
break;
case f_cmsline:
CMSLINE(ARGR);
break;
case f_cmsuser:
CMSUSER(ARGR);
break;
default:
fprintf(stderr, "unknown function %d in VM_O", func);
}
} /* VM_O */
#endif
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
BREXX CMS Change LOG
====================

F0035 - Code reformatting
Added -D__CMS__ to CMAKE so that the right #ifdefs work including code
reformatting
F0034 - Fix Function package in search path breaks EXEC to EXEC function
calls (Issue #51)
F0033 - Fix PULL stripping trailing blanks (issue #50)
Expand Down
77 changes: 43 additions & 34 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,34 +168,34 @@ struct sort_list_st {
}
/* WARNING THE LIST MUST BE SORTED!!!!!!!!!!!! */
statements_list[] = {
{"ADDRESS", C_address},
{"ARG", C_arg},
{"CALL", C_call},
{"DO", C_do},
{"DROP", C_drop},
{"ELSE", C_error},
{"EXIT", C_exit},
{"IF", C_if},
{"ADDRESS", C_address},
{"ARG", C_arg},
{"CALL", C_call},
{"DO", C_do},
{"DROP", C_drop},
{"ELSE", C_error},
{"EXIT", C_exit},
{"IF", C_if},
{"INTERPRET", C_interpret},
{"ITERATE", C_iterate},
{"LEAVE", C_leave},
{"LOWER", C_lower},
{"NOP", C_nop},
{"NUMERIC", C_numeric},
{"ITERATE", C_iterate},
{"LEAVE", C_leave},
{"LOWER", C_lower},
{"NOP", C_nop},
{"NUMERIC", C_numeric},
{"OTHERWISE", C_error},
{"PARSE", C_parse},
{"PARSE", C_parse},
{"PROCEDURE", C_error},
{"PULL", C_pull},
{"PUSH", C_push},
{"QUEUE", C_queue},
{"RETURN", C_return},
{"SAY", C_say},
{"SELECT", C_select},
{"SIGNAL", C_signal},
{"THEN", C_error},
{"TRACE", C_trace},
{"UPPER", C_upper},
{"WHEN", C_error}
{"PULL", C_pull},
{"PUSH", C_push},
{"QUEUE", C_queue},
{"RETURN", C_return},
{"SAY", C_say},
{"SELECT", C_select},
{"SIGNAL", C_signal},
{"THEN", C_error},
{"TRACE", C_trace},
{"UPPER", C_upper},
{"WHEN", C_error}
};

/* ---------------- crloopctrl ------------------- */
Expand Down Expand Up @@ -226,11 +226,16 @@ CreateClause(void) {
return;

/* --- create a clause --- */
(context->compileCompileClause)[(context->compileCompileCurClause)].ptr = (context->nextsymbsymbolprevptr);
(context->compileCompileClause)[(context->compileCompileCurClause)].line = (context->nextsymbsymboline);
(context->compileCompileClause)[(context->compileCompileCurClause)].code = (context->compileCompileCodeLen);
(context->compileCompileClause)[(context->compileCompileCurClause)].nesting = (context->compileCompileNesting);
(context->compileCompileClause)[(context->compileCompileCurClause)].fptr = (context->compileCompileRxFile);
(context->compileCompileClause)[(context->compileCompileCurClause)].ptr =
(context->nextsymbsymbolprevptr);
(context->compileCompileClause)[(context->compileCompileCurClause)].line =
(context->nextsymbsymboline);
(context->compileCompileClause)[(context->compileCompileCurClause)].code =
(context->compileCompileCodeLen);
(context->compileCompileClause)[(context->compileCompileCurClause)]
.nesting = (context->compileCompileNesting);
(context->compileCompileClause)[(context->compileCompileCurClause)].fptr =
(context->compileCompileRxFile);

(context->compileCompileCurClause)++;
if ((context->compileCompileCurClause) ==
Expand Down Expand Up @@ -1803,7 +1808,8 @@ C_chk4assign(void) {
if (IN_RANGE('0', LSTR((context->nextsymbsymbolstr))[0], '9'))
(context->lstring_Lerror)(ERR_INVALID_START,
(_Lisnum(
&(context->nextsymbsymbolstr)) !=
&(context
->nextsymbsymbolstr)) !=
LSTRING_TY) ? 1 : 2,
&(context->nextsymbsymbolstr));
else if (LSTR((context->nextsymbsymbolstr))[0] == '.')
Expand Down Expand Up @@ -1993,9 +1999,12 @@ RxCompile(void) {

/* mark the end of clauses */
(context->compileCompileClause)[(context->compileCompileCurClause)].ptr = 0;
(context->compileCompileClause)[(context->compileCompileCurClause)].line = 0;
(context->compileCompileClause)[(context->compileCompileCurClause)].code = 0;
(context->compileCompileClause)[(context->compileCompileCurClause)].fptr = 0;
(context->compileCompileClause)[(context->compileCompileCurClause)].line =
0;
(context->compileCompileClause)[(context->compileCompileCurClause)].code =
0;
(context->compileCompileClause)[(context->compileCompileCurClause)].fptr =
0;

/* ---- Mark the End of compilation ----- */
(context->nextsymbsymbolptr) = NULL; /* mark end of compilation */
Expand Down
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 "F0034"
#define CMS_VERSION "F0035"
/*
#define CMS_VERSION "0.9.8"
#define CMS_VERSION "F0020"
Expand Down
2 changes: 1 addition & 1 deletion context.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void InitContext() {
context->interpre_no_loc_fp = 0;
context->interpre_no_sys_fp = 0;

context->rawstdin = fopen("CONSOLE","rb");
context->rawstdin = fopen("CONSOLE", "rb");
}

#undef __CONTEXT_C__
12 changes: 8 additions & 4 deletions error.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ RxSignalCondition(int cnd) {
leaf = BinFind(&(context->rexx_labels), cndstr);
if (leaf == NULL || ((RxFunc *) (leaf->value))->label == UNKNOWN_LABEL) {
if (cnd == SC_SYNTAX) /* disable the error handling */
(context->rexx_proc)[(context->rexx_rx_proc)].condition &= ~SC_SYNTAX;
(context->rexx_proc)[(context->rexx_rx_proc)].condition &=
~SC_SYNTAX;
(context->lstring_Lerror)(ERR_UNEXISTENT_LABEL, 1, cndstr);
}
func = (RxFunc *) (leaf->value);
Expand Down Expand Up @@ -174,9 +175,12 @@ Rerror(const int errno, const int subno, ...) {
(context->rexx_proc)[(context->rexx_rx_proc)].env);

(context->rexx_rx_proc)--;
(context->interpreRx_id) = (context->rexx_proc)[(context->rexx_rx_proc)].id;
(context->interpre_VarScope) = (context->rexx_proc)[(context->rexx_rx_proc)].scope;
(context->lstring_lNumericDigits) = (context->rexx_proc)[(context->rexx_rx_proc)].digits;
(context->interpreRx_id) =
(context->rexx_proc)[(context->rexx_rx_proc)].id;
(context->interpre_VarScope) =
(context->rexx_proc)[(context->rexx_rx_proc)].scope;
(context->lstring_lNumericDigits) =
(context->rexx_proc)[(context->rexx_rx_proc)].digits;
if ((context->rexx_proc)[(context->rexx_rx_proc)].trace &
(normal_trace | off_trace | error_trace))
(context->interpre__trace) = FALSE;
Expand Down
Loading

0 comments on commit e586daa

Please sign in to comment.