+/* Check if the characters in ABBREV have word syntax in either the
+ * current (if global == 0) or standard syntax table. */
+static void
+abbrev_check_chars (abbrev, global)
+ Lisp_Object abbrev;
+ int global;
+{
+ int i, i_byte, len, nbad = 0;
+ int j, found, nuniq = 0;
+ char *badchars, *baduniq;
+
+ CHECK_STRING (abbrev);
+ len = SCHARS (abbrev);
+
+ badchars = (char *) alloca (len + 1);
+
+ for (i = 0, i_byte = 0; i < len; )
+ {
+ int c;
+
+ FETCH_STRING_CHAR_ADVANCE (c, abbrev, i, i_byte);
+
+ if (global)
+ {
+ /* Copied from SYNTAX in syntax.h, except using FOLLOW_PARENT. */
+ Lisp_Object syntax_temp
+ = CHAR_TABLE_REF (Vstandard_syntax_table, c);
+ if ( (CONSP (syntax_temp)
+ ? (enum syntaxcode) (XINT (XCAR (syntax_temp)) & 0xff)
+ : Swhitespace) != Sword ) badchars[nbad++] = c;
+ }
+ else if (SYNTAX (c) != Sword)
+ badchars[nbad++] = c;
+ }
+
+ if (nbad == 0) return;
+
+ baduniq = (char *) alloca (nbad + 1);
+
+ for (i = 0; i < nbad; i++)
+ {
+ found = 0;
+
+ for (j = 0; j < nuniq; j++)
+ {
+ if (badchars[i] == baduniq[j])
+ {
+ found = 1;
+ break;
+ }
+ }
+
+ if (found) continue ;
+
+ baduniq[nuniq++] = badchars[i];
+ }
+
+ baduniq[nuniq] = '\0';
+
+ error ("Some abbrev characters (%s) are not word constituents %s",
+ baduniq, global ? "in the standard syntax" : "in this mode" );
+}
+