#! /usr/bin/perl
#
# ----------------------------------------------------------------------
#     T-Kernel 2.0 Software Package
#
#     Copyright 2011 by Ken Sakamura.
#     This software is distributed under the latest version of T-License 2.x.
# ----------------------------------------------------------------------
#
#     Released by T-Engine Forum(http://www.t-engine.org/) at 2011/05/17.
#     Modified by T-Engine Forum at 2014/07/14.
#     Modified by TRON Forum(http://www.tron.org/) at 2015/06/01.
#
# ----------------------------------------------------------------------
#

#       mergesrec
#
#       merge S-Record format files to one file
#
#

$usage = "usage: mergesrec file ... > out\n";

$top = "";
$end = "";

while ( <> ) {
        if ( /^S0/ ) {
                if ( $top eq "" ) {
                        $top = $_;
                        print;
                }
                next;
        }
        if ( /^S7/ ) {
                $end = $_;
                next;
        }
        print;
}

print $end;

exit 0;


