bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# CDDL HEADER START
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# The contents of this file are subject to the terms of the
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# Common Development and Distribution License (the "License").
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# You may not use this file except in compliance with the License.
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# See the License for the specific language governing permissions
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# and limitations under the License.
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# When distributing Covered Code, include this CDDL HEADER in each
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# If applicable, add the following below this CDDL HEADER, with the
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# fields enclosed by brackets "[]" replaced with your own identifying
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# information: Portions Copyright [yyyy] [name of copyright owner]
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# CDDL HEADER END
8276d7915abc7c44934b5701e6ae35ec26eba740Jonathan Adams# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami# Check that source files contain a valid comment block
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami for actual, valid in map(lambda x, y: (x and x.lstrip(CmntChrs), y),
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahramidef cmtblkchk(fh, blk_name, blk_text, filename=None,
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami lenient=False, verbose=False, output=sys.stderr):
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami full_text = [StartText, ''] + blk_text + ['', EndText]
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami StartRE = re.compile(r'^[%s ]*%s' % (CmntChrs, StartText))
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami EndRE = re.compile(r'^[%s ]*%s' % (CmntChrs, EndText))
8276d7915abc7c44934b5701e6ae35ec26eba740Jonathan Adams output.write('%s: %s: Error: Incomplete %s block\n''' %
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami # Check for no comment block, warn if we're not being lenient
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami # Check for multiple comment blocks
8276d7915abc7c44934b5701e6ae35ec26eba740Jonathan Adams output.write('%s: Error: Multiple %s blocks\n'
bfed486ad8de8b8ebc6345a8e10accae08bf2f45Ali Bahrami # Validate each comment block
8276d7915abc7c44934b5701e6ae35ec26eba740Jonathan Adams "%s: %d: Error: Invalid line in %s block:\n"
8276d7915abc7c44934b5701e6ae35ec26eba740Jonathan Adams " should be\n"