From 1eb5c9800789e0f6b14c84656b12418bd86e0786 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 25 Feb 2012 04:27:49 -0800 Subject: * parser.l (source_loc_str): Missing function re-written. (Accidentally originally written in lex.yy.c file!) (parse_reset): If file can't be opened, try adding .txr suffix to it. * txr.1: Suffix-handling behavior documented. --- parser.l | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'parser.l') diff --git a/parser.l b/parser.l index 6ad32847..3c09aabc 100644 --- a/parser.l +++ b/parser.l @@ -687,6 +687,14 @@ val source_loc(val form) return gethash(form_to_ln_hash, form); } +val source_loc_str(val form) +{ + cons_bind (line, file, gethash(form_to_ln_hash, form)); + return if3(line, + format(nil, lit("~a:~a"), file, line, nao), + lit("source location n/a")); +} + void parse_init(void) { protect(&yyin_stream, &prepared_error_message, @@ -702,8 +710,12 @@ void parse_reset(val spec_file) spec_file_str = spec_file; { FILE *in = w_fopen(c_str(spec_file_str), L"r"); - if (in == 0) - uw_throwf(file_error_s, lit("unable to open ~a"), spec_file_str, nao); + if (in == 0) { + spec_file_str = cat_str(list(spec_file_str, lit("txr"), nao), lit(".")); + in = w_fopen(c_str(spec_file_str), L"r"); + if (in == 0) + uw_throwf(file_error_s, lit("unable to open ~a"), spec_file, nao); + } yyin_stream = make_stdio_stream(in, spec_file_str, t, nil); } } -- cgit v1.2.3