Commit Graph

26 Commits

Author SHA1 Message Date
Kelvin Sherlock d600cd0b61 assert - use updated ph2/ph4 macros that support pei dp vs lda dp / pha.
also expand a couple tabs -> spaces.
2018-06-27 23:36:02 -04:00
Stephen Heumann a11660f597 Implement support for 'hh' length modifier in *scanf.
Also support '%ln', although the length that can be reported is still limited to 64k.
2018-03-22 22:10:56 -05:00
Stephen Heumann 5ee6e87f44 Implement support for 'hh' length modifier in *printf.
This corresponds to signed char or unsigned char (although arguments of those types will have been promoted to int).
2018-03-22 21:13:09 -05:00
Kelvin Sherlock 6a2e3c1abd fix typos and misleading commentary. 2018-03-21 23:05:46 -04:00
Stephen Heumann 6e97906678 Make strtol/strtoul return LONG_MIN/LONG_MAX/ULONG_MAX for out-of-range values.
This fixes #10.

There are still issues with the end pointer value generated in error cases.
2018-03-13 22:11:40 -05:00
Stephen Heumann 7abdfc9beb Make system(NULL) detect whether a command processor is available.
Previously, it just ran an Execute shell call with NULL as the command-line pointer.

The fix is to still call Execute, but with an empty string as the command line, and then check if the call gave an error. If running under plain GS/OS, this gives an error for an unknown system call, whereas both ORCA/APW and GNO shells will return with no error in this case. (Golden Gate doesn't implement the Execute shell call, so it also gives an error and will report no command processor available.)

This fixes issue #25.
2018-03-13 17:49:49 -05:00
Stephen Heumann 21d34a30ce mktime: tm_yday should be indexed from 0 for January 1st, not 1.
This fixes the libca07.c test case.
2018-03-09 17:38:55 -06:00
Stephen Heumann a77e44d7b5 Fix asctime() to properly print years 1000 through 9999.
Also, use a leading space rather than a leading 0 in days 1 through 9.

This fixes the libca11.c test case.
2018-03-09 13:10:53 -06:00
Stephen Heumann 73f04eaab4 Add snprintf() and vsnprintf() functions (C99). 2018-03-05 18:52:43 -06:00
Stephen Heumann 8562842f66 sprintf/vsprintf should write a terminating null character even if the string produced is empty.
They were just not writing anything in this case.
2018-03-05 18:02:36 -06:00
Kelvin Sherlock 6006cefc70 add the c99 isblank() function 2018-03-04 22:31:11 -05:00
Stephen Heumann 8533ea221c When argc==0, argv should be a valid pointer and argv[0] should be NULL.
This is normal for S16 programs or inits, and can happen with shell executables in certain cases like when being run from Prizm.
2018-02-28 00:17:35 -06:00
Stephen Heumann 33ab148cea Merge commit 'd95f9f29d27d02d8c57bd23620f41afbf7607ac5' 2018-02-27 23:01:51 -06:00
Stephen Heumann 62f6b712e7 Add support for 'F', 'a', and 'A' conversion specifiers for scanf (C99).
These all behave identically to 'f'. Note that none of these accept the hexadecimal floating-point representation as input, which they should under C99.
2018-02-27 21:39:49 -06:00
Stephen Heumann a6d7d91f37 Add initial support for 'F', 'a', and 'A' conversion specifiers for printf (C99).
'F' is currently treated identically to 'f'. This should be a correct implementation for 'F' under C99. (It's not quite correct for 'f', which should print "inf" or "nan" in lower case according to C99.)

'A' and 'a' are not correctly formatted (they are currently treated identically to 'E' and 'e', rather than using the hexadecimal floating-point representation specified by C99), but at least they print the number in some form and consume the correct number of bytes so that the stack isn't corrupted and subsequent conversion specifications print the right values.

The floating-point formats are also moved to the top of the list of conversion specifiers to check, which means they are checked last. This should marginally speed up the integer cases.
2018-02-27 21:29:22 -06:00
Stephen Heumann f58ef8aea3 Add support for 'z', 't', and 'j' length modifiers in printf and scanf (C99).
'z' corresponds to size_t, 't' to ptrdiff_t, and 'j' to intmax_t. In ORCA/C, these are all 32-bit types, so these size modifiers are equivalent to 'l'. (Note that C99/C11 require intmax_t to be at least 64-bit, but that is not currently the case in ORCA/C since there is no 64-bit integer type.)
2018-02-27 18:44:07 -06:00
Stephen Heumann e3c0c962d4 Revert various stdio changes to make it match the version in the ORCA/C 2.1.1 B3 ORCALib binary on Opus ][.
The reverted changes relate mainly to adding a second character position in the putback buffer, but the library with those changes crashes on basic stdio operations like printing a string.

For now, this patch reverts stdio to a working, tested version. If the reverted changes are valuable, they can be fixed and then reintroduced later.
2018-02-26 22:49:10 -06:00
Kelvin Sherlock d95f9f29d2 during initial count of arguments on the command-line, use the same logic as the second count when the argv vector is built. 2018-02-24 22:40:01 -05:00
Stephen Heumann 89acbf2ced
Merge pull request #2 from ksherlock/toupper
tolower/toupper should work with EOF/-1
2017-11-01 18:10:48 -05:00
Stephen Heumann 56b101a214 Change keep location for stdio to be in the obj directory. 2017-10-31 23:09:27 -05:00
Stephen Heumann 9d116eae35 Rename isctrl() function to correct standard name of iscntrl().
This doesn't affect the macro, which already had the correct name.

Fixes the bug in the libca15.c test case.
2017-10-31 22:52:12 -05:00
Stephen Heumann 649aef5b0f Change sys_nerr from 6 to 12, to reflect actual number of error messages.
Fixes the bug in the libca05.c test case.
2017-10-31 22:50:22 -05:00
Kelvin Sherlock 6ebb56af57 fix tolower/toupper to work with EOF/-1 2017-10-31 22:10:46 -04:00
Stephen Heumann e4a8afe476
Merge pull request #1 from ksherlock/crlf
Convert to LF for line endings.
2017-10-31 19:24:09 -05:00
Kelvin Sherlock 578bda8439 CR -> LF 2017-10-31 13:14:07 -04:00
mikew50 954c3a02b5 ORCA libraries, from the Opus ][ CD 2017-10-01 18:00:58 -06:00