Revision: 21297
          http://sourceforge.net/p/jmol/code/21297
Author:   hansonr
Date:     2016-12-02 13:01:31 +0000 (Fri, 02 Dec 2016)
Log Message:
-----------
Jmol.___JmolVersion="14.7.4_2016.12.02"

new feature: fully implemented CIF 2.0 reader

new feature: x = getProperty("cifInfo", "c:/temp/test.cif")
 -- reads CIF file data in structured format
 -- automatically uses CIF 1.0 or CIF 2.0, as needed.

Modified Paths:
--------------
    trunk/Jmol/src/javajs/util/CifDataParser.java
    trunk/Jmol/src/org/jmol/adapter/readers/cif/Cif2DataParser.java
    trunk/Jmol/src/org/jmol/viewer/Jmol.properties
    trunk/Jmol/src/org/jmol/viewer/PropertyManager.java

Modified: trunk/Jmol/src/javajs/util/CifDataParser.java
===================================================================
--- trunk/Jmol/src/javajs/util/CifDataParser.java       2016-12-02 05:30:58 UTC 
(rev 21296)
+++ trunk/Jmol/src/javajs/util/CifDataParser.java       2016-12-02 13:01:31 UTC 
(rev 21297)
@@ -857,49 +857,48 @@
   /**
    * CIF 1.0 only; we handle various quote types here 
    * @param ch
-   * @return true if this character is a (starting) qyuote
+   * @return true if this character is a (starting) quote
    */
   protected boolean isQuote(char ch) {
     switch (ch) {
     case '\'':
     case '\"':
     case '\1':
-    case '[':
       return  true;
     }
     return false;
   }
 
   /**
-   * CIF 1.0 only, with addition of SIMPLE arrays due to the fact that 
-   * the MagCIF format includes one data value of that type even though it is 
not a CIF 2.0 file.
+   * CIF 1.0 only. 
    * 
-   * This is just a rudimentary hack to allow simple [....] in  magCIF files.
-   * See Cif2DataParser for the real thing.
    *  
    * @param ch current character being pointed to
    * @return a String data object
    */
   protected Object getQuotedStringOrObject(char ch) {
     int ichStart = ich;
-    boolean isArray = (ch  == '[');
-    char chClosingQuote = (isArray ? ']' : ch);
+    char chClosingQuote = ch;
     boolean wasQuote = false;
     while (++ich < cch) {
       ch = str.charAt(ich);
-      // CIF 1.0 rules require that the closing ' or ""  be followed by space 
or tab 
+      // CIF 1.0 rules require that the closing ' or ""  be followed by space 
or tab or EOL
       if (wasQuote && (ch == ' ' || ch == '\t'))
         break;
       wasQuote = (ch == chClosingQuote);
     }
-    if (ich == cch || isArray) {
-      if (wasQuote && !isArray) // close quote was last char of string
-        return str.substring(ichStart + 1, ich - 1);
-      // reached the end of the string without finding closing ', or we have 
[...]
-      return str.substring(ichStart, ich);
+    int pt1 = ichStart + 1;
+    int pt2 = ich - 1;
+    if (ich == cch && !wasQuote) {
+      // reached the end of the string without finding closing '
+      // so take the whole thing. Probably a bad CIF file.
+      pt1--;
+      pt2++;
+    } else {
+      // throw away the last white character
+      ++ich; 
     }
-    ++ich; // throw away the last white character
-    return str.substring(ichStart + 1, ich - 2);
+    return str.substring(pt1, pt2);
   }
 
   

Modified: trunk/Jmol/src/org/jmol/adapter/readers/cif/Cif2DataParser.java
===================================================================
--- trunk/Jmol/src/org/jmol/adapter/readers/cif/Cif2DataParser.java     
2016-12-02 05:30:58 UTC (rev 21296)
+++ trunk/Jmol/src/org/jmol/adapter/readers/cif/Cif2DataParser.java     
2016-12-02 13:01:31 UTC (rev 21297)
@@ -3,8 +3,6 @@
 import java.util.Hashtable;
 import java.util.Map;
 
-import org.jmol.util.Logger;
-
 import javajs.util.CifDataParser;
 import javajs.util.Lst;
 import javajs.util.PT;
@@ -158,8 +156,17 @@
 //
 // 
 
-  
+
   /**
+   * There is no need to convert to unicode in CIF 2.0.
+   * 
+   */
+  @Override
+  public String toUnicode(String data) {
+    return data;
+  }
+
+  /**
    * Includes all possible operator tokens
    */
   @Override

Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2016-12-02 05:30:58 UTC 
(rev 21296)
+++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties      2016-12-02 13:01:31 UTC 
(rev 21297)
@@ -47,16 +47,13 @@
  -- sets the echo offset to a specific screen pixel offset
  -- TODO not saved in state
 
-Jmol.___JmolVersion="14.7.4_2016.12.01"
+Jmol.___JmolVersion="14.7.4_2016.12.02"
 
 new feature: fully implemented CIF 2.0 reader
 
 new feature: x = getProperty("cifInfo", "c:/temp/test.cif")
  -- reads CIF file data in structured format
  -- automatically uses CIF 1.0 or CIF 2.0, as needed.
-
-new feature: CIF reader allows for nonstandard [ .... ] array notation in CIF 
1.0 files
- -- returned as an unaltered string for CIF 1.x; JSON string in CIF 2.x 
  
 JmolVersion="14.7.4_2016.11.28"
 

Modified: trunk/Jmol/src/org/jmol/viewer/PropertyManager.java
===================================================================
--- trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2016-12-02 05:30:58 UTC 
(rev 21296)
+++ trunk/Jmol/src/org/jmol/viewer/PropertyManager.java 2016-12-02 13:01:31 UTC 
(rev 21297)
@@ -174,7 +174,7 @@
     "domainInfo"  , atomExpression, "{visible}",
     "validationInfo"  , atomExpression, "{visible}",
     "service"    , "<hashTable>", "",
-    "CIFInfo"        , "<filename>", "_modelFile",
+    "CIFInfo"        , "<filename>", "",
 
   };
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Jmol-commits mailing list
Jmol-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-commits

Reply via email to