@echo off

echo updatedb -- build locate pathname database
echo csh original by James Woods; sh conversion by David MacKenzie.
echo OS/2 conversion Kai Uwe Rommel
echo Public domain.
echo Modified by Justin Gibbs for the Hobbes OS/2 CDROM 2/23/94

rem The directory containing the subprograms.
set bindir=%CDROM%\bin

rem Directories to put in the database.
set search=%LOCATE_INCLUDE_DIRS%

rem Entries that match this regular expression are omitted.
set regex="\(^/temp$\)\|\(^/tmp$\)"

REM The database file.
set fcodes=%LOCATE_WRITE_PATH%

rem Temporary files.
set bigrams=%TEMP%\bigram.tmp
set filelist=%TEMP%\filelist.tmp

echo Making the file list.  This may take a little while.
REM Alphabetize '/' before any other char with 'tr'.
gfind %search% ^( -type d -regex %regex% ^) -prune -o -print | tr "/" "\001" | gsort -f | tr "\001" "/" >%filelist%

echo Computing common bigrams.
bigram <%filelist% | gsort | uniq -c | gsort -nr | gawk "{ if (NR <= 128) print $2 }" | tr -d "\012" >%bigrams%

echo Coding the file list.
code %bigrams% <%filelist% > %fcodes% 

del %bigrams% %filelist%
echo Finished!
