comparison src/charset.c @ 20152:9a3343c36e83

(char_valid_p): New function (Fchar_valid_p): New function. (syms_of_charset): Declare it as a Lisp function.
author Kenichi Handa <handa@m17n.org>
date Thu, 23 Oct 1997 12:01:50 +0000
parents a62008636710
children d4ad4463384d
comparison
equal deleted inserted replaced
20151:82ca32c55fa3 20152:9a3343c36e83
723 CHECK_NUMBER (final_char, 2); 723 CHECK_NUMBER (final_char, 2);
724 724
725 if ((charset = ISO_CHARSET_TABLE (dimension, chars, final_char)) < 0) 725 if ((charset = ISO_CHARSET_TABLE (dimension, chars, final_char)) < 0)
726 return Qnil; 726 return Qnil;
727 return CHARSET_SYMBOL (charset); 727 return CHARSET_SYMBOL (charset);
728 }
729
730 /* If GENERICP is nonzero, return nonzero iff C is a valid normal or
731 generic character. If GENERICP is zero, return nonzero iff C is a
732 valid normal character. Do not call this function directly,
733 instead use macro CHAR_VALID_P. */
734 int
735 char_valid_p (c, genericp)
736 int c, genericp;
737 {
738 int charset, c1, c2;
739
740 if (c < 0)
741 return 0;
742 if (SINGLE_BYTE_CHAR_P (c))
743 return 1;
744 SPLIT_NON_ASCII_CHAR (c, charset, c1, c2);
745 if (!CHARSET_VALID_P (charset))
746 return 0;
747 return (c < MIN_CHAR_COMPOSITION
748 ? ((c & CHAR_FIELD1_MASK) /* i.e. dimension of C is two. */
749 ? (genericp && c1 == 0 && c2 == 0
750 || c1 >= 32 && c2 >= 32)
751 : (genericp && c1 == 0
752 || c1 >= 32))
753 : c < MIN_CHAR_COMPOSITION + n_cmpchars);
754 }
755
756 DEFUN ("char-valid-p", Fchar_valid_p, Schar_valid_p, 1, 2, 0,
757 "Return t if OBJECT is a valid normal character.
758 If optional arg GENERICP is non-nil, also return t if OBJECT is
759 a valid generic character.")
760 (object, genericp)
761 Lisp_Object object, genericp;
762 {
763 if (! NATNUMP (object))
764 return Qnil;
765 return (CHAR_VALID_P (XFASTINT (object), !NILP (genericp)) ? Qt : Qnil);
728 } 766 }
729 767
730 DEFUN ("char-bytes", Fchar_bytes, Schar_bytes, 1, 1, 0, 768 DEFUN ("char-bytes", Fchar_bytes, Schar_bytes, 1, 1, 0,
731 "Return byte length of multi-byte form of CHAR.") 769 "Return byte length of multi-byte form of CHAR.")
732 (ch) 770 (ch)
1582 defsubr (&Sfind_charset_string); 1620 defsubr (&Sfind_charset_string);
1583 defsubr (&Smake_char_internal); 1621 defsubr (&Smake_char_internal);
1584 defsubr (&Ssplit_char); 1622 defsubr (&Ssplit_char);
1585 defsubr (&Schar_charset); 1623 defsubr (&Schar_charset);
1586 defsubr (&Siso_charset); 1624 defsubr (&Siso_charset);
1625 defsubr (&Schar_valid_p);
1587 defsubr (&Schar_bytes); 1626 defsubr (&Schar_bytes);
1588 defsubr (&Schar_width); 1627 defsubr (&Schar_width);
1589 defsubr (&Sstring_width); 1628 defsubr (&Sstring_width);
1590 defsubr (&Schar_direction); 1629 defsubr (&Schar_direction);
1591 defsubr (&Schars_in_string); 1630 defsubr (&Schars_in_string);