Changeset 286


Ignore:
Timestamp:
Dec 4, 2009 5:03:31 PM (11 years ago)
Author:
toby
Message:

# on 2000/09/26 17:57:10, toby did:
change processing of ' & " for element symbol & element type
report error when a data name is used more than once in a block

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/import_cif.tcl

    • Property rcs:date changed from 2000/09/26 14:51:04 to 2000/09/26 17:57:10
    • Property rcs:lines changed from +155 -48 to +27 -4
    • Property rcs:rev changed from 1.2 to 1.3
    r285 r286  
    120120            lbl $lbllist uiso $uisolist occ $occlist type $typelist {
    121121        # should not be any quotes, but remove them, if there are
    122         regsub -all {'} $lbl {} lbl
    123         regsub -all {'} $type {} type
     122        foreach var {lbl type} {
     123            foreach char {' \"} {
     124                set q {\\}
     125                append q $char
     126                set hidden [regsub -all $q [set $var] \200 $var]
     127                if {[string index [set $var] 0] == $char} {
     128                    regsub -all $char [set $var] {} $var
     129                }
     130                if {$hidden} {regsub -all \200 [set $var] $char $var}
     131            }
     132        }
    124133        # CIF specifies types as Cu2+; GSAS uses Cu+2
    125134        if {[regexp {([A-Za-z]+)([1-9])([+-])} $type junk elem sign val]} {
     
    256265                # -- should not be needed for a valid CIF but if a name is used
    257266                # -- twice in the same block, want to wipe out the 1st data
    258                 set block${blocks}($dataname) {}
     267                catch {
     268                    if {[set block${blocks}($dataname)] != ""} {
     269                        # this is an error -- repeated data name
     270                        append block${blocks}(errors) \
     271                                "Data item $dataname is repeated near line $linenum\n"
     272                    }   
     273                    set block${blocks}($dataname) {}
     274                }
    259275                set dataname {}
    260276            } elseif {$loopflag > 0} {
     
    349365            append block${blocks}(errors) "The string \"$item\" on line $linenum was unexpected\n"
    350366        } else {
     367            catch {
     368                if {[set block${blocks}($dataname)] != ""} {
     369                    # this is an error -- repeated data name
     370                    append block${blocks}(errors) \
     371                            "Data item $dataname is repeated near line $linenum\n"
     372                }
     373            }
    351374            set block${blocks}($dataname) $item
    352375            set dataname ""
Note: See TracChangeset for help on using the changeset viewer.