From: <ai...@us...> - 2010-10-27 02:45:40
|
Revision: 11280 http://plplot.svn.sourceforge.net/plplot/?rev=11280&view=rev Author: airwin Date: 2010-10-27 02:45:33 +0000 (Wed, 27 Oct 2010) Log Message: ----------- Implement check for parity bits in our non-binary source files. utils/parity_bit_check.c is the C code for an app that checks for parity bits for the stream of bytes coming from stdin. scripts/parity_bit_check.sh is a bash script to check all our source code files for parity bits being set except for the files listed in scripts/parity_bit_check.exclude. The latter list of files includes, e.g., image files and utf8 files which go beyond the ascii subset of utf8. Modified Paths: -------------- trunk/utils/CMakeLists.txt Added Paths: ----------- trunk/scripts/parity_bit_check.exclude trunk/scripts/parity_bit_check.sh trunk/utils/parity_bit_check.c Added: trunk/scripts/parity_bit_check.exclude =================================================================== --- trunk/scripts/parity_bit_check.exclude (rev 0) +++ trunk/scripts/parity_bit_check.exclude 2010-10-27 02:45:33 UTC (rev 11280) @@ -0,0 +1,25 @@ +\.svn +~$ +\.jpg$ +\.gif$ +\.cgm$ +\.map$ +\.fnt$ +x2[46] +xw2[46] +xthick2[46] +lena +README.release +test_hebrew_diacritic.py +test_plplot_encodings.py +NEWS +ChangeLog +simplepie.inc +qsastime.html +qsastime.txt +qsastime.xml +README.deltaT.dat +api2man.pl.in +api2text.pl +docbook/AUTHORS +__pl_pltext.m Property changes on: trunk/scripts/parity_bit_check.exclude ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/scripts/parity_bit_check.sh =================================================================== --- trunk/scripts/parity_bit_check.sh (rev 0) +++ trunk/scripts/parity_bit_check.sh 2010-10-27 02:45:33 UTC (rev 11280) @@ -0,0 +1,65 @@ +#!/bin/bash + +# $Id$ + +# This script will run parity_bit_check on all files in the PLplot +# source tree (except those listed below) to discover which of those +# files have any character with the eighth (parity) bit set. + +# Copyright (C) 2010 Alan W. Irwin +# +# This file is part of PLplot. +# +# PLplot is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Library Public License as published +# by the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# PLplot is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with PLplot; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +which parity_bit_check >/dev/null +parity_bit_check_rc=$? +if [ "$parity_bit_check_rc" != 0 ] ; then + echo " +This script only works when parity_bit_check is on the PATH. +To make this so please run + +make parity_bit_check + +in the build tree and put the utils subdirectory of that build tree +where parity_bit_check will be built by the above command on your +PATH." + exit 1 +fi + +# Find absolute PATH of script without using readlink (since readlink is +# not available on all platforms). Followed advice at +# http://fritzthomas.com/open-source/linux/551-how-to-get-absolute-path-within-shell-script-part2/ +ORIGINAL_PATH="$(pwd)" +cd "$(dirname $0)" +# Absolute Path of the script +SCRIPT_PATH="$(pwd)" + +# Assumption: top-level source tree is parent directory of where script +# is located. +SOURCE_TREE="$(dirname ${SCRIPT_PATH})" +cd "${SOURCE_TREE}" + +#List of all files in source tree other than .svn ones.... +find -type f >| /tmp/temporary_source_tree_list + +for FILE in $(grep -v -f "$SOURCE_TREE"/scripts/parity_bit_check.exclude /tmp/temporary_source_tree_list); do + parity_bit_check <$FILE + parity_bit_check_rc=$? + if [ "$parity_bit_check_rc" -ne 0 ]; then + printf "%s %x\n" $FILE $parity_bit_check_rc + fi +done +rm -f /tmp/temporary_source_tree_list \ No newline at end of file Property changes on: trunk/scripts/parity_bit_check.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/utils/CMakeLists.txt =================================================================== --- trunk/utils/CMakeLists.txt 2010-10-27 02:02:12 UTC (rev 11279) +++ trunk/utils/CMakeLists.txt 2010-10-27 02:45:33 UTC (rev 11280) @@ -94,3 +94,7 @@ DESTINATION ${BIN_DIR} ) endif(ENABLE_tcl) + +# Build simple executable to check parity bits of all characters read +# by stdin. +add_executable(parity_bit_check parity_bit_check.c) \ No newline at end of file Added: trunk/utils/parity_bit_check.c =================================================================== --- trunk/utils/parity_bit_check.c (rev 0) +++ trunk/utils/parity_bit_check.c 2010-10-27 02:45:33 UTC (rev 11280) @@ -0,0 +1,18 @@ + +#include <stdio.h> +#include <ctype.h> + +// Checks whether the eighth (parity) bit is set on any character of stdin. +// Returns the first such character found or zero if no such character +// found. +int +main( int argc, char *argv[] ) +{ + int c; + while ((c=getchar())!= EOF) + { + if(c & 0x80) + return c; + } + return 0; +} Property changes on: trunk/utils/parity_bit_check.c ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |