Update programming style.

This commit is contained in:
Zoltan Somogyi
2021-01-26 14:33:09 +11:00
parent c00b42ec3c
commit 4910a8564d
6 changed files with 168 additions and 174 deletions

View File

@@ -1,10 +1,9 @@
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et tw=0 wm=0 ff=unix
% bitbuf2.m
% Ralph Becket <rbeck@microsoft.com>
% Fri Nov 10 18:03:25 GMT 2000
%
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- module bitbuf2.
:- interface.
@@ -14,7 +13,7 @@
:- import_module io.
:- import_module store.
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- type bitbuf(S).
@@ -35,15 +34,15 @@
:- pred flush_buffer(bitbuf(S)::in, S::di, S::uo, io::di, io::uo)
is det <= store(S).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- implementation.
:- import_module bmio.
:- import_module util.
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- type bitbuf(S)
---> bitbuf(
@@ -54,7 +53,7 @@
size :: generic_mutvar(int, S) % Number of bits in buffer.
).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
new_bitbuf(bitbuf(A,B,C,D,E), !:S) :-
store.init(!:S),
@@ -64,14 +63,14 @@ new_bitbuf(bitbuf(A,B,C,D,E), !:S) :-
store.new_mutvar(0, D, !S),
store.new_mutvar(0, E, !S).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
read_byte(Result, Buf, !S, !IO) :-
store.get_mutvar(Buf ^ bits_in, BitsIn, !S),
bmio.read_byte(Result, !IO),
store.set_mutvar(Buf ^ bits_in, BitsIn + 8, !S).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
write_code(C, BPC, Buf, !S, !IO) :-
store.get_mutvar(Buf ^ bits_in, BitsIn, !S),
@@ -87,7 +86,7 @@ write_code(C, BPC, Buf, !S, !IO) :-
store.set_mutvar(Buf ^ data, Data, !S),
store.set_mutvar(Buf ^ size, Size, !S).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- pred write_full_bytes(int::in, int::out, int::in, int::out,
io::di, io::uo) is det.
@@ -100,7 +99,7 @@ write_full_bytes(!Data, !Size, !IO) :-
true
).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
compression_ratio_fallen(Buf, Result, !S) :-
store.get_mutvar(Buf ^ bits_in, BitsIn, !S),
@@ -108,19 +107,19 @@ compression_ratio_fallen(Buf, Result, !S) :-
store.get_mutvar(Buf ^ ratio, Ratio, !S),
Result = ( if ratio(BitsIn, BitsOut) < Ratio then yes else no ).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
reset_compression_ratio(Buf, !S) :-
store.set_mutvar(Buf ^ bits_in, 0, !S),
store.set_mutvar(Buf ^ bits_out, 0, !S),
store.set_mutvar(Buf ^ ratio, 0, !S).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
flush_buffer(Buf, !S, !IO) :-
store.get_mutvar(Buf ^ data, Data, !S),
bmio.write_byte(Data, !IO).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- end_module bitbuf2.
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%

View File

