Skip to content

Commit

Permalink
updated to r2176 from official svn repo
Browse files Browse the repository at this point in the history
  • Loading branch information
irmen committed Mar 24, 2020
1 parent 3fbfd43 commit af962ae
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 122 deletions.
6 changes: 3 additions & 3 deletions 64tass.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH 64tass 1 "Feb 17 2019" "64tass 1.54" "64tass 1.54"
.TH 64tass 1 "Mar 23 2020" "64tass 1.55" "64tass 1.55"
.SH NAME
64tass \- A multi pass optimizing macro assembler for the 65xx series of processors
.SH SYNOPSIS
Expand Down Expand Up @@ -379,9 +379,9 @@ Normally the exit status is 0 if no error occured.
.SH AUTHOR
Written by Zsolt Kajtar.
.SH "REPORTING BUGS"
Online bug tracker: <http://sourceforge.net/p/tass64/bugs/>
Online bug tracker: <https://sourceforge.net/p/tass64/bugs/>
.SH COPYRIGHT
Copyright \(co 2019 Zsolt Kajtar.
Copyright \(co 2020 Zsolt Kajtar.
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
.br
This is free software: you are free to change and redistribute it.
Expand Down
3 changes: 2 additions & 1 deletion 64tass.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Turbo Assembler 6502/65C02/65816/DTV
$Id: 64tass.c 2156 2020-03-08 12:44:05Z soci $
$Id: 64tass.c 2158 2020-03-22 07:58:51Z soci $
6502/65C02 Turbo Assembler Version 1.3
(c) 1996 Taboo Productions, Marek Matula
Expand Down Expand Up @@ -4879,6 +4879,7 @@ int main2(int *argc2, char **argv2[]) {
int argc;

err_init(*argv2[0]);
setvbuf(stdout, NULL, _IOLBF, 1024);
avltree_init(&star_root);
objects_init();
init_section();
Expand Down
6 changes: 3 additions & 3 deletions 64tass.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: 64tass.h 2050 2019-11-01 08:37:21Z soci $
$Id: 64tass.h 2176 2020-03-23 20:12:04Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -23,10 +23,10 @@
#include "inttypes.h"
#include "wait_e.h"
#ifndef REVISION
#define REVISION "1900?"
#define REVISION "2176?"
#endif
#undef VERSION
#define VERSION "1.54." REVISION
#define VERSION "1.55." REVISION
#define MAX_PASS 20

#define ignore() while(pline[lpoint.pos]==0x20 || pline[lpoint.pos]==0x09) lpoint.pos++
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OBJ = 64tass.o opcodes.o str.o avl.o my_getopt.o eval.o error.o section.o \
errorobj.o macroobj.o mfuncobj.o identobj.o memblocksobj.o foldobj.o main.o
LDLIBS = -lm
LANG = C
REVISION := $(shell svnversion | grep --color=none "^[1-9]" || echo "1900?")
REVISION := $(shell svnversion | grep --color=none "^[1-9]" || echo "2176?")
CFLAGS = -O2 -W -Wall -Wextra -Wwrite-strings -Wshadow -fstrict-aliasing -DREVISION="\"$(REVISION)\"" -Wstrict-aliasing=2 -Werror=missing-prototypes
LDFLAGS = -g
CFLAGS += $(LDFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion Makefile.amigaos
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OBJ = 64tass.o opcodes.o str.o avl.o my_getopt.o eval.o error.o section.o \
errorobj.o macroobj.o mfuncobj.o identobj.o memblocksobj.o foldobj.o main.o
LDLIBS = -lmsoft
LANG = C
REVISION := $(shell svnversion | grep --color=none "^[1-9]" || echo "1900?")
REVISION := $(shell svnversion | grep --color=none "^[1-9]" || echo "2176?")
CFLAGS = -c99 -soft-float
LDFLAGS =
CFLAGS += $(LDFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion Makefile.amigaos4
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OBJ = 64tass.o opcodes.o str.o avl.o my_getopt.o eval.o error.o section.o \
errorobj.o macroobj.o mfuncobj.o identobj.o memblocksobj.o foldobj.o main.o
LDLIBS = -lm
LANG = C
REVISION := $(shell svnversion | grep --color=none "^[1-9]" || echo "1900?")
REVISION := $(shell svnversion | grep --color=none "^[1-9]" || echo "2176?")
CFLAGS = -O2 -W -Wall -Wextra -DREVISION="\"$(REVISION)\""
LDFLAGS = -s
CFLAGS += $(LDFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion Makefile.win
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OBJ = 64tass.o opcodes.o str.o avl.o my_getopt.o eval.o error.o section.o \
errorobj.o macroobj.o mfuncobj.o identobj.o memblocksobj.o foldobj.o main.o
LDLIBS = -lm
LANG = C
REVISION := $(shell svnversion | grep --color=none "^[1-9]" || echo "1900?")
REVISION := $(shell svnversion | grep --color=none "^[1-9]" || echo "2176?")
CFLAGS = -O2 -march=i586 -W -Wall -Wextra -DREVISION="\"$(REVISION)\""
LDFLAGS = -s
CFLAGS += $(LDFLAGS)
Expand Down
4 changes: 2 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
64tass v1.54 r1900 reference manual
64tass v1.55 r2176 reference manual

This is the manual for 64tass, the multi pass optimizing macro assembler for
the 65xx series of processors. Key features:
Expand Down Expand Up @@ -27,7 +27,7 @@ This is a development version. Features or syntax may change as a result of
corrections in non-backwards compatible ways in some rare cases. It's difficult
to get everything `right' first time.

Project page: http://sourceforge.net/projects/tass64/
Project page: https://sourceforge.net/projects/tass64/

The page hosts the latest and older versions with sources and a bug and a
feature request tracker.
Expand Down
8 changes: 4 additions & 4 deletions README.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>64tass v1.54 r1900 reference manual</title>
<title>64tass v1.55 r2176 reference manual</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Description" content="64tass, an advanced multi pass macro assembler for the 65xx family of microprocessors">
<meta name="Keywords" content="6502 assembler, 65816, 6510, 65C02, dtv, c64 cross assembler">
Expand Down Expand Up @@ -84,7 +84,7 @@
</head>
<body>
<div>
<h1>64tass v1.54 r1900 reference manual</h1>
<h1>64tass v1.55 r2176 reference manual</h1>

<p>This is the manual for 64tass, the multi pass optimizing macro assembler for
the 65xx series of processors. Key features:</p>
Expand Down Expand Up @@ -112,7 +112,7 @@ <h1>64tass v1.54 r1900 reference manual</h1>
of corrections in non-backwards compatible ways in some rare cases. It's
difficult to get everything <q>right</q> first time.</b></p>

<p>Project page: <a href="http://sourceforge.net/projects/tass64/">http://sourceforge.net/projects/tass64/</a></p>
<p>Project page: <a href="https://sourceforge.net/projects/tass64/">https://sourceforge.net/projects/tass64/</a></p>

<p>The page hosts the latest and older versions with sources and a bug and a feature request tracker.</p>

Expand Down Expand Up @@ -279,7 +279,7 @@ <h2>Usage tips<a name="usage-tips" href="#usage-tips"></a></h2>

<p>There are also some useful parameters which are described later.</p>

<p>For comfortable compiling I use such <q>Makefile</q>s (for <a href="http://en.wikipedia.org/wiki/Make_%28software%29">make</a>):</p>
<p>For comfortable compiling I use such <q>Makefile</q>s (for <a href="https://en.wikipedia.org/wiki/Make_%28software%29">make</a>):</p>

<pre width=80 class="make">
<span>demo.prg:</span> source.asm macros.asm pic.drp music.bin
Expand Down
9 changes: 7 additions & 2 deletions arguments.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: arguments.c 2125 2019-12-23 19:50:58Z soci $
$Id: arguments.c 2172 2020-03-22 19:46:59Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -458,6 +458,7 @@ static MUST_CHECK char *read_one(FILE *f) {

static address_t get_all_mem2(void) {
size_t i;
bool tostdout = false;
address_t min = 0xffffffff;
for (i = 0; i < arguments.output_len; i++) {
const struct output_s *output = &arguments.output[i];
Expand All @@ -471,7 +472,11 @@ static address_t get_all_mem2(void) {
case OUTPUT_APPLE:
case OUTPUT_XEX: min &= 0xffff; break;
}
if (dash_name(output->name)) arguments.quiet = false;
if (dash_name(output->name)) tostdout = true;
}
if (tostdout) {
arguments.quiet = false;
setvbuf(stdout, NULL, _IOFBF, BUFSIZ);
}
return min;
}
Expand Down
6 changes: 3 additions & 3 deletions encoding.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: encoding.c 2108 2019-12-10 19:16:03Z soci $
$Id: encoding.c 2175 2020-03-23 19:18:35Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,7 +31,7 @@

struct encoding_s *actual_encoding;

#define identmap (const uint8_t *)petscii_esc
#define identmap (const uint8_t *)petscii_trans

struct encoding_s {
str_t name;
Expand Down Expand Up @@ -840,7 +840,7 @@ int encode_string(void) {
t = cavltree_container_of(c, struct trans_s, node);
if (tmp.start >= t->start && tmp.end <= t->end) {
encode_state.i += ln;
if ((ch & 0x80) == 0) {
if (ch < 0x80) {
actual_encoding->table_use[ch / 32] |= 1 << (ch % 32);
actual_encoding->table[ch] = (uint8_t)(ch - t->start + t->offset);
}
Expand Down
33 changes: 17 additions & 16 deletions error.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: error.c 2155 2020-03-08 09:33:08Z soci $
$Id: error.c 2175 2020-03-23 19:18:35Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1350,11 +1350,15 @@ static void print_error(FILE *f, const struct errorentry_s *err, bool caret) {

#ifdef COLOR_OUTPUT
static void color_detect(FILE *f) {
char const *term = getenv ("TERM");
print_use_color = term != NULL && strcmp(term, "dumb") != 0 && isatty(fileno(f)) == 1;
static int terminal;
if (terminal == 0) {
char const *term = getenv("TERM");
terminal = (term != NULL && strcmp(term, "dumb") != 0) ? 1 : 2;
}
print_use_color = terminal == 1 && isatty(fileno(f)) == 1;
}
#else
#define color_detect(f) {}
#define color_detect(f) do {} while (false)
#endif

static inline bool caret_needed(const struct errorentry_s *err) {
Expand Down Expand Up @@ -1404,7 +1408,7 @@ bool error_print(void) {
}
} else ferr = stderr;

color_detect(ferr);
if (ferr != stderr) color_detect(ferr); else if (arguments.quiet) fflush(stdout);

warnings = errors = 0;
close_error();
Expand Down Expand Up @@ -1466,7 +1470,7 @@ bool error_print(void) {
}
if (err3 != NULL) print_error(ferr, err3, different_line(err2, err3));
if (err2 != NULL) print_error(ferr, err2, caret_needed(err2));
color_detect(stderr);
if (ferr != stderr) color_detect(stderr);
if (ferr != stderr && ferr != stdout) fclose(ferr); else fflush(ferr);
return errors != 0;
}
Expand Down Expand Up @@ -1546,9 +1550,6 @@ void err_msg_file(Error_types no, const char *prm, linepos_t epoint) {
int err = errno;
bool more;

#ifdef _WIN32
setlocale(LC_ALL, "");
#endif
s = strerror(err);
n = strlen(s);

Expand All @@ -1574,17 +1575,17 @@ void err_msg_file(Error_types no, const char *prm, linepos_t epoint) {
adderror((char *)s2);
i += (size_t)l;
}
#ifdef _WIN32
setlocale(LC_ALL, "C");
#endif
if (more) new_error_msg_more();
}

static void error_status_val(const char *head, unsigned int val) {
fputs(head, stdout);
if (val != 0) printf("%u\n", val); else puts("None");
}

void error_status(void) {
printf("Error messages: ");
if (errors != 0) printf("%u\n", errors); else puts("None");
printf("Warning messages: ");
if (warnings != 0) printf("%u\n", warnings); else puts("None");
error_status_val("Error messages: ", errors);
error_status_val("Warning messages: ", warnings);
}

linecpos_t interstring_position(linepos_t epoint, const uint8_t *data, size_t i) {
Expand Down
68 changes: 44 additions & 24 deletions file.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
$Id: file.c 2125 2019-12-23 19:50:58Z soci $
$Id: file.c 2163 2020-03-22 12:45:33Z soci $
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -24,6 +24,9 @@
#include <locale.h>
#include <windows.h>
#endif
#if defined _POSIX_C_SOURCE || defined __MINGW32__
#include <sys/stat.h>
#endif
#include "64tass.h"
#include "unicode.h"
#include "error.h"
Expand Down Expand Up @@ -355,6 +358,26 @@ static inline uchar_t fromiso(uchar_t c) {
return conv[c];
}

static size_t fsize(FILE *f) {
#if defined _POSIX_C_SOURCE || defined __MINGW32__
struct stat st;
if (fstat(fileno(f), &st) == 0) {
if (S_ISREG(st.st_mode) && st.st_size > 0) {
return (size_t)st.st_size;
}
}
#else
if (fseek(f, 0, SEEK_END) == 0) {
long len = ftell(f);
rewind(f);
if (len > 0) {
return (size_t)len;
}
}
#endif
return 0;
}

static struct file_s *command_line = NULL;
static struct file_s *lastfi = NULL;
static struct ubuff_s last_ubuff;
Expand Down Expand Up @@ -419,23 +442,23 @@ struct file_s *openfile(const char *name, const char *base, int ftype, const str
if (path == NULL) path = s;
tmp->realname = path;
if (arguments.quiet) {
printf((ftype == 1) ? "Reading file: " : "Assembling file: ");
fputs((ftype == 1) ? "Reading file: " : "Assembling file: ", stdout);
argv_print(path, stdout);
putchar('\n');
}
if (f == NULL) goto openerr;
#ifndef __DJGPP__
setvbuf(f, NULL, _IONBF, 0);
#endif
tmp->read_error = true;
if (ftype == 1) {
bool check = true;
if (fseek(f, 0, SEEK_END) == 0) {
long len = ftell(f);
if (len > 0) {
size_t len2 = (size_t)len;
tmp->data = (uint8_t *)malloc(len2);
if (tmp->data != NULL) tmp->len = len2;
}
rewind(f);
bool check;
size_t fs = fsize(f);
if (fs > 0) {
tmp->data = (uint8_t *)malloc(fs);
if (tmp->data != NULL) tmp->len = fs;
}
check = (tmp->data != NULL);
clearerr(f); errno = 0;
if (tmp->len != 0 || !extendfile(tmp)) {
for (;;) {
Expand Down Expand Up @@ -464,19 +487,16 @@ struct file_s *openfile(const char *name, const char *base, int ftype, const str
line_t lines = 0;
uint8_t buffer[BUFSIZ * 2];
size_t bp = 0, bl, qr = 1;
if (fseek(f, 0, SEEK_END) == 0) {
long len = ftell(f);
if (len > 0) {
size_t len2 = (size_t)len + 4096;
if (len2 < 4096) len2 = SIZE_MAX; /* overflow */
tmp->data = (uint8_t *)malloc(len2);
if (tmp->data != NULL) tmp->len = len2;
max_lines = (len2 / 20 + 1024) & ~(size_t)1023;
if (max_lines > SIZE_MAX / sizeof *tmp->line) max_lines = SIZE_MAX / sizeof *tmp->line; /* overflow */
tmp->line = (size_t *)malloc(max_lines * sizeof *tmp->line);
if (tmp->line == NULL) max_lines = 0;
}
rewind(f);
size_t fs = fsize(f);
if (fs > 0) {
size_t len2 = fs + 4096;
if (len2 < 4096) len2 = SIZE_MAX; /* overflow */
tmp->data = (uint8_t *)malloc(len2);
if (tmp->data != NULL) tmp->len = len2;
max_lines = (len2 / 20 + 1024) & ~(size_t)1023;
if (max_lines > SIZE_MAX / sizeof *tmp->line) max_lines = SIZE_MAX / sizeof *tmp->line; /* overflow */
tmp->line = (size_t *)malloc(max_lines * sizeof *tmp->line);
if (tmp->line == NULL) max_lines = 0;
}
clearerr(f); errno = 0;
bl = fread(buffer, 1, BUFSIZ, f);
Expand Down
Loading

0 comments on commit af962ae

Please sign in to comment.