#!/bin/sh # Shell script to spell check files. Mixed case words are split up # Author: Christopher Hylands # Version: $Id: ptspell 67778 2013-10-26 15:50:13Z cxh $ # # Copyright (c) 1999-2013 The Regents of the University of California. # All Rights Reserved. # # Permission is hereby granted, without written agreement and without # license or royalty fees, to use, copy, modify, and distribute this # software and its documentation for any purpose, provided that the # above copyright notice and the following two paragraphs appear in all # copies of this software. # # IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY # FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES # ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF # THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE # PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF # CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, # ENHANCEMENTS, OR MODIFICATIONS. # # PT_COPYRIGHT_VERSION_2 # COPYRIGHTENDKEY # Spell check the arguments. # Mixed case words are split into their constituent words # If the local dictionary can be found, use it # Keep the local dictionary in sort order LOCALFILE= if [ -f "$PTII/util/testsuite/ptlocaldict" ]; then LOCALFILE="$PTII/util/testsuite/ptlocaldict" else echo "$0: The Ptolemy II local dictionary at '$PTII/util/testsuite/ptlocaldict' can't be found" fi ISPELL=/usr/local/bin/ispell if [ -f $ISPELL ]; then cat ${1+"$@"} |$ISPELL -l -p $LOCALFILE | \ sed -e 's/\./ /g' | $ISPELL -l -p $LOCALFILE | \ sed -e 's/\([a-z]\)\([A-Z]\)/\1 \2/g' | $ISPELL -l -p $LOCALFILE | \ sed -e 's/^\([A-Z]*\)\([A-Z]\)/\1 \2/g' | \ $ISPELL -l -p $LOCALFILE | sort else # Determine if we are on windows windows=no case "`uname -s`" in CYGWIN*) windows=yes;; # Tcsh Windows*) windows=yes;; esac if [ "$windows" = "yes" ]; then echo "$0: Could not find" echo " '$ISPELL'." fi SPELL=`which spell` if [ -f "$SPELL" ]; then SPELLCMD=$SPELL SPELLARGS="+$LOCALFILE" else ASPELL=`which aspell` if [ -f "$ASPELL" ]; then SPELLCMD=$ASPELL # First line of ptlocaldict must be # personal_ws-1.1 en 719 #SPELLARGS="-C --run-together-limit=10 -a list --personal=$LOCALFILE --repl=$PTII/util/testsuite/aspell.en.prepl" SPELLARGS="-C --run-together-limit=10 -a list --personal=$LOCALFILE" cat ${1+"$@"} | $SPELLCMD $SPELLARGS | \ awk '{if ($1 == "&") {print $2}}' | \ sed -e 's/\([a-z]\)\([A-Z]\)/\1 \2/g' | \ $SPELLCMD $SPELLARGS | \ awk '{if ($1 == "&") {print $2}}' | \ sort | uniq exit $? else echo "$0: could not find ispell, spell or aspell" exit 2 fi fi # The sed calls split up words with internal capitalization $SPELLCMD $SPELLARGS ${1+"$@"} | \ sed -e 's/\./ /g' \ -e 's/"/ /g' \ -e 's/&/ /g' \ -e 's/ / /g' \ -e 's/nbsp;/ /g' \ -e 's/</ /g' \ -e 's/>/ /g' \ -e 's/</ /g' \ -e 's/>/ /g' \ -e 's/lt;/ /g' \ -e 's/gt;/ /g' \ -e 's/quot;/ /g' \ | $SPELLCMD $SPELLARGS | \ sed -e 's/\([a-z]\)\([A-Z]\)/\1 \2/g' | $SPELLCMD $SPELLARGS | \ sed -e 's/^\([A-Z]*\)\([A-Z]\)/\1 \2/g' \ | $SPELLCMD $SPELLARGS | sort | uniq fi