|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
#define _BSD_SOURCE
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <string.h>
|
|
|
@ -26,7 +27,7 @@ struct entity {
|
|
|
|
struct letter {
|
|
|
|
struct letter {
|
|
|
|
unsigned char c;
|
|
|
|
unsigned char c;
|
|
|
|
struct letters* weiter;
|
|
|
|
struct letters* weiter;
|
|
|
|
uint32_t marshaled; // lower 8 bits: char. rest: ofs from start of marshaled blob
|
|
|
|
uint32_t marshaled; /* lower 8 bits: char. rest: ofs from start of marshaled blob */
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct letters {
|
|
|
|
struct letters {
|
|
|
@ -98,19 +99,19 @@ void marshalhelper(struct letters* s) {
|
|
|
|
if (!s) return;
|
|
|
|
if (!s) return;
|
|
|
|
used+=s->n;
|
|
|
|
used+=s->n;
|
|
|
|
assert(used<nodes+2);
|
|
|
|
assert(used<nodes+2);
|
|
|
|
for (i=1; i!=0; ++i) { // start at 1, go to 256, then access modulo 256; effect: sort but put 0 last
|
|
|
|
for (i=1; i!=0; ++i) { /* start at 1, go to 256, then access modulo 256; effect: sort but put 0 last */
|
|
|
|
uint32_t x;
|
|
|
|
uint32_t x;
|
|
|
|
i&=0xff;
|
|
|
|
i&=0xff;
|
|
|
|
// printf("%c ",i);
|
|
|
|
/* printf("%c ",i); */
|
|
|
|
if (s->liste[i].c!=i) {
|
|
|
|
if (s->liste[i].c!=i) {
|
|
|
|
if (i==0) return;
|
|
|
|
if (i==0) return;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// printf("marshalhelper: %c\n",i);
|
|
|
|
/* printf("marshalhelper: %c\n",i); */
|
|
|
|
x=(unsigned char)s->liste[i].c;
|
|
|
|
x=(unsigned char)s->liste[i].c;
|
|
|
|
if (!x) {
|
|
|
|
if (!x) {
|
|
|
|
size_t l=strlen((char*)s->liste[i].weiter)+1;
|
|
|
|
size_t l=strlen((char*)s->liste[i].weiter)+1;
|
|
|
|
// puts((char*)s->liste[i].weiter);
|
|
|
|
/* puts((char*)s->liste[i].weiter); */
|
|
|
|
x|=useddata<<8;
|
|
|
|
x|=useddata<<8;
|
|
|
|
assert(useddata+l<=datasize);
|
|
|
|
assert(useddata+l<=datasize);
|
|
|
|
memcpy(data+useddata,s->liste[i].weiter,l);
|
|
|
|
memcpy(data+useddata,s->liste[i].weiter,l);
|
|
|
@ -123,7 +124,7 @@ void marshalhelper(struct letters* s) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
marshaled[++myindex]=x;
|
|
|
|
marshaled[++myindex]=x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// printf("return\n");
|
|
|
|
/* printf("return\n"); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void marshal(struct letters* s) {
|
|
|
|
void marshal(struct letters* s) {
|
|
|
@ -169,13 +170,13 @@ int main() {
|
|
|
|
char* s,* entity;
|
|
|
|
char* s,* entity;
|
|
|
|
size_t ul;
|
|
|
|
size_t ul;
|
|
|
|
if (!isspace(buf[0])) continue;
|
|
|
|
if (!isspace(buf[0])) continue;
|
|
|
|
for (s=buf; *s && *s!='"'; ++s) ; // skip whitespace
|
|
|
|
for (s=buf; *s && *s!='"'; ++s) ; /* skip whitespace */
|
|
|
|
if (!(*s=='"')) continue;
|
|
|
|
if (!(*s=='"')) continue;
|
|
|
|
++s;
|
|
|
|
++s;
|
|
|
|
entity=s;
|
|
|
|
entity=s;
|
|
|
|
if (*entity!='&') continue;
|
|
|
|
if (*entity!='&') continue;
|
|
|
|
++entity; ++s;
|
|
|
|
++entity; ++s;
|
|
|
|
for (; *s && *s!='"'; ++s) ; // skip to end of entity
|
|
|
|
for (; *s && *s!='"'; ++s) ; /* skip to end of entity */
|
|
|
|
if (!(*s=='"')) continue;
|
|
|
|
if (!(*s=='"')) continue;
|
|
|
|
if (s[-1]!=';') continue;
|
|
|
|
if (s[-1]!=';') continue;
|
|
|
|
s[-1]=0; ++s;
|
|
|
|
s[-1]=0; ++s;
|
|
|
@ -217,7 +218,7 @@ int main() {
|
|
|
|
addword(&d,(*cur)->entity,(*cur)->utf8);
|
|
|
|
addword(&d,(*cur)->entity,(*cur)->utf8);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
fclose(f);
|
|
|
|
// dump(d,0);
|
|
|
|
/* dump(d,0); */
|
|
|
|
marshal(d);
|
|
|
|
marshal(d);
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE* f=fopen("entities.h","w");
|
|
|
|
FILE* f=fopen("entities.h","w");
|
|
|
@ -235,7 +236,7 @@ int main() {
|
|
|
|
fprintf(f,"\n }\n};");
|
|
|
|
fprintf(f,"\n }\n};");
|
|
|
|
fclose(f);
|
|
|
|
fclose(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// puts(lookup(heap,1,"zwnj"));
|
|
|
|
/* puts(lookup(heap,1,"zwnj")); */
|
|
|
|
#if 0
|
|
|
|
#if 0
|
|
|
|
puts("};");
|
|
|
|
puts("};");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|