Changeset 8d687fe in tol


Ignore:
Timestamp:
Feb 13, 2012, 5:41:00 PM (15 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
1053ab7
Parents:
ab6d232
Message:

fixes #994, refs #1404,

  • using tol::checksyntax
  • before invoking tol::checksyntax it is changed the cwd to the directory containing the file checked

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@4126 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tolbase/lib/toltk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tolbase/lib/toltk/bystext.tcl

    rab6d232 r8d687fe  
    795795
    796796#/////////////////////////////////////////////////////////////////////////////
    797 proc ::BayesText::TolSyntaxCheck {editor} {
     797proc ::BayesText::TolSyntaxCheck { editor {dir ""} } {
    798798#/////////////////////////////////////////////////////////////////////////////
    799799  global toltk_script_path
    800   # guardamos el archivo en un temporal
    801   set path [file join $::env(HOME) __check__.tol]
    802   set texto [GetSelectionOrAll $editor]
    803   set ok [::BayesText::SaveTxt $texto $path]
    804   if {$ok} {
    805     # evaluamos el archivo
    806     set check [TolFileSyntaxCheck $path]
    807     if {[lindex $check 0]} {
    808       tk_messageBox -type ok -icon info -title [mc "Syntax Check"] -parent $editor \
    809         -message [mc "Syntax check done successfully"]
    810     } else  {
    811       # hay errores
    812           #puts "TolSyntaxCheck (hay errores)"
    813       ShowSyntaxErrors $editor [lindex $check 1]
    814     }
    815     # borrar el archivo
    816     catch "file delete $path" error
    817   } else  {
    818     tk_messageBox -type ok -icon warning -title [mc Editor] -parent $editor \
    819                 -message [mc "Syntax check cannot be done"]
    820   }
     800
     801  set buffer [ GetSelectionOrAll $editor ]
     802  if { $dir ne "" } {
     803    set cwd [ pwd ]
     804    cd $dir
     805  }
     806
     807  if { [ catch { tol::checksyntax $buffer } check ] } {
     808    Tolcon_Trace "within ::BayesText::TolSyntaxCheck($editor,$dir): $check"
     809    return 0
     810  }
     811  set check [ string trim $check ]
     812  if { $check eq "" } {
     813    tk_messageBox -type ok -icon info -title [mc "Syntax Check"] \
     814        -parent $editor -message [mc "Syntax check done successfully"]
     815  } else {
     816    ShowSyntaxErrors $editor $check
     817  }
     818  return 1
    821819}
    822820
  • tolbase/lib/toltk/editor.tcl

    rab6d232 r8d687fe  
    15711571#///////////////////////////////////////////////////////////////////////////// 
    15721572  upvar \#0 ${this}::data data
    1573   ::BayesText::TolSyntaxCheck $data(txt)
     1573  ::BayesText::TolSyntaxCheck $data(txt) [ file dir $data(nameFile) ]
    15741574}
    15751575
Note: See TracChangeset for help on using the changeset viewer.