Skip to content

Commit

Permalink
Merge branch 'v2.5_branch'
Browse files Browse the repository at this point in the history
  • Loading branch information
SebKuzminsky committed Mar 9, 2013
2 parents 724f269 + b5bca20 commit 6dfcae3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/hal/utils/halsh.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ Tcl_Interp *target_interp = NULL;
static int pending_cr = 0;

static void halError(Tcl_Interp *interp, int result) {
Tcl_SetResult(interp, strerror(-result), TCL_VOLATILE);
// Usually, halcmd leaves a good string message via halcmd_error()
// but just in case, fall back to using the result of the halcmd api call as
// a negative errno value...
if(!*Tcl_GetStringResult(interp))
Tcl_SetResult(interp, strerror(-result), TCL_VOLATILE);
}

static int refcount = 0;
Expand Down
24 changes: 20 additions & 4 deletions tcl/twopass.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ proc ::tp::prep_the_files {} {
verbose "convert $f to $::TP($f,tmp)"
hal_to_tcl $f $::TP($f,tmp)
lappend ::TP(runfiles) $::TP($f,tmp)
set ::TP(origfile,$::TP($f,tmp)) $f
}
default {return -code error \
"source_the_files:unknown file type <$suffix>"}
Expand All @@ -305,8 +306,13 @@ proc ::tp::hal_to_tcl {ifile ofile} {
set ::TP(conflictwords) {list gets}
# in a .tcl file, use "hal list" and "hal gets" instead

set fdin [open $ifile r]
set fdout [open $ofile w]
if [catch {set fdin [open $ifile r]
set fdout [open $ofile w]
} msg
] {
puts "twopass: Error: $msg"
exit 1
}
puts $fdout "# temporary tcl file generated by twopass.tcl"
set lno 0
while 1 {
Expand Down Expand Up @@ -356,7 +362,7 @@ proc ::tp::hal_to_tcl {ifile ofile} {
set line "$notcomment$comment"
}
puts $fdout $line
if {"$theline" != "$line"} {
if {[string trim "$theline"] != [string trim "$line"]} {
verbose "converted hal line for tcl from $ifile:"
verbose " hal: $theline"
verbose " tcl: $line"
Expand All @@ -370,7 +376,17 @@ proc ::tp::hal_to_tcl {ifile ofile} {
proc ::tp::source_the_files {} {
foreach f $::TP(runfiles) {
verbose "sourcing: $f"
source $f
set errct 0
if [catch {source $f} msg] {
if [info exists ::TP(origfile,$f)] {
set f $::TP(origfile,$f)
}
puts "twopass: Error in file $f:\n $msg"
incr errct
}
}
if {$errct} {
exit 1
}
} ;# source_the_files

Expand Down

0 comments on commit 6dfcae3

Please sign in to comment.