Commit Graph

33 Commits

Author SHA1 Message Date
Scott Olsen
8c5845ea65
docs: cleanup core IO docs (#1447) 2022-12-28 08:16:04 +01:00
Scott Olsen
9d9f982ce8
feat: add fputc wrapper to IO (#1417)
* feat: add fputc wrapper to IO

fputc is a low-level function that writes a single C character to a
file. We can use this as a basis for more elegant APIs.

The signature matches that of the C standard library function for
compatibility, which takes an Int instead of a char. However, the
documentation notes that the int argument is converted to an unsigned
char.

* doc: fix typos for fgetc and fputc docs
2022-04-19 16:29:26 +02:00
Scott Olsen
bf6df6405c
feat: add IO.fgetc (#1405)
* feat: add feof and ferror

These are C stdio functions that enable programmers to determine if a
file read resulted in an error or EOF encounter.

We can use these to power a definition of IO.fgetc, which is currently
not defined.

* feat: implement missing IO.fgetc

IO defined a function, fgetc (distinct from IO.Raw.fgetc) which actually
produced invalid code, since the name was not overridden and C does not
define IO_fgetc.

There was also a TODO to handle EOF conditions; so, I've implemented the
function, checking for EOF and error conditions using the Raw stdio
wrappers. IO.fgetc returns a Char in Success on success and an error
string on failure.

* refactor: distinguish EOF from errors in IO.fgetc

We now report whether or not the error encountered in fgetc was EOF.
Note that we don't yet report on the contents of other errors.
2022-03-28 10:16:51 +02:00
Veit Heller
5a449b0919
fix: use non-deprecated unlink function on windows (#1311) 2021-09-16 07:56:32 +02:00
Veit Heller
d3a6ca562f
docs: document core modules (#1271) 2021-07-05 14:48:35 +02:00
guberathome
0c038365d7
IO.Raw (#1243)
* feat!: move C library wrapper funtions to IO.Raw

* docs: fixed doc string for (String.allocated?)

* docs: removed superfluous parameter names for defns

* fix: replaces IO.exit by System.exit

* fix: ./test/regression.carp for (IO.read->EOF)

* fix: ./test/system.carp

* feat: implemented IO.fwrite!

* feat!: removed IO.exit

* feat!: raw character input now returns Int instead of Char

* fix: removed irritating space chars

* fix: repaired ./example/carp_demo.carp

* fix: reverted System.exit to return an Int for SDL examples

* fix: removed System.exit!

Co-authored-by: guberatsie <gunnar.bernhardt@siemens.com>
2021-06-17 17:33:10 +02:00
guberathome
6cd2a96486
clean up IO library (#1232) 2021-06-08 21:05:51 +02:00
Veit Heller
007d020e05
refactor: use assert-dynamic-equal in test (#1186) 2021-03-16 11:14:01 +01:00
Veit Heller
bdaf96550f
refactor: use quasiquoting in STDLIB and go through array in quasiquote (#1135) 2021-01-21 06:20:03 +01:00
Erik Svedäng
f78fd16a71
refactor: Move code out of Macros.carp into other files (#1014)
* refactor: Move code out of Macros.carp into other files

* fix: Move back some macros needed in --no-core mode

* refactor: Remove weird 'evaluate' macros

* fix: Put back more macros

* fix: Remove transitive loading of Macros.carp

* refactor: Remove ArrayMacros.carp and put 'for' at top of Array.carp instead

* refactor: More splitting up

* refactor: Move back save-docs

* fix: Moved back some stuff

Co-authored-by: Erik Svedang <erik@Eriks-iMac.local>
2020-11-28 12:53:18 +01:00
Jorge Acereda
9b08b6df3c Merge 2020-05-11 16:10:35 +02:00
hellerve
95739d0cea core: add IO.getenv 2020-01-25 14:23:14 +01:00
sdilts
5614103107 open-file: Return the value of errno instead of an error string 2019-11-01 17:28:52 -06:00
sdilts
0386971f00 Add open-file function
`fopen` returns a nullable pointer, which doesn't fit very well with
Carp's notions of saftey and error handling. Instead, return a
`Result` type that forces the user to check if the operation was
successful.
+ Can't call the function fopen because we can't overload a C
  function.
+ Leave `fopen` public in the IO module so extant code doesn't need to
  be changed.
2019-11-01 14:54:18 -06:00
hellerve
e33c5fd7b4 core: actually register error 2019-10-28 14:28:37 +01:00
Jorge Acereda
a5b527efbe Add stdin/stdout/stderr. 2019-07-29 21:50:08 +02:00
Jorge Acereda
c76177dfa7 Implement zero for Char. 2019-06-14 13:02:03 +02:00
hellerve
992b0c5fc5 core: fix IO.read->EOF 2019-05-10 11:21:46 +02:00
hellerve
6e33a8c2f9 core: add IO.errorln and IO.error 2018-10-22 17:47:40 -04:00
hellerve
3877f3988c core: add more file io functions 2018-10-18 17:22:35 +02:00
hellerve
3f4cad15ad core: add fread, fflush, and rewind to IO 2018-10-17 11:46:11 +02:00
hellerve
f3e559dc28 docs: more documentation work 2018-05-12 16:08:48 +02:00
andretshurotshka
6246ceb7b3 Replace with Carp version of function 2018-03-23 20:24:32 +05:00
andretshurotshka
a8481b2184 Add read-file-eof function for dynamic files 2018-03-23 17:28:04 +05:00
Erik Svedäng
9dae63491d fopen takes String& instead 2018-03-18 17:51:23 +01:00
Erik Svedäng
00105618a4 A few extra functions for handling files and char pointers. 2018-03-18 14:40:49 +01:00
Erik Svedäng
fcc01ff268 Some new functions and macros. 2018-03-11 14:53:50 +01:00
hellerve
b7ea8d1487 core: namespaced split-up carp headers 2018-02-27 15:08:39 +01:00
hellerve
f56b1ff93f core: split up core.h, installment 1 2018-02-27 15:08:36 +01:00
Erik Svedäng
6998bb04d7 File reading function. 2017-11-28 10:07:46 +01:00
hellerve
631e2ab95f testing: added Test module 2017-10-23 16:07:54 +02:00
Erik Svedäng
8cae7a7a3b A way to run all tests in one go. 2017-09-08 12:24:57 +02:00
Erik Svedäng
c80526cfaa REPLACE WITH HASKELL VERSION 2017-06-26 11:15:03 +02:00