fixes to message handling
This commit is contained in:
parent
26c80b0624
commit
bcc1757989
@ -2852,7 +2852,7 @@ YAP_Read(IOSTREAM *inp)
|
|||||||
BACKUP_MACHINE_REGS();
|
BACKUP_MACHINE_REGS();
|
||||||
|
|
||||||
|
|
||||||
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(inp, FALSE, &tpos);
|
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(inp, FALSE, &tpos, &rd);
|
||||||
if (LOCAL_ErrorMessage)
|
if (LOCAL_ErrorMessage)
|
||||||
{
|
{
|
||||||
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
|
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
|
||||||
|
@ -504,7 +504,7 @@ Yap_read_term(term_t t0, IOSTREAM *inp_stream, struct read_data_t *rd)
|
|||||||
old_H = H;
|
old_H = H;
|
||||||
LOCAL_Comments = TermNil;
|
LOCAL_Comments = TermNil;
|
||||||
LOCAL_CommentsNextChar = LOCAL_CommentsTail = NULL;
|
LOCAL_CommentsNextChar = LOCAL_CommentsTail = NULL;
|
||||||
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(inp_stream, store_comments, &tpos);
|
tokstart = LOCAL_tokptr = LOCAL_toktide = Yap_tokenizer(inp_stream, store_comments, &tpos, rd);
|
||||||
if (LOCAL_Error_TYPE != YAP_NO_ERROR && seekable) {
|
if (LOCAL_Error_TYPE != YAP_NO_ERROR && seekable) {
|
||||||
H = old_H;
|
H = old_H;
|
||||||
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
|
Yap_clean_tokenizer(tokstart, LOCAL_VarTable, LOCAL_AnonVarTable, LOCAL_Comments);
|
||||||
|
@ -820,7 +820,7 @@ ch_to_wide(char *base, char *charp)
|
|||||||
{ charp = _PL__utf8_put_char(charp, ch); } }
|
{ charp = _PL__utf8_put_char(charp, ch); } }
|
||||||
|
|
||||||
TokEntry *
|
TokEntry *
|
||||||
Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp)
|
Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp, void *rd0)
|
||||||
{
|
{
|
||||||
GET_LD
|
GET_LD
|
||||||
TokEntry *t, *l, *p;
|
TokEntry *t, *l, *p;
|
||||||
@ -829,6 +829,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp)
|
|||||||
int ch;
|
int ch;
|
||||||
wchar_t *wcharp;
|
wchar_t *wcharp;
|
||||||
struct qq_struct_t *cur_qq = NULL;
|
struct qq_struct_t *cur_qq = NULL;
|
||||||
|
struct read_data_t *rd = rd0;
|
||||||
|
|
||||||
LOCAL_ErrorMessage = NULL;
|
LOCAL_ErrorMessage = NULL;
|
||||||
LOCAL_Error_Size = 0;
|
LOCAL_Error_Size = 0;
|
||||||
@ -843,7 +844,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp)
|
|||||||
ch = getchr(inp_stream);
|
ch = getchr(inp_stream);
|
||||||
}
|
}
|
||||||
*tposp = Yap_StreamPosition(inp_stream);
|
*tposp = Yap_StreamPosition(inp_stream);
|
||||||
Yap_setCurrentSourceLocation(&inp_stream);
|
Yap_setCurrentSourceLocation( rd );
|
||||||
LOCAL_StartLine = inp_stream->posbuf.lineno;
|
LOCAL_StartLine = inp_stream->posbuf.lineno;
|
||||||
do {
|
do {
|
||||||
wchar_t och;
|
wchar_t och;
|
||||||
@ -907,7 +908,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp)
|
|||||||
}
|
}
|
||||||
CHECK_SPACE();
|
CHECK_SPACE();
|
||||||
*tposp = Yap_StreamPosition(inp_stream);
|
*tposp = Yap_StreamPosition(inp_stream);
|
||||||
Yap_setCurrentSourceLocation(&inp_stream);
|
Yap_setCurrentSourceLocation( rd );
|
||||||
}
|
}
|
||||||
goto restart;
|
goto restart;
|
||||||
} else {
|
} else {
|
||||||
@ -1230,7 +1231,7 @@ Yap_tokenizer(IOSTREAM *inp_stream, int store_comments, Term *tposp)
|
|||||||
}
|
}
|
||||||
CHECK_SPACE();
|
CHECK_SPACE();
|
||||||
*tposp = Yap_StreamPosition(inp_stream);
|
*tposp = Yap_StreamPosition(inp_stream);
|
||||||
Yap_setCurrentSourceLocation(&inp_stream);
|
Yap_setCurrentSourceLocation( rd );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto restart;
|
goto restart;
|
||||||
|
@ -264,7 +264,7 @@ getUnknownModule(module_t m);
|
|||||||
|
|
||||||
COMMON(int) debugmode(debug_type new, debug_type *old);
|
COMMON(int) debugmode(debug_type new, debug_type *old);
|
||||||
COMMON(int) tracemode(debug_type new, debug_type *old);
|
COMMON(int) tracemode(debug_type new, debug_type *old);
|
||||||
COMMON(void) Yap_setCurrentSourceLocation(IOSTREAM **s);
|
COMMON(void) Yap_setCurrentSourceLocation( void *rd );
|
||||||
|
|
||||||
extern int raiseSignal(PL_local_data_t *ld, int sig);
|
extern int raiseSignal(PL_local_data_t *ld, int sig);
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ extern Int Yap_GetCurrentPredArity(void);
|
|||||||
extern term_t Yap_fetch_module_for_format(term_t args, Term *modp);
|
extern term_t Yap_fetch_module_for_format(term_t args, Term *modp);
|
||||||
extern IOENC Yap_DefaultEncoding(void);
|
extern IOENC Yap_DefaultEncoding(void);
|
||||||
extern void Yap_SetDefaultEncoding(IOENC);
|
extern void Yap_SetDefaultEncoding(IOENC);
|
||||||
extern void Yap_setCurrentSourceLocation(IOSTREAM **s);
|
extern void Yap_setCurrentSourceLocation( void *rd );
|
||||||
extern void *Yap_GetStreamHandle(Atom at);
|
extern void *Yap_GetStreamHandle(Atom at);
|
||||||
|
|
||||||
extern atom_t codeToAtom(int chrcode);
|
extern atom_t codeToAtom(int chrcode);
|
||||||
|
@ -240,7 +240,7 @@ Term Yap_Variables(VarEntry *,Term);
|
|||||||
Term Yap_Singletons(VarEntry *,Term);
|
Term Yap_Singletons(VarEntry *,Term);
|
||||||
|
|
||||||
/* routines in scanner.c */
|
/* routines in scanner.c */
|
||||||
TokEntry *Yap_tokenizer(struct io_stream *, int, Term *);
|
TokEntry *Yap_tokenizer(struct io_stream *, int, Term *, void *rd);
|
||||||
void Yap_clean_tokenizer(TokEntry *, VarEntry *, VarEntry *,Term);
|
void Yap_clean_tokenizer(TokEntry *, VarEntry *, VarEntry *,Term);
|
||||||
Term Yap_scan_num(struct io_stream *);
|
Term Yap_scan_num(struct io_stream *);
|
||||||
char *Yap_AllocScannerMemory(unsigned int);
|
char *Yap_AllocScannerMemory(unsigned int);
|
||||||
|
10
os/pl-read.c
10
os/pl-read.c
@ -20,7 +20,7 @@ void
|
|||||||
init_read_data(ReadData _PL_rd, IOSTREAM *in ARG_LD)
|
init_read_data(ReadData _PL_rd, IOSTREAM *in ARG_LD)
|
||||||
{ CACHE_REGS
|
{ CACHE_REGS
|
||||||
memset(_PL_rd, 0, sizeof(*_PL_rd)); /* optimise! */
|
memset(_PL_rd, 0, sizeof(*_PL_rd)); /* optimise! */
|
||||||
|
|
||||||
_PL_rd->magic = RD_MAGIC;
|
_PL_rd->magic = RD_MAGIC;
|
||||||
_PL_rd->varnames = 0;
|
_PL_rd->varnames = 0;
|
||||||
_PL_rd->module = Yap_GetModuleEntry(CurrentModule);
|
_PL_rd->module = Yap_GetModuleEntry(CurrentModule);
|
||||||
@ -356,14 +356,10 @@ addToBuffer(int c, ReadData _PL_rd)
|
|||||||
|
|
||||||
#if __YAP_PROLOG__
|
#if __YAP_PROLOG__
|
||||||
void
|
void
|
||||||
Yap_setCurrentSourceLocation(IOSTREAM ** rd)
|
Yap_setCurrentSourceLocation( void *rd )
|
||||||
{
|
{
|
||||||
GET_LD
|
GET_LD
|
||||||
if (*rd) {
|
setCurrentSourceLocation(rd PASS_LD);
|
||||||
read_data rdt;
|
|
||||||
rdt._rb.stream = *rd;
|
|
||||||
setCurrentSourceLocation(&rdt PASS_LD);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ no_style_check([H|T]) :- no_style_check(H), no_style_check(T).
|
|||||||
'$pred_arity'((H:-_),Name,Arity) :- !,
|
'$pred_arity'((H:-_),Name,Arity) :- !,
|
||||||
functor(H,Name,Arity).
|
functor(H,Name,Arity).
|
||||||
'$pred_arity'((H-->_),Name,Arity) :- !,
|
'$pred_arity'((H-->_),Name,Arity) :- !,
|
||||||
functor(HL,Name,1).
|
functor(HL,Name,1),
|
||||||
Arity is A1+2.
|
Arity is A1+2.
|
||||||
'$pred_arity'(H,Name,Arity) :-
|
'$pred_arity'(H,Name,Arity) :-
|
||||||
functor(H,Name,Arity).
|
functor(H,Name,Arity).
|
||||||
|
@ -275,15 +275,16 @@ print_message(_, Term) :-
|
|||||||
'$print_system_message'(_, banner, _) :-
|
'$print_system_message'(_, banner, _) :-
|
||||||
current_prolog_flag(verbose, silent), !.
|
current_prolog_flag(verbose, silent), !.
|
||||||
'$print_system_message'(Term, Level, Lines) :-
|
'$print_system_message'(Term, Level, Lines) :-
|
||||||
'$messages':prefix(Level, LinePrefix, Stream, Prefix),
|
( Level == error -> Term \= error(syntax_error(_), _) ; Level == warning ),
|
||||||
'$messages':file_location(Prefix, LinesF, Lines), !,
|
'$messages':prefix(Level, LinePrefix, Stream, LinesF, Lines2),
|
||||||
|
'$messages':file_location(Lines2, Lines), !,
|
||||||
flush_output(user_output),
|
flush_output(user_output),
|
||||||
flush_output(user_error),
|
flush_output(user_error),
|
||||||
print_message_lines(Stream, LinePrefix, LinesF).
|
print_message_lines(Stream, LinePrefix, [nl|LinesF]).
|
||||||
'$print_system_message'(Error, Level, Lines) :-
|
'$print_system_message'(Error, Level, Lines) :-
|
||||||
flush_output(user_output),
|
flush_output(user_output),
|
||||||
flush_output(user_error),
|
flush_output(user_error),
|
||||||
'$messages':prefix(Level, LinePrefix, Stream, LinesF, Lines), !,
|
'$messages':prefix(Level, LinePrefix, Stream, LinesF, Lines), !,
|
||||||
print_message_lines(Stream, LinePrefix, LinesF).
|
print_message_lines(Stream, LinePrefix, LinesF).
|
||||||
|
s
|
||||||
|
|
||||||
|
@ -234,10 +234,6 @@ user:prolog_file_type(A, executable) :-
|
|||||||
|
|
||||||
:- dynamic file_search_path/2.
|
:- dynamic file_search_path/2.
|
||||||
|
|
||||||
:- multifile generate_message_hook/3.
|
|
||||||
|
|
||||||
:- dynamic generate_message_hook/3.
|
|
||||||
|
|
||||||
:- multifile swi:swi_predicate_table/4.
|
:- multifile swi:swi_predicate_table/4.
|
||||||
|
|
||||||
:- multifile user:message_hook/3.
|
:- multifile user:message_hook/3.
|
||||||
|
@ -24,18 +24,17 @@
|
|||||||
|
|
||||||
:- multifile prolog:message/3.
|
:- multifile prolog:message/3.
|
||||||
|
|
||||||
file_location(Prefix) -->
|
:- multifile user:generate_message_hook/3.
|
||||||
{
|
|
||||||
prolog_load_context(file, FileName)
|
file_location -->
|
||||||
},
|
{ source_location(FileName, LN) },
|
||||||
{ '$start_line'(LN) },
|
file_position(FileName,LN),
|
||||||
file_position(FileName,LN,Prefix),
|
|
||||||
[ nl ].
|
[ nl ].
|
||||||
|
|
||||||
file_position(user_input,LN,MsgCodes) -->
|
file_position(user_input,LN) -->
|
||||||
[ '~a (user_input:~d).' - [MsgCodes,LN] ].
|
[ 'at line ~d in user_input,' - [LN] ].
|
||||||
file_position(FileName,LN,MsgCodes) -->
|
file_position(FileName,LN) -->
|
||||||
[ '~a (~a:~d).' - [MsgCodes,FileName,LN] ].
|
[ 'at line ~d in ~a,' - [LN,FileName] ].
|
||||||
|
|
||||||
|
|
||||||
translate_message(Term) -->
|
translate_message(Term) -->
|
||||||
@ -499,7 +498,7 @@ syntax_error_token(A) --> !,
|
|||||||
% Quintus/SICStus/SWI compatibility predicate to print message lines
|
% Quintus/SICStus/SWI compatibility predicate to print message lines
|
||||||
% using a prefix.
|
% using a prefix.
|
||||||
|
|
||||||
prolog:print_message_lines(_, _, []) :- !.
|
prolog:print_message_lines(S, _, []) :- !.
|
||||||
prolog:print_message_lines(S, P, [at_same_line|Lines]) :- !,
|
prolog:print_message_lines(S, P, [at_same_line|Lines]) :- !,
|
||||||
print_message_line(S, Lines, Rest),
|
print_message_line(S, Lines, Rest),
|
||||||
prolog:print_message_lines(S, P, Rest).
|
prolog:print_message_lines(S, P, Rest).
|
||||||
@ -517,7 +516,7 @@ prolog:print_message_lines(S, P-Opts, Lines) :- !,
|
|||||||
atom_concat('~N', P, Prefix),
|
atom_concat('~N', P, Prefix),
|
||||||
format(S, Prefix, Opts),
|
format(S, Prefix, Opts),
|
||||||
print_message_line(S, Lines, Rest),
|
print_message_line(S, Lines, Rest),
|
||||||
prolog:print_message_lines(S, P-Opts, Rest).
|
prolog:print_message_lines(S, P-Opts, Rest)x.
|
||||||
prolog:print_message_lines(S, P, Lines) :-
|
prolog:print_message_lines(S, P, Lines) :-
|
||||||
atom(P), !,
|
atom(P), !,
|
||||||
atom_concat('~N', P, Prefix),
|
atom_concat('~N', P, Prefix),
|
||||||
|
Reference in New Issue
Block a user