+static int ampr (int (*get_byte)(void *fh), void *fh, int *amp)
+{
+ int c = (*get_byte)(fh);
+ *amp = 0;
+ if (c == '&')
+ {
+ char ent[20];
+ int i = 0;
+
+ while (1)
+ {
+ c = (*get_byte)(fh);
+ if (c == ';')
+ {
+ ent[i] = 0;
+
+ c = ' ';
+ if (!strcmp (ent, "quot"))
+ c = '"';
+ if (!strcmp (ent, "apos"))
+ c = '\'';
+ if (!strcmp (ent, "gt"))
+ c = '>';
+ if (!strcmp (ent, "lt"))
+ c = '<';
+ if (!strcmp (ent, "amp"))
+ c = '&';
+ *amp = 1;
+ break;
+ }
+ else if (c == 0 || d1_isspace(c))
+ break;
+ if (i < 19)
+ ent[i++] = c;
+ }
+ }
+ return c;
+}