@@ -1,10 +1,11 @@
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
% vim: ft=mercury ts=4 sw=4 et
%---------------------------------------------------------------------------%
%
% bmio.m
% Simple test harness for 129.compress benchmark. Uses C because it's easier...
%
% Simple test harness for 129.compress benchmark. Uses C because it's
% easier...
%
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
:- module bmio.
@@ -12,38 +13,30 @@
:- import_module io.
:- type bmio.state == io.state.
:- type state == io.state.
:- pred bmio.init(string, int, bmio.state, bmio.state).
:- mode bmio.init(in, in, di, uo) is det.
:- pred init(string::in, int::in, bmio.state::di, bmio.state::uo) is det.
:- pred bmio.use_compression_io(bmio.state, bmio.state).
:- mode bmio.use_compression_io(di, uo) is det.
:- pred use_compression_io(bmio.state::di, bmio.state::uo) is det.
:- pred bmio.use_decompression_io(bmio.state, bmio.state).
:- mode bmio.use_decompression_io(di, uo) is det.
:- pred use_decompression_io(bmio.state::di, bmio.state::uo) is det.
:- pred bmio.read_byte(io.result(int), bmio.state, bmio.state).
:- mode bmio.read_byte(out, di, uo) is det.
:- pred read_byte(io.result(int)::out, bmio.state::di, bmio.state::uo) is det.
:- pred bmio.write_byte(int, bmio.state, bmio.state).
:- mode bmio.write_byte(in, di, uo) is det.
:- pred write_byte(int::in, bmio.state::di, bmio.state::uo) is det.
:- pred bmio.mark_decompression_eof(bmio.state, bmio.state).
:- mode bmio.mark_decompression_eof(di, uo) is det.
:- pred write_byte_checked(int::in, bmio.state::di, bmio.state::uo) is det.
:- pred bmio.write_byte_checked(int, bmio.state, bmio.state).
:- mode bmio.write_byte_checked(in, di, uo) is det.
:- pred mark_decompression_eof(bmio.state::di, bmio.state::uo) is det.
:- pred bmio.report_stats(bmio.state, bmio.state).
:- mode bmio.report_stats(di, uo) is det.
:- pred report_stats(bmio.state::di, bmio.state::uo) is det.
:- implementation.
:- import_module list, string.
:- pragma foreign_decl("C", "
:- pragma foreign_decl("C",
"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@@ -59,51 +52,42 @@ unsigned char *bmio__rd_eof;
unsigned char *bmio__wr_buf;
unsigned char *bmio__wr_ptr;
unsigned char *bmio__wr_eof;
FILE *bmio__fp;
FILE *bmio__fp;
").
% :- pragma no_inline(bmio.init/4).
:- pragma foreign_proc("C",
bmio.init(FileName::in, NumBytes::in, _IO0::di, _IO::uo),
init(FileName::in, NumBytes::in, _IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury],
"
/* printf(""starting bmio__init\n""); */
/* printf(""starting bmio__init\n""); */
assert(NumBytes > 0);
bmio__buf_size = NumBytes;
assert((
bmio__plain_buf = malloc(NumBytes * sizeof(char))
) != NULL);
bmio__plain_buf_eof = bmio__plain_buf + NumBytes;
assert((bmio__plain_buf = malloc(NumBytes * sizeof(char))) != NULL);
bmio__plain_buf_eof = bmio__plain_buf + NumBytes;
assert((
bmio__fp = fopen(FileName, ""rb"")
) != NULL);
assert((
fread(bmio__plain_buf, sizeof(char), NumBytes, bmio__fp)
) == NumBytes);
assert((bmio__fp = fopen(FileName, ""rb"")) != NULL);
assert((fread(bmio__plain_buf, sizeof(char), NumBytes, bmio__fp))
== NumBytes);
fclose(bmio__fp);
assert((
bmio__zipped_buf = malloc(NumBytes * sizeof(char))
) != NULL);
assert((bmio__zipped_buf = malloc(NumBytes * sizeof(char))) != NULL);
bmio__zipped_buf_eof = bmio__zipped_buf + NumBytes;
/* printf(""finished bmio__init\n""); */
/* printf(""finished bmio__init\n""); */
").
% :- pragma no_inline(bmio.use_compression_io/2).
:- pragma foreign_proc("C",
bmio.use_compression_io(_IO0::di, _IO::uo),
use_compression_io(_IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury],
"
bmio__rd_buf = bmio__plain_buf;
bmio__rd_ptr = bmio__plain_buf;
bmio__rd_eof = bmio__plain_buf_eof;
@@ -116,7 +100,7 @@ FILE *bmio__fp;
% :- pragma no_inline(bmio.use_decompression_io/2).
:- pragma foreign_proc("C",
bmio.use_decompression_io(_IO0::di, _IO::uo),
use_decompression_io(_IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury],
"
bmio__rd_buf = bmio__zipped_buf;
@@ -130,24 +114,19 @@ FILE *bmio__fp;
:- pragma inline(bmio.read_byte/3).
bmio.read_byte(Result) -->
rd(Byte),
{ if Byte = -1 then Result = eof else Result = ok(Byte) }.
read_byte(Result, !IO) :-
rd(Byte, !IO),
( if Byte = -1 then
Result = eof
else
Result = ok(Byte)
).
bmio.write_byte(Byte) -->
wr(Byte).
write_byte(Byte, !IO) :-
wr(Byte, !IO).
% :- pragma no_inline(bmio.mark_decompression_eof/2).
:- pragma foreign_proc("C",
bmio.mark_decompression_eof(_IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury],
"
bmio__zipped_buf_eof = bmio__wr_ptr;
").
bmio.write_byte_checked(Byte) -->
chk_wr(Byte).
write_byte_checked(Byte, !IO) :-
chk_wr(Byte, !IO).
% :- pragma no_inline(rd/3).
@@ -157,13 +136,23 @@ bmio.write_byte_checked(Byte) -->
rd(Byte::out, _IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury],
"
/* assert(bmio__rd_buf <= bmio__rd_ptr); */
/* assert(bmio__rd_ptr <= bmio__rd_eof); */
/* assert(bmio__rd_buf <= bmio__rd_ptr); */
/* assert(bmio__rd_ptr <= bmio__rd_eof); */
if(bmio__rd_ptr < bmio__rd_eof)
Byte = (unsigned char)(*bmio__rd_ptr++);
else
if (bmio__rd_ptr < bmio__rd_eof) {
Byte = (unsigned char) (*bmio__rd_ptr++);
} else {
Byte = -1;
}
").
:- pred rd_bytes(int::out, bmio.state::di, bmio.state::uo) is det.
:- pragma foreign_proc("C",
rd_bytes(R::out, _IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury],
"
R = bmio__rd_ptr - bmio__rd_buf;
").
% :- pragma no_inline(wr/3).
@@ -174,17 +163,18 @@ bmio.write_byte_checked(Byte) -->
wr(Byte::in, _IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury],
"
/*
if(bmio__wr_buf > bmio__wr_ptr || bmio__wr_ptr >= bmio__wr_eof) {
fprintf(stderr, ""bmio__wr_buf = %p\n"", bmio__wr_buf);
fprintf(stderr, ""bmio__wr_ptr = %p\n"", bmio__wr_ptr);
fprintf(stderr, ""bmio__wr_eof = %p\n"", bmio__wr_eof);
}
*/
/* if(bmio__wr_buf > bmio__wr_ptr || bmio__wr_ptr >= bmio__wr_eof) {
fprintf(stderr, ""bmio__wr_buf = %p\n"", bmio__wr_buf);
fprintf(stderr, ""bmio__wr_ptr = %p\n"", bmio__wr_ptr);
fprintf(stderr, ""bmio__wr_eof = %p\n"", bmio__wr_eof);
} */
/* assert(bmio__wr_buf <= bmio__wr_ptr); */
/* assert(bmio__wr_ptr < bmio__wr_eof); */
/* assert(bmio__wr_buf <= bmio__wr_ptr); */
/* assert(bmio__wr_ptr < bmio__wr_eof); */
*bmio__wr_ptr++ = Byte;
*bmio__wr_ptr++ = Byte;
").
% :- pragma no_inline(chk_wr/3).
@@ -195,37 +185,32 @@ bmio.write_byte_checked(Byte) -->
chk_wr(Byte::in, _IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury],
"
/* assert(bmio__wr_buf <= bmio__wr_ptr); */
/* assert(bmio__wr_ptr < bmio__wr_eof); */
assert((
*bmio__wr_ptr++
) == Byte);
").
bmio.report_stats -->
rd_bytes(R),
wr_bytes(W),
io.stderr_stream(E),
io.write_many(E, [s("bmio: read "), i(R), s(" bytes\n")]),
io.write_many(E, [s("bmio: written "), i(W), s(" bytes\n")]).
:- pred rd_bytes(int::out, bmio.state::di, bmio.state::uo) is det.
:- pragma foreign_proc("C",
rd_bytes(R::out, _IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury],
"
R = bmio__rd_ptr - bmio__rd_buf;
/* assert(bmio__wr_buf <= bmio__wr_ptr); */
/* assert(bmio__wr_ptr < bmio__wr_eof); */
assert((*bmio__wr_ptr++) == Byte);
").
:- pred wr_bytes(int::out, bmio.state::di, bmio.state::uo) is det.
:- pragma foreign_proc("C",
wr_bytes(W::out, _IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury], "
[promise_pure, will_not_call_mercury],
"
W = bmio__wr_ptr - bmio__wr_buf;
").
% :- pragma no_inline(bmio.mark_decompression_eof/2).
:- pragma foreign_proc("C",
mark_decompression_eof(_IO0::di, _IO::uo),
[promise_pure, will_not_call_mercury],
"
bmio__zipped_buf_eof = bmio__wr_ptr;
").
report_stats(!IO) :-
rd_bytes(R, !IO),
wr_bytes(W, !IO),
io.stderr_stream(E, !IO),
io.write_many(E, [s("bmio: read "), i(R), s(" bytes\n")], !IO),
io.write_many(E, [s("bmio: written "), i(W), s(" bytes\n")], !IO).

View File

@@ -1,10 +1,9 @@
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et tw=0 wm=0 ff=unix
% code_table4.m
% Ralph Becket <rbeck@microsoft.com>
% Thu Nov 9 15:01:55 GMT 2000
% vim: ts=4 sw=4 et tw=0 wm=0 ff=unix
%
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
:- module code_table4.
@@ -13,9 +12,7 @@
:- import_module util, array.
:- type code_table.
:- type hash.
:- type key.
:- func key(code, byte) = key.
@@ -29,12 +26,13 @@
:- func set(code_table, hash, key, code) = code_table.
:- mode set(array_di, in, in, in) = array_uo is det.
% ---------------------------------------------------------------------------- %
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- implementation.
:- import_module assoc_list, int.
:- import_module assoc_list.
:- import_module int.
:- type hash == int.
@@ -60,15 +58,15 @@ hash(C, B) = C `xor` (B `lshift` 8).
:- func hash_delta(hash) = int.
hash_delta(H) = ( if H = 0 then 1 else table_size - H ).
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
key(C, B) = (C `lshift` 8) \/ B.
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
new_code_table = array.init(array_size, empty_code).
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
lookup(C, B, T, H, K, Code) :-
H0 = hash(C, B),
@@ -77,11 +75,11 @@ lookup(C, B, T, H, K, Code) :-
( if (K0 = K ; K0 = empty_code) then
H = H0,
Code = array.lookup(T, code_idx(H0))
else
else
lookup_0(H0, hash_delta(H0), K, T, H, Code)
).
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
:- pred lookup_0(hash, int, key, code_table, hash, code).
:- mode lookup_0(in, in, in, array_ui, out, out) is det.
@@ -92,14 +90,14 @@ lookup_0(H0, DH, K, T, H, Code) :-
( if (K0 = K ; K0 = empty_code) then
H = H1,
Code = array.lookup(T, code_idx(H1))
else
else
lookup_0(H1, DH, K, T, H, Code)
).
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
set(T0, H, K, C) = T :-
T1 = array.set(T0, key_idx(H), K),
T = array.set(T1, code_idx(H), C).
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%

View File

@@ -1,10 +1,9 @@
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et tw=0 wm=0 ff=unix
% compress5.m
% Ralph Becket <rbeck@microsoft.com>
% Thu Nov 9 16:52:58 GMT 2000
%
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- module compress5.
:- interface.
@@ -13,22 +12,29 @@
:- pred go(io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- implementation.
:- import_module bitbuf2, code_table4, util, int, array, require, store, bool.
:- import_module bmio. % XXX to get better intermodule optimization
%-----------------------------------------------------------------------------%
:- import_module array.
:- import_module bitbuf2.
:- import_module bool.
:- import_module code_table4.
:- import_module int.
:- import_module require.
:- import_module store.
:- import_module util.
%---------------------------------------------------------------------------%
go(!IO) :-
new_bitbuf(Buf, S),
start(Buf, S, !IO).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- pragma inline(start/4).
:- pred start(bitbuf(T)::in, T::di, io::di, io::uo) is det <= store(T).
@@ -46,7 +52,7 @@ start(Buf, !.S, !IO) :-
error(io.error_message(ErrNo))
).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- pred main_loop(code::in, code::in, code_table::array_di, int::in,
bitbuf(T)::in, T::di, io::di, io::uo) is det <= store(T).
@@ -58,16 +64,16 @@ main_loop(C, N, T, BPC, Buf, !.S, !IO) :-
lookup(C, B, T, H, K, C0),
( if C0 \= empty_code then
main_loop(C0, N, T, BPC, Buf, !.S, !IO)
else if N =< max_code then
else if N =< max_code then
write_code(C, BPC, Buf, !S, !IO),
main_loop(B, N + 1, set(T, H, K, N), update_bpc(N, BPC), Buf,
!.S, !IO)
else
else
compression_ratio_fallen(Buf, Fallen, !S),
( if Fallen = no then
write_code(C, BPC, Buf, !S, !IO),
main_loop(B, N, T, BPC, Buf, !.S, !IO)
else
else
write_code(C, BPC, Buf, !S, !IO),
write_code(B, BPC, Buf, !S, !IO),
write_code(clear_code, BPC, Buf, !S, !IO),
@@ -84,6 +90,6 @@ main_loop(C, N, T, BPC, Buf, !.S, !IO) :-
error(io.error_message(ErrNo))
).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- end_module compress5.
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%

View File

@@ -1,10 +1,9 @@
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et tw=0 wm=0 ff=unix
% harness.m
% Ralph Becket <rbeck@microsoft.com>
% Mon Nov 13 13:12:09 GMT 2000
%
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- module harness.
:- interface.
@@ -13,25 +12,32 @@
:- pred main(io::di, io::uo) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- implementation.
:- import_module bmio, int, list, string, require.
% :- import_module compress1, compress2, compress3, compress4, compress5.
:- import_module bmio.
% :- import_module compress1.
% :- import_module compress2.
% :- import_module compress3.
% :- import_module compress4.
:- import_module compress5.
:- import_module int.
:- import_module list.
:- import_module require.
:- import_module string.
:- func num_iterations = int.
num_iterations = 10.
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
main(!IO) :-
io.command_line_arguments(ArgV, !IO),
( if
ArgV = [FileName, NumBytesStr],
string.to_int(NumBytesStr, NumBytes)
string.to_int(NumBytesStr, NumBytes)
then
bmio.init(FileName, NumBytes, !IO),
%test("compress1", compress1.go),
@@ -43,18 +49,19 @@ main(!IO) :-
error("usage: compress <infile> <nbytes>")
).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- pred test(string::in, pred(io, io)::in(pred(di, uo) is det),
io::di, io::uo) is det.
test(_Name, Go, !IO) :-
% io.format("\n\n******* %s x %d *******\n", [s(Name), i(num_iterations)], !IO),
% io.format("\n\n******* %s x %d *******\n",
% [s(Name), i(num_iterations)], !IO),
% io.report_stats(!IO),
test_loop(num_iterations, Go, !IO).
% io.report_stats(!IO).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- pred test_loop(int::in, pred(io, io)::in(pred(di, uo) is det),
io::di, io::uo) is det.
@@ -68,6 +75,6 @@ test_loop(N, Go, !IO) :-
true
).
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- end_module harness.
%-----------------------------------------------------------------------------%
%---------------------------------------------------------------------------%

View File

@@ -1,10 +1,9 @@
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et tw=0 wm=0 ff=unix
% util.m
% Ralph Becket <rbeck@microsoft.com>
% Thu Nov 9 15:14:21 GMT 2000
% vim: ts=4 sw=4 et tw=0 wm=0 ff=unix
%
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
:- module util.
@@ -34,12 +33,12 @@
:- func ratio(int, int) = int.
% ---------------------------------------------------------------------------- %
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
:- implementation.
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
first_new_code = 257.
@@ -51,18 +50,18 @@ max_code = 65535.
initial_bpc = 9.
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
update_bpc(N, BPC) = BPC + ( if N >= (1 `lshift` BPC) then 1 else 0 ).
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
X `lshift` N = unchecked_left_shift(X, N).
X `rshift` N = unchecked_right_shift(X, N).
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%
ratio(BitsIn, BitsOut) = (BitsIn - BitsOut) `rshift` 11.
% ---------------------------------------------------------------------------- %
%---------------------------------------------------------------------------%