Commit graph

497 commits

Author SHA1 Message Date
George Koehler 36f16b0cb8 Cut down some clang warnings
Edit C code to reduce warnings from clang.  Most warnings are for
implicit declarations of functions, but some warnings want me to add
parentheses or curly braces, or to cast arguments for printf().

Make a few other changes, like declaring float_cst() in h/con_float to
be static, and using C99 bool in ego/ra/makeitems.c and
ego/share/makecldef.c.  Such changes don't silence warnings; I make
such changes while I silence warnings in the same file.  In
float_cst(), rename parameter `str` to `float_str`, so it doesn't
share a name with the global variable `str`.

Remove `const` from `newmodule(const char *)` in mach/proto/as to
silence a warning.  I wrongly added the `const` in d347207.

For warnings about implicit declarations of functions, the fix is to
declare the function before calling it.  For example, my OpenBSD
system needs <sys/wait.h> to declare wait().

In util/int, add "whatever.h" to declare more functions.  Remove old
declarations from "mem.h", to prefer the newer declarations of the
same functions in "data.h" and "stack.h".
2019-10-30 18:36:38 -04:00
carl b1f6d5d827 ANSI C compilation fixes 2019-05-14 23:22:38 +08:00
carl ccfd8a3e18 rename rd_long/wr_long to rd_int4/wr_int4 for consistency. Align declaration and definition name of parameters and adapt man page accordingly. 2019-05-11 01:03:36 +08:00
carl bb6540c5f4 Adapt man page with correct prototype information. 2019-05-11 01:01:52 +08:00
carl 3466e84f46 ANSI C conversion of code, adapt man pages accordingly. Some autodocs added. 2019-05-11 01:01:21 +08:00
carl 8b290cf68a ANSI C conversion of code, rename some parameters to better names and adapt man page accordingly. 2019-05-11 00:57:58 +08:00
carl add131b6f9 ANSI C conversion of code, rename some parameters to better names and adapt man page accordingly. 2019-05-11 00:56:13 +08:00
carl dc269e57d8 ANSI C conversion of code and adapt man page accordingly. 2019-05-11 00:53:52 +08:00
carl 5bb20bdb9e Add init/free functions and rename parameters. 2019-05-11 00:52:40 +08:00
carl 7cb2b3de7f Fix syntax mistake in man page. 2019-05-11 00:51:42 +08:00
carl 7973e87b2f Additional check with NULL or empty string (now same behaviour as POSIX version) 2019-03-26 00:58:14 +08:00
carl 78899705d5 Bug of fseek and wrong setting of position. 2019-03-25 02:20:50 +08:00
carl 8457ec6791 Object module now uses ANSI C I/O 2019-03-25 00:07:12 +08:00
carl 56e64a1fd0 Merge remote-tracking branch 'upstream/default' into carl-ansi-part1
# Conflicts:
#	util/arch/archiver.c
#	util/led/finish.c
#	util/led/output.c
2019-03-24 21:42:56 +08:00
carl 75394c93e1 Better ANSI C portability. 2019-03-24 17:40:27 +08:00
George Koehler bec236c108 Include more headers to declare functions.
This causes clang to give fewer warnings of implicit declarations of
functions.

In mach/pdp/cv/cv.c, rename wr_int2() to cv_int2() because it
conflicts with wr_int2() in <object.h>.

In util/ack, rename F_OK to F_TRANSFORM because it conflicts with F_OK
for access() in <unistd.h>.
2019-03-22 15:59:35 -04:00
George Koehler cdbff0dd1c Include <fcntl.h> or <unistd.h>
This silences some clang warnings of implicit declarations of
functions.  The `register int` silences a warning of implicit int.
2019-03-22 14:19:02 -04:00
George Koehler f8cbe04447 Include <unistd.h> for lseek()
This unbreaks my build in OpenBSD.  The old `long lseek()` conflicts
with `off_t lseek()` in OpenBSD headers, because long and off_t are
different types.  Commit b4df26e caused "system.h" to include some
headers where OpenBSD declares lseek().

Manuals for lseek() say to #include <unistd.h>.  Do so to be portable
to systems where other headers don't declare lseek().
2019-03-22 13:18:07 -04:00
carl 6bfac1d24d + Add sys_tmpnam() and sys_basename() 2019-03-17 22:46:31 +08:00
carl da71e5a018 Addition of tmpnam system function. 2019-03-17 22:46:31 +08:00
carl 91adc2849b + Have the DEBUG version compile 2019-03-17 22:46:31 +08:00
carl 9e93eb642b Better type checking on function callback. 2019-03-17 22:46:31 +08:00
carl 4b5de6c203 Remove unused variable. 2019-02-21 00:43:49 +08:00
carl f7ba3eec50 Remove CMake changes and generic sed scripts so they are move to a separate branch. 2019-02-21 00:43:04 +08:00
carl a80248f204 * Was trying to use the new system API which is not ready causing stack issues. 2019-02-20 00:44:32 +08:00
carl b4df26e79d Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Initial support for CMake
+ Added support for sys_tmpdir for better portability.
2019-02-19 00:54:23 +08:00
carl 7317ae3291 * Initial support of CMake 2019-02-19 00:54:23 +08:00
carl 3214ddfa68 Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
2019-02-19 00:54:23 +08:00
carl 288e81355e * Add missing header file. 2019-02-19 00:54:23 +08:00
carl bd25701a3f * Initial support of CMake 2019-02-19 00:54:23 +08:00
carl 18730a361d * Adapt to new sys_filesize prototype. 2019-02-19 00:54:23 +08:00
carl 8c7de90005 * Initial support of CMake 2019-02-19 00:54:23 +08:00
carl 7c7379c46f Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Convert to sed scripts some shell scripts for better portability.
+ Reduce usage of em_path.h (TMPDIR is no longer hard coded)
2019-02-19 00:54:23 +08:00
carl a4650360a3 * Initial support of CMake
+ Generation of header files is now made through a C program to make it more portable.
2019-02-19 00:54:23 +08:00
carl 0ac16f6116 Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Convert to sed scripts some shell scripts for better portability.
+ Reduce usage of em_path.h
2019-02-19 00:54:23 +08:00
carl 90d4797ff7 * Initial support of CMake 2019-02-19 00:54:23 +08:00
carl 0f75cc09ad Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Convert to sed scripts some shell scripts for better portability.
+ Reduce usage of em_path.h
2019-02-19 00:54:23 +08:00
David Given 58698bed19 Removed a whole bunch of old strcpy() prototypes in favour of <string.h>. 2019-02-10 13:20:04 +01:00
David Given 9e2d45b301 Rename all files called 'aux.*' to something else; Windows can't handle them. 2019-02-09 00:02:41 +01:00
David Given fa1ba55ad2 Convert CRLF into LF on read; this should avoid problems with parsing CRLF files.
Fixes #117.
2018-09-02 11:30:20 +02:00
David Given 05ddefad65 Adopt a copy of Minix 2's ed; this allows the ACK's antiquated ed scripts to
run with a minimum of tweaking. Rewriting them for modern ed looks really hard.

Fixes: #84
2018-06-02 18:02:51 +02:00
George Koehler 860df1b067 Read from new, not old, buffer after realloc.
This got caught by MALLOC_OPTIONS=S in OpenBSD.  The B compiler filled
the buffer while compiling hilo.b.  Then realloc moved the buffer and
unmapped the old buffer.  The compiler tried to read the old buffer
and segfaulted.
2018-03-08 12:04:02 -05:00
George Koehler 0720671f7a Fix wr_ranlib() for big-endian machines.
With this change, I built and ran ack on a big-endian PowerPC Linux
machine.  I used gcc 4.9.4 to build ack, and I only built the linuxppc
back end.

Before this change, wr_ranlib() corrupted a value by changing it from
0x66 to 0x66000066.  This value was too big, so led made a fatal
error, "bad ranlib string offset".
2018-03-08 11:49:40 -05:00
George Koehler 88207db638 Use <stdarg.h> in util/misc/convert.c
I made a syntax error in some .e file, and em_encode dumped core
because a 64-bit pointer didn't fit in a 32-bit int.  Now use stdarg
to pass pointers to error() and fatal().

Stop using the number of errors as the exit status.  Many systems use
only the low 8 bits of the exit status, so 256 errors would become 0.

Also change modules/src/print to accept const char *buf
2017-12-06 17:09:12 -05:00
David Given 6d91bdbbbd
Merge pull request #69 from kernigh/kernigh-stdc
use libc assert, strcmp; declare more functions; fewer clang warnings
2017-11-19 12:00:40 +01:00
David Given fb90b7b8d8
Merge pull request #66 from davidgiven/dtrg-warnings
lang/basic/lib: fewer warnings
2017-11-19 11:39:45 +01:00
George Koehler 805c916ab0 Add more const in <object.h>. 2017-11-11 13:08:13 -05:00
George Koehler 3463f0c944 bts2str(), long2str() are in <ack_string.h> 2017-11-10 18:00:00 -05:00
George Koehler b5b1da6f1a Adjust dependencies in modules/src{print,string,system}
Drop dependency on <ansi.h> in modules+headers; assume that compiler
knows ANSI C89.

Add missing dependency from print to string; #include <ack_string.h>.

Because <print.h> had commented out the declarations of sys_lock() and
sys_unlock(), I now stop building lock.c and unlock.c.
2017-11-10 17:56:42 -05:00
George Koehler 6367467499 Remove functions that also exist in libc.
Some of these functions were slightly different from libc:

 - This strncpy() didn't pad the buffer with '\0' bytes beyond the end
   of the string; libc does the padding.  This string.3 manual said
   that this strncpy() does "null-padding", but it didn't.

 - This strcmp() and strncmp() compared using char (which might be
   signed); libc compares using unsigned char.
2017-11-09 23:35:54 -05:00