Commit graph

368 commits

Author SHA1 Message Date
tkchia 14c386561a Fix use-after-free in Modula-2 middle-end's em_m2
Partly fixes https://github.com/davidgiven/ack/issues/262
2022-08-01 17:48:54 +00:00
David Given 04f723b406 Eliminate make.allocd --- something about it makes Windows unhappy and it
doesn't add value anyway.
2022-07-16 19:34:25 +02:00
David Given 1a861669c5 Try and work around CRLF problems... again. 2022-07-16 17:58:39 +02:00
David Given 020c84db3d Try forcing ed to produce LF output files rather than CRLF ones. 2022-07-15 23:42:23 +02:00
David Given b727599882 Try some build debugging. 2022-07-15 23:34:55 +02:00
David Given 25b6712e63 Rework all the ackbuilder scripts not to use wildcards, because we can't expand
them without luaposix, which isn't available (easily) on OSX or Windows.
2022-07-14 23:57:54 +02:00
carl e8243402be Move to use C structures instead of typedef to align with other ACK compilers and to avoid forward declaration issues with include files. 2019-05-11 01:09:03 +08:00
carl 3867cfdaca + M2 Compiler ISO C90 compatibility
* Fixing of potential crash issue with function tables in compiler.
+ SYSTEM.h is now renamed to SYSTEMM2.h to avoid conflicts on non case sensitive filesystems.
2019-03-02 01:44:16 +08:00
carl fdf5da62d7 Better ANSI C compatibility and portability - part 1:
* Adapt to new sys_filesize prototype.
2019-02-19 00:54:23 +08:00
David Given f8ba7ef962 Move the Modula-2 library includes into a directory in lang/m2 where they belong. 2018-06-24 20:32:59 +02:00
George Koehler 229b80a004 Free buf in GetFile().
aprintf() returns a const char *; the assignment to char * caused both
clang and gcc to warn of the dropped const.

Commit 893471a introduced a tiny memory leak, because GetFile()
stopped freeing buf.  The const return type of aprintf() suggests that
the buffer must not be freed.

Now use Malloc() to allocate the buffer and free() to free it.  This
also checks if we are out of memory, because Malloc() does the check
and aprintf() currently doesn't.
2017-11-13 21:34:31 -05:00
George Koehler 3463f0c944 bts2str(), long2str() are in <ack_string.h> 2017-11-10 18:00:00 -05:00
George Koehler 59b3c10563 Use (arith) 1 << ... when getting the sign bit.
This prevents an overflow reported by @hexcoder- in
https://github.com/davidgiven/ack/issues/56

lang/cem/cpp.ansi/LLlex.c used a plain 1 << ... and caused an overflow
on machines where sizeof(int) < sizeof(long).  Using 1L << ... would
work for now but might fail later if arith became long long.

C doesn't specify whether negative integers use 2's complement or some
other format.  Therefore, (arith) 1 << ... has an undefined value.  It
should still work because the value is some integer where the sign bit
is set and all other bits are clear.

(unsigned arith) 1 << ... would also get the sign bit, but casting it
from unsigned back to signed would make the same undefined value.

(arith) -1 << ... would assume 2's complement.
2017-10-29 17:45:10 -04:00
George Koehler 038fb6fb55 Get correct sign of a MOD b when (a > 0) and (b < 0).
Reported by me in https://github.com/davidgiven/ack/issues/60

This doesn't change DIV.  Right now a DIV b does floor division and
a MOD b has the sign of b.  This is the same as Lua, Python, Ruby,
Tcl; but is different from other Modula-2 implementations.
2017-10-28 19:55:06 -04:00
George Koehler 649410bb27 Always use unsigned long.
Traditional C compilers had long but not unsigned long.  I now assume
that everyone can compile unsigned long.  Remove macro UNSIGNED_ARITH
and act like it is always defined.  The type `unsigned arith` works
because arith is a macro for long.
2017-10-28 17:56:20 -04:00
David Given 60e7d06d82 Ansification and warning fixes. 2017-08-06 11:58:36 +02:00
David Given a1043bc5fe Attempt to correct file system case sensitivity. 2017-08-06 11:15:53 +02:00
David Given 064fd52d52 Update man page not to mention the filename length restriction removed in
893471a42e.
2017-08-02 00:07:51 +02:00
George Koehler f91bc2804d Tune the installed manual pages.
This commit slightly improves the formatting of the manuals.  My
OpenBSD machine uses mandoc(1) to format manuals.  I check the manuals
with `mandoc -T lint` and fix most of the warnings.  I also make
other changes where mandoc didn't warn me.

roff(7) says, "Each sentence should terminate at the end of an input
line," but we often forgot this rule.  I insert some newlines after
sentences that had ended mid-line.

roff(7) also says that blank lines "are only permitted within literal
contexts."  I delete blank lines.  This removes some extra blank lines
from mandoc's output.  If I do want a blank line in the output, I call
".sp 1" to make it in man(7).  If I want a blank line in the source,
but not the output, I put a plain dot "." so roff ignores it.

Hyphens used for command-line options, like \-a, should be escaped by
a backslash.  I insert a few missing backslashes.

mandoc warns if the date in .TH doesn't look like a date.  Our manuals
had a missing date or the RCS keyword "$Revision$".  Git doesn't
expand RCS keywords.  I put in today's date, 2017-01-18.

Some manuals used tab characters in filled mode.  That doesn't work.
I use .nf to turn off filled mode, or I use .IP in man(7) to make the
indentation without a tab character.

ack(1) defined a macro .SB but never used it, so I delete the
definition.  I also remove a call to the missing macro .RF.

mandoc warns about empty paragraphs.  I deleted them.  mandoc also
warned about these macro pairs in anm(1):

    .SM
    .B text

The .SM did nothing because the .B text is on a different line.  I
changed each pair to .SB for small bold text.

I make a few other small changes.
2017-01-18 23:02:30 -05:00
David Given 612e14b4b4 Improve confusing error message when calling function procedures from a
top-level statement.

Fixes: #30
2017-01-08 11:25:57 +01:00
David Given ee5ef73dfb Run through clang-format. 2017-01-08 11:23:56 +01:00
David Given 893471a42e No longer truncate module names at 10 characters when constructing paths;
rename some library modules to their full names.
2017-01-07 23:00:52 +01:00
David Given d50a6f99de Run through clang-format. 2017-01-07 22:56:00 +01:00
David Given fd91851005 Add enough return types to the K&R C that the ACK builds (on Linux) using clang
now.
2016-11-10 22:04:18 +01:00
David Given f67c98e239 Distributions are a pain --- let's not bother any more. Instead, we just tag
the repository and download a complete snapshot, old and ancient stuff and all.
2016-09-02 23:00:38 +02:00
David Given 612e38f1c6 Remove the old make-based build system, plus some big chunks of horribly
obsolete protomake build system.
2016-09-02 22:17:51 +02:00
David Given 4d24666432 Move util/data into modules/src/em_data, for consistency with the other
modules.
2016-08-14 14:09:38 +02:00
David Given e770d09dc8 Pascal compiler builds. 2016-08-13 13:03:06 +02:00
David Given dbf8332bf0 Fixed a small bug where two line number directives next to each other wouldn't
be parsed properly (the second one would be treated as Modula-2 syntax).
2016-08-13 12:21:16 +02:00
David Given 8e869b56e7 The Modula-2 compiler now builds. 2016-08-13 00:02:21 +02:00
David Given 88bd7ce126 Remove defunct pmfiles.
--HG--
branch : default-branch
2016-06-03 13:56:50 +02:00
David Given 3d5e72e20b Newer versions of GNU Make have a new function which collides with a
variable we're using; change the name of the variable.
2015-03-22 12:09:46 +01:00
David Given 9a513e8ef3 Fix warning. 2013-05-17 00:04:54 +01:00
David Given 11377070fd Update distribution files.
--HG--
branch : dtrg-buildsystem
2013-05-15 23:46:15 +01:00
David Given f6c43b95ef Modula-2 now works.
--HG--
branch : dtrg-buildsystem
rename : lang/pc/build.mk => lang/m2/build.mk
rename : lang/pc/libpc/build.mk => lang/m2/comp/build.mk
rename : lang/pc/libpc/build.mk => lang/m2/libm2/build.mk
2013-05-14 22:24:38 +01:00
George Koehler 0131ca4d46 Delete 689 undead files.
These files "magically reappeared" after the conversion from CVS to
Mercurial.  The old CVS repository deleted these files but did not
record *when* it deleted these files.  The conversion resurrected these
files because they have no history of deletion.  These files were
probably deleted before year 1995.  The CVS repository begins to record
deletions around 1995.

These files may still appear in older revisions of this Mercurial
repository, when they should already be deleted.  There is no way to fix
this, because the CVS repository provides no dates of deletion.

See http://sourceforge.net/mailarchive/message.php?msg_id=29823032
2012-09-20 22:26:32 -04:00
dtrg b611731ec3 Updated .distr files for the new release. 2007-02-25 12:51:55 +00:00
dtrg dbe10d2c19 Updated to the version 0.1 of Prime Mover (which involves some syntax changes). 2006-10-15 00:28:12 +00:00
dtrg 45b4fef7d6 Rationalised use of #includes to be more standards-compliant. 2006-07-30 23:40:35 +00:00
dtrg d3b557e0db Adjusted to only check the module name against the leaf of the filename, to prevent unnecessary warnings if the source file isn't in the current directory. 2006-07-30 23:38:41 +00:00
dtrg c65c560acd Tweaked the CVS settings. 2006-07-26 18:19:15 +00:00
dtrg 2d2ee38770 Added support for the Modula-2 compiler. 2006-07-26 17:12:19 +00:00
dtrg 26b17074a1 Rationalised use of #includes to be more standards-compliant. 2006-07-26 17:10:30 +00:00
dtrg 8558656665 Now avoids piping shell scripts into a new instance of sh, instead
using a subshell.
2006-07-26 12:29:47 +00:00
dtrg 014be56fb0 Replaced calls to the custom strindex() and strrindex() functions with the
exactly equivalent and standard strchr() and strrchr() functions instead.
2006-07-23 20:01:02 +00:00
dtrg 454bdae81f Added the appropriate #! magic at the beginning of shell scripts. (Some modern shells don't like scripts to be without it.) 2006-07-18 16:45:57 +00:00
cvs2hg 5cb054f106 fixup commit for tag 'llgen-1-0' 2006-02-04 00:57:05 +00:00
ceriel 6db931eee6 Link em_data.a as well (needed when producing readable EM 1997-04-01 13:58:58 +00:00
ceriel 99ac23b4b4 Additions for non-correcting error recovery 1997-02-21 17:11:04 +00:00
ceriel 322c1c1b4c Some fixes 1996-11-19 09:12:36 +00:00