int findNextWordFromIndex(const UChar* chars, int len, int position, bool forward) { TextBreakIterator* it = wordBreakIterator(chars, len); if (forward) { position = textBreakFollowing(it, position); while (position != -1) { // We stop searching when the character preceeding the break // is alphanumeric. if (position < len && iswalpha(chars[position - 1])) return position; position = textBreakFollowing(it, position); } return len; } else { position = textBreakPreceding(it, position); while (position != -1) { // We stop searching when the character following the break // is alphanumeric. if (position > 0 && iswalpha(chars[position])) return position; position = textBreakPreceding(it, position); } return 0; } }
wstring Parse::parse() { wstring str; WCHAR c; while (infile.get(c)) { if (c == L' ') { continue; }else if (c == L'\t') { continue; }else if (c == L'\n') { continue; } if (c == L'<') { while (c != L'>') { str += c; infile.get(c); } str += c; break; } if (c == L'"') { infile.get(c); while (c != L'"') { str += c; infile.get(c); } break; } if (iswdigit(c)) { while (iswdigit(c)) { str += c; infile.get(c); } break; } if (iswalpha(c)) { while (iswalpha(c)) { str += c; infile.get(c); } break; } } return str; }
int is_url(const ichar *name) { if ( iswalpha(name[0]) ) { while(*name && iswalpha(*name)) name++; if ( *name && name[0] == ':' && name[1] == '/' && name[2] == '/' ) return TRUE; } return FALSE; }
static int unichar_getprops_point__enUS(const unichar *ptr) { unichar before, after; if ((ptr[-1] & ~0xFF) || ptr[+1] & ~0xFF) return UCP_PUNCT; before = ptr[-1]; after = ptr[+1]; if (iswdigit((unsigned)before) && iswdigit((unsigned)after)) return UCP_ALPHA; if (iswalpha((unsigned)before) && iswalpha((unsigned)after)) return UCP_ALPHA; return UCP_PUNCT; }
static int unichar_getprops_point__xftqenUK(const unichar *ptr) { unichar before, after; if ((ptr[-1] & ~0xFF) || ptr[+1] & ~0xFF) return UCP_PUNCT; before = ptr[-1]; after = ptr[+1]; if (('*' == before) && (('*' == after) || iswdigit(after) || iswalpha(after))) return UCP_ALPHA; if (iswdigit(before) && (('*' == after) || iswdigit(after))) return UCP_ALPHA; if (iswalpha(before) && (('*' == after) || iswalpha(after))) return UCP_ALPHA; return UCP_PUNCT; }
/* Strips "\\\\?\\" extended prefix or * "\\??\\" NT Object Manager prefix from * @str in-place, using memmove. * @str_size must point to the size of @str * in gunichar2s, including NUL-terminator * (if @str is NUL-terminated; it doesn't have to be). * On return @str_size will correctly reflect changes * in @str size (if any). * Returns TRUE if @str was modified. */ static gboolean _g_win32_strip_extended_ntobjm_prefix (gunichar2 *str, gsize *str_size) { const wchar_t *extended_prefix = L"\\\\?\\"; const gsize extended_prefix_len = wcslen (extended_prefix); const gsize extended_prefix_len_bytes = sizeof (gunichar2) * extended_prefix_len; const gsize extended_prefix_with_drive_len_bytes = sizeof (gunichar2) * (extended_prefix_len + 2); const wchar_t *ntobjm_prefix = L"\\??\\"; const gsize ntobjm_prefix_len = wcslen (ntobjm_prefix); const gsize ntobjm_prefix_len_bytes = sizeof (gunichar2) * ntobjm_prefix_len; const gsize ntobjm_prefix_with_drive_len_bytes = sizeof (gunichar2) * (ntobjm_prefix_len + 2); gboolean do_move = FALSE; gsize move_shift = 0; if ((*str_size) * sizeof (gunichar2) > extended_prefix_with_drive_len_bytes && memcmp (str, extended_prefix, extended_prefix_len_bytes) == 0 && iswascii (str[extended_prefix_len]) && iswalpha (str[extended_prefix_len]) && str[extended_prefix_len + 1] == L':') { do_move = TRUE; move_shift = extended_prefix_len; } else if ((*str_size) * sizeof (gunichar2) > ntobjm_prefix_with_drive_len_bytes && memcmp (str, ntobjm_prefix, ntobjm_prefix_len_bytes) == 0 && iswascii (str[ntobjm_prefix_len]) && iswalpha (str[ntobjm_prefix_len]) && str[ntobjm_prefix_len + 1] == L':') { do_move = TRUE; move_shift = ntobjm_prefix_len; } if (do_move) { *str_size -= move_shift; memmove (str, str + move_shift, (*str_size) * sizeof (gunichar2)); } return do_move; }
/** Przetwarza jedno słowo @param[in,out] index Indeks znaku w buforze @param[in,out] char_number Nr znaku w aktualnie przetwarzanej linii @param[in,out] line_number Nr linii przetwarzanej @param[in] buffer Bufor @param[in] dict Słownik @param[in] v_option Czy włączono opcję -v */ void parse_word(int *index, int *char_number, int *line_number, wchar_t *buffer, struct dictionary *dict, bool v_option) { const int first_char = *char_number; vector *word = vector_new(sizeof(wchar_t), BUFFER_START_SIZE); for(; iswalpha(buffer[*index]); (*index)++, (*char_number)++) vector_push_back(word, buffer + *index); vector_push_back(word, L"\0"); (*index)--; (*char_number)--; wchar_t *word_content = vector_content(word); wchar_t *word_small = malloc(vector_size(word) * sizeof(wchar_t)); for(int i = 0; i < vector_size(word); i++) word_small[i] = towlower(word_content[i]); if(!dictionary_find(dict, word_small)) { wprintf(L"#"); if(v_option) { fwprintf(stderr, L"%d,%d %ls:", *line_number, first_char, word_content); struct word_list list; dictionary_hints(dict, word_small, &list); const wchar_t * const *hints = word_list_get(&list); int number_of_hints = word_list_size(&list); for(int i = 0; i < number_of_hints; i++) fwprintf(stderr, L" %ls", hints[i]); if(number_of_hints == 0) fwprintf(stderr, L" "); fwprintf(stderr, L"\n"); } } wprintf(L"%ls", word_content); free(word_small); vector_done(word); }
local int FSusesLocalTimeW(const wchar_t *path) { wchar_t *tmp0; wchar_t rootPathName[4]; wchar_t tmp1[MAX_PATH], tmp2[MAX_PATH]; DWORD volSerNo, maxCompLen, fileSysFlags; #if defined(__RSXNT__) /* RSXNT/EMX C rtl uses OEM charset */ wchar_t *ansi_path = (wchar_t *)alloca((wcslen(path) + 1) * sizeof(wchar_t)); CharToAnsiW(path, ansi_path); path = ansi_path; #endif if (iswalpha(path[0]) && (path[1] == (wchar_t)':')) tmp0 = (wchar_t *)path; else { GetFullPathNameW(path, MAX_PATH, tmp1, &tmp0); tmp0 = &tmp1[0]; } wcsncpy(rootPathName, tmp0, 3); /* Build the root path name, */ rootPathName[3] = (wchar_t)'\0'; /* e.g. "A:/" */ GetVolumeInformationW(rootPathName, tmp1, (DWORD)MAX_PATH, &volSerNo, &maxCompLen, &fileSysFlags, tmp2, (DWORD)MAX_PATH); /* Volumes in (V)FAT and (OS/2) HPFS format store file timestamps in * local time! */ return !wcsncmp(_wcsupr(tmp2), L"FAT", 3) || !wcsncmp(tmp2, L"VFAT", 4) || !wcsncmp(tmp2, L"HPFS", 4); } /* end function FSusesLocalTimeW() */
bool FFont::CanPrint(const uint8_t *string) const { if (!string) return true; while (*string) { auto chr = GetCharFromString(string); if (!MixedCase) chr = upperforlower[chr]; // For uppercase-only fonts we shouldn't check lowercase characters. if (chr == TEXTCOLOR_ESCAPE) { // We do not need to check for UTF-8 in here. if (*string == '[') { while (*string != '\0' && *string != ']') { ++string; } } if (*string != '\0') { ++string; } continue; } else if (chr != '\n') { int cc = GetCharCode(chr, true); if (chr != cc && iswalpha(chr) && cc != getAlternative(chr)) { return false; } } } return true; }
int addConn(PCWSTR letter, PCWSTR path) { BOOL ret; PWSTR inputBuffer; DWORD inputBufferSize; if (iswalpha(letter[0]) == 0) { wprintf(L"Invalid letter provided\n"); return 1; } if (wcschr(path, L'\\') != NULL) { wprintf(L"Only give the name of a share\n"); return 1; } inputBufferSize = (wcslen(path) + wcslen(devices[2]) + wcslen(L"\\;Z:\\vboxsvr\\")) * sizeof(WCHAR) + sizeof(UNICODE_NULL); inputBuffer = malloc(inputBufferSize); if (inputBuffer == NULL) { wprintf(L"Memory failure\n"); return 1; } swprintf(inputBuffer, L"%s\\;%c:\\vboxsvr\\%s", devices[2], towupper(letter[0]), path); wprintf(L"Will create the following connection: %s\n", inputBuffer); ret = performDevIoCtl(IOCTL_MRX_VBOX_ADDCONN, inputBuffer, inputBufferSize, NULL, 0); free(inputBuffer); return (ret == FALSE); }
static int pg_wc_isalpha(pg_wchar c) { switch (pg_regex_strategy) { case PG_REGEX_LOCALE_C: return (c <= (pg_wchar) 127 && (pg_char_properties[c] & PG_ISALPHA)); case PG_REGEX_LOCALE_WIDE: #ifdef USE_WIDE_UPPER_LOWER if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswalpha((wint_t) c); #endif /* FALL THRU */ case PG_REGEX_LOCALE_1BYTE: return (c <= (pg_wchar) UCHAR_MAX && isalpha((unsigned char) c)); case PG_REGEX_LOCALE_WIDE_L: #if defined(HAVE_LOCALE_T) && defined(USE_WIDE_UPPER_LOWER) if (sizeof(wchar_t) >= 4 || c <= (pg_wchar) 0xFFFF) return iswalpha_l((wint_t) c, pg_regex_locale); #endif /* FALL THRU */ case PG_REGEX_LOCALE_1BYTE_L: #ifdef HAVE_LOCALE_T return (c <= (pg_wchar) UCHAR_MAX && isalpha_l((unsigned char) c, pg_regex_locale)); #endif break; } return 0; /* can't get here, but keep compiler quiet */ }
int deleteLetter(WCHAR letter) { WCHAR capsLetter; if (iswalpha(letter) == 0) { wprintf(L"Invalid letter provided\n"); return 1; } capsLetter = towupper(letter); if (capsLetter == L'C') { wprintf(L"Looks suspicious, won't proceed\n"); return 1; } if (!startService()) { return 1; } Sleep(500); return (performDevIoCtl(FSCTL_HACKSSIGN_DELETE, &capsLetter, sizeof(WCHAR)) == FALSE); }
int BLC_PREFIX(iswctype)(wint_t wc, wctype_t desc) { switch (desc) { case wctype_alnum: return iswalnum(wc); case wctype_alpha: return iswalpha(wc); case wctype_blank: return iswblank(wc); case wctype_cntrl: return iswcntrl(wc); case wctype_digit: return iswdigit(wc); case wctype_graph: return iswgraph(wc); case wctype_lower: return iswlower(wc); case wctype_print: return iswprint(wc); case wctype_punct: return iswpunct(wc); case wctype_space: return iswspace(wc); case wctype_upper: return iswupper(wc); case wctype_xdigit: return iswxdigit(wc); default: return 0; } }
int get_trait (qse_wcint_t code) { int trait = 0; if (iswupper(code)) trait |= TRAIT_UPPER; if (iswlower(code)) trait |= TRAIT_LOWER; if (iswalpha(code)) trait |= TRAIT_ALPHA; if (iswdigit(code)) trait |= TRAIT_DIGIT; if (iswxdigit(code)) trait |= TRAIT_XDIGIT; if (iswalnum(code)) trait |= TRAIT_ALNUM; if (iswspace(code)) trait |= TRAIT_SPACE; if (iswprint(code)) trait |= TRAIT_PRINT; if (iswgraph(code)) trait |= TRAIT_GRAPH; if (iswcntrl(code)) trait |= TRAIT_CNTRL; if (iswpunct(code)) trait |= TRAIT_PUNCT; if (iswblank(code)) trait |= TRAIT_BLANK; /* if (iswascii(code)) trait |= TRAIT_ASCII; if (isphonogram(code)) trait |= TRAIT_PHONO; if (isideogram(code)) trait |= TRAIT_IDEOG; if (isenglish(code)) trait |= TRAIT_ENGLI; */ return trait; }
const wchar_t *VDFileSplitRoot(const wchar_t *s) { // Test for a UNC path. if (s[0] == L'\\' && s[1] == L'\\') { // For these, we scan for the fourth backslash. s += 2; for(int i=0; i<2; ++i) { while(*s && *s != L'\\') ++s; if (*s == L'\\') ++s; } return s; } const wchar_t *t = s; for(;;) { const wchar_t c = *t; if (c == L':') { if (t[1] == L'/' || t[1] == L'\\') return t+2; return t+1; } // check if it was a valid drive identifier if (!iswalpha(c) && (s == t || !iswdigit(c))) return s; ++t; } }
static int p_isalpha(TParser *prs) { Assert( prs->state ); if (prs->usewide) { if (lc_ctype_is_c()) { unsigned int c = *(prs->wstr + prs->state->poschar); /* * any non-ascii symbol with multibyte encoding * with C-locale is an alpha character */ if ( c > 0x7f ) return 1; return isalpha(0xff & c); } return iswalpha( (wint_t)*( prs->wstr + prs->state->poschar)); } return isalpha( *(unsigned char*)( prs->str + prs->state->posbyte )); }
static wchar_t __towcase(wchar_t wc, int lower) { int i; int lmul = 2*lower-1; int lmask = lower-1; if ((unsigned)wc - 0x10400 < 0x50) return wc + lmul*0x28; /* no letters with case in these large ranges */ if (!iswalpha(wc) || (unsigned)wc - 0x0600 <= 0x0fff-0x0600 || (unsigned)wc - 0x2e00 <= 0xa6ff-0x2e00 || (unsigned)wc - 0xa800 <= 0xfeff-0xa800) return wc; /* special case because the diff between upper/lower is too big */ if ((unsigned)wc - 0x10a0 < 0x26 || (unsigned)wc - 0x2d00 < 0x26) return wc + lmul*(0x2d00-0x10a0); for (i=0; casemaps[i].len; i++) { int base = casemaps[i].upper + (lmask & casemaps[i].lower); if ((unsigned)wc-base < casemaps[i].len) { if (casemaps[i].lower == 1) return wc + lower - ((wc-casemaps[i].upper)&1); return wc + lmul*casemaps[i].lower; } } for (i=0; pairs[i][1-lower]; i++) { if (pairs[i][1-lower] == wc) return pairs[i][lower]; } if ((unsigned)wc - 0x10428 + (lower<<5) + (lower<<3) < 0x28) return wc - 0x28 + (lower<<10) + (lower<<6); return wc; }
static int tokenize(mvc * c, int cur) { struct scanner *lc = &c->scanner; while (1) { if (cur == 0xFEFF) { /* on Linux at least, iswpunct returns TRUE * for U+FEFF, but we don't want that, we just * want to go to the scanner_error case * below */ ; } else if (iswspace(cur)) { if ((cur = skip_white_space(lc)) == EOF) return cur; continue; /* try again */ } else if (iswdigit(cur)) { return number(c, cur); } else if (iswalpha(cur) || cur == '_') { return keyword_or_ident(c, cur); } else if (iswpunct(cur)) { return scanner_symbol(c, cur); } if (cur == EOF) { if (lc->mode == LINE_1 || !lc->started ) return cur; return scanner_error(c, cur); } /* none of the above: error */ return scanner_error(c, cur); } }
static wchar_t __towcase(wchar_t wc, int lower) { int i; int lmul = 2*lower-1; int lmask = lower-1; /* no letters with case in these large ranges */ if (!iswalpha(wc) || (unsigned)wc - 0x0600 <= 0x0fff-0x0600 || (unsigned)wc - 0x2e00 <= 0xa63f-0x2e00 || (unsigned)wc - 0xa800 <= 0xfeff-0xa800) return wc; /* special case because the diff between upper/lower is too big */ if (lower && (unsigned)wc - 0x10a0 < 0x2e) if (wc>0x10c5 && wc != 0x10c7 && wc != 0x10cd) return wc; else return wc + 0x2d00 - 0x10a0; if (!lower && (unsigned)wc - 0x2d00 < 0x26) if (wc>0x2d25 && wc != 0x2d27 && wc != 0x2d2d) return wc; else return wc + 0x10a0 - 0x2d00; for (i=0; casemaps[i].len; i++) { int base = casemaps[i].upper + (lmask & casemaps[i].lower); if ((unsigned)wc-base < casemaps[i].len) { if (casemaps[i].lower == 1) return wc + lower - ((wc-casemaps[i].upper)&1); return wc + lmul*casemaps[i].lower; } } for (i=0; pairs[i][1-lower]; i++) { if (pairs[i][1-lower] == wc) return pairs[i][lower]; } if ((unsigned)wc - (0x10428 - 0x28*lower) < 0x28) return wc - 0x28 + 0x50*lower; return wc; }
bool StringIsDriveLetter(const std::wstring& in) { if (in.length() != 2) return false; if (! iswalpha(in[0])) return false; if (in[1] != L':') return false; return true; }
bool VSSClient::GetShadowPathW(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBuflen) { if (!m_bBackupIsInitialized) return false; /* check for valid pathname */ bool bIsValidName; bIsValidName = wcslen(szFilePath) > 3; if (bIsValidName) bIsValidName &= iswalpha (szFilePath[0]) && szFilePath[1]==':' && szFilePath[2] == '\\'; if (bIsValidName) { int nDriveIndex = towupper(szFilePath[0])-'A'; if (m_szShadowCopyName[nDriveIndex][0] != 0) { wcsncpy(szShadowPath, m_szShadowCopyName[nDriveIndex], nBuflen); nBuflen -= (int)wcslen(m_szShadowCopyName[nDriveIndex]); wcsncat(szShadowPath, szFilePath+2, nBuflen); return true; } } wcsncpy(szShadowPath, szFilePath, nBuflen); errno = EINVAL; return false; }
int iswctype(wint_t wc, wctype_t type) { switch (type) { case WCTYPE_ALNUM: return iswalnum(wc); case WCTYPE_ALPHA: return iswalpha(wc); case WCTYPE_BLANK: return iswblank(wc); case WCTYPE_CNTRL: return iswcntrl(wc); case WCTYPE_DIGIT: return iswdigit(wc); case WCTYPE_GRAPH: return iswgraph(wc); case WCTYPE_LOWER: return iswlower(wc); case WCTYPE_PRINT: return iswprint(wc); case WCTYPE_PUNCT: return iswpunct(wc); case WCTYPE_SPACE: return iswspace(wc); case WCTYPE_UPPER: return iswupper(wc); case WCTYPE_XDIGIT: return iswxdigit(wc); } return 0; }
void test1() { int i; for (i = 0; i < 256; i++) { printf(" %02x: ", i); check_bool(isalnum(i), iswalnum(i), '1'); check_bool(isalpha(i), iswalpha(i), '2'); check_bool(isblank(i), iswblank(i), '3'); check_bool(iscntrl(i), iswcntrl(i), '4'); check_bool(isdigit(i), iswdigit(i), '5'); check_bool(isgraph(i), iswgraph(i), '6'); check_bool(islower(i), iswlower(i), '6'); check_bool(isprint(i), iswprint(i), '7'); check_bool(ispunct(i), iswpunct(i), '8'); check_bool(isspace(i), iswspace(i), '9'); check_bool(isupper(i), iswupper(i), 'a'); check_bool(isxdigit(i), iswxdigit(i), 'b'); check_value(tolower(i), towlower(i), 'c'); check_value(toupper(i), towupper(i), 'd'); if (i % 8 == 7) printf("\n"); } printf("%\n"); }
/* em_capitol_case(): * Capitalize the characters from cursor to end of current word * [M-c] */ libedit_private el_action_t /*ARGSUSED*/ em_capitol_case(EditLine *el, wint_t c __attribute__((__unused__))) { wchar_t *cp, *ep; ep = c__next_word(el->el_line.cursor, el->el_line.lastchar, el->el_state.argument, ce__isword); for (cp = el->el_line.cursor; cp < ep; cp++) { if (iswalpha(*cp)) { if (iswlower(*cp)) *cp = towupper(*cp); cp++; break; } } for (; cp < ep; cp++) if (iswupper(*cp)) *cp = towlower(*cp); el->el_line.cursor = ep; if (el->el_line.cursor > el->el_line.lastchar) el->el_line.cursor = el->el_line.lastchar; return CC_REFRESH; }
void unifiedWstringfromWstring(std::wstring& uniWstr, const std::wstring& sourceWStr, size_t begin, size_t end) { for (size_t idx = begin; idx < end; idx++){ if (iswalpha(sourceWStr[idx])) uniWstr += towupper(sourceWStr[idx]); else if (iswdigit(sourceWStr[idx])) uniWstr += sourceWStr[idx]; } };
int GTextUtils::Gisalpha(const gint c) { #ifdef USE_WIDE_CHARS return iswalpha(c); #else return isalpha(c); #endif }
//----------------------------------------------------------------------- bool UnicodeFileSystemArchive::isAbsolutePath(const WString& _wFilename) const { const wchar_t* p = _wFilename.c_str(); if (iswalpha(p[0]) && p[1] == ':') return true; return p[0] == '/' || p[0] == '\\'; }
void unifiedWstringfromWstring(std::wstring& uniWstr, const std::wstring& /*sourceWStr*/, std::wstring::iterator begin, std::wstring::iterator end) { //avoid warning C4100 for (auto iter = begin; iter != end; iter++) { if (iswalpha(*iter)) uniWstr += towupper(*iter); else if (iswdigit(*iter)) uniWstr += *iter; } };
bool is_letter(char_t c) { #ifdef _UTF16_STRINGS return iswalpha(c) != 0; #else return isalpha(c) != 0; #endif }
int _Fr_iswalpha(FrChar16 c) { #ifndef NO_WCTYPE return iswalpha(c) ; #else return Fr_is8bit(c) && isalpha(c) ; #endif /* NO_WCTYPE */ }