Initial commit based on v1.6.6

This commit is contained in:
Andrew Wood
2021-09-04 20:51:25 +01:00
commit 12f28d0689
80 changed files with 12819 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
#!/bin/bash
#
# Benchmark the read/write performance of pv by looking at the number of
# read() and write() calls and the average amount of data transferred each
# time, as suggested by Ville Herva <Ville.Herva@iki.fi>.
#
test_input=`mktemp /tmp/pvbench1XXXXXX`
strace_output=`mktemp /tmp/pvbench2XXXXXX`
trap "rm -f ${test_input} ${strace_output}" 0
pv=${pv:-./pv}
test -x ${pv} || pv=pv
dd if=/dev/zero of=${test_input} bs=1k count=1k >/dev/null 2>&1
echo -e "Buf(k)\tRate(k)\tReads\tRsize\tWrites\tWsize"
for ((buffer=100; buffer<=1000; buffer+=100)); do
for ((rate=0; rate<=1000; rate+=100)); do
rateparm="-L ${rate}k"
test ${rate} -eq 0 && rateparm=""
strace -tt -o ${strace_output} \
${pv} ${rateparm} -B ${buffer}k \
-f < ${test_input} > /dev/null 2>&1
rdata=$(
awk '$2~/^read\(0,/{c++;t+=$NF}END{print c "\t" t/c}' \
${strace_output}
)
wdata=$(
awk '$2~/^write\(1,/{c++;t+=$NF}END{print c "\t" t/c}' \
${strace_output}
)
echo -e "${buffer}\t${rate}\t${rdata}\t${wdata}"
done
done
# EOF
+30
View File
@@ -0,0 +1,30 @@
#!/bin/sh
#
# Generate dependencies for a C source file.
#
CC=$1
shift
file=$1
shift
stem=$1
shift
srcdir=$1
abssrc=`echo $srcdir | sed ':1
s,^\./,,g
t1'`
shift
abssrc=`echo "$abssrc" | sed 's,\\.,\\\\.,g'`
srcdir=`echo "$srcdir" | sed 's,\\.,\\\\.,g'`
$CC -M -MG $* $file \
| sed -e 's, /[^ ]*,,g' -e "s,^.*\.o:,${stem}.d ${stem}.o:," \
-e '/^ \\$/d' -e 's/ \\$//' \
-e 's,'"$srcdir"'/,,g' -e 's,'"$abssrc"'/,,g' \
| tr '\n' ' ' \
| tr -s ' '
echo
# EOF
+171
View File
@@ -0,0 +1,171 @@
#!/bin/ash
#
# Script to generate an HTML index of all C code from the current directory
# downwards (skipping directories ending in ~). The header comment in each
# file is listed, and each function's prototype and comment are given. A
# list of "TODO:" comments is also generated.
#
# Outputs the HTML on standard output.
#
# If a parameter is given, it is the prefix to put before any "view file"
# links, eg ".." to link to "../dir/file.c" instead of "dir/file.c".
#
# Skips any files containing the string !NOINDEX.
#
# Requires ctags and cproto.
#
OFFS=$1
# Convert the given string to HTML-escaped values (<, >, & escaped) on
# stdout.
#
html_safe () {
echo "$*" \
| sed -e 's|&|\&amp;|g;s|<|\&lt;|g;s|>|\&gt;|g'
}
# Convert the given string to HTML-escaped values (<, >, & escaped) on
# stdout, also adding a <BR> to the end of each line.
#
html_safebr () {
echo "$*" \
| sed -e 's|&|\&amp;|g;s|<|\&lt;|g;s|>|\&gt;|g;s/$/<BR>/'
}
ALLFILES=`find . -name '*~' -prune -o -type f -name '*.c' \
-exec grep -FL '!NOINDEX' /dev/null '{}' ';'`
CTAGDATA=`echo "$ALLFILES" \
| ctags -nRf- -L- --c-types=f \
| sed 's/ .\// /;s/;" .*$//'`
FILELIST=`echo "$CTAGDATA" | cut -d ' ' -f 2 | sort | uniq`
echo '<HTML><HEAD>'
echo '<TITLE>Source Code Index</TITLE>'
echo '</HEAD><BODY>'
echo '<H1><A NAME="top">Source Code Index</A></H1>'
echo '<P><UL>'
echo '<LI><A HREF="#files">File Listing</A></LI>'
echo '<LI><A HREF="#funcs">Function Listing</A></LI>'
echo '<LI><A HREF="#todo">To-Do Listing</A></LI>'
echo '</UL></P>'
echo '<H2><A NAME="files">File Listing</A></H2>'
echo '<P><UL>'
echo "$FILELIST" \
| sed -e \
's|^.*$|<LI><CODE CLASS="filename"><A HREF="#file-\0">\0</A></CODE></LI>|'
echo '</UL></P>'
for FILE in $FILELIST; do
DIR=`dirname $FILE`
FUNCDEFS=`cproto -f1 -I. -Isrc/include -I$DIR $FILE 2>/dev/null \
| sed -n 's/^.*[ *]\([^ *(]*\)(.*$/\1/p'`
FILEHEAD="`sed -n -e \
'1,/\*\//{/\/\*/,/\*\//{s/^[\/ *]//;s/^\*[\/]*//;p;};}' \
< $FILE`"
FILESHORTDESC=`echo "$FILEHEAD" | sed -n '1,/^ *$/{/^ *[^ ]*/p;}'`
FILELONGDESC=`echo "$FILEHEAD" | sed '1,/^ *$/d'`
echo '<P><HR WIDTH="100%"></P>'
echo '<P><TABLE BORDER="0"><TR>'
echo '<TD VALIGN="TOP"><CODE CLASS="filename">'
echo '<A NAME="file-'"$FILE"'">'"$FILE"'</A></CODE></TD>'
echo '<TD VALIGN="TOP"> - </TD>'
echo '<TD VALIGN="TOP">'`html_safe "$FILESHORTDESC"`'</TD>'
echo '</TR></TABLE></P>'
echo '<P><SMALL>[<A HREF="'"$OFFS/$FILE"'">View File</A>]</SMALL></P>'
echo '<P><BLOCKQUOTE>'
echo "`html_safebr "$FILELONGDESC"`"
echo '</BLOCKQUOTE></P>'
if [ -n "$FUNCDEFS" ]; then
echo '<P>Functions defined:</P>'
echo '<P><UL>'
echo "$FUNCDEFS" \
| sed 's|^.*$|<A HREF="#func-\0---'"$FILE"'">\0</A>|' \
| sed 's/^/<LI><CODE CLASS="funcname">/;s|$|</CODE></LI>|'
echo '</UL></P>'
fi
echo '<P ALIGN="RIGHT"><SMALL CLASS="navbar">['
echo '<A HREF="#top">Top</A> |'
echo '<A HREF="#todo">To Do</A> |'
echo '<A HREF="#funcs">Functions</A> ]</SMALL></P>'
done
echo '<H2><A NAME="funcs">Function Listing</A></H2>'
echo '<P><UL>'
echo "$CTAGDATA" | while read FUNC FILE LINENUM REST; do
echo -n '<LI><CODE CLASS="funcname">'
echo -n '<A HREF="#func-'"$FUNC"'---'"$FILE"'">'"$FUNC"'</A></CODE> '
echo '[<CODE CLASS="filename">'"$FILE"'</CODE>]</LI>'
done
echo '</UL></P>'
echo "$CTAGDATA" | while read FUNC FILE LINENUM REST; do
FUNCDEF=`sed -n "$LINENUM,/{/p" < $FILE \
| tr '\n' ' ' \
| tr -d '{'`
LASTCOMLINE=`sed -n '1,'"$LINENUM"'{/\/\*/=;}' < $FILE | sed -n '$p'`
[ -z "$LASTCOMLINE" ] && LASTCOMLINE=1
LASTENDFUNCLINE=`sed -n '1,'"$LINENUM"'{/}/=;}' < $FILE | sed -n '$p'`
[ -z "$LASTENDFUNCLINE" ] && LASTENDFUNCLINE=1
FUNCHEAD="`sed -n -e \
"$LASTCOMLINE,"'/\*\//{h;s/^[\/ *]//;s/^\*[\/]*//;p;x;/\*\//q;}' \
< $FILE`"
[ "$LASTCOMLINE" -le "$LASTENDFUNCLINE" ] && FUNCHEAD=""
echo '<P><HR WIDTH="100%"></P>'
echo '<P ALIGN="LEFT">'
echo -n '<CODE CLASS="funcname"><A NAME="func-'"$FUNC"'---'"$FILE"'">'
echo -n "$FUNC"'</A></CODE> '
echo -n '[<CODE CLASS="filename"><A HREF="#file-'"$FILE"'">'
echo "$FILE"'</A></CODE>]'
echo '</P>'
echo '<P><CODE CLASS="funcdef">'"`html_safe "$FUNCDEF"`"'</CODE></P>'
echo '<P><BLOCKQUOTE>'
echo "`html_safebr "$FUNCHEAD"`"
echo '</BLOCKQUOTE></P>'
echo '<P ALIGN="RIGHT"><SMALL CLASS="navbar">['
echo '<A HREF="#top">Top</A> |'
echo '<A HREF="#todo">To Do</A> |'
echo '<A HREF="#files">Files</A> ]</SMALL></P>'
done
echo '<H2><A NAME="todo">To Do Listing</A></H2>'
echo '<P><UL>'
for FILE in $FILELIST; do
TODOLINES=`sed -n \
-e '/\/\*.*\*\//!{/\/\*/,/\*\//{/TODO:/{=;};};}' \
-e '/\/\*.*\*\//{/TODO:/{=;};}' \
< $FILE`
[ -z "$TODOLINES" ] && continue
echo -n '<LI><CODE CLASS="filename">'
echo '<A HREF="#file-'"$FILE"'">'"$FILE"'</A></CODE>'
echo '<UL>'
for NUM in $TODOLINES; do
TODO=`sed -n "$NUM"'{s/^.*TODO://;s/\*\/.*$//;p;}' < $FILE`
echo "<LI>[<B>$NUM</B>] `html_safe "$TODO"`</LI>"
done
echo '</UL></LI>'
done
echo '</BODY></HTML>'
# EOF
+250
View File
@@ -0,0 +1,250 @@
#! /bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0
+113
View File
@@ -0,0 +1,113 @@
#!/bin/sh
#
# Generate Makefile dependencies inclusion and module target file "depend.mk~"
# by scanning the directory "src" for files ending in ".c" and ".d", and for
# subdirectories not starting with "_".
#
# Modules live inside subdirectories called [^_]* - i.e. a directory "foo" will
# have a rule created which links all code inside it to "foo.o".
#
# The directory "src/include" is never scanned; neither are CVS or SVN
# directories.
#
outlist=$1
outlink=$2
FIND=find
GREP=grep
which gfind 2>/dev/null | grep /gfind >/dev/null && FIND=gfind
which ggrep 2>/dev/null | grep /ggrep >/dev/null && GREP=ggrep
echo '# Automatically generated file listings' > $outlist
echo '#' >> $outlist
echo "# Creation time: `date`" >> $outlist
echo >> $outlist
echo '# Automatically generated module linking rules' > $outlink
echo '#' >> $outlink
echo "# Creation time: `date`" >> $outlink
echo >> $outlink
echo -n "Scanning for source files: "
allsrc=`$FIND src -type f -name "*.c" -print`
allobj=`echo $allsrc | tr ' ' '\n' | sed 's/\.c$/.o/'`
alldep=`echo $allsrc | tr ' ' '\n' | sed 's/\.c$/.d/'`
echo `echo $allsrc | wc -w | tr -d ' '` found
echo -n "Scanning for modules: "
modules=`$FIND src -type d -print \
| $GREP -v '^src$' \
| $GREP -v '/_' \
| $GREP -v '^src/include' \
| $GREP -v 'CVS' \
| $GREP -v '.svn' \
| while read DIR; do \
CONTENT=\$(/bin/ls -d \$DIR/* \
| $GREP -v '.po$' \
| $GREP -v '.gmo$' \
| $GREP -v '.mo$' \
| $GREP -v '.h$' \
| sed -n '$p'); \
[ -n "\$CONTENT" ] || continue; \
echo \$DIR; \
done
`
echo up to `echo $modules | wc -w | tr -d ' '` found
echo "Writing module linking rules"
echo -n [
for i in $modules; do echo -n ' '; done
echo -n -e ']\r['
for i in $modules; do
echo -n '.'
allobj="$allobj $i.o"
deps=""
for j in $i/*.c; do
[ -f $j ] || continue
newobj=`echo $j | sed -e 's@\.c$@.o@'`
deps="$deps $newobj"
done
for j in $i/*; do
[ -d "$j" ] || continue
[ `basename $j` = "CVS" ] && continue
[ `basename $j` = ".svn" ] && continue
CONTENT=`/bin/ls -d $j/* \
| $GREP -v '.po$' \
| $GREP -v '.gmo$' \
| $GREP -v '.mo$' \
| $GREP -v '.h$' \
| sed -n '$p'`
[ -n "$CONTENT" ] || continue
deps="$deps $j.o"
done
[ -n "$deps" ] || continue
echo "$i.o: $deps" >> $outlink
echo ' $(LD) $(LDFLAGS) -o $@' "$deps" >> $outlink
echo >> $outlink
done
echo ']'
echo "Listing source, object and dependency files"
echo -n "allsrc = " >> $outlist
echo $allsrc | sed 's,src/nls/cat-id-tbl.c,,' | sed -e 's/ / \\!/g'\
| tr '!' '\n' >> $outlist
echo >> $outlist
echo -n "allobj = " >> $outlist
echo $allobj | sed -e 's/ / \\!/g' | tr '!' '\n' >> $outlist
echo >> $outlist
echo -n "alldep = " >> $outlist
echo $alldep | sed -e 's/ / \\!/g' | tr '!' '\n' >> $outlist
echo >> $outlist
echo >> $outlink
# EOF
+33
View File
@@ -0,0 +1,33 @@
#!/bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Last modified: 1994-03-25
# Public domain
errstatus=0
for file in ${1+"$@"} ; do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d in ${1+"$@"} ; do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp" 1>&2
mkdir "$pathcomp" || errstatus=$?
chmod 755 $pathcomp 2>/dev/null
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here
+65
View File
@@ -0,0 +1,65 @@
#!/bin/sh
#
# Messy script to convert all of the given .po files to a single C file on
# stdout.
cat <<EOF
/*
* Translation table - automatically generated by po2table.sh.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
struct msgtable_s {
char *msgid;
char *msgstr;
};
struct msgtable_s *minigettext__gettable(char *lang)
{
if (0 == lang)
return 0;
EOF
for POFILE in $*; do
LANG=`basename "$POFILE" | sed 's/.po$//'`
echo " if (strncmp(lang, \"$LANG\", 2) == 0) {"
echo " static struct msgtable_s data[] = {";
awk 'BEGIN{i=0;s=0;}
/^msgid[ ]+/ {
if (s) print " }, ";
print " {";
print " " substr($0,7);
i=1;
s=0;
}
/^msgstr[ ]+/ {
print " ,";
i=0;s=1;
print " " substr($0,8);
}
/^[ ]*"/ {
if (i||s) print " " $0;
}
END {if (i||s) print " }\n";}
' < "$POFILE"
echo ' , { 0, 0 } };'
echo " return data;"
echo " }"
done
cat <<EOF
return 0;
}
/* EOF */
EOF
# EOF
+45
View File
@@ -0,0 +1,45 @@
#!/bin/sh
#
# Run a test. Parameters are program name and source directory; if
# additional parameters are given, they are the tests to run, otherwise all
# tests are run.
#
PROG="$1"
SRCDIR="$2"
shift
shift
TESTS="$*"
# Temporary working files
#
TMP1=`mktemp 2>/dev/null` || TMP1=.tmp1
TMP2=`mktemp 2>/dev/null` || TMP2=.tmp2
TMP3=`mktemp 2>/dev/null` || TMP3=.tmp3
TMP4=`mktemp 2>/dev/null` || TMP4=.tmp4
export PROG TMP1 TMP2 TMP3 TMP4 # variables used by test scripts
FAIL=0
test -n "$TESTS" || TESTS=`ls "$SRCDIR/tests" | sort -n`
for SCRIPT in $TESTS; do
test -f "$SCRIPT" || SCRIPT="$SRCDIR/tests/$SCRIPT"
test -f "$SCRIPT" || SCRIPT=`ls "$SRCDIR/tests/$SCRIPT"*`
test -f "$SCRIPT" || continue
echo `basename "$SCRIPT"`: " " | cut -b1-20 | sed 's/-/ - /' | tr "\n" ' '
STATUS=0
sh -e "$SCRIPT" || STATUS=1
test $STATUS -eq 1 && FAIL=1
test $STATUS -eq 1 && echo "FAILED" || echo "OK"
done
rm -f $TMP1 $TMP2 $TMP3 $TMP4
exit $FAIL
# EOF