#!/bin/sh # Copyright for the Uniform Repository Service (c) 1995, 1996, 1997, # 1998, # by Gerald Banon. All rights reserved. # Version 1.1 # ui.tcl \ exec ../../../../../dpi.inpe.br/banon/1997/10.21.17.24/doc/tcl8.0/unix/tclsh "$0" ${1+"$@"} set col ../../../../.. set not_sent dpi.inpe.br/banon/1995/08.08.00.00/not_sent if [catch {open ../not_sent/.setenv/index_path r} fileId] { puts stderr "Cannot open ../not_sent/.setenv/index_path: $fileId" } else { set indexPath [string trim [read $fileId]] close $fileId } # Turn the @reference.bib file content into a set of variables, # one for each entry, the variable name being the repository name set repList {} if [file exists $col/$indexPath/doc/@reference.bib] { # @reference.bib exists # > if [catch {open $col/$indexPath/doc/@reference.bib r} fileId] { puts stderr \ "Cannot open $col/$indexPath/doc/@reference.bib: $fileId" } else { set fileContent [read $fileId] close $fileId regsub {.*$} $fileContent {} fileContent regsub -all "(\[^\n\])@" $fileContent {\1#x#} fileContent regsub -all {%} $fileContent {#+#} fileContent # in this script, % is special character and it should be hiden regsub -all {@} $fileContent {%@} fileContent foreach entry [lrange [split $fileContent %] 1 end] { regexp {repository *= *"([^"]*)"} $entry m rep set $rep $entry lappend repList $rep } } # < } else { # @reference.bib does not exist cd $col set pathList [glob */*/*/*/bib/*/.b/@z] cd $not_sent foreach path $pathList { regsub {/bib/.*/\.b/@z$} $path {} rep if [catch {open $col/$path r} fileId] { puts stderr $fileId } else { set $rep "[string trim [read $fileId]]\n\n" close $fileId if {[lsearch -exact $repList $rep] < 0} { lappend repList $rep } } } } # Update the set of variables from the @z files #if [file exists .t/add] { ## > #if [catch {open .t/add r} fileId] { # puts stderr "Cannot open .t/add: $fileId" #} else { # set add [string trim [read $fileId]] # close $fileId # foreach item [split $add \n] { # set rep [lindex $item 1] # set path [glob $col/$rep/bib/*/.b/@z] # if [catch {open $path r} fileId] { # puts stderr "Cannot open $path: $fileId" # } else { # set $rep "[string trim [read $fileId]]\n\n" # close $fileId # if {[lsearch -exact $repList $rep] < 0} { # lappend repList $rep # } # } # } #} ## < #} set fileList [glob -nocomplain $col/*/*/*/*/.reserved/last_change] if [file exists .setenv/last_change] { set referenceTime [file mtime .setenv/last_change] } else { set referenceTime 0 } foreach file $fileList { if {[file mtime $file] > $referenceTime} { regexp "$col/(.*)/.reserved/last_change" $file m rep set path [glob -nocomplain $col/$rep/bib/*/.b/@z] if {$path == ""} {continue} if [catch {open $path r} fileId] { puts stderr "Cannot open $path: $fileId" } else { set $rep "[string trim [read $fileId]]\n\n" close $fileId if {[lsearch -exact $repList $rep] < 0} { lappend repList $rep } } } } if [file exists .tremove] { # > if [catch {open .tremove r} fileId] { puts stderr "Cannot open .tremove: $fileId" } else { set item [string trim [read $fileId]] close $fileId set rep [lindex $item 1] if [info exists $rep] {unset $rep} set i [lsearch -exact $repList $rep] if {$i >= 0} {set repList [lreplace $repList $i $i]} } # < } # Compare entries based on the citation keys proc EntryCompare1 {a b} { upvar #0 $a A upvar #0 $b B regexp "\{(\[^,\]*)," $A m citationKeyA regexp "\{(\[^,\]*)," $B m citationKeyB return [string compare $citationKeyA $citationKeyB] } # Create the updated @reference.bib file from the updated set of variables set indexBib "" set header \ "\nBibliographic index\n
\
\nNumber of entries: [llength $repList]\n\n"
lappend indexBib $header

set sortedRepList [lsort -command EntryCompare1 $repList]
foreach rep $sortedRepList {
	lappend indexBib [set $rep]
}
if [catch {open $col/$indexPath/doc/@reference.bib w} fileId] {
	puts stderr \
		"Cannot open $col/$indexPath/doc/@reference.bib: $fileId"
} else {
	regsub -all {#x#} [join $indexBib {}] {@} indexBib
	regsub -all {#+#} $indexBib {%} indexBib
	set fileContent "$indexBib
" puts $fileId $fileContent close $fileId } # Turn the all.html file content into a set of variables, # one for each entry, the variable name being the repository name set repList {} if [file exists $col/$indexPath/not_sent/all.html] { # all.html exists # > if [catch {open $col/$indexPath/not_sent/all.html r} fileId] { puts stderr "Cannot open $col/$indexPath/not_sent/all.html: $fileId" } else { set fileContent [read $fileId] close $fileId regsub {.*$} $fileContent {} fileContent regsub -all {%} $fileContent {#+#} fileContent # in this script, % is special character and it should be hiden regsub -all {

} $fileContent {%

} fileContent foreach entry [lrange [split $fileContent %] 1 end] { regexp {