+/************************************************************************/
+/* Lisp string representation convenience functions */
+/************************************************************************/
+/* Because the representation of internally formatted data is subject to change,
+ It's bad style to do something like strcmp (XSTRING_DATA (s), "foo")
+ Instead, use the portable: bufbyte_strcmp (XSTRING_DATA (s), "foo")
+ or bufbyte_memcmp (XSTRING_DATA (s), "foo", 3) */
+
+/* Like strcmp, except first arg points at internally formatted data,
+ while the second points at a string of only ASCII chars. */
+INLINE_HEADER int
+bufbyte_strcmp (const Bufbyte *bp, const char *ascii_string);
+INLINE_HEADER int
+bufbyte_strcmp (const Bufbyte *bp, const char *ascii_string)
+{
+#ifdef MULE
+ while (1)
+ {
+ int diff;
+ type_checking_assert (BYTE_ASCII_P (*ascii_string));
+ if ((diff = charptr_emchar (bp) - *(Bufbyte *) ascii_string) != 0)
+ return diff;
+ if (*ascii_string == '\0')
+ return 0;
+ ascii_string++;
+ INC_CHARPTR (bp);
+ }
+#else
+ return strcmp ((char *)bp, ascii_string);
+#endif
+}
+
+
+/* Like memcmp, except first arg points at internally formatted data,
+ while the second points at a string of only ASCII chars. */
+INLINE_HEADER int
+bufbyte_memcmp (const Bufbyte *bp, const char *ascii_string, size_t len);
+INLINE_HEADER int
+bufbyte_memcmp (const Bufbyte *bp, const char *ascii_string, size_t len)
+{
+#ifdef MULE
+ while (len--)
+ {
+ int diff = charptr_emchar (bp) - *(Bufbyte *) ascii_string;
+ type_checking_assert (BYTE_ASCII_P (*ascii_string));
+ if (diff != 0)
+ return diff;
+ ascii_string++;
+ INC_CHARPTR (bp);
+ }
+ return 0;
+#else
+ return memcmp (bp, ascii_string, len);
+#endif
+}
+