Skip to content

Commit

Permalink
Improvements for writing tape marks.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbrinkhoff committed Mar 19, 2022
1 parent 780eeea commit 135ab6c
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions tape-word.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
static word_t record[65536];
static int reclen = 0;
static int beginning_of_tape = 1;
static int marks = 0;

static int
get_byte (FILE *f)
Expand Down Expand Up @@ -133,7 +134,11 @@ void write_7track_record (FILE *f, word_t *buffer, int n)

write_reclen (f, 6 * n);
if (n == 0)
return;
{
marks++;
return;
}
marks = 0;

for (i = 0; i < n; i++)
write_7track_word (f, *buffer++);
Expand All @@ -156,7 +161,11 @@ void write_9track_record (FILE *f, word_t *buffer, int n)
/* A record of length zero is a tape mark, and the length is only
written once. */
if (n == 0)
return;
{
marks++;
return;
}
marks = 0;

for (i = 0; i < n; i++)
write_core_word (f, *buffer++);
Expand Down Expand Up @@ -290,11 +299,20 @@ write_tape_mark (FILE *f)
write_tape_record (f, NULL, 0);
}

void
write_tape_eof (FILE *f)
{
int i;
for (i = marks; i < 1; i++)
write_tape_mark (f);
}

void
write_tape_eot (FILE *f)
{
write_tape_mark (f);
write_tape_mark (f);
int i;
for (i = marks; i < 2; i++)
write_tape_mark (f);
}

static void
Expand All @@ -311,10 +329,10 @@ write_tape_word (FILE *f, word_t word)
{
if (word & (START_RECORD|START_FILE|START_TAPE))
flush_record (f);
if (word & (START_FILE|START_TAPE))
if (word & START_FILE)
write_tape_mark (f);
if (word & START_TAPE)
write_tape_mark (f);
write_tape_eot (f);
}
beginning_of_tape = 0;

Expand All @@ -327,6 +345,7 @@ flush_tape_word (FILE *f)
flush_record (f);
write_tape_eot (f);
beginning_of_tape = 1;
marks = 0;
}

struct word_format tape_word_format = {
Expand Down

0 comments on commit 135ab6c

Please sign in to comment.