The Tycho Glimpse browser uses the glimpse
program to search
the sources for patterns. glimpse
is a binary that is not
shipped with the Tycho sources, you can get glimpse
sources from
http://glimpse.cs.arizona.edu
.
In Tycho, $TYCHO/makefile
contains a glimpse
rule that will update
$TYCHO/.glimpse_index
if glimpse
is
installed.
Note that the Glimpse browser uses the Tcl exec
command, which is unavailable on the Macintosh, so the Glimpse browser
is not present on that platform. Note further that we have not tested
the Glimpse browser under Windows.
If your Tycho distribution is located in a directory with a
pathname that includes a space, then the glimpseindex
command may fail. The workaround is to move Tycho to a pathname that
does not include a space.
The Glimpse browser is a window that prompts for a pattern to search
for. Clicking the Find
button passes the pattern to the
glimpse
binary and then places the output into a Tycho
index browser.
If you click on the entry in the index browser, an editor is opened at the
line where the pattern matched.
If $PTOLEMY/src/.glimpse_index
is exists, then two
additional buttons are created, one to set the glimpse_index
to $PTOLEMY/src/.glimpse_index
, one to set it to
$TYCHO/.glimpse_index
The Update Tycho DB
button will run make glimpse
for you, and update $TYCHO/.glimpse_index
.
http://www.cygnus.com
Prebuilt glimpse
binaries can be downloaded from
http://ptolemy.eecs.berkeley.edu/tycho/tychoTools/tychoTools.html
.
configure
, make the changes below.
These changes can be wrapped in #ifdef _WIN32
or #ifdef __CYGWIN32__
main.c
SIGURG
.
communicate.c
, agrep/agrep.h
#include <errno.h>
to the top.
communicate.c
#include "sys/un.h"
index/io.c
O_BINARY
to the open()
call in my_fopen()
.
return open(temp, flag|O_BINARY, mode);This fixes runtime
glimpseindex
errors about:
read error on file xxx at offset xxx
"rb"
for "r"
and
"wb"
for "w"
#! /bin/sh SRC=/src/glimpse-4.0.src cd $SRC files="get_filename.c get_index.c main.c main_server.c index/region.c \ index/partition.c index/io.c index/glimpse.c index/convert.c \ index/build_in.c compress/string.c compress/tbuild.c \ compress/uncast.c compress/cast.c compress/hash.c compress/misc.c \ compress/quick.c" for file in $files do echo $file sed 's/"r"/"rb"/' $file | sed 's/"w"/"wb"/' > t.c mv t.c $file done
index/glimpse.h
SYSTEM_SORT
to
#define SYSTEM_SORT "/gnuwin32/b18/H-i386-cygwin32/bin/sort"This fixes runtime
glimpseindex
errors about:
SORT: invalid switch
, as the MSDOS sort
binary does not understand the -T
flag.
The alternative is to adjust your path so that the MSDOS sort is not first in your path.
index/build_in.c
sort
binary will
truncate a file at the first Control-Z
character.
The workaround is to modify traverse1()
so that
just after the traverse()
call, skip the call to sort
traverse(); /* will produce .i2 and my_free allocated memory */ #ifdef _WIN32 #else [...] sprintf(s, "%s -10 '%s/%s'\n", SYSTEM_HEAD, escapesinglequote(INDEX_DIR, es1), I2); system(s); #endif /*0*/ #endif /*_WIN32*/
index/build_in.c
traverse1()
, we need to append the contents
of .glimpse_tmpI2
onto .glimpse_index
because
under Cygwin b18, the cat
command will only cop
until the first Control-Z
character.
#ifdef _WIN32 /* Cygwin cat can't deal with files that contain control-Z chars. */ { FILE *fin, *fout; char tmpptr[BUFSIZ]; sprintf(s, "%s/%s",escapesinglequote(INDEX_DIR, es1), I2); if ((fin = fopen(s, "rb")) == (FILE *)NULL) { fprintf(stderr, "Failed to open %s:",s); perror(""); } sprintf(s, "%s/%s",escapesinglequote(INDEX_DIR, es2), INDEX_FILE); if ((fout = fopen(s, "ab")) == (FILE *)NULL) { fprintf(stderr, "Failed to open %s:",s); perror(""); } while(fgets(tmpptr,BUFSIZ,fin)) fputs(tmpptr, fout); fclose(fin); fclose(fout); } #else sprintf(s, "%s '%s/%s' >> '%s/%s'\n", SYSTEM_CAT, escapesinglequote(INDEX_DIR, es1), I2, escapesinglequote(INDEX_DIR, es2), INDEX_FILE); system(s); #endif _WIN32
index/glimpse.c
fflush(TIMEFILE) fclose(TIMEFILE)above the
fflush(MESSAGEFILE) line
in main()
.
This gets rid of glimpseindex
messages about
ls: .glimpse_filetimes: Permission denied
index/glimpse.c
determine_sync()
: Add the following block and
place the rest of the body inside the #else
statement.
#ifdef _WIN32 strcpy(sync_path, "sync"); return 0; #elseNote that under cygwin b18,
sync
will produce messages
like sync(() called, but it is not done yet.
. The
next step obviates the need for calls to sync
.
system()
where it then exec
s a shell command (i.e. system("exec cp foo bar");
. The problem here is that we don't have a reliable
sync
, so there is no way to ensure that the exec
has finished and the files have been written out. The workaround
is to remove all instances of exec that starts a double quoted string.
The real fix here would be to parameterize the exec so that configure
could set a #define
properly and the lines that create
the system()
calls could use the #define
(i.e. sprintf(s,"%s cp foo bar",SYSTEM_EXEC);
.
Below is a shell script that does the proper substitutions.
#! /bin/sh SRC=/src/glimpse-4.0.src cd $SRC files="files="main.c compress/hash.c compress/string.c \ compress/tbuild.c index/glimpse.c index/build_in.c \ index/partition.c"index/io.c" for file in $files do echo $file sed 's/"exec /" /' $file > t.c mv t.c $file done
Makefile
.exe
to the end of glimpse
etc.
glimpseindex
produces messages about whereis
and sync
.