Index: ChangeLog =================================================================== RCS file: /cvsroot/xforms/xforms/ChangeLog,v retrieving revision 1.68 diff -u -p -r1.68 ChangeLog --- ChangeLog 26 Nov 2003 11:28:16 -0000 1.68 +++ ChangeLog 26 Nov 2003 16:34:13 -0000 @@ -1,5 +1,24 @@ 2003-11-26 Angus Leeming + * fdesign/fd_main.h: add a 'char * output_dir' var to the FD_Opt struct. + + * fdesign/fd_main.c: add code to initialize FD_Opt::output_dir. + + * fdesign/fd_forms.c (save_forms): pass fdopt.output_dir var to the + external converter if non-zero. + + * fdesign/fd_printC.c (filename_only, build_fname): new helper functions + that use FD_Opt::output_dir if it is set. + (C_output): invoke build_fname rather than building the file name + itself. + +2003-11-26 Jean-Marc Lasgouttes + + * fdesign/fd_forms.c (save_forms): do not try twice to remove .fd + from file name (avoids problem with path names containing a '.'). + +2003-11-26 Angus Leeming + * demos/boxtype.c: squash warning about uninitialized data. 2003-11-24 Angus Leeming Index: fdesign/fd_forms.c =================================================================== RCS file: /cvsroot/xforms/xforms/fdesign/fd_forms.c,v retrieving revision 1.5 diff -u -p -r1.5 fd_forms.c --- fdesign/fd_forms.c 24 Apr 2003 09:35:33 -0000 1.5 +++ fdesign/fd_forms.c 26 Nov 2003 16:34:13 -0000 @@ -491,15 +491,12 @@ save_forms(char *str) conv = convertor + fdopt.language; - if ((ff = strrchr(fname, '.'))) - *ff = '\0'; - /* some converter works on the c code */ if (conv->need_c_code) - convertor[FD_C].convert(fname, forms, fnumb); + convertor[FD_C].convert(filename, forms, fnumb); if (conv->convert) - return conv->convert(fname, forms, fnumb); + return conv->convert(filename, forms, fnumb); else if (conv->extern_convertor) { char cmdbuf[1024]; @@ -516,8 +513,12 @@ save_forms(char *str) strcat(optbuf, "-altformat "); if (fdopt.compensate) strcat(optbuf, "-compensate "); + if (fdopt.output_dir) { + strcat(optbuf, "-dir "); + strcat(optbuf, fdopt.output_dir); + } - sprintf(cmdbuf, "%s %s%s", conv->extern_convertor, optbuf, fname); + sprintf(cmdbuf, "%s %s%s", conv->extern_convertor, optbuf, filename); M_warn("Convert", "Executing %s", cmdbuf); if (fdopt.conv_only) Index: fdesign/fd_main.c =================================================================== RCS file: /cvsroot/xforms/xforms/fdesign/fd_main.c,v retrieving revision 1.8 diff -u -p -r1.8 fd_main.c --- fdesign/fd_main.c 21 Nov 2003 13:23:22 -0000 1.8 +++ fdesign/fd_main.c 26 Nov 2003 16:34:14 -0000 @@ -355,6 +355,7 @@ static FL_CMD_OPT fd_cmdopt[] = {"-geometry", "*geometry", XrmoptionSepArg, 0}, {"-border", ".XForm.Border", XrmoptionNoArg, "1"}, {"-convert", ".convert", XrmoptionNoArg, "1"}, + {"-dir", ".dir", XrmoptionSepArg, 0}, {"-unit", "*unit", XrmoptionSepArg, 0}, {"-altformat", "*altformat", XrmoptionNoArg, "1"}, {"-I", "*xformHeader", XrmoptionSepArg, 0}, @@ -402,6 +403,7 @@ static FL_resource fdres[] = {"align.geometry", "Align.Geometry", FL_STRING, fdaligngeom, 0, NG}, {"control.border", "XForm.Border", FL_BOOL, &fd_cntlborder, "0", 0}, {"convert", "Convert", FL_BOOL, &fdopt.conv_only, "0", 0}, + {"dir", "Dir", FL_STRING, &fdopt.output_dir, "", NG}, {"compensate", "Compensate", FL_BOOL, &fdopt.compensate, "0", 0}, {"unit", "Unit", FL_STRING, fd_sunit, "pixel", 30}, {"language", "Language", FL_STRING, fd_slanguage, "C", 30}, @@ -432,6 +434,7 @@ char *helps[] = "-lax go easy on syntax checking", "-I headername alternate header file (forms.h default)", "-convert file-list convert .fd to code non-interactively", + "-dir destdir output any generated files in destdir", "-geometry geom initial working area geometry", 0, }; @@ -557,6 +560,10 @@ pre_connect(int ac, char *av[]) { fl_set_no_connection(1); fdopt.conv_only = 1; + } + else if (strncmp(av[i] + 1, "dir", 3) == 0 && (i + 1) < ac) { + fdopt.output_dir = (char *)malloc(strlen(av[++i])); + strcpy(fdopt.output_dir, av[i]); } else if (strncmp(av[i] + 1, "lang", 4) == 0 && (i + 1) < ac) fdopt.language = lang_val(av[++i]); Index: fdesign/fd_main.h =================================================================== RCS file: /cvsroot/xforms/xforms/fdesign/fd_main.h,v retrieving revision 1.5 diff -u -p -r1.5 fd_main.h --- fdesign/fd_main.h 9 Sep 2003 00:28:25 -0000 1.5 +++ fdesign/fd_main.h 26 Nov 2003 16:34:14 -0000 @@ -60,6 +60,7 @@ typedef struct int show_pallete; int compensate; /* if emit font size compensation code */ int unit; + char * output_dir; } FD_Opt; Index: fdesign/fd_printC.c =================================================================== RCS file: /cvsroot/xforms/xforms/fdesign/fd_printC.c,v retrieving revision 1.6 diff -u -p -r1.6 fd_printC.c --- fdesign/fd_printC.c 20 Nov 2003 10:46:15 -0000 1.6 +++ fdesign/fd_printC.c 26 Nov 2003 16:34:15 -0000 @@ -64,6 +64,28 @@ make_backup(const char *s) } } +static char const * +filename_only(char const * filename) +{ + char const * ptr = filename + strlen(filename) - 1; + for (; ptr >= filename; --ptr) { + if (*ptr == '/') + break; + } + return ptr; +} + +static void +build_fname(char * fname, char const * filename, char const * ext) +{ + if (fdopt.output_dir) { + strcpy(fname, fdopt.output_dir); + strcat(fname, filename_only(filename)); + } else + strcpy(fname, filename); + strcat(fname, ext); +} + /* filename is without extensions */ int C_output(const char *filename, FRM * forms, int fnumb) @@ -72,8 +94,7 @@ C_output(const char *filename, FRM * for int i, j; FILE *fn; - strcpy(fname, filename); - strcat(fname, ".h"); + build_fname(fname, filename, ".h"); make_backup(fname); if (!(fn = fopen(fname, "w"))) @@ -109,8 +130,7 @@ C_output(const char *filename, FRM * for fclose(fn); /* Make the .c file. */ - strcpy(fname, filename); - strcat(fname, ".c"); + build_fname(fname, filename, ".c"); make_backup(fname); if (!(fn = fopen(fname, "w")))