aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1997-10-23 12:01:50 +0000
committerKenichi Handa1997-10-23 12:01:50 +0000
commit9d3d8cba5a8430544f433330a0c8b3bc727b0d50 (patch)
treea33daa22aa00e455c849130554566f265e5f81fb /src
parent15979e9ebcdeb0e622057faa81c935f98c67a80d (diff)
downloademacs-9d3d8cba5a8430544f433330a0c8b3bc727b0d50.tar.gz
emacs-9d3d8cba5a8430544f433330a0c8b3bc727b0d50.zip
(char_valid_p): New function
(Fchar_valid_p): New function. (syms_of_charset): Declare it as a Lisp function.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/charset.c b/src/charset.c
index c8665b49130..7d8716e134e 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -727,6 +727,44 @@ DEFUN ("iso-charset", Fiso_charset, Siso_charset, 3, 3, 0,
727 return CHARSET_SYMBOL (charset); 727 return CHARSET_SYMBOL (charset);
728} 728}
729 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. */
734int
735char_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
756DEFUN ("char-valid-p", Fchar_valid_p, Schar_valid_p, 1, 2, 0,
757 "Return t if OBJECT is a valid normal character.
758If optional arg GENERICP is non-nil, also return t if OBJECT is
759a 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);
766}
767
730DEFUN ("char-bytes", Fchar_bytes, Schar_bytes, 1, 1, 0, 768DEFUN ("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)
@@ -1584,6 +1622,7 @@ syms_of_charset ()
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);