summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2009-07-08 19:57:06 -0700
committerJoshua Haberman <joshua@reverberate.org>2009-07-08 19:57:06 -0700
commit6d77fa04597f453e7af38c5b3f791c2aba3a282a (patch)
tree2123387eac3d31da0f956a432dc666a52c602acf
parente8718306a5bc688bea31c03d52b997166f0ba578 (diff)
More compiler work.
-rw-r--r--tools/upbc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/upbc.c b/tools/upbc.c
index 51029d0..fa264d7 100644
--- a/tools/upbc.c
+++ b/tools/upbc.c
@@ -205,7 +205,7 @@ static void write_h(struct upb_symtab_entry *entries[], int num_entries,
struct strtable_entry {
struct upb_strtable_entry e;
- size_t offset;
+ int offset;
int num;
};
@@ -275,7 +275,7 @@ static void write_c(struct upb_symtab_entry *entries[], int num_entries,
qsort(str_entries, size, sizeof(void*), compare_entries);
/* Emit strings. */
- fputs("static const char strings[] =\n \"", stream);
+ fputs("static char strdata[] =\n \"", stream);
int col = 2;
int offset = 0;
for(int i = 0; i < size; i++) {
@@ -291,7 +291,16 @@ static void write_c(struct upb_symtab_entry *entries[], int num_entries,
}
offset += s->byte_len;
}
- fputs("\"\n\n", stream);
+ fputs("\";\n\n", stream);
+
+ fputs("static struct upb_string strings[] = {\n", stream);
+ for(int i = 0; i < size; i++) {
+ struct strtable_entry *e = str_entries[i];
+ fprintf(stream, " {.ptr = &strdata[%d], .byte_len=%d}", e->offset, e->e.key.byte_len);
+ if(i+1 != size) fputc(',', stream);
+ fputc('\n', stream);
+ }
+ fputs("};\n\n", stream);
}
const char usage[] =
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback