Commit Graph

6 Commits

Author SHA1 Message Date
Julien Fischer
ee9aaa8c1b Always use 64-bit offsets with fseek() and ftell().
Most sane systems use 64-bit offsets with those functions; Windows does not.

runtime/mercury_file.h:
   Define macros MR_fseek and MR_ftell that expand to the name of the
   fseek or ftell function that uses 64-bit offsets.

runtime/mercury_deep_profiling.c:
library/io.m:
    Use the new macros and always use 64-bit offsets.
2019-10-08 21:36:11 +11:00
Mark Brown
d465fa53cb Update the COPYING.LIB file and references to it.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.

COPYING.LIB:
    Add a special linking exception to the LGPL.

*:
    Update references to COPYING.LIB.

    Clean up some minor errors that have accumulated in copyright
    messages.
2018-06-09 17:43:12 +10:00
Paul Bone
cffad33fd8 Fix a bug with I/O errors while reading files
Mercury did not properly test for I/O errors for file reading.  If an I/O
error occurred it would be reported as EOF.  If this happened at just the
right spot it could be silently ignored.  I found the mistake when trying to
open a directory as a file.  Opening the file succeeded but reading from it
incorrectly gave an EOF.

library/io.m:
    read_char_code has always been documented as returning -1 for EOF
    and -2 for an error.  But the C code did not correctly implement
    this.  fgetc will return EOF in either case and the caller must use
    ferror or feof to determine what has happened.

    Make it clearer that valid characters and bytes from read_char_code
    must be >= 0.

    Conform to changes in the runtime regarding supporting ferror

runtime/mercury_library_types.h:
    Add MR_FERROR macro

    Add ferror field to the MercuryFile struct.

runtime/mercury_file.[ch]:
    Add ferror field to the MercuryFile struct.

tests/general/Mmakefile:
tests/general/read_dir_regression.exp:
tests/general/read_dir_regression.exp2:
tests/general/read_dir_regression.exp3:
tests/general/read_dir_regression.exp4:
tests/general/read_dir_regression.m:
    Add regression test.

tests/.gitignore
    Add *.java_date to .gitignore.
2016-08-31 14:58:43 +10:00
Zoltan Somogyi
53b573692a Convert C code to use // style comments.
runtime/*.[ch]:
trace/*.[chyl]:
    As above. In some places, improve comments, e.g. by expanding contractions
    such as "we've". Add #ifndef guards against double inclusion around
    the trace/*.h files that did not already have them.

tools/*:
    Make the corresponding changes in shell scripts that generate .[ch] files
    in the runtime.

tests/*:
    Conform to a slight change in the text of a message.
2016-07-14 13:57:35 +02:00
Zoltan Somogyi
67326f16e4 Fix style issues in the runtime.
Move all .h and .c files to four-space indentation without tabs,
if they weren't there already.

Use the same vim line for all .h and .c files.

Align all backslashes at the ends of lines in macro definitions.
Align close comment signs.

In some places, fix inconsistent indentation.

Fix a bunch of comments. Add XXXs to a few of them.
2016-07-09 12:14:00 +02:00
Peter Ross
ae43e3ec1d Change the MercuryFile structure so that it now contains pointers to
Estimated hours taken: 20

Change the MercuryFile structure so that it now contains pointers to
functions which operate on the MercuryFile.  This allows us, for
example, to create a MercuryFile structure which operates on sockets and
use the predicates in io.m to operate on the socket stream.


runtime/mercury_library_types.h:
    Define the new implementation of MercuryFile structure.
    The MercuryFile structure now contains pointers to functions to do
    all the basic I/O operations.
    Define macros to access all the different parts of the MercuryFile
    structure.

runtime/mercury_file.h:
runtime/mercury_file.c:
    Implement a MercuryFile structure which operates on C FILE *'s.

library/io.m:
    Call the basic I/O operations from the MercuryFile structure.
    Explicitly check that we are using a file stream when required.
    As we cannot supply a variable number of arguments to a macro,
    define a new function ML_fprintf() to provide fprintf functionality.
    Hide all direct access to the MercuryFile data structure behind
    macros.

browser/util.m:
trace/mercury_trace_browse.c:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
    Hide all direct access to the MercuryFile data structure behind
    macros.

extras/logged_output/Mmakefile:
extras/logged_output/README:
extras/logged_output/logged_output.m:
extras/logged_output/main.m:
    Add an example of defining a new MercuryFile structure.  This new
    structure defines an output stream which writes to stdout and logs
    to a file at the same time.

runtime/Mmakefile:
    Add the new files mercury_file.{c,h}.

runtime/mercury_imp.h:
    Include `mercury_file.h'.
2000-08-11 16:50:24 +00:00