Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with master #10

Merged
merged 19 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Bin/spin652_windows64.exe.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions Doc/V6.Updates
Original file line number Diff line number Diff line change
Expand Up @@ -950,3 +950,5 @@ Smaller changes:
assert(B[1]);
}
the explicit removal of the initialization value is now removed.
- february 2024: minor update, full(q) now returns false for a
rendez-vous channel (it used to return true)
14 changes: 9 additions & 5 deletions Src/flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ if_seq(Lextok *n)
e->sub = s;
for (z = s; z; z = z->nxt)
add_el(t, z->this); /* append target */

if (tok == DO)
{ add_el(t, cur_s->this); /* target upfront */
t = new_el(nn(n, BREAK, ZN, ZN)); /* break target */
Expand Down Expand Up @@ -861,6 +862,7 @@ make_atomic(Sequence *s, int added)
#if 0
static int depth = 0;
void dump_sym(Symbol *, char *);
void explain(int);

void
dump_lex(Lextok *t, char *s)
Expand All @@ -871,7 +873,7 @@ dump_lex(Lextok *t, char *s)
for (i = 0; i < depth; i++)
printf("\t");
explain(t->ntyp);
if (t->ntyp == NAME) printf(" %s ", t->sym->name);
if (t->ntyp == NAME || t->ntyp == TYPE) printf(" '%s' ", t->sym->name);
if (t->ntyp == CONST) printf(" %d ", t->val);
if (is_typedef(t->ntyp))
{ dump_sym(t->sym, "\n:Z:");
Expand All @@ -887,7 +889,7 @@ dump_lex(Lextok *t, char *s)
void
dump_sym(Symbol *z, char *s)
{ int i;
char txt[64];
// char txt[64];
depth++;
printf(s);
for (i = 0; i < depth; i++)
Expand All @@ -899,11 +901,11 @@ dump_sym(Symbol *z, char *s)
if (z->ini->rgt->rgt
|| !z->ini->rgt->sym)
fatal("chan %s in for should have only one field (a typedef)", z->name);
printf(" -- %s %p -- ", z->ini->rgt->sym->name, z->ini->rgt->sym);
printf(" -- %s %p -- ", z->ini->rgt->sym->name, (void *) z->ini->rgt->sym);
}
} else if (is_typedef(z->type))
{ if (z->Snm)
printf(" == %s %p == ", z->Snm->name, z->Snm);
printf(" == %s %p == ", z->Snm->name, (void *) z->Snm);
else
{ if (z->Slst)
dump_lex(z->Slst, "\n:X:");
Expand Down Expand Up @@ -1037,7 +1039,9 @@ for_index(Lextok *a3, Lextok *a5)
leaf = leaf->lft;
// printf("%s %d\n", leaf->sym->name, leaf->sym->isarray);
}

if (!leaf)
{ fatal("unexpected type of for-loop", (char *) 0);
}
if (leaf->sym->isarray == 0
|| leaf->sym->nel <= 0)
{ fatal("bad arrayname %s", leaf->sym->name);
Expand Down
8 changes: 4 additions & 4 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void explain(int);
can later be truncated at that point
*/
#if 1
#define CPP "gcc -std=gnu99 -Wformat-overflow=0 -E -x c"
#define CPP "gcc -std=gnu99 -Wno-unknown-warning-option -Wformat-overflow=0 -E -x c"
/* if gcc-4 is available, this setting is modified below */
#else
#if defined(PC) || defined(MAC)
Expand Down Expand Up @@ -587,9 +587,9 @@ preprocess(char *a, char *b, int a_tmp)
*/
if (strncmp(PreProc, "gcc ", strlen("gcc ")) == 0)
{ if (e_system(0, "gcc-4 --version > pan.pre 2>&1") == 0)
{ strcpy(PreProc, "gcc-4 -std=gnu99 -Wformat-overflow=0 -E -x c");
{ strcpy(PreProc, "gcc-4 -std=gnu99 -Wno-unknown-warning-option -Wformat-overflow=0 -E -x c");
} else if (e_system(0, "gcc-3 --version > pan.pre 2>&1") == 0)
{ strcpy(PreProc, "gcc-3 -std=gnu99 -Wformat-overflow=0 -E -x c");
{ strcpy(PreProc, "gcc-3 -std=gnu99 -Wno-unknown-warning-option -Wformat-overflow=0 -E -x c");
} }
#endif

Expand Down Expand Up @@ -1076,7 +1076,7 @@ samecase: if (buzzed != 0)
strcpy(out1, "pan.pre");

if (add_ltl || nvr_file)
{ assert(strlen(argv[1]) < sizeof(out2));
{ assert(strlen(argv[1])+6 < sizeof(out2));
sprintf(out2, "%s.nvr", argv[1]);
if ((fd = fopen(out2, MFLAGS)) == NULL)
{ printf("spin: cannot create tmp file %s\n",
Expand Down
39 changes: 24 additions & 15 deletions Src/mesg.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,12 @@ int
qfull(Lextok *n)
{ int whichq = eval(n->lft)-1;

if (whichq < MAXQ && whichq >= 0 && ltab[whichq])
return (ltab[whichq]->qlen >= ltab[whichq]->nslots);
if (whichq < MAXQ
&& whichq >= 0 // valid qid
&& ltab[whichq] // q exists
&& ltab[whichq]->nslots > 0) // !q_is_sync added 02/24
{ return (ltab[whichq]->qlen >= ltab[whichq]->nslots);
}
return 0;
}

Expand Down Expand Up @@ -325,13 +329,15 @@ a_snd(Queue *q, Lextok *n)
{ Value New = evalValue(m->lft);
q->contents[i+j] = cast_val(q->fld_width[j], New, 0);

if (q->fld_width[i+j] == MTYPE)
{ mtype_ck(q->mtp[i+j], m->lft); /* 6.4.8 */
if (q->fld_width[j] == MTYPE) /* may 30, 2023: i+j -> j */
{ mtype_ck(q->mtp[j], m->lft); /* 6.4.8 - may 30: same change */
}
if ((verbose&16) && depth >= jumpsteps)
{ sr_talk(n, New, "Send ", "->", j, q); /* XXX j was i+j in 6.4.8 */
}
typ_ck(q->fld_width[i+j], Sym_typ(m->lft), "send");

/* may 30, 2023: the field types are 0..nflds, not i+0..nflds */
typ_ck(q->fld_width[j], Sym_typ(m->lft), "send");
}

if ((verbose&16) && depth >= jumpsteps)
Expand Down Expand Up @@ -363,8 +369,8 @@ a_rcv(Queue *q, Lextok *n, int full)
/* test executability */
for (m = n->rgt, j=0; m && j < q->nflds; m = m->rgt, j++)
{
if (q->fld_width[i*q->nflds+j] == MTYPE)
{ mtype_ck(q->mtp[i*q->nflds+j], m->lft); /* 6.4.8 */
if (q->fld_width[j] == MTYPE) /* may 30, 2023: i*q->nflds+j -> j */
{ mtype_ck(q->mtp[j], m->lft); /* 6.4.8 -- may 30, same change */
}

if (m->lft->ntyp == CONST
Expand Down Expand Up @@ -920,7 +926,7 @@ typedef struct BaseName {

static BaseName *bsn;

void
static void
newbasename(char *s)
{ BaseName *b;

Expand All @@ -938,7 +944,7 @@ newbasename(char *s)
bsn = b;
}

void
static void
delbasename(char *s)
{ BaseName *b, *prv = (BaseName *) 0;

Expand All @@ -956,7 +962,7 @@ delbasename(char *s)
} }
}

void
static void
checkindex(char *s, char *t)
{ BaseName *b;

Expand All @@ -970,7 +976,7 @@ checkindex(char *s, char *t)
} }
}

void
static void
scan_tree(Lextok *t, char *mn, char *mx)
{ char sv[512];
char tmp[32];
Expand All @@ -981,14 +987,17 @@ scan_tree(Lextok *t, char *mn, char *mx)
lineno = t->ln;

if (t->ntyp == NAME)
{ if (strlen(t->sym->name) + strlen(mn) > 256) // conservative
{ if (strlen(t->sym->name) + strlen(mn) > 512)
{ fatal("name too long", t->sym->name);
}

strcat(mn, t->sym->name);
strcat(mx, t->sym->name);

if (t->lft) /* array index */
{ strcat(mn, "[]");
{ if(strlen(t->sym->name) + strlen("[]") > 512)
{ fatal("name too long", t->sym->name);
}
strcat(mn, "[]");
newbasename(mn);
strcpy(sv, mn); /* save */
strcpy(mn, ""); /* clear */
Expand Down Expand Up @@ -1017,7 +1026,7 @@ scan_tree(Lextok *t, char *mn, char *mx)
lineno = oln;
}

void
static void
no_nested_array_refs(Lextok *n) /* a [ a[1] ] with a[1] = 1, causes trouble in pan.b */
{ char mn[512];
char mx[512];
Expand Down
5 changes: 2 additions & 3 deletions Src/pangen1.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ c_var(FILE *fd, char *pref, Symbol *sp)
buf, ptr, pref, sp->name);
}
} else
{ fprintf(fd, "\t{\tint l_in;\n");
{ fprintf(fd, "\t{\tint l_in; /* 1 */\n");
fprintf(fd, "\t\tfor (l_in = 0; l_in < %d; l_in++)\n", sp->nel);
fprintf(fd, "\t\t{\n");
fprintf(fd, "\t\t\tprintf(\"\t%s %s[%%d]:\t%%d\\n\", l_in, %s%s[l_in]);\n",
Expand Down Expand Up @@ -927,7 +927,6 @@ do_var(FILE *ofd, int dowhat, char *s, Symbol *sp,
switch(dowhat) {
case PUTV:
if (sp->hidden&1) break;

typ2c(sp);
break;

Expand Down Expand Up @@ -985,7 +984,7 @@ do_var(FILE *ofd, int dowhat, char *s, Symbol *sp,
fprintf(ofd, "%s", ter);
}
} else
{ fprintf(ofd, "\t{\tint l_in;\n");
{ fprintf(ofd, "\t{\tint l_in; /* 2 */\n");
fprintf(ofd, "\t\tfor (l_in = 0; l_in < %d; l_in++)\n",
sp->nel);
fprintf(ofd, "\t\t{\n");
Expand Down
114 changes: 58 additions & 56 deletions Src/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ static int pc_enabled(Lextok *n);
static int get_priority(Lextok *n);
static void set_priority(Lextok *n, Lextok *m);
extern void sr_buf(int, int, const char *);
extern char *which_mtype(const char *);
extern char *which_mtype_val(const int);

void
Srand(unsigned int s)
Expand Down Expand Up @@ -638,62 +640,62 @@ interprint(FILE *fd, Lextok *n)

GBuf[0] = '\0';
if (!no_print)
if (!s_trail || depth >= jumpsteps) {
for (i = 0; i < (int) strlen(s); i++)
switch (s[i]) {
case '\"': break; /* ignore */
case '\\':
switch(s[++i]) {
case 't': strcat(GBuf, "\t"); break;
case 'n': strcat(GBuf, "\n"); break;
default: goto onechar;
}
break;
case '%':
if ((c = s[++i]) == '%')
{ strcat(GBuf, "%"); /* literal */
break;
}
if (!tmp)
{ non_fatal("too few print args %s", s);
break;
}
j = evalValue(tmp->lft);

if (c == 'e'
&& tmp->lft
&& tmp->lft->sym
&& tmp->lft->sym->mtype_name)
{ t = tmp->lft->sym->mtype_name->name;
}

tmp = tmp->rgt;
switch(c) {
case 'c': sprintf(lbuf, "%c", getInt(j)); break;
case 'd': sprintf(lbuf, "%d", getInt(j)); break;

case 'e': strcpy(tBuf, GBuf); /* event name */
GBuf[0] = '\0';

sr_buf(getInt(j), 1, t); // TODO PG - hanlde float in j value

strcpy(lbuf, GBuf);
strcpy(GBuf, tBuf);
break;

case 'o': sprintf(lbuf, "%o", getInt(j)); break;
case 'u': sprintf(lbuf, "%u", (unsigned) getInt(j)); break;
case 'x': sprintf(lbuf, "%x", getInt(j)); break;
case 'f': sprintf(lbuf, "%f", getFloat(j)); break;
default: non_fatal("bad print cmd: '%s'", &s[i-1]);
lbuf[0] = '\0'; break;
}
goto append;
default:
onechar: lbuf[0] = s[i]; lbuf[1] = '\0';
append: strcat(GBuf, lbuf);
break;
}
if (!s_trail || depth >= jumpsteps)
{ for (i = 0; i < (int) strlen(s); i++)
{ switch (s[i]) {
case '\"': break; /* ignore */
case '\\':
switch(s[++i]) {
case 't': strcat(GBuf, "\t"); break;
case 'n': strcat(GBuf, "\n"); break;
default: goto onechar;
}
break;
case '%':
if ((c = s[++i]) == '%')
{ strcat(GBuf, "%"); /* literal */
break;
}
if (!tmp)
{ non_fatal("too few print args %s", s);
break;
}
j = evalValue(tmp->lft);
if (c == 'e'
&& tmp->lft)
{ if (tmp->lft->sym)
{ if (tmp->lft->sym->mtype_name)
{ t = tmp->lft->sym->mtype_name->name;
}
} else if (tmp->lft->ntyp == CONST)
{ t = which_mtype_val(tmp->lft->val);
} }

tmp = tmp->rgt;
switch(c) {
case 'c': sprintf(lbuf, "%c", getInt(j)); break;
case 'd': sprintf(lbuf, "%d", getInt(j)); break;

case 'e': strcpy(tBuf, GBuf); /* event name */
GBuf[0] = '\0';
sr_buf(getInt(j), 1, t); // TODO PG - hanlde float in j value
strcpy(lbuf, GBuf);
strcpy(GBuf, tBuf);
break;

case 'o': sprintf(lbuf, "%o", getInt(j)); break;
case 'u': sprintf(lbuf, "%u", (unsigned) getInt(j)); break;
case 'x': sprintf(lbuf, "%x", getInt(j)); break;
case 'f': sprintf(lbuf, "%f", getFloat(j)); break;
default: non_fatal("bad print cmd: '%s'", &s[i-1]);
lbuf[0] = '\0'; break;
}
goto append;
default:
onechar: lbuf[0] = s[i]; lbuf[1] = '\0';
append: strcat(GBuf, lbuf);
break;
} }
dotag(fd, GBuf);
}
if (strlen(GBuf) >= 4096) fatal("printf string too long", 0);
Expand Down
1 change: 0 additions & 1 deletion Src/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,6 @@ addsymbol(RunList *r, Symbol *s)
&& (old_scope_rules
|| strcmp((const char *)t->bscp, (const char *)s->bscp) == 0))
return; /* it's already there */

t = (Symbol *) emalloc(sizeof(Symbol));
t->name = s->name;
t->type = s->type;
Expand Down
1 change: 1 addition & 0 deletions Src/spin.y
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <unistd.h>
#endif
#include <stdarg.h>
#include <stdlib.h>

#define YYMAXDEPTH 20000 /* default is 10000 */
#define YYDEBUG 0
Expand Down
5 changes: 3 additions & 2 deletions Src/spinlex.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "spin.h"
#include "y.tab.h"

#define MAXINL 16 /* max recursion depth inline fcts */
#define MAXINL 32 /* max recursion depth inline fcts */
#define MAXPAR 32 /* max params to an inline call */
#define MAXLEN 512 /* max len of an actual parameter text */
#define MAX_TOKEN_TEXT_LENGTH 2048 /* max len of an actual token text */
Expand Down Expand Up @@ -746,7 +746,8 @@ c_add_loc(FILE *fd, char *s) /* state vector entries for proctype s */
for (r = c_added; r; r = r->nxt) /* pickup local decls */
{ if (strncmp(r->t->name, " Local", strlen(" Local")) == 0)
{ p = r->t->name + strlen(" Local");
fprintf(fd, "/* XXX p=<%s>, s=<%s>, buf=<%s> r->s->name=<%s>XXX */\n", p, s, buf, r->s->name);
fprintf(fd, "/* XXX p=<%s>, s=<%s>, buf=<%s> r->s->name=<%s>XXX */\n",
p, s, buf, r->s->name);
while (*p == ' ' || *p == '\t')
{ p++;
}
Expand Down
Loading
Loading