From 36b8a40cd7458b76e5eb646f58a3eb9f705d0154 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 14 Jun 2002 10:51:32 +0000 Subject: [PATCH] Fail gracefully if fdesign fails. Don't overwrite the .h file if the newly generated one is identical. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4400 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/xforms/ChangeLog | 14 ++++++++++---- src/frontends/xforms/forms/README | 16 ++++++++++------ src/frontends/xforms/forms/fdfix.sh | 23 +++++++++++++++++++++-- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index fb67613d56..827643a63a 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -2,6 +2,12 @@ * forms/Makefile.am: make the .Ch files dependent on the fdfix files. + * fdfix.sh: test whether "fdesign -convert file.fd" succeeds and + if not, exit gracefully. + Test whether the newly generated .h file is different from the existing + one and if not discard it to prevent unnecessary recompilation in the + xforms directory. + 2002-06-14 Angus Leeming * FormPreferences (XYZ::build): pass "&parent_" to build_xyz, not @@ -30,10 +36,10 @@ FormXyz class. It's unnecessary and needs patch files in addition to the sed magic to work properly. Thus, the structs above are now generated by routines - FD_aboutlyx * build_aboutlyx(); - FD_aboutlyx_version * build_aboutlyx_version(); - FD_aboutlyx_credits * build_aboutlyx_credits(); - FD_aboutlyx_license * build_aboutlyx_license(); + FD_aboutlyx * build_aboutlyx(void *); + FD_aboutlyx_version * build_aboutlyx_version(void *); + FD_aboutlyx_credits * build_aboutlyx_credits(void *); + FD_aboutlyx_license * build_aboutlyx_license(void *); * forms/README: document all the above. diff --git a/src/frontends/xforms/forms/README b/src/frontends/xforms/forms/README index 4bbbf0922f..c5c941d7e2 100644 --- a/src/frontends/xforms/forms/README +++ b/src/frontends/xforms/forms/README @@ -52,9 +52,13 @@ If you follow these simple rules then you will generate code for functions build_xxx that will need no further editing to make them work. For example, form_graphics.h contains the struct declarations and build methods, so: -extern FD_graphics * build_graphics(); -extern FD_graphics_file * build_graphics_file(); -extern FD_graphics_size * build_graphics_size(); -extern FD_graphics_bbox * build_graphics_bbox(); -extern FD_graphics_special * build_graphics_special(); -extern FD_graphics_lyxview * build_graphics_lyxview(); +extern FD_graphics * build_graphics(void *); +extern FD_graphics_file * build_graphics_file(void *); +extern FD_graphics_size * build_graphics_size(void *); +extern FD_graphics_bbox * build_graphics_bbox(void *); +extern FD_graphics_special * build_graphics_special(void *); +extern FD_graphics_lyxview * build_graphics_lyxview(void *); + +where the function is to be passed a pointer to the parent dialog +(usually "this") so that this pointer can be cast of to FormBase * and +the appropriate method called. diff --git a/src/frontends/xforms/forms/fdfix.sh b/src/frontends/xforms/forms/fdfix.sh index 6a4d143dc8..154fa09dbb 100644 --- a/src/frontends/xforms/forms/fdfix.sh +++ b/src/frontends/xforms/forms/fdfix.sh @@ -52,6 +52,10 @@ fi FDESIGN=fdesign FDFILE=${BASENAME}.fd (cd ${DIRNAME}; ${FDESIGN} -convert ${FDFILE}) +if [ $? -ne 0 ]; then + echo "\"${FDESIGN} -convert ${FDFILE}\" failed. Please investigate." + exit 1 +fi #================================== # Modify the .h file for use by LyX @@ -72,9 +76,24 @@ if [ -f "${HPATCH}" ] ; then patch -s ${HOUT} < ${HPATCH} fi -# Clean up, to leave the finished .h file +# Clean up, to leave the finished .h file. We can be a little tricky here +# testing to see if the finished file exists already and if it does +# testing whether there are any differences. +# If there are no differences, then don't overwrite to prevent unnecessary +# compilation in the xforms directory. rm -f ${HIN} -mv ${HOUT} ${BASENAME}.h +MOVE_H_FILE=1 +if [ -r ${BASENAME}.h ]; then + cmp -s ${HOUT} ${BASENAME}.h + if [ $? -eq 0 ]; then + MOVE_H_FILE=0 + fi +fi +if [ ${MOVE_H_FILE} -eq 1 ]; then + mv ${HOUT} ${BASENAME}.h +else + rm -f ${HOUT} +fi #================================== # Create the .C file for use by LyX