Index: openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/Attic/01-database-procs.tcl,v diff -u -N -r1.1.2.31 -r1.1.2.32 --- openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl 30 Sep 2021 12:34:12 -0000 1.1.2.31 +++ openacs-4/packages/acs-tcl/tcl/01-database-procs.tcl 29 Nov 2021 14:33:46 -0000 1.1.2.32 @@ -2836,13 +2836,9 @@ set pgpass "<<$pgpass" } - # DRB: Submitted patch was in error - the driver opens a -h hostname connection - # unless the hostname is localhost. We need to do the same here. The submitted - # patch checked for a blank hostname, which fails in the driver. Arguably the - # driver's wrong but a lot of non-OpenACS folks use it, and even though I'm the - # maintainer we shouldn't break existing code over such trivialities... + # # GN: windows requires $pghost "-h ..." - + # if { ([db_get_dbhost] eq "localhost" || [db_get_dbhost] eq "") && $::tcl_platform(platform) ne "windows" } { @@ -2851,39 +2847,40 @@ set pghost "-h [db_get_dbhost]" } - set errno [catch { - cd [ad_file dirname $file] - set fp [open "|[file join [db_get_pgbin] psql] $pghost $pgport $pguser -f $file [db_get_database] $pgpass" "r"] - } errorMsg] + set dir [ad_file dirname $file] + set cmd "[file join [db_get_pgbin] psql] \ + $pghost $pgport $pguser \ + -f $file \ + [db_get_database] $pgpass" - if {$errno > 0} { + try { + if {[info commands proxy::exec] ne ""} { + ns_log notice [list ::proxy::exec -call $cmd -cd $dir] + ::proxy::exec -call $cmd -cd $dir + } { + set fp [open "|$cmd" r] + catch {set result [read $fp]} + close $fp + } + } on error {errorMsg} { set error_found 1 set error_lines $errorMsg - } else { - while { [gets $fp line] >= 0 } { - # Don't bother writing out lines which are purely whitespace. + } on ok {result} { + set error_found 0 + foreach line [split $result \n] { + # + # Don't bother writing out lines which are purely + # whitespace. + # if { ![string is space $line] } { apm_callback_and_log $callback "[ns_quotehtml $line]\n" } - } - - # PSQL dumps errors and notice information on stderr, and has no option to turn - # this off. So we have to chug through the "error" lines looking for those that - # really signal an error. - - set errno [ catch { - close $fp - } error] - - if { $errno == 2 } { - return $error - } - - # Just filter out the "NOTICE" lines, so we get the stack dump along with real - # ERRORs. This could be done with a couple of opaque-looking regexps... - - set error_found 0 - foreach line [split $error "\n"] { + # + # PSQL dumps errors and notice information on + # stderr, and has no option to turn this off. So + # we have to chug through the "error" lines + # looking for those that really signal an error. + # if { [string first NOTICE $line] == -1 } { append error_lines "$line\n" set error_found [expr { $error_found @@ -2892,7 +2889,7 @@ } } } - + ns_log notice "ERROR_FOUND=$error_found" if { $error_found } { return -code error -errorinfo $error_lines -errorcode $::errorCode $error_lines } Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -N -r1.189.2.104 -r1.189.2.105 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 4 Nov 2021 16:11:28 -0000 1.189.2.104 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 29 Nov 2021 14:33:47 -0000 1.189.2.105 @@ -3402,20 +3402,26 @@ close $old_fd close $new_fd + # # Diff output is 1 based, our lists are 0 based, so insert a dummy # element to start the list with. + # set old_w [linsert [split $old $split_by] 0 {}] set sv 1 - # For debugging purposes: - # set diff_pipe [open "| diff -f $old_f $new_f" "r"] - # while {![eof $diff_pipe]} { - # append res "[gets $diff_pipe]
" - # } - - set diff_pipe [open "| diff -f $old_f $new_f" "r"] - while {![eof $diff_pipe]} { - gets $diff_pipe diff + try { + exec -ignorestderr diff -f $old_f $new_f + } on error {output} { + } on ok {output} { + } + set lines [split $output \n] + set pos -1 + set nrLines [llength $lines] + while {1} { + if {$nrLines < $pos} { + break + } + set diff [lindex $lines [incr pos]] if {[regexp {^d(\d+)(\s+(\d+))?$} $diff full m1 m2]} { if {$m2 ne ""} {set d_end $m2} else {set d_end $m1} for {set i $sv} {$i < $m1} {incr i} { @@ -3433,8 +3439,11 @@ for {set i $m1} {$i <= $d_end} {incr i} { append res "${split_by}${start_old}[lindex $old_w $i]${end_old}" } - while {![eof $diff_pipe]} { - gets $diff_pipe diff + while {1} { + if {$nrLines < $pos} { + break + } + set diff [lindex $lines [incr pos]] if {$diff eq "."} { break } else { @@ -3447,8 +3456,11 @@ for {set i $sv} {$i < $m1} {incr i} { append res "${split_by}[lindex $old_w $i]" } - while {![eof $diff_pipe]} { - gets $diff_pipe diff + while {1} { + if {$nrLines < $pos} { + break + } + set diff [lindex $lines [incr pos]] if {$diff eq "."} { break } else {