static const char *ParseNumber(ParseArgs& args, const char *data) { const char *start = data; // integer part if ('-' == *data) data++; if ('0' == *data) data++; else if (str::IsDigit(*data)) data = SkipDigits(data + 1); else return NULL; // fractional part if ('.' == *data) data = SkipDigits(data + 1); // magnitude if ('e' == *data || 'E' == *data) { data++; if ('+' == *data || '-' == *data) data++; data = SkipDigits(data + 1); } // validity check if (!str::IsDigit(*(data - 1)) || str::IsDigit(*data)) return NULL; char *number = str::DupN(start, data - start); args.canceled = !args.visitor->Visit(args.path.Get(), number, Type_Number); free(number); return data; }
static INLINE int hi_server_extract_status_code(HI_SESSION *Session, const u_char *start, const u_char *ptr, const u_char *end, URI_PTR *result) { int iRet = HI_SUCCESS; SkipBlankSpace(start,end,&ptr); result->uri = ptr; while( hi_util_in_bounds(start, end, ptr) ) { if(isdigit((int)*ptr)) { SkipDigits(start, end, &ptr); if ( hi_util_in_bounds(start, end, ptr) ) { if(isspace((int)*ptr)) { result->uri_end = ptr; iRet = STAT_END; return iRet; } else { iRet = HI_NONFATAL_ERR; return iRet; } } else { iRet = HI_OUT_OF_BOUNDS; return iRet; } } else { if(hi_eo_generate_event(Session, HI_EO_SERVER_INVALID_STATCODE)) { hi_eo_server_event_log(Session, HI_EO_SERVER_INVALID_STATCODE, NULL, NULL); } ptr++; } } iRet = HI_OUT_OF_BOUNDS; return iRet; }
wxScopedCharTypeBuffer<CharType> Convert(const CharType *format) { // this is reset to NULL if we modify the format string m_fmtOrig = format; while ( *format ) { if ( CopyFmtChar(*format++) == wxT('%') ) { // skip any flags while ( IsFlagChar(*format) ) CopyFmtChar(*format++); // and possible width if ( *format == wxT('*') ) CopyFmtChar(*format++); else SkipDigits(&format); // precision? if ( *format == wxT('.') ) { CopyFmtChar(*format++); if ( *format == wxT('*') ) CopyFmtChar(*format++); else SkipDigits(&format); } // next we can have a size modifier SizeModifier size; switch ( *format ) { case 'h': size = Size_Short; format++; break; case 'l': // "ll" has a different meaning! if ( format[1] != 'l' ) { size = Size_Long; format++; break; } //else: fall through default: size = Size_Default; } CharType outConv = *format; SizeModifier outSize = size; // and finally we should have the type switch ( *format ) { case wxT('S'): case wxT('s'): // all strings were converted into the same form by // wxArgNormalizer<T>, this form depends on the context // in which the value is used (scanf/printf/wprintf): HandleString(*format, size, outConv, outSize); break; case wxT('C'): case wxT('c'): HandleChar(*format, size, outConv, outSize); break; default: // nothing special to do break; } if ( outConv == *format && outSize == size ) // no change { if ( size != Size_Default ) CopyFmtChar(*(format - 1)); CopyFmtChar(*format); } else // something changed { switch ( outSize ) { case Size_Long: InsertFmtChar(wxT('l')); break; case Size_Short: InsertFmtChar(wxT('h')); break; case Size_Default: // nothing to do break; } InsertFmtChar(outConv); } format++; } } // notice that we only translated the string if m_fmtOrig == NULL (as // set by CopyAllBefore()), otherwise we should simply use the original // format if ( m_fmtOrig ) { return wxScopedCharTypeBuffer<CharType>::CreateNonOwned(m_fmtOrig); } else { // shrink converted format string to actual size (instead of // over-sized allocation from CopyAllBefore()) and NUL-terminate // it: m_fmt.shrink(m_fmtLast - m_fmt.data()); return m_fmt; } }
wxScopedCharTypeBuffer<CharType> Convert(const CharType *format) { // this is reset to NULL if we modify the format string m_fmtOrig = format; #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while ( *format ) { if ( CopyFmtChar(*format++) == wxT('%') ) { #if wxUSE_PRINTF_POS_PARAMS if ( *format >= '0' && *format <= '9' ) { SkipDigits(&format); if ( *format == '$' ) { // It was a positional argument specification. CopyFmtChar(*format++); } //else: it was a width specification, nothing else to do. } #endif // wxUSE_PRINTF_POS_PARAMS // skip any flags #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ while ( IsFlagChar(*format) ) CopyFmtChar(*format++); // and possible width if ( *format == wxT('*') ) CopyFmtChar(*format++); else SkipDigits(&format); // precision? if ( *format == wxT('.') ) { CopyFmtChar(*format++); if ( *format == wxT('*') ) CopyFmtChar(*format++); else SkipDigits(&format); } // next we can have a size modifier SizeModifier size; switch ( *format ) { #ifdef __VISUALC__ case 'z': // Used for size_t printing (e.g. %zu) and is in C99, // but is not portable, MSVC uses 'I' with the same // meaning. ChangeFmtChar('I'); format++; size = Size_Default; break; #endif // __VISUALC__ case 'h': size = Size_Short; format++; break; case 'l': // "ll" has a different meaning! if ( format[1] != 'l' ) { size = Size_Long; format++; break; } wxFALLTHROUGH; default: size = Size_Default; } CharType outConv = *format; SizeModifier outSize = size; // and finally we should have the type switch ( *format ) { case wxT('S'): case wxT('s'): // all strings were converted into the same form by // wxArgNormalizer<T>, this form depends on the context // in which the value is used (scanf/printf/wprintf): HandleString(*format, size, outConv, outSize); break; case wxT('C'): case wxT('c'): HandleChar(*format, size, outConv, outSize); break; default: // nothing special to do break; } if ( outConv == *format && outSize == size ) // no change { if ( size != Size_Default ) CopyFmtChar(*(format - 1)); CopyFmtChar(*format); } else // something changed { switch ( outSize ) { case Size_Long: InsertFmtChar(wxT('l')); break; case Size_Short: InsertFmtChar(wxT('h')); break; case Size_Default: // nothing to do break; } InsertFmtChar(outConv); } format++; } } // notice that we only translated the string if m_fmtOrig == NULL (as // set by CopyAllBefore()), otherwise we should simply use the original // format if ( m_fmtOrig ) { return wxScopedCharTypeBuffer<CharType>::CreateNonOwned(m_fmtOrig); } else { // shrink converted format string to actual size (instead of // over-sized allocation from CopyAllBefore()) and NUL-terminate // it: m_fmt.shrink(m_fmtLast - m_fmt.data()); return m_fmt; } }