void test2() { unsigned char *s; unsigned char *buf; int i, j; size_t n; wchar_t c, d; mbstate_t state; s = malloc(256); if (!s) { bad++; return; } buf = malloc(MB_CUR_MAX); if (!buf) { bad++; free(s); return; } for (i = 0; i < 256; i++) s[i] = i+1; j = 0; mbrtowc(NULL, NULL, 1, &state); printf(" %02x: ", 0); while ((n = mbrtowc(&c, s+j, 256-j, &state)) == 1) { printf(" %02x: ", s[j]); check_bool(isalnum(s[j]), iswalnum(c), '1'); check_bool(isalpha(s[j]), iswalpha(c), '2'); check_bool(isblank(s[j]), iswblank(c), '3'); check_bool(iscntrl(s[j]), iswcntrl(c), '4'); check_bool(isdigit(s[j]), iswdigit(c), '5'); check_bool(isgraph(s[j]), iswgraph(c), '6'); check_bool(islower(s[j]), iswlower(c), '6'); check_bool(isprint(s[j]), iswprint(c), '7'); check_bool(ispunct(s[j]), iswpunct(c), '8'); check_bool(isspace(s[j]), iswspace(c), '9'); check_bool(isupper(s[j]), iswupper(c), 'a'); check_bool(isxdigit(s[j]), iswxdigit(c), 'b'); d = towlower(c); if (wctomb(buf, d) == 1) { check_value(tolower(s[j]), buf[0], 'c'); } else { bad++; } d = towupper(c); if (wctomb(buf, d) == 1) { check_value(toupper(s[j]), buf[0], 'c'); } else { bad++; } if (s[j] % 8 == 7) printf("\n"); j++; } if (n != 0 || j != 255) { bad++; } free(s); free(buf); }
int iswupper_l(wint_t c, locale_t l) { return iswupper(c); }
bool isUpper(UChar c) { return !!iswupper(c); }
/* * Read a string or regular expression, terminated by ``endc'', * for lexical analyzer, processing escape sequences. * Return string length. */ static size_t lexescape(wint_t endc, int regx, int cmd_line_operand) { static char nlre[256]; static char nlstr[256]; static char eofre[256]; static char eofstr[256]; int first_time = 1; wint_t c; wchar_t *cp; int n, max; if (first_time == 1) { (void) strcpy(nlre, gettext("Newline in regular expression\n")); (void) strcpy(nlstr, gettext("Newline in string\n")); (void) strcpy(eofre, gettext("EOF in regular expression\n")); (void) strcpy(eofstr, gettext("EOF in string\n")); first_time = 0; } cp = linebuf; while ((c = lexgetc()) != endc) { if (c == '\n') awkerr(regx ? nlre : nlstr); if (c == '\\') { switch (c = lexgetc(), c) { case '\\': if (regx) *cp++ = '\\'; break; case '/': c = '/'; break; case 'n': c = '\n'; break; case 'b': c = '\b'; break; case 't': c = '\t'; break; case 'r': c = '\r'; break; case 'f': c = '\f'; break; case 'v': c = '\v'; break; case 'a': c = (char)0x07; break; case 'x': n = 0; while (iswxdigit(c = lexgetc())) { if (iswdigit(c)) c -= '0'; else if (iswupper(c)) c -= 'A'-10; else c -= 'a'-10; n = (n<<4) + c; } lexungetc(c); c = n; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': #if 0 /* * Posix.2 draft 10 disallows the use of back-referencing - it explicitly * requires processing of the octal escapes both in strings and * regular expressions. The following code is disabled instead of * removed as back-referencing may be reintroduced in a future draft * of the standard. */ /* * For regular expressions, we disallow * \ooo to mean octal character, in favour * of back referencing. */ if (regx) { *cp++ = '\\'; break; } #endif max = 3; n = 0; do { n = (n<<3) + c-'0'; if ((c = lexgetc()) > '7' || c < '0') break; } while (--max); lexungetc(c); /* * an octal escape sequence must have at least * 2 digits after the backslash, otherwise * it gets passed straight thru for possible * use in backreferencing. */ if (max == 3) { *cp++ = '\\'; n += '0'; } c = n; break; case '\n': continue; default: if (c != endc || cmd_line_operand) { *cp++ = '\\'; if (c == endc) lexungetc(c); } } } if (c == WEOF) awkerr(regx ? eofre : eofstr); *cp++ = c; } *cp = '\0'; return (cp - linebuf); }
int iswalpha(wint_t wc) { return((iswlower(wc) || iswupper(wc))?1:0); }
static CharacterEntry * getCharacterEntry (wchar_t character) { int first = 0; int last = table->characters.count - 1; while (first <= last) { int current = (first + last) / 2; CharacterEntry *entry = &table->characters.array[current]; if (entry->value < character) { first = current + 1; } else if (entry->value > character) { last = current - 1; } else { return entry; } } if (table->characters.count == table->characters.size) { int newSize = table->characters.size; newSize = newSize? newSize<<1: 0X80; { CharacterEntry *newArray = realloc(table->characters.array, (newSize * sizeof(*newArray))); if (!newArray) { logMallocError(); return NULL; } table->characters.array = newArray; table->characters.size = newSize; } } memmove(&table->characters.array[first+1], &table->characters.array[first], (table->characters.count - first) * sizeof(*table->characters.array)); table->characters.count += 1; { CharacterEntry *entry = &table->characters.array[first]; memset(entry, 0, sizeof(*entry)); entry->value = entry->uppercase = entry->lowercase = character; if (iswspace(character)) { entry->attributes |= CTC_Space; } else if (iswalpha(character)) { entry->attributes |= CTC_Letter; if (iswupper(character)) { entry->attributes |= CTC_UpperCase; entry->lowercase = towlower(character); } if (iswlower(character)) { entry->attributes |= CTC_LowerCase; entry->uppercase = towupper(character); } } else if (iswdigit(character)) { entry->attributes |= CTC_Digit; } else if (iswpunct(character)) { entry->attributes |= CTC_Punctuation; } if (!table->command) { const ContractionTableCharacter *ctc = getContractionTableCharacter(character); if (ctc) entry->attributes |= ctc->attributes; } return entry; } }
bool isUpper(wchar_t c) { return !!iswupper(c); }
/* ** ** [func] - wcstoul. ** [desc] - if s is a valid long integer string then converts the string to ** it's corresponding long integer value and returns the value. else ** returns the long integer huge value. if eptr is not NULL then ** stores the pointer to the last processed character in the string. ** [entr] - const char *s; the source string pointer. ** char **eptr; the pointer to store the string end pointer. ** int b; the long integer base. ** [exit] - long; the converted long integer value. else the long integer huge value. ** [prec] - s is a valid string pointer and eptr is a valid string pointer ** pointer. ** [post] - the memory pointed to by eptr is modified. ** */ unsigned long int wcstoul(const wchar_t *nptr, wchar_t **endptr, int base) { register const wchar_t *s = nptr; register unsigned long acc; register int c; register unsigned long cutoff; register int any, cutlim; /* * Skip white space and pick up leading +/- sign if any. * If base is 0, allow 0x for hex and 0 for octal, else * assume decimal; if base is already 16, allow 0x. */ do { c = *s++; } while (iswspace(c)); if (c == '-') { 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 = ULONG_MAX; cutlim = cutoff % (unsigned long)base; cutoff /= (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { if (iswdigit(c)) c -= '0'; else if (iswalpha(c)) c -= iswupper(c) ? 'A' - 10 : 'a' - 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 = ULONG_MAX; errno = E_LIB_MATH_RANGE; } if (endptr != 0) *endptr = (wchar_t *) (any ? s - 1 : nptr); return (acc); }
/* ** ** [func] - wcstol. ** [desc] - if s is a valid long integer string then converts the string to ** it's corresponding long integer value and returns the value. else ** returns the long integer huge value. if eptr is not NULL then ** stores the pointer to the last processed character in the string. ** [entr] - const char *s; the source string pointer. ** char **eptr; the pointer to store the string end pointer. ** int b; the long integer base. ** [exit] - long; the converted long integer value. else the long integer huge value. ** [prec] - s is a valid string pointer and eptr is a valid string pointer ** pointer. ** [post] - the memory pointed to by eptr is modified. ** */ long int wcstol(const wchar_t *nptr, wchar_t **endptr, int base) { register const wchar_t *s = nptr; register unsigned long acc; register int c; register unsigned long cutoff; register int neg = 0, any, cutlim; /* * Skip white space and pick up leading +/- sign if any. * If base is 0, allow 0x for hex and 0 for octal, else * assume decimal; if base is already 16, allow 0x. */ do { c = *s++; } while (iswspace(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; /* * Compute the cutoff value between legal numbers and illegal * numbers. That is the largest legal value, divided by the * base. An input number that is greater than this value, if * followed by a legal input character, is too big. One that * is equal to this value may be valid or not; the limit * between valid and invalid numbers is then based on the last * digit. For instance, if the range for longs is * [-2147483648..2147483647] and the input base is 10, * cutoff will be set to 214748364 and cutlim to either * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated * a value > 214748364, or equal but the next digit is > 7 (or 8), * the number is too big, and we will return a range error. * * Set any if any `digits' consumed; make it negative to indicate * overflow. */ cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; cutlim = cutoff % (unsigned long)base; cutoff /= (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { if (iswdigit(c)) c -= '0'; else if (iswalpha(c)) c -= iswupper(c) ? 'A' - 10 : 'a' - 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; errno = E_LIB_MATH_RANGE; } else if (neg) acc = -acc; if (endptr != 0) *endptr = (wchar_t *) (any ? s - 1 : nptr); return (acc); }
bool CLocale::cl_isuppercase(wchar_t c) { return iswupper(c) != 0; };
static int Isupper(int c) { return iswupper(c); }
static int MatchOne( DaoRegex *self, DaoRgxItem *patt, daoint pos ) { DCharState st = { 0, 1, 0 }; DCharState st2 = { 0, 1, 0 }; uint_t ch, ch2, b1, b2; int i; patt->offset = 0; patt->count += 1; switch( patt->type ){ case PAT_WBORDER : if( pos == self->start || pos >= self->end ) return 1; for(i=1; i <= 4 && (pos-i) >= self->start; ++i){ st = DString_DecodeChar( self->source + pos - i, self->source + self->end ); if( i == 1 ) st2 = st; if( st.type == i ) break; } if( st.type == 0 ) st = st2; st2 = DString_DecodeChar( self->source + pos, self->source + self->end ); if( dao_character( st.value ) != dao_character( st2.value ) ) return 1; return 0; case PAT_ANY : if( pos >= self->end ) return 0; st = DString_DecodeChar( self->source + pos, self->source + self->end ); if( pos + st.width > self->end ) st.width = 1; patt->offset = st.width; return 1; case PAT_SPLIT: case PAT_BEGIN: case PAT_JOIN: return 1; case PAT_START: return (pos == self->start); case PAT_END : return (pos >= self->end); case PAT_SET : return MatchSet( self, patt, pos ); case PAT_WORD : return MatchWord( self, patt, pos ); case PAT_PAIR : return MatchPair( self, patt, pos ); case PAT_PATPAIR : return MatchPatPair( self, patt, pos ); case PAT_BACKREF: return MatchBackRef( self, patt, pos ); default : break; } if( pos >= self->end ) return 0; st = DString_DecodeChar( self->source + pos, self->source + self->end ); if( st.type == 0 ) return 0; patt->offset = st.width; ch = ch2 = st.value; if( sizeof(wchar_t) == 2 && ch > 0xFFFF ) ch = 0; /* for isw*(); */ switch( patt->type ){ case 'a' : return iswalpha( ch ); case 's' : return iswspace( ch ); case 'k' : return iswcntrl( ch ); case 'p' : return iswpunct( ch ); case 'd' : return iswdigit( ch ); case 'x' : return iswxdigit( ch ); case 'e' : return dao_cjk( ch2 ); case 'w' : return dao_character( ch2 ); case 'c' : return iswlower( ch ); case 'A' : return ! iswalpha( ch ); case 'S' : return ! iswspace( ch ); case 'K' : return ! iswcntrl( ch ); case 'P' : return ! iswpunct( ch ); case 'D' : return ! iswdigit( ch ); case 'X' : return ! iswxdigit( ch ); case 'E' : return ! dao_cjk( ch2 ); case 'W' : return ! dao_character( ch2 ); case 'C' : return iswupper( ch ); default : return 0; } return 0; }
/* Might this line be a mail header? * We deem a line to be a possible header if it matches the * Perl regexp /^[A-Z][-A-Za-z0-9]*:\s/. This is *not* the same * as in RFC whatever-number-it-is; we want to be gratuitously * conservative to avoid mangling ordinary civilised text. */ static int might_be_header(const wchar_t *line) { if (!iswupper(*line++)) return 0; while (*line && (iswalnum(*line) || *line=='-')) ++line; return (*line==':' && iswspace(line[1])); }
int _PyUnicode_IsUppercase(register const Py_UNICODE ch) { return iswupper(ch); }
int _PyUnicode_IsUppercase(Py_UNICODE ch) { return iswupper(ch); }
inline bool isUpper(Char c) { return IF_UNICODE( iswupper(c) , isupper((unsigned char)c) ); }
static int compile_line(char *linebuf, char *dict_line, int *hash) {//=============================================================== // Compile a line in the language_list file unsigned char c; char *p; char *word; char *phonetic; unsigned int ix; int step; unsigned int n_flag_codes = 0; int flag_offset; int length; int multiple_words = 0; char *multiple_string = NULL; char *multiple_string_end = NULL; int len_word; int len_phonetic; int text_not_phonemes; // this word specifies replacement text, not phonemes unsigned int wc; int all_upper_case; char *mnemptr; char *comment; unsigned char flag_codes[100]; char encoded_ph[200]; unsigned char bad_phoneme[4]; static char nullstring[] = {0}; comment = NULL; text_not_phonemes = 0; phonetic = word = nullstring; if(memcmp(linebuf,"_-",2)==0) { step=1; // TEST } p = linebuf; // while(isspace2(*p)) p++; #ifdef deleted if(*p == '$') { if(memcmp(p,"$textmode",9) == 0) { text_mode = 1; return(0); } if(memcmp(p,"$phonememode",12) == 0) { text_mode = 0; return(0); } } #endif step = 0; c = 0; while(c != '\n') { c = *p; if((c == '?') && (step==0)) { // conditional rule, allow only if the numbered condition is set for the voice flag_offset = 100; p++; if(*p == '!') { // allow only if the numbered condition is NOT set flag_offset = 132; p++; } ix = 0; if(isdigit(*p)) { ix += (*p-'0'); p++; } if(isdigit(*p)) { ix = ix*10 + (*p-'0'); p++; } flag_codes[n_flag_codes++] = ix + flag_offset; c = *p; } if((c == '$') && isalnum(p[1])) { /* read keyword parameter */ mnemptr = p; while(!isspace2(c = *p)) p++; *p = 0; ix = LookupMnem(mnem_flags,mnemptr); if(ix > 0) { if(ix == 200) { text_mode = 1; } else if(ix == 201) { text_mode = 0; } else if(ix == BITNUM_FLAG_TEXTMODE) { text_not_phonemes = 1; } else { flag_codes[n_flag_codes++] = ix; } } else { fprintf(f_log,"%5d: Unknown keyword: %s\n",linenum,mnemptr); error_count++; } } if((c == '/') && (p[1] == '/') && (multiple_words==0)) { c = '\n'; /* "//" treat comment as end of line */ comment = p; } switch(step) { case 0: if(c == '(') { multiple_words = 1; word = p+1; step = 1; } else if(!isspace2(c)) { word = p; step = 1; } break; case 1: if((c == '-') && (word[0] != '_')) { flag_codes[n_flag_codes++] = BITNUM_FLAG_HYPHENATED; c = ' '; } if(isspace2(c)) { p[0] = 0; /* terminate english word */ if(multiple_words) { multiple_string = multiple_string_end = p+1; step = 2; } else { step = 3; } } else if((c == ')') && multiple_words) { p[0] = 0; step = 3; multiple_words = 0; } break; case 2: if(isspace2(c)) { multiple_words++; } else if(c == ')') { p[0] = ' '; // terminate extra string multiple_string_end = p+1; step = 3; } break; case 3: if(!isspace2(c)) { phonetic = p; step = 4; } break; case 4: if(isspace2(c)) { p[0] = 0; /* terminate phonetic */ step = 5; } break; case 5: break; } p++; } if(word[0] == 0) { #ifdef OPT_FORMAT if(comment != NULL) fprintf(f_log,"%s",comment); else fputc('\n',f_log); #endif return(0); /* blank line */ } if(text_mode) text_not_phonemes = 1; if(text_not_phonemes != translator->langopts.textmode) { flag_codes[n_flag_codes++] = BITNUM_FLAG_TEXTMODE; } if(text_not_phonemes) { // this is replacement text, so don't encode as phonemes. Restrict the length of the replacement word strncpy0(encoded_ph,phonetic,N_WORD_BYTES-4); } else { EncodePhonemes(phonetic,encoded_ph,bad_phoneme); if(strchr(encoded_ph,phonSWITCH) != 0) { flag_codes[n_flag_codes++] = BITNUM_FLAG_ONLY_S; // don't match on suffixes (except 's') when switching languages } // check for errors in the phonemes codes for(ix=0; ix<sizeof(encoded_ph); ix++) { c = encoded_ph[ix]; if(c == 0) break; if(c == 255) { /* unrecognised phoneme, report error */ fprintf(f_log,"%5d: Bad phoneme [%c] (0x%x) in: %s %s\n",linenum,bad_phoneme[0],bad_phoneme[0],word,phonetic); error_count++; } } } if(sscanf(word,"U+%x",&wc) == 1) { // Character code ix = utf8_out(wc, word); word[ix] = 0; } else if(word[0] != '_') { // convert to lower case, and note if the word is all-capitals int c2; all_upper_case = 1; p = word; for(p=word;;) { // this assumes that the lower case char is the same length as the upper case char // OK, except for Turkish "I", but use towlower() rather than towlower2() ix = utf8_in(&c2,p); if(c2 == 0) break; if(iswupper(c2)) { utf8_out(towlower(c2),p); } else { all_upper_case = 0; } p += ix; } if(all_upper_case) { flag_codes[n_flag_codes++] = BITNUM_FLAG_ALLCAPS; } } len_word = strlen(word); if(transpose_offset > 0) { len_word = TransposeAlphabet(word, transpose_offset, transpose_min, transpose_max); } *hash = HashDictionary(word); len_phonetic = strlen(encoded_ph); dict_line[1] = len_word; // bit 6 indicates whether the word has been compressed len_word &= 0x3f; memcpy(&dict_line[2],word,len_word); if(len_phonetic == 0) { // no phonemes specified. set bit 7 dict_line[1] |= 0x80; length = len_word + 2; } else { length = len_word + len_phonetic + 3; strcpy(&dict_line[(len_word)+2],encoded_ph); } for(ix=0; ix<n_flag_codes; ix++) { dict_line[ix+length] = flag_codes[ix]; } length += n_flag_codes; if((multiple_string != NULL) && (multiple_words > 0)) { if(multiple_words > 10) { fprintf(f_log,"%5d: Two many parts in a multi-word entry: %d\n",linenum,multiple_words); } else { dict_line[length++] = 80 + multiple_words; ix = multiple_string_end - multiple_string; memcpy(&dict_line[length],multiple_string,ix); length += ix; } } dict_line[0] = length; #ifdef OPT_FORMAT spaces = 16; for(ix=0; ix<n_flag_codes; ix++) { if(flag_codes[ix] >= 100) { fprintf(f_log,"?%d ",flag_codes[ix]-100); spaces -= 3; } } fprintf(f_log,"%s",word); spaces -= strlen(word); DecodePhonemes(encoded_ph,decoded_ph); while(spaces-- > 0) fputc(' ',f_log); spaces += (14 - strlen(decoded_ph)); fprintf(f_log," %s",decoded_ph); while(spaces-- > 0) fputc(' ',f_log); for(ix=0; ix<n_flag_codes; ix++) { if(flag_codes[ix] < 100) fprintf(f_log," %s",lookup_mnem(mnem_flags,flag_codes[ix])); } if(comment != NULL) fprintf(f_log," %s",comment); else fputc('\n',f_log); #endif return(length); } /* end of compile_line */
static int startsWithCapital (const char32 *word) { return iswupper ((int) word [0]) || (word [0] == '\\' && iswupper ((int) word [1])); }
int main (int argc, char *argv[]) { int result = 0; wint_t ch; for (ch = 0; ch < 128; ++ch) { if (iswlower (ch)) { /* Get corresponding upper case character. */ wint_t up = towupper (ch); /* This should have no effect. */ wint_t low = towlower (ch); if ((ch != low) || (up == ch) || (up == low)) { printf ("iswlower/towupper/towlower for character \\%x failed\n", ch); result++; } } if (iswupper (ch)) { /* Get corresponding lower case character. */ wint_t low = towlower (ch); /* This should have no effect. */ wint_t up = towupper (ch); if ((ch != up) || (low == ch) || (up == low)) { printf ("iswupper/towlower/towupper for character \\%x failed\n", ch); result++; } } } /* Finally some specific tests. */ ch = L'A'; if (!iswupper (ch) || iswlower (ch)) { printf ("!iswupper/iswlower (L'A') failed\n"); result++; } ch = L'a'; if (iswupper (ch) || !iswlower (ch)) { printf ("iswupper/!iswlower (L'a') failed\n"); result++; } if (towlower (L'A') != L'a') { printf ("towlower(L'A') failed\n"); result++; } if (towupper (L'a') != L'A') { printf ("towupper(L'a') failed\n"); result++; } if (result == 0) puts ("All test successful!"); return result != 0; }
void speakCharacters (const ScreenCharacter *characters, size_t count, int spell) { int immediate = 1; if (isAllSpaceCharacters(characters, count)) { switch (prefs.whitespaceIndicator) { default: case wsNone: if (immediate) muteSpeech("white space"); break; case wsSaySpace: { wchar_t buffer[0X100]; size_t length = convertTextToWchars(buffer, gettext("space"), ARRAY_COUNT(buffer)); sayWideCharacters(buffer, NULL, length, immediate); break; } } } else if (count == 1) { wchar_t character = characters[0].text; const char *prefix = NULL; int restorePitch = 0; int restorePunctuation = 0; if (iswupper(character)) { switch (prefs.uppercaseIndicator) { default: case ucNone: break; case ucSayCap: // "cap" here, used during speech output, is short for "capital". // It is spoken just before an uppercase letter, e.g. "cap A". prefix = gettext("cap"); break; case ucRaisePitch: if (canSetSpeechPitch()) { unsigned char pitch = prefs.speechPitch + 7; if (pitch > SPK_PITCH_MAXIMUM) pitch = SPK_PITCH_MAXIMUM; if (pitch != prefs.speechPitch) { setSpeechPitch(pitch, 0); restorePitch = 1; } } break; } } if (canSetSpeechPunctuation()) { unsigned char punctuation = SPK_PUNCTUATION_ALL; if (punctuation != prefs.speechPunctuation) { setSpeechPunctuation(punctuation, 0); restorePunctuation = 1; } } if (prefix) { wchar_t buffer[0X100]; size_t length = convertTextToWchars(buffer, prefix, ARRAY_COUNT(buffer)); buffer[length++] = WC_C(' '); buffer[length++] = character; sayWideCharacters(buffer, NULL, length, immediate); } else { sayWideCharacters(&character, NULL, 1, immediate); } if (restorePunctuation) setSpeechPunctuation(prefs.speechPunctuation, 0); if (restorePitch) setSpeechPitch(prefs.speechPitch, 0); } else if (spell) { wchar_t string[count * 2]; size_t length = 0; unsigned int index = 0; while (index < count) { string[length++] = characters[index++].text; string[length++] = WC_C(' '); } string[length] = WC_C('\0'); sayWideCharacters(string, NULL, length, immediate); } else { sayScreenCharacters(characters, count, immediate); } }
bool NWChar::IsUpper(wchar_t c) { return iswupper(c); }
static ID rb_intern_uchars(const UChar *chars, const size_t chars_len, VALUE str) { const unsigned long name_hash = rb_str_hash_uchars(chars, chars_len); LOCK(); ID id = (ID)CFDictionaryGetValue(sym_id, (const void *)name_hash); UNLOCK(); if (id != 0) { goto return_id; } if (str == Qnil) { str = rb_unicode_str_new(chars, chars_len); } rb_sym_t *sym = NULL; long pos = 0; if (chars_len > 0) { UChar c = chars[0]; switch (c) { case '$': id = ID_GLOBAL; goto new_id; case '@': if (chars_len > 1 && chars[1] == '@') { pos++; id = ID_CLASS; } else { id = ID_INSTANCE; } pos++; break; default: if (chars_len > 1 && chars[chars_len - 1] == '=') { // Attribute assignment. id = rb_intern_str(rb_str_substr(str, 0, chars_len - 1)); if (!is_attrset_id(id)) { id = rb_id_attrset(id); goto id_register; } id = ID_ATTRSET; } else if (iswupper(c)) { id = ID_CONST; } else { id = ID_LOCAL; } break; } } if (pos < chars_len && !isdigit(chars[pos])) { for (; pos < chars_len; pos++) { if (!is_identchar(chars[pos])) { break; } } } if (pos < chars_len) { id = ID_JUNK; } new_id: id |= ++last_id << ID_SCOPE_SHIFT; id_register: //printf("register %s hash %ld id %ld\n", RSTRING_PTR(str), name_hash, id); sym = sym_alloc(str, id); LOCK(); CFDictionarySetValue(sym_id, (const void *)name_hash, (const void *)id); CFDictionarySetValue(id_str, (const void *)id, (const void *)sym); UNLOCK(); return_id: return id; }
CharacterEntry * getCharacterEntry (BrailleContractionData *bcd, wchar_t character) { int first = 0; int last = bcd->table->characters.count - 1; while (first <= last) { int current = (first + last) / 2; CharacterEntry *entry = &bcd->table->characters.array[current]; if (entry->value < character) { first = current + 1; } else if (entry->value > character) { last = current - 1; } else { return entry; } } if (bcd->table->characters.count == bcd->table->characters.size) { int newSize = bcd->table->characters.size; newSize = newSize? newSize<<1: 0X80; { CharacterEntry *newArray = realloc(bcd->table->characters.array, (newSize * sizeof(*newArray))); if (!newArray) { logMallocError(); return NULL; } bcd->table->characters.array = newArray; bcd->table->characters.size = newSize; } } memmove(&bcd->table->characters.array[first+1], &bcd->table->characters.array[first], (bcd->table->characters.count - first) * sizeof(*bcd->table->characters.array)); bcd->table->characters.count += 1; { CharacterEntry *entry = &bcd->table->characters.array[first]; memset(entry, 0, sizeof(*entry)); entry->value = entry->uppercase = entry->lowercase = character; if (iswspace(character)) { entry->attributes |= CTC_Space; } else if (iswalpha(character)) { entry->attributes |= CTC_Letter; if (iswupper(character)) { entry->attributes |= CTC_UpperCase; entry->lowercase = towlower(character); } if (iswlower(character)) { entry->attributes |= CTC_LowerCase; entry->uppercase = towupper(character); } } else if (iswdigit(character)) { entry->attributes |= CTC_Digit; } else if (iswpunct(character)) { entry->attributes |= CTC_Punctuation; } bcd->table->translationMethods->finishCharacterEntry(bcd, entry); return entry; } }
int towlower(wint_t wc) { if (iswupper(wc)) wc+=32; return wc; }