CifDataValueFormatter.cpp (pymol-v1.8.6.0.tar.bz2) | : | CifDataValueFormatter.cpp (pymol-v2.1.0.tar.bz2) | ||
---|---|---|---|---|
/* | /* | |||
* Cif export helper stuff | * Cif export helper stuff | |||
* | * | |||
* (c) 2016 Schrodinger, Inc. | * (c) 2016 Schrodinger, Inc. | |||
*/ | */ | |||
#include "os_std.h" | #include "os_std.h" | |||
#include "CifDataValueFormatter.h" | #include "CifDataValueFormatter.h" | |||
#include "strcasecmp.h" | ||||
#ifdef WIN32 | ||||
#define strcasecmp(s1, s2) _stricmp(s1, s2) | ||||
#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n) | ||||
#endif | ||||
/* | /* | |||
* Simplified whitespace test. Returns true if string `s` contains any character | * Simplified whitespace test. Returns true if string `s` contains any character | |||
* between 0x01 and 0x20 (this range contains all whitespace characters and | * between 0x01 and 0x20 (this range contains all whitespace characters and | |||
* no printable characters) | * no printable characters) | |||
*/ | */ | |||
static | static | |||
bool has_whitespace(const char * s) { | bool has_whitespace(const char * s) { | |||
for (; *s; ++s) | for (; *s; ++s) | |||
if (*s <= ' ') | if (*s <= ' ') | |||
skipping to change at line 50 | skipping to change at line 46 | |||
* Return true if `s` is a "simple data value" according to the CIF | * Return true if `s` is a "simple data value" according to the CIF | |||
* syntax specification | * syntax specification | |||
*/ | */ | |||
static | static | |||
bool cif_is_simpledatavalue(const char * s) { | bool cif_is_simpledatavalue(const char * s) { | |||
return ( | return ( | |||
// first character is special | // first character is special | |||
!strchr("_#$'\"[];", s[0]) && | !strchr("_#$'\"[];", s[0]) && | |||
// whitespace | // whitespace | |||
!has_whitespace(s) && | !has_whitespace(s) && | |||
// special values '.' (inapplicable) and '?' (unknown) | ||||
!((s[0] == '.' || s[0] == '?') && !s[1]) && | ||||
// prefix is special | // prefix is special | |||
strncasecmp("data_", s, 5) && | strncasecmp("data_", s, 5) && | |||
strncasecmp("save_", s, 5) && | strncasecmp("save_", s, 5) && | |||
// reserved words | // reserved words | |||
strcasecmp("loop_", s) && | strcasecmp("loop_", s) && | |||
strcasecmp("stop_", s) && | strcasecmp("stop_", s) && | |||
strcasecmp("global_", s)); | strcasecmp("global_", s)); | |||
} | } | |||
std::string & CifDataValueFormatter::nextbuf() { | std::string & CifDataValueFormatter::nextbuf() { | |||
End of changes. 2 change blocks. | ||||
5 lines changed or deleted | 3 lines changed or added |