int minscanf(char *fmt, ...) { int c, cnt = 0; va_list ap; char *p; int *intp; char inputstr[MAXWORD]; char d[MAXWORD]; char *dp, *argsp; char *sp = inputstr; while ((c = getchar()) != EOF && c != '\n') *sp++ = c; *sp = '\0'; sp = inputstr; va_start(ap, fmt); for (p = fmt; *p; p++) { if (*p != '%') { continue; } switch (*++p) { case 'd': intp = va_arg(ap, int *); dp = d; while (_isspace(*sp)) sp++; while (_isdigit(*sp)) *dp++ = *sp++; *dp = '\0'; *intp = _atoi(d); cnt++; break; case 's': argsp = va_arg(ap, char *); while (_isspace(*sp)) sp++; while (!_isspace(*sp)) *argsp++ = *sp++; *argsp = '\0'; cnt++; break; default: break; } } va_end(ap); return cnt; }
bool SVGPathTokenizer::next(std::string &output) { if (m_ipos < m_path.length()) { // Scan forward to first non-space character while (m_ipos < m_path.length() && _isspace(m_path.at(m_ipos))) { m_ipos++; } int start = m_ipos; char c = m_path.at(start); if (_isctrl(c)) { output = m_path.substr(start, 1); m_ipos++; return true; } if (_isnumber(c)) { while (m_ipos < m_path.length() && _isnumber(m_path.at(m_ipos))) { m_ipos++; }; int end = m_ipos; output = m_path.substr(start, end-start); m_ipos++; return true; } } return false; }
int my_htoi(const char * const s) { //int neg = 0; if (s == NULL) return 0; char* cur = (char*)s; while(*cur != '\0' && _isspace(*cur)) { cur++; } if (*cur++ == '0' && (*cur == 'x' || *cur == 'X')) { cur++; } else { // backtrack cur--; } int acc = 0; while(*cur != '\0' && (_isdigit(*cur) || _isvalidchar(*cur))) { acc = acc * 16 + convert(*cur); //printf("acc = %x \n", acc); ++cur; } if (*cur != '\0') acc = 0; return acc; }
double _atof( const char * src ) { double _integer = 0.0; double _minority = 0.0; double _set = 1; double mark = 1; while (_isspace(*src)) src++; if (*src == '-') mark = -1, src++; else if(*src == '+') src++; while (*src && _isnumeric(*src)) _integer = (_integer * 10) + (*src++ & 0xf); if (*src == '.') src++; while (*src && _isnumeric(*src)) _minority = (_minority * 10) + (*src++ & 0xf), _set *= 0.1; return mark * (_integer + _minority * _set); }
Boolean XmlParser::_getOpenElementName( char*& p, const char*& localName, Boolean& openCloseElement) { openCloseElement = false; if (!_getQName(p, localName)) throw XmlException(XmlException::BAD_START_TAG, _line); // The next character must be a space: if (_isspace(*p)) { *p++ = '\0'; _skipWhitespace(_line, p); } if (*p == '>') { *p++ = '\0'; return true; } if (p[0] == '/' && p[1] == '>') { openCloseElement = true; *p = '\0'; p += 2; return true; } return false; }
int isspace(int c) { #if !CAM_DRYOS return _isspace(c); #else return _ctype(c,_S); #endif }
unsigned long _strtoul_t( const char *nptr, char **endptr, register int base ) { register const char *s = nptr; register unsigned long acc; register int c; register unsigned long cutoff; register int neg = 0, any, cutlim; do { c = *s++; } while (_isspace(c)); if (c == '-') { neg = 1; c = *s++; } else if (c == '+') c = *s++; if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) { c = s[1]; s += 2; base = 16; } if (base == 0) base = c == '0' ? 8 : 10; cutoff = neg ? (~((unsigned long)_LONG_MIN)+1) : _LONG_MAX; cutlim = cutoff % (unsigned long)base; cutoff /= (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { if (_isdigit(c)) c -= '0'; else if (_isalpha(c)) c -= _to_upper(c) & 0xf + 10; else break; if (c >= base) break; if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; acc *= base; acc += c; } } if (any < 0) { acc = neg ? _LONG_MIN : _LONG_MAX; } else if (neg) acc = ~acc+1; if (endptr != 0) *endptr = (char *) (any ? s - 1 : nptr); return (acc); }
inline int Tag::getQuotedValue (_char *&pStr, _char **pValue, bool bSetNull) { while ((pStr < m_pStrEnd) && _isspace (*pStr)) { pStr++; } if (pStr >= m_pStrEnd) { return -1; } if ('"' == *pStr || '\'' == *pStr) { _char wideQuote = *pStr; pStr++; if (pStr >= m_pStrEnd) return -1; *pValue = pStr; while ((pStr < m_pStrEnd) && *pStr != wideQuote) { pStr++; } if (bSetNull) { *pStr = '\0'; } pStr++; return 0; } else { *pValue = pStr; while ((pStr < m_pStrEnd) && !_isspace (*pStr)) { pStr++; } if (bSetNull) { *pStr = '\0'; } pStr++; return 0; } }
inline void _skipWhitespace(Uint32& line, char*& p) { while (*p && _isspace(*p)) { if (*p == '\n') line++; p++; } }
//***************************************************************************** // Lex::IsSpaceNextChar - checks is the next character space and skip it if // true; correctly deals with the lines' counter. // Returns : 1 if space character, 0 otherwise. //***************************************************************************** int Lex::IsSpaceNextChar( void ) { QChar ch = NextChar(); if( _isspace( ch ) ) return 1; else { PutBack(); return 0; } }
static void _findEnds( const char* str, const char*& first, const char*& last) { first = str; while (_isspace(*first)) first++; if (!*first) { last = first; return; } last = first + strlen(first); while (last != first && _isspace(last[-1])) last--; }
int _ltrim( char *str ) { int str_len = strlen( str ); int cur_len = 0; while ( cur_len < str_len ) { if ( _isspace( str[cur_len] ) ) { cur_len++; continue; } strcpy( str, &str[cur_len] ); break; } return cur_len; }
Boolean XmlParser::_getElementName(char*& p, const char*& localName) { if (!_getQName(p, localName)) throw XmlException(XmlException::BAD_START_TAG, _line); // The next character must be a space: if (_isspace(*p)) { *p++ = '\0'; _skipWhitespace(_line, p); } if (*p == '>') { *p++ = '\0'; return true; } return false; }
_CODE_ACCESS int atoi(const char *st) { int result = 0; char cp; int sign; while (_isspace(*st)) ++st; /* SKIP WHITE SPACE */ if (sign = ((cp = *st) == '-')) cp = *++st; else if (cp == '+') cp = *++st; while (_isdigit(cp)) { result *= 10; result += cp - '0'; cp = *++st; } if (sign) result *= -1; return result; }
int _rtrim( char *str ) { int str_len = 0; int cur_len = 0; while ( true ) { str_len = strlen( str ); if ( str_len && _isspace( str[str_len - 1] ) ) { str[str_len - 1] = '\0'; cur_len++; } else { break; } } return cur_len; }
long _atol( const char * src ) { #ifndef USING_DEVICE_FLAG_STRINGH long int_str = 0; long mark = 1; while (_isspace(*src)) src++; if (*src == '-') mark = -1, src++; else if(*src == '+') src++; while (*src && _isnumeric(*src)) int_str = (int_str * 10) + (*src++ & 0xf); return mark * int_str; #else return (long) _strtol_t (src, (char **) NULL, 10); #endif }
static unsigned long _strtoxl_asc( const char *nptr, char **endptr, register int base, int flags ) { register const char *n_ptr = nptr; register char c; register unsigned long number = 0; register unsigned digval; register unsigned long maxval; c = *n_ptr++; while (_isspace(*n_ptr)) c = *n_ptr++; if (c == '-') { flags |= FL_NEG; c = *n_ptr++; } else if(c == '+') c = *n_ptr++; if(base < 0 || base > 36 || base == 1) { if (endptr) *endptr = nptr; return 0L; } else if(base == 0) { if (c != '0') base = 10; else if (*n_ptr == 'x' || *n_ptr == 'X') base = 16; else base = 8; } else if (base == 16) { if (c == '0' && (*n_ptr == 'x' || *n_ptr == 'X')) { ++n_ptr; c = *n_ptr++; } } maxval = _ULONG_MAX / base; for (;;) { if (_isdigit((int)(unsigned char)c)) digval = c - '0'; else if (_isalpha((int)(unsigned char)c)) digval = _to_upper(c) & 0xf + 10; else break; if (digval >= (unsigned)base) break; flags |= FL_READDIGIT; if (number < maxval || (number == maxval && (unsigned long)digval <= _ULONG_MAX %base)) { number = number * base + digval; } else { flags |= FL_OVERFLOW; if (endptr == _NULL) break; } c = *n_ptr++; } --n_ptr; if (!(flags & FL_READDIGIT)) { if (endptr) n_ptr = nptr; number = 0L; } else if ((flags & FL_OVERFLOW) || (!(flags & FL_UNSIGNED) && (((flags & FL_NEG) && (number > -_LONG_MIN)) || (!(flags & FL_NEG) && (number > _LONG_MAX))))) { if (flags & FL_UNSIGNED) number = _ULONG_MAX; else if (flags & FL_NEG) number = (unsigned long)(-_LONG_MIN); else number = _LONG_MAX; } if (endptr != _NULL) *endptr = n_ptr; if (flags & FL_NEG) number = (unsigned long)(-(long)number); return number; }
void XmlParser::_getElement(char*& p, XmlEntry& entry) { //-------------------------------------------------------------------------- // Get the element name (expect one of these: '?', '!', [A-Za-z_]) //-------------------------------------------------------------------------- if (*p == '?') { entry.type = XmlEntry::XML_DECLARATION; entry.text = ++p; if (_getElementName(p, entry.localName)) return; } else if (*p == '!') { p++; // Expect a comment or CDATA: if (p[0] == '-' && p[1] == '-') { p += 2; entry.type = XmlEntry::COMMENT; entry.text = p; _getComment(p); return; } else if (memcmp(p, "[CDATA[", 7) == 0) { p += 7; entry.type = XmlEntry::CDATA; entry.text = p; _getCData(p); entry.textLen = strlen(entry.text); return; } else if (memcmp(p, "DOCTYPE", 7) == 0) { entry.type = XmlEntry::DOCTYPE; entry.text = ""; _getDocType(p); return; } throw(XmlException(XmlException::EXPECTED_COMMENT_OR_CDATA, _line)); } else if (*p == '/') { entry.type = XmlEntry::END_TAG; entry.text = ++p; if (!_getElementName(p, entry.localName)) throw(XmlException(XmlException::BAD_END_TAG, _line)); return; } else if (CharSet::isAlphaUnder(Uint8(*p))) { entry.type = XmlEntry::START_TAG; entry.text = p; Boolean openCloseElement = false; if (_getOpenElementName(p, entry.localName, openCloseElement)) { if (openCloseElement) entry.type = XmlEntry::EMPTY_TAG; return; } } else throw XmlException(XmlException::BAD_START_TAG, _line); //-------------------------------------------------------------------------- // Grab all the attributes: //-------------------------------------------------------------------------- for (;;) { if (entry.type == XmlEntry::XML_DECLARATION) { if (p[0] == '?' && p[1] == '>') { p += 2; return; } } else if (entry.type == XmlEntry::START_TAG && p[0] == '/' && p[1] =='>') { entry.type = XmlEntry::EMPTY_TAG; p += 2; return; } else if (*p == '>') { p++; return; } XmlAttribute attr; attr.nsType = -1; attr.name = p; _getAttributeNameAndEqual(p, attr.localName); // Get the attribute value (e.g., "some value") { if ((*p != '"') && (*p != '\'')) { throw XmlException(XmlException::BAD_ATTRIBUTE_VALUE, _line); } char quote = *p++; char* start; _normalizeAttributeValue(_line, p, quote, start); attr.value = start; if (*p != quote) { throw XmlException(XmlException::BAD_ATTRIBUTE_VALUE, _line); } // Overwrite the closing quote with a null-terminator: *p++ = '\0'; } if (entry.type == XmlEntry::XML_DECLARATION) { // The next thing must a space or a "?>": if (!(p[0] == '?' && p[1] == '>') && !_isspace(*p)) { throw XmlException( XmlException::BAD_ATTRIBUTE_VALUE, _line); } } else if (!(*p == '>' || (p[0] == '/' && p[1] == '>') || _isspace(*p))) { // The next thing must be a space or a '>': throw XmlException(XmlException::BAD_ATTRIBUTE_VALUE, _line); } _skipWhitespace(_line, p); entry.attributes.append(attr); } }
int _isnspace( int ch ) { return !_isspace(ch); }
CFormulaNode* CLineNode::InsertMMLFormulaNode_MFENCED( AST_TXML_Tag *node ) { AST_TXML_Attribute *_attr; QString attr_open, attr_close, b_attr_separator, attr_separator = _T(""); long i; //=== 'open', 'close' and 'separator' attributes (or their defaults) _attr = node->getAttribute( FBL_ATTR_open ); attr_open = ::formatBlankAsXML( _attr ? _attr->getStringValue() : FBL_VAL_DEFAULT_mfenced_open ); _attr = node->getAttribute( FBL_ATTR_close ); attr_close = ::formatBlankAsXML( _attr ? _attr->getStringValue() : FBL_VAL_DEFAULT_mfenced_close ); _attr = node->getAttribute( FBL_ATTR_separators ); if( node->getTags() && node->getTags()->getChildNumber() == 1 && node->getTags()->getChild( 0 ) && node->getTags()->getChild( 0 )->getNodeType() == ASTT_TXML_Tag ) { QString fid = _T(""); if( ::isXMLSymbol__BracketL( attr_open ) && ::isXMLSymbol__BracketR( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_LR; else if( ::isXMLSymbol__BracketLB( attr_open ) && ::isXMLSymbol__BracketRB( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_LRB; else if( ::isXMLSymbol__BracketLF( attr_open ) && ::isXMLSymbol__BracketRF( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_LRF; else if( ::isXMLSymbol__BracketLA( attr_open ) && ::isXMLSymbol__BracketRA( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_LRA; else if( ::isXMLSymbol__BracketVerBar( attr_open ) && ::isXMLSymbol__BracketVerBar( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_ABS; else if( ::isXMLSymbol__BracketDblVerBar( attr_open ) && ::isXMLSymbol__BracketDblVerBar( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_NORM; else if( ::isXMLSymbol__BracketLFloor( attr_open ) && ::isXMLSymbol__BracketRFloor( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_FLOOR; else if( ::isXMLSymbol__BracketLCeil( attr_open ) && ::isXMLSymbol__BracketRCeil( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_CEIL; else if( attr_close.length() == 0 ) { if( ::isXMLSymbol__BracketL( attr_open ) ) fid = HF_BTNID_DEFAULT_BRACKET_L; else if( ::isXMLSymbol__BracketLB( attr_open ) ) fid = HF_BTNID_DEFAULT_BRACKET_LB; else if( ::isXMLSymbol__BracketLF( attr_open ) ) fid = HF_BTNID_DEFAULT_BRACKET_LF; else if( ::isXMLSymbol__BracketLA( attr_open ) ) fid = HF_BTNID_DEFAULT_BRACKET_LA; else if( ::isXMLSymbol__BracketVerBar( attr_open ) ) fid = HF_BTNID_DEFAULT_BRACKET_ABS_L; else if( ::isXMLSymbol__BracketDblVerBar( attr_open ) ) fid = HF_BTNID_DEFAULT_BRACKET_NORM_L; } else if( attr_open.length() == 0 ) { if( ::isXMLSymbol__BracketR( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_R; else if( ::isXMLSymbol__BracketRB( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_RB; else if( ::isXMLSymbol__BracketRF( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_RF; else if( ::isXMLSymbol__BracketRA( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_RA; else if( ::isXMLSymbol__BracketVerBar( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_ABS_R; else if( ::isXMLSymbol__BracketDblVerBar( attr_close ) ) fid = HF_BTNID_DEFAULT_BRACKET_NORM_R; } CFormulaNode *r; if( fid.length() && (r = InsertMMLFormulaNode_OTHERS_byID( fid, node )) != 0 ) return r; } b_attr_separator = _attr ? _attr->getStringValue() : FBL_VAL_DEFAULT_mfenced_separator; for( i = 0; i < (long) b_attr_separator.length(); i++ ) if( !_isspace( b_attr_separator.at(i) ) ) attr_separator += b_attr_separator.at(i); AST_TXML_Compound *_tags = new AST_TXML_Compound(); AST_TXML_Compound *_a; AST_TXML_Value *_v; AST_TXML_Compound *_innner_tags = new AST_TXML_Compound(); AST_TXML_Tag *node_inner_mrow; _a = new AST_TXML_Compound(); _a->Add( new AST_TXML_Attribute( &fenceV, &trueV ) ); QString sV( attr_open ), s2V( attr_close ); _v = new AST_TXML_Value( &sV ); _tags->Add( new AST_TXML_Tag( &moV, _a, _v ) ); _tags->Add( node_inner_mrow = new AST_TXML_Tag( &mrowV, 0, _innner_tags ) ); _a = new AST_TXML_Compound(); _a->Add( new AST_TXML_Attribute( &fenceV, &trueV ) ); _v = new AST_TXML_Value( &s2V ); _tags->Add( new AST_TXML_Tag( &moV, _a, _v ) ); std::vector<long> loan; if( node->getTags() && node->getTags()->getChildNumber() ) { if( attr_separator.length() && ((long) attr_separator.length()) < node->getTags()->getChildNumber() - 1 ) attr_separator.append( QString( node->getTags()->getChildNumber() - 1 - attr_separator.length(), attr_separator.at(attr_separator.length() - 1) ) ); for( i = 0; i < node->getTags()->getChildNumber() - 1; i++ ) { loan.push_back( _innner_tags->Add( node->getTags()->getChild( i ) ) ); if( i < (long) attr_separator.length() ) { _a = new AST_TXML_Compound(); _a->Add( new AST_TXML_Attribute( &separatorV, &trueV ) ); QString s3V(1, attr_separator.at(i)); _v = new AST_TXML_Value( &s3V ); _innner_tags->Add( new AST_TXML_Tag( &moV, _a, _v ) ); } } loan.push_back( _innner_tags->Add( node->getTags()->getChild( i ) ) ); } AST_TXML_Tag *node_mrow = new AST_TXML_Tag( &mrowV, 0, _tags ); node_mrow->mode.setFlag(OLIMP_MATHML_FLAG__MROW_KEEP1CHILD); CFormulaNode *_node = InsertMMLFormulaNode( node_mrow ); for( i = 0; i < (long) loan.size(); i++ ) _innner_tags->ReplaceChild( loan[ i ], 0 ); delete node_mrow; return _node; }
_CODE_ACCESS long double strtold(const char *st, char **endptr) { long double result = 0.0L; char cp; const char *fst = st; int exp = 0; /* EXPONENT */ int count; /* EXPONENT CALCULATION */ int value = 0; /* SUCCESSFUL PARSE */ int sign; int plus_or_minus = 0; /* READ IN EXPONENT SIGN (+/-) */ while (_isspace(*fst)) ++fst; /* SKIP WHITE SPACE */ if ((sign = ((cp = *fst) == '-')) || (cp == '+')) { ++fst; value = 1; } /*----------------------------------------------------------------------*/ /* READ IN FRACTIONAL PART OF NUMBER, UNTIL AN 'E' IS REACHED. */ /* COUNT DIGITS AFTER DECIMAL POINT. */ /*----------------------------------------------------------------------*/ for (; _isdigit(cp = *fst); ++fst) { result = result * 10 + digits[cp - '0']; value = 1; } if (cp == '.') { while (_isdigit(cp = *++fst)) { result = result * 10 + digits[cp - '0']; value = 1; --exp; } } if (sign) result = -result; /* IF NEGATIVE NUMBER, REVERSE SIGN */ /*----------------------------------------------------------------------*/ /* READ IN EXPLICIT EXPONENT AND CALCULATE REAL EXPONENT. */ /* IF EXPONENT IS BOGUS (i.e. "1.234empty" or "1.234e+mpty") RESTORE */ /* BOGUS EXPONENT BACK ONTO RETURNED STRING (endptr). */ /*----------------------------------------------------------------------*/ if (value && _toupper(*fst) == 'E') { if ((sign = ((cp = *++fst) == '-')) || (cp == '+')) { cp = *++fst; plus_or_minus = 1; } if (!_isdigit(cp)) { if (plus_or_minus) *--fst; *--fst; goto skip_loop; } for (count = 0; _isdigit(cp); cp = *++fst) { if ((INT_MAX - abs(exp) - (cp - '0')) / 10 > count) { count *= 10; count += cp - '0'; } else { count = INT_MAX - exp; break; } } skip_loop: if (sign) exp -= count; else exp += count; } /*----------------------------------------------------------------------*/ /* ADJUST NUMBER BY POWERS OF TEN SPECIFIED BY FORMAT AND EXPONENT. */ /*----------------------------------------------------------------------*/ if (result != 0.0) { if (exp > LDBL_MAX_10_EXP) { errno = ERANGE; result = (result < 0) ? -HUGE_VALL : HUGE_VALL; } else if (exp < LDBL_MIN_10_EXP) { errno = ERANGE; result = 0.0; } else if (exp < 0) { for (count = 0, exp = -exp; exp; count++, exp >>= 1) { if (exp & 1) result /= powerof10[count]; } } else { for (count = 0; exp; count++, exp >>= 1) { if (exp & 1) result *= powerof10[count]; } } }
/*call by main*/ int next_cmd(char *out_cmd) { unsigned char c = 0; int key_no = 0; int seq_char = 0; int str_valid = 0; /*set terminal new attrib */ term_config(); /*termial initial */ term_init(out_cmd); /*main loop */ while ((c = getc(stdin)) != '\n') { key_no = 0; seq_char = 0; if (!_isspace(c)) { str_valid = 1; } if (c == 27) { /*escape sequence */ if ((c = getc(stdin)) == '[' || c == 'O') { c = getc(stdin); seq_char = 1; } } /*search for bind key handle function */ while (key_no < sizeof (key_bind) / sizeof (key_bind[0])) { if ((seq_char == key_bind[key_no].is_eseq) && (c == key_bind[key_no].key_last)) { key_bind[key_no].func(); break; } key_no++; } if (key_no == sizeof (key_bind) / sizeof (key_bind[0])) handle_normal(out_cmd, c); } /*handle enter when at the end of a line */ if (term_cursor) putchar('\n'); /* record command history without '\n' */ history_record(out_cmd); #if 0 /* add '\n' to out_cmd */ if (str_valid) { out_cmd[cmd_strlen++] = '\n'; } else { cmd_strlen = 0; out_cmd[cmd_strlen++] = '\n'; } if (cmd_strlen > 1 && out_cmd[cmd_strlen - 1] == '\n') out_cmd[cmd_strlen - 1] = 0; #else if (!str_valid) cmd_strlen = 0; #endif /*retore terminal to orginal status */ term_restore(); fflush(stdout); return cmd_strlen; }
_CODE_ACCESS unsigned long strtoul(const char *st, char **endptr, int base) { register unsigned long result = 0; register char cp; register const char *fst = st; int digits = 0; int minus = 0; while (_isspace(*fst)) ++fst; /* SKIP WHITE SPACE */ if (base > 36) base = 0; if ((cp = *fst) == '+') cp = *++fst; else if ((cp = *fst) == '-') { cp = *++fst; minus = 1; } /*-------------------------------------------------------------------*/ /* DETERMINE BASE IF ZERO BASE ASKED FOR. */ /*-------------------------------------------------------------------*/ switch (base) { case 0 : if (cp != '0') base = 10; else if ((cp = *++fst) == 'x' || cp == 'X') if (_isxdigit(fst[1])) { base = 16; cp = *++fst; } else { base = 10; cp = *--fst; } else { base = 8; if (cp < '0' || cp > '7') cp = *--fst; } break; case 16 : if (cp == '0' && ((fst[1] == 'x') || (fst[1] == 'X')) && _isxdigit(fst[2])) cp = *(fst += 2); } /*-------------------------------------------------------------------*/ /* CONVERT THE NUMBER USING THE SPECIFIED BASE. */ /*-------------------------------------------------------------------*/ for (;; cp = *++fst) { register unsigned long addval; if (!((_isdigit(cp) && (addval = cp - '0') < base) || (_isupper(cp) && (addval = cp - 'A' + 10) < base) || (_islower(cp) && (addval = cp - 'a' + 10) < base))) break; if (result == (addval = (result * base + addval))/base) result = addval; else { errno = ERANGE; if (endptr) *endptr = (char *)st; return ULONG_MAX; } digits++; } /*-------------------------------------------------------------------*/ /* MARK THE END OF THE CONVERTED INPUT. */ /*-------------------------------------------------------------------*/ if (endptr) *endptr = (char *)(digits ? fst : st); return minus ? -result : result; }
int isspace(int c) { return _isspace(c); }
int Tag::parseTag (_char *pTagString, bool bParseAttributes) { _char *pTmpStr = pTagString; while ((pTmpStr < m_pStrEnd) && _isspace (*pTmpStr)) { pTmpStr++; } if (*pTmpStr == SLASH) { m_bEndTag = true; pTmpStr++; } while ((pTmpStr < m_pStrEnd) && _isspace (*pTmpStr)) { pTmpStr++; } m_pName = pTmpStr; while ((pTmpStr < m_pStrEnd) && !_isspace(*pTmpStr)) { if (*pTmpStr == SLASH) { m_bSelfClosing = true; *pTmpStr = NULLCHAR; } else { *pTmpStr = _tolower (*pTmpStr); } pTmpStr++; } if (pTmpStr < m_pStrEnd) { *pTmpStr = NULLCHAR; pTmpStr++; } while ((pTmpStr < m_pStrEnd) && _isspace (*pTmpStr)) { pTmpStr++; } if ((pTmpStr < m_pStrEnd)) { _char *pSelfClosing = pTmpStr; while ((pSelfClosing + 1) < m_pStrEnd) { pSelfClosing++; } while (_isspace (*pSelfClosing)) { pSelfClosing--; } if (SLASH == *pSelfClosing) { m_bSelfClosing = true; *pSelfClosing = NULLCHAR; } m_pTagAttrString = pTmpStr; if (bParseAttributes) { parseAttributes (pTmpStr); } } return 0; }
static inline void _normalizeElementValue( Uint32& line, char*& p, Uint32 &textLen) { // Process one character at a time: char* q = p; char *start = p; while (*p && (*p != '<')) { if (_isspace(*p)) { // Trim whitespace from the end of the value, but do not compress // whitespace within the value. const char* start = p; if (*p++ == '\n') { line++; } _skipWhitespace(line, p); if (*p && (*p != '<')) { // Transfer internal whitespace to q without compressing it. const char* i = start; while (i < p) { *q++ = *i++; } } else { // Do not transfer trailing whitespace to q. break; } } else if (*p == '&') { // Process an entity reference or a character reference. *q++ = _getRef(line, ++p); } else { *q++ = *p++; } } // If q got behind p, it is safe and necessary to null-terminate q if (q != p) { *q = '\0'; } textLen = (Uint32)(q - start); }
static inline void _normalizeAttributeValue( Uint32& line, char*& p, char end_char, char*& start) { // Skip over leading whitespace: _skipWhitespace(line, p); start = p; // Process one character at a time: char* q = p; while (*p && (*p != end_char)) { if (_isspace(*p)) { // Compress sequences of whitespace characters to a single space // character. Update line number when newlines encountered. if (*p++ == '\n') { line++; } *q++ = ' '; _skipWhitespace(line, p); } else if (*p == '&') { // Process an entity reference or a character reference. *q++ = _getRef(line, ++p); } else { *q++ = *p++; } } // Remove single trailing whitespace (consecutive whitespaces already // compressed above). Since p >= q, we can tell if we need to strip a // trailing space from q by looking at the end of p. We must not look at // the last character of p, though, if p is an empty string. Boolean adjust_q = (p != start) && _isspace(p[-1]); // We encountered a the end_char or a zero-terminator. *q = *p; if (adjust_q) { q--; } // If q got behind p, it is safe and necessary to null-terminate q if (q != p) { *q = '\0'; } }
_CODE_ACCESS int isspace(int c) { return(_isspace(c)); }
char *_costume_get_string(const pcostumestrx cxstrlist, const pcostumex cxlist, const CHAR *target, const CHAR *format) { char *ret = (char *) malloc (sizeof(char) * 1024); char *ptr = ret, *tmpptr, *tarptr; char tmp; char _temp[20] = {0,}; // find temp u32 inttmp; int count; pcostumex costmp; pcostumestrx cosstrtmp; BOOL not; #define CONDITION(x) ((x) && not) || (!(x) && !not) tarptr = target; _costume_ict = format; zeroset(ret, sizeof(char) * 1024); do { switch(*_costume_ict++) { case '+': // add variable to ret switch(*_costume_ict++) { case _COTM_VARIABLE: for (count = 0; _isalnumub((int)(*_costume_ict)); _costume_ict++, count++) _temp[count] = *_costume_ict; _temp[count] = 0; if (NULL == (costmp = _costume_find_variable(cxlist, _temp))) return -1; // error inttmp = costmp->data; tmpptr = __itoa(inttmp); for (; *tmpptr; tmpptr++) *ptr++ = *tmpptr; break; case _COTM_STRVARIABLE: for (count = 0; _isalnumub((int)(*_costume_ict)); _costume_ict++, count++) _temp[count] = *_costume_ict; _temp[count] = 0; if (NULL == (cosstrtmp = _costume_find_strvariable(cxstrlist, _temp))) return -1; // error tmpptr = cosstrtmp->data; for (; *tmpptr; tmpptr++) *ptr++ = *tmpptr; break; case '*': // *x, *@int, *$str, *!x RE1: switch(*_costume_ict++) { case '!': switch(*_costume_ict++) { case 's': while (CONDITION(_isspace(*tarptr))) *ptr++ = *tarptr++; break; case 'S': while (CONDITION(!_isspace(*tarptr))) *ptr++ = *tarptr++; break; case 'd': while (CONDITION(_isnumeric(*tarptr))) *ptr++ = *tarptr++; break; case 'D': while (CONDITION(!_isnumeric(*tarptr))) *ptr++ = *tarptr++; break; case 'w': while (CONDITION(_isalnumub(*tarptr))) *ptr++ = *tarptr++; break; case 'W': while (CONDITION(!_isalnumub(*tarptr))) *ptr++ = *tarptr++; break; case '\\': switch(*_costume_ict++) { case 'n': while (CONDITION(*tarptr == '\n')) *ptr++ = *tarptr++; break; case 'r': while (CONDITION(*tarptr == '\r')) *ptr++ = *tarptr++; break; case 't': while (CONDITION(*tarptr == '\t')) *ptr++ = *tarptr++; break; case 'f': while (CONDITION(*tarptr == '\f')) *ptr++ = *tarptr++; break; default: while(CONDITION(*tarptr == *(_costume_ict-1))) *ptr++ = *tarptr++; break; } break; } not = TRUE; break; case '\\': switch(*_costume_ict++) { case 'n': if(CONDITION(*tarptr == '\n')) *ptr++ = *tarptr++; break; case 'r': if(CONDITION(*tarptr == '\r')) *ptr++ = *tarptr++; break; case 't': if(CONDITION(*tarptr == '\t')) *ptr++ = *tarptr++; break; case 'f': if(CONDITION(*tarptr == '\f')) *ptr++ = *tarptr++; break; default: if(CONDITION(*tarptr == *(_costume_ict-1))) *ptr++ = *tarptr++; break; } not = TRUE; break; case '^': // not not = FALSE; goto RE1; break; default: if(_isalnumub((int)(*_costume_ict))) { if(CONDITION(*tarptr == *_costume_ict)) *ptr++ = *tarptr++; not = TRUE; } break; } break; } break; case '*': // *x, *@int, *$str, *!x RE2: switch(*_costume_ict++) { case '!': switch(*_costume_ict++) { case 's': while (CONDITION(_isspace(*tarptr))) tarptr++; break; case 'S': while (CONDITION(!_isspace(*tarptr))) tarptr++; break; case 'd': while (CONDITION(_isnumeric(*tarptr))) tarptr++; break; case 'D': while (CONDITION(!_isnumeric(*tarptr))) tarptr++; break; case 'w': while (CONDITION(_isalnumub(*tarptr))) tarptr++; break; case 'W': while (CONDITION(!_isalnumub(*tarptr))) tarptr++; break; case '\\': switch(*_costume_ict++) { case 'n': while (CONDITION(*tarptr == '\n')) tarptr++; break; case 'r': while (CONDITION(*tarptr == '\r')) tarptr++; break; case 't': while (CONDITION(*tarptr == '\t')) tarptr++; break; case 'f': while (CONDITION(*tarptr == '\f')) tarptr++; break; default: while(CONDITION(*tarptr == *(_costume_ict-1))) tarptr++; break; } break; } not = TRUE; break; case '\\': switch(*_costume_ict++) { case 'n': if(CONDITION(*tarptr == '\n')) tarptr++; break; case 'r': if(CONDITION(*tarptr == '\r')) tarptr++; break; case 't': if(CONDITION(*tarptr == '\t')) tarptr++; break; case 'f': if(CONDITION(*tarptr == '\f')) tarptr++; break; default: if(CONDITION(*tarptr == *(_costume_ict-1))) tarptr++; break; } not = TRUE; break; case '^': // not not = FALSE; goto RE2; break; default: if(_isalnumub((int)(*_costume_ict))) { if(CONDITION(*tarptr == *_costume_ict)) *tarptr++; not = TRUE; } break; } break; case '/': // Delimiter break; case '\\': switch(*_costume_ict++) { case 'n': *ptr++ = '\n'; break; case 'r': *ptr++ = '\r'; break; case 't': *ptr++ = '\t'; break; case 'f': *ptr++ = '\f'; break; default: *ptr++ = *(_costume_ict-1); break; } break; default: if (_isalnum((int)(tmp = *(_costume_ict - 1)))) { *ptr++ = tmp; for (; _isalnum((int)*_costume_ict); _costume_ict++) *ptr++ = *_costume_ict; } break; } } while (*_costume_ict && *_costume_ict != ']'); return ret; }
_CODE_ACCESS int iswspace(wint_t c) { return (c == WEOF || (char)c != c) ? 0 : _isspace((char)c); }