diff options
Diffstat (limited to 'fluid/code.cxx')
| -rw-r--r-- | fluid/code.cxx | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/fluid/code.cxx b/fluid/code.cxx index b07c9675c..f8fd58e6e 100644 --- a/fluid/code.cxx +++ b/fluid/code.cxx @@ -246,7 +246,9 @@ int write_number; // recursively dump code, putting children between the two parts // of the parent code: static Fl_Type* write_code(Fl_Type* p) { - p->write_code1(); + // don't write the last comment until the very end + if (!(p==Fl_Type::last && p->is_comment())) + p->write_code1(); Fl_Type* q; for (q = p->next; q && q->level > p->level;) q = write_code(q); p->write_code2(); @@ -271,6 +273,15 @@ int write_code(const char *s, const char *t) { if (!f) {fclose(code_file); return 0;} header_file = f; } + // if the first entry in the Type tree is a comment, then it is probably + // a copyright notice. We print that before anything else in the file! + Fl_Type* first_type = Fl_Type::first; + if (first_type && first_type->is_comment()) { + // this is ok, because comments have no children or code2 blocks + first_type->write_code1(); + first_type = first_type->next; + } + const char *hdr = "\ // generated by Fast Light User Interface Designer (fluid) version %.4f\n\n"; fprintf(header_file, hdr, FL_VERSION); @@ -311,7 +322,7 @@ int write_code(const char *s, const char *t) { write_c("#include \"%s\"\n", t); } } - for (Fl_Type* p = Fl_Type::first; p;) { + for (Fl_Type* p = first_type; p;) { // write all static data for this & all children first p->write_static(); for (Fl_Type* q = p->next; q && q->level > p->level; q = q->next) @@ -323,9 +334,16 @@ int write_code(const char *s, const char *t) { delete included_root; included_root = 0; if (!s) return 1; + + fprintf(header_file, "#endif\n"); + + Fl_Type* last_type = Fl_Type::last; + if (last_type && last_type->is_comment()) { + last_type->write_code1(); + } + int x = fclose(code_file); code_file = 0; - fprintf(header_file, "#endif\n"); int y = fclose(header_file); header_file = 0; return x >= 0 && y >= 0; |
