add `port-counts-lines?'

This commit is contained in:
Matthew Flatt 2013-02-14 15:04:08 -07:00
parent 99d5dc95bf
commit 421cb24138
7 changed files with 543 additions and 518 deletions

View File

@ -61,6 +61,12 @@ counting is automatically enabled for the port. Line counting cannot
be disabled for a port after it is enabled.}
@defproc[(port-counts-lines? [port port?]) boolean?]{
Returns @racket[#t] if line and column counting has been enabled for
@racket[port], @racket[#f] otherwise.}
@defproc[(port-next-location [port port?])
(values (or/c exact-positive-integer? #f)
(or/c exact-nonnegative-integer? #f)

View File

@ -512,7 +512,9 @@
(let ([mk
(lambda (adjust-locs)
(let ([p (open-input-string "Hello\n\n world")])
(test #f port-counts-lines? p)
(port-count-lines! p)
(test #t port-counts-lines? p)
(let ([p2 (make-input-port 'with-loc
(lambda (s) (read-bytes-avail! s p))
(lambda (s skip progress-evt)

View File

@ -1,3 +1,6 @@
Version 5.3.3.2
Added port-counts-lines?
Version 5.3.3.1
Change sync, wrap-evt, and handle-evt to support multiple
evt results

File diff suppressed because it is too large Load Diff

View File

@ -122,6 +122,7 @@ static Scheme_Object *port_print_handler(int, Scheme_Object **args);
static Scheme_Object *global_port_print_handler(int, Scheme_Object **args);
static Scheme_Object *global_port_count_lines(int, Scheme_Object **args);
static Scheme_Object *port_count_lines(int, Scheme_Object **args);
static Scheme_Object *port_counts_lines_p(int, Scheme_Object **args);
static Scheme_Object *port_next_location(int, Scheme_Object **args);
static Scheme_Object *set_port_next_location(int, Scheme_Object **args);
@ -322,6 +323,7 @@ scheme_init_port_fun(Scheme_Env *env)
GLOBAL_NONCM_PRIM("port-file-unlock", scheme_file_unlock, 1, 1, env);
GLOBAL_NONCM_PRIM("port-file-identity", scheme_file_identity, 1, 1, env);
GLOBAL_NONCM_PRIM("port-count-lines!", port_count_lines, 1, 1, env);
GLOBAL_NONCM_PRIM("port-counts-lines?", port_counts_lines_p, 1, 1, env);
p = scheme_make_folding_prim(eof_object_p, "eof-object?", 1, 1, 1);
SCHEME_PRIM_PROC_FLAGS(p) |= scheme_intern_prim_opt_flags(SCHEME_PRIM_IS_UNARY_INLINED
@ -4271,6 +4273,18 @@ static Scheme_Object *port_count_lines(int argc, Scheme_Object *argv[])
return scheme_void;
}
static Scheme_Object *port_counts_lines_p(int argc, Scheme_Object *argv[])
{
Scheme_Port *ip;
if (!SCHEME_INPUT_PORTP(argv[0]) && !SCHEME_OUTPUT_PORTP(argv[0]))
scheme_wrong_contract("port-counts-lines?", "port?", 0, argc, argv);
ip = scheme_port_record(argv[0]);
return (ip->count_lines ? scheme_true : scheme_false);
}
static Scheme_Object *global_port_count_lines(int argc, Scheme_Object **argv)
{
return scheme_param_config("port-count-lines-enabled",

View File

@ -14,7 +14,7 @@
#define USE_COMPILED_STARTUP 1
#define EXPECTED_PRIM_COUNT 1085
#define EXPECTED_PRIM_COUNT 1086
#define EXPECTED_UNSAFE_COUNT 98
#define EXPECTED_FLFXNUM_COUNT 69
#define EXPECTED_EXTFL_COUNT 45

View File

@ -13,12 +13,12 @@
consistently.)
*/
#define MZSCHEME_VERSION "5.3.3.1"
#define MZSCHEME_VERSION "5.3.3.2"
#define MZSCHEME_VERSION_X 5
#define MZSCHEME_VERSION_Y 3
#define MZSCHEME_VERSION_Z 3
#define MZSCHEME_VERSION_W 1
#define MZSCHEME_VERSION_W 2
#define MZSCHEME_VERSION_MAJOR ((MZSCHEME_VERSION_X * 100) + MZSCHEME_VERSION_Y)
#define MZSCHEME_VERSION_MINOR ((MZSCHEME_VERSION_Z * 1000) + MZSCHEME_VERSION_W)