%
% the newline module catering different 'nl' requirement
% in different Prolog platform
%

:- module(newline,[	newline/0,
			newline/1
		]).

:- [prolog_detect].
:- prolog_detect:prolog(Prolog),
	(	(Prolog=sicstus,
		prolog_flag(character_escapes,_,on)
		);
		(Prolog=pfdm,
		prolog_flag(character_escapes,_,on)
		);
		true			%both SWI & ECLiPSe
	).

newline :-
	prolog_detect:prolog(Prolog),
	newline_with_prolog(Prolog).

newline(Stream) :-
	prolog_detect:prolog(Prolog),
	newline_with_prolog(Prolog,Stream).

%
% output a newline according to different Prolog platforms
%
newline_with_prolog(sicstus) :-
	write('\n').

newline_with_prolog(pfdm) :-
	write('\n').

newline_with_prolog(quintus) :-
	write('\n').

newline_with_prolog(swi) :-
	write('\n').

newline_with_prolog(eclipse) :-
	nl.


newline_with_prolog(sicstus,Stream) :-
	write(Stream,'\n').

newline_with_prolog(pfdm,Stream) :-
	write(Stream,'\n').

newline_with_prolog(quintus,Stream) :-
	write(Stream,'\n').

newline_with_prolog(swi,Stream) :-
	write(Stream,'\n').

newline_with_prolog(eclipse,Stream) :-
	nl(Stream).

