rename get_word_kbinput() to get_unicode_kbinput(), and also rename

related variables


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2968 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-08-01 19:12:05 +00:00
parent 56e36ef7b5
commit 6a83647a11
3 changed files with 48 additions and 45 deletions

View File

@ -262,7 +262,9 @@ CVS code -
- winio.c: - winio.c:
get_word_kbinput() get_word_kbinput()
- Limit the input word to hexadecimal FFFD instead of FFFF, as - Limit the input word to hexadecimal FFFD instead of FFFF, as
FFFE and FFFF are invalid Unicode characters. (DLR) FFFE and FFFF are invalid Unicode characters, rename variables
word and word_digits to uni and uni_digits, and rename to
get_unicode_kbinput(). (DLR)
display_string() display_string()
- Instead of using parse_mbchar()'s bad_chr parameter, use - Instead of using parse_mbchar()'s bad_chr parameter, use
mbrep() to get the representation of a bad character. (DLR) mbrep() to get the representation of a bad character. (DLR)

View File

@ -589,7 +589,7 @@ int get_byte_kbinput(int kbinput
, bool reset , bool reset
#endif #endif
); );
int get_word_kbinput(int kbinput int get_unicode_kbinput(int kbinput
#ifndef NANO_SMALL #ifndef NANO_SMALL
, bool reset , bool reset
#endif #endif

View File

@ -118,7 +118,7 @@ void reset_kbinput(void)
{ {
parse_kbinput(NULL, NULL, NULL, TRUE); parse_kbinput(NULL, NULL, NULL, TRUE);
get_byte_kbinput(0, TRUE); get_byte_kbinput(0, TRUE);
get_word_kbinput(0, TRUE); get_unicode_kbinput(0, TRUE);
} }
#endif #endif
@ -1206,7 +1206,7 @@ int get_byte_kbinput(int kbinput
retval = byte; retval = byte;
} else } else
/* If the character we got isn't a decimal digit, or if /* If the character we got isn't a decimal digit, or if
* it is and it would put the word sequence out of word * it is and it would put the byte sequence out of word
* range, save it as the result. */ * range, save it as the result. */
retval = kbinput; retval = kbinput;
break; break;
@ -1231,85 +1231,86 @@ int get_byte_kbinput(int kbinput
return retval; return retval;
} }
/* Translate a word sequence: turn a four-digit hexadecimal number from /* Translate a Unicode sequence: turn a four-digit hexadecimal number
* 0000 to fffd (case-insensitive) into its corresponding word value. */ * from 0000 to FFFD (case-insensitive) into its corresponding multibyte
int get_word_kbinput(int kbinput * value. */
int get_unicode_kbinput(int kbinput
#ifndef NANO_SMALL #ifndef NANO_SMALL
, bool reset , bool reset
#endif #endif
) )
{ {
static int word_digits = 0, word = 0; static int uni_digits = 0, uni = 0;
int retval = ERR; int retval = ERR;
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (reset) { if (reset) {
word_digits = 0; uni_digits = 0;
word = 0; uni = 0;
return ERR; return ERR;
} }
#endif #endif
/* Increment the word digit counter. */ /* Increment the word digit counter. */
word_digits++; uni_digits++;
switch (word_digits) { switch (uni_digits) {
case 1: case 1:
/* One digit: reset the word sequence holder and add the /* One digit: reset the Unicode sequence holder and add the
* digit we got to the 4096's position of the word sequence * digit we got to the 4096's position of the Unicode
* holder. */ * sequence holder. */
word = 0; uni = 0;
if ('0' <= kbinput && kbinput <= '9') if ('0' <= kbinput && kbinput <= '9')
word += (kbinput - '0') * 4096; uni += (kbinput - '0') * 4096;
else if ('a' <= tolower(kbinput) && tolower(kbinput) <= 'f') else if ('a' <= tolower(kbinput) && tolower(kbinput) <= 'f')
word += (tolower(kbinput) + 10 - 'a') * 4096; uni += (tolower(kbinput) + 10 - 'a') * 4096;
else else
/* If the character we got isn't a hexadecimal digit, or /* If the character we got isn't a hexadecimal digit, or
* if it is and it would put the word sequence out of * if it is and it would put the Unicode sequence out of
* word range, save it as the result. */ * valid range, save it as the result. */
retval = kbinput; retval = kbinput;
break; break;
case 2: case 2:
/* Two digits: add the digit we got to the 256's position of /* Two digits: add the digit we got to the 256's position of
* the word sequence holder. */ * the Unicode sequence holder. */
if ('0' <= kbinput && kbinput <= '9') if ('0' <= kbinput && kbinput <= '9')
word += (kbinput - '0') * 256; uni += (kbinput - '0') * 256;
else if ('a' <= tolower(kbinput) && tolower(kbinput) <= 'f') else if ('a' <= tolower(kbinput) && tolower(kbinput) <= 'f')
word += (tolower(kbinput) + 10 - 'a') * 256; uni += (tolower(kbinput) + 10 - 'a') * 256;
else else
/* If the character we got isn't a hexadecimal digit, or /* If the character we got isn't a hexadecimal digit, or
* if it is and it would put the word sequence out of * if it is and it would put the Unicode sequence out of
* word range, save it as the result. */ * valid range, save it as the result. */
retval = kbinput; retval = kbinput;
break; break;
case 3: case 3:
/* Three digits: add the digit we got to the 16's position /* Three digits: add the digit we got to the 16's position
* of the word sequence holder. */ * of the Unicode sequence holder. */
if ('0' <= kbinput && kbinput <= '9') if ('0' <= kbinput && kbinput <= '9')
word += (kbinput - '0') * 16; uni += (kbinput - '0') * 16;
else if ('a' <= tolower(kbinput) && tolower(kbinput) <= 'f') else if ('a' <= tolower(kbinput) && tolower(kbinput) <= 'f')
word += (tolower(kbinput) + 10 - 'a') * 16; uni += (tolower(kbinput) + 10 - 'a') * 16;
else else
/* If the character we got isn't a hexadecimal digit, or /* If the character we got isn't a hexadecimal digit, or
* if it is and it would put the word sequence out of * if it is and it would put the Unicode sequence out of
* word range, save it as the result. */ * valid range, save it as the result. */
retval = kbinput; retval = kbinput;
break; break;
case 4: case 4:
/* Four digits: add the digit we got to the 1's position of /* Four digits: add the digit we got to the 1's position of
* the word sequence holder, and save the corresponding word * the Unicode sequence holder, and save the corresponding
* value as the result. */ * Unicode value as the result. */
if ('0' <= kbinput && kbinput <= '9') { if ('0' <= kbinput && kbinput <= '9') {
word += (kbinput - '0'); uni += (kbinput - '0');
retval = word; retval = uni;
} else if ('a' <= tolower(kbinput) && } else if ('a' <= tolower(kbinput) &&
tolower(kbinput) <= 'd') { tolower(kbinput) <= 'd') {
word += (tolower(kbinput) + 10 - 'a'); uni += (tolower(kbinput) + 10 - 'a');
retval = word; retval = uni;
} else } else
/* If the character we got isn't a hexadecimal digit, or /* If the character we got isn't a hexadecimal digit, or
* if it is and it would put the word sequence out of * if it is and it would put the Unicode sequence out of
* word range, save it as the result. */ * valid range, save it as the result. */
retval = kbinput; retval = kbinput;
break; break;
default: default:
@ -1322,12 +1323,12 @@ int get_word_kbinput(int kbinput
/* If we have a result, reset the word digit counter and the word /* If we have a result, reset the word digit counter and the word
* sequence holder. */ * sequence holder. */
if (retval != ERR) { if (retval != ERR) {
word_digits = 0; uni_digits = 0;
word = 0; uni = 0;
} }
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "get_word_kbinput(): kbinput = %d, word_digits = %d, word = %d, retval = %d\n", kbinput, word_digits, word, retval); fprintf(stderr, "get_unicode_kbinput(): kbinput = %d, uni_digits = %d, uni = %d, retval = %d\n", kbinput, uni_digits, uni, retval);
#endif #endif
return retval; return retval;
@ -1410,8 +1411,8 @@ int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
/* Read in a stream of all available characters, and return the length /* Read in a stream of all available characters, and return the length
* of the string in kbinput_len. Translate the first few characters of * of the string in kbinput_len. Translate the first few characters of
* the input into the corresponding word value if possible. After that, * the input into the corresponding multibyte value if possible. After
* leave the input as-is. */ * that, leave the input as-is. */
int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len) int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
{ {
int *kbinput, word, *retval; int *kbinput, word, *retval;
@ -1420,7 +1421,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
while ((kbinput = get_input(win, 1)) == NULL); while ((kbinput = get_input(win, 1)) == NULL);
/* Check whether the first keystroke is a hexadecimal digit. */ /* Check whether the first keystroke is a hexadecimal digit. */
word = get_word_kbinput(*kbinput word = get_unicode_kbinput(*kbinput
#ifndef NANO_SMALL #ifndef NANO_SMALL
, FALSE , FALSE
#endif #endif
@ -1439,7 +1440,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len)
while (word == ERR) { while (word == ERR) {
while ((kbinput = get_input(win, 1)) == NULL); while ((kbinput = get_input(win, 1)) == NULL);
word = get_word_kbinput(*kbinput word = get_unicode_kbinput(*kbinput
#ifndef NANO_SMALL #ifndef NANO_SMALL
, FALSE , FALSE
#endif #endif