2000-06-12 11:55:12 +00:00
|
|
|
#! /bin/sh
|
|
|
|
#
|
|
|
|
# NOTE: This is NOT the same fdfix.sh as in ${top_srcdir}/forms
|
|
|
|
# It is a modified version to suit use for gui-indep.
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ ! -f $1 ]; then
|
2000-08-14 05:24:35 +00:00
|
|
|
echo "Input file does not exist. Cannot continue"
|
2000-06-12 11:55:12 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2000-08-14 05:24:35 +00:00
|
|
|
FDESIGN=fdesign
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
# names of the files generated by fdesign and by running the sed scripts
|
|
|
|
BASE=`basename $1 .fd`
|
|
|
|
|
|
|
|
if [ $1 = $BASE ]; then
|
2000-08-14 05:24:35 +00:00
|
|
|
echo "Input file is not a .fd file. Cannot continue"
|
|
|
|
exit 1
|
2000-06-12 11:55:12 +00:00
|
|
|
fi
|
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
CIN=$BASE.c
|
|
|
|
COUT=$BASE.C
|
|
|
|
HIN=$BASE.h
|
|
|
|
HOUT=$BASE.H
|
|
|
|
|
|
|
|
# Ascertain the class name from the name of the file
|
|
|
|
# eg form_my_new_dialog -> FormMyNewDialog
|
|
|
|
CLASSNAME=""
|
|
|
|
SECTION="start"
|
|
|
|
i=1
|
|
|
|
while :
|
|
|
|
do
|
|
|
|
SECTION=`echo $BASE | cut -d_ -f$i`
|
|
|
|
i=`expr $i + 1 `
|
2000-06-12 11:55:12 +00:00
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
if [ $SECTION ]
|
|
|
|
then
|
|
|
|
FIRST=`echo $SECTION | cut -c1 | tr a-z A-Z`
|
|
|
|
SECOND=`echo $SECTION | cut -c2-`
|
|
|
|
CLASSNAME=$CLASSNAME$FIRST$SECOND
|
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2000-06-12 11:55:12 +00:00
|
|
|
|
2000-08-14 05:24:35 +00:00
|
|
|
# Create .c and .h files
|
|
|
|
$FDESIGN -convert $1
|
2000-10-24 13:13:59 +00:00
|
|
|
FDFIXH=fdfixh.sed
|
|
|
|
FDFIXC=fdfixc.sed
|
2000-08-14 05:24:35 +00:00
|
|
|
|
|
|
|
# Modify .h file for use by LyX
|
2000-10-24 13:13:59 +00:00
|
|
|
echo "// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext" > $HOUT
|
|
|
|
sed -f $FDFIXH < $HIN >> $HOUT
|
2000-08-14 05:24:35 +00:00
|
|
|
|
|
|
|
# Patch the .h file if a patch exists
|
2000-10-24 13:13:59 +00:00
|
|
|
if [ -f "$HOUT.patch" ] ; then
|
|
|
|
echo "Patching $HOUT with $HOUT.patch"
|
|
|
|
patch -s $HOUT < $HOUT.patch
|
2000-08-14 05:24:35 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Modify .c file for use by LyX
|
2000-10-24 13:13:59 +00:00
|
|
|
echo "// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext" > $COUT
|
|
|
|
echo "#include <config.h>" >> $COUT
|
|
|
|
echo "#include \"lyx_gui_misc.h\"" >> $COUT
|
|
|
|
echo "#include \"gettext.h\"" >> $COUT
|
|
|
|
echo >> $COUT
|
2000-08-14 05:24:35 +00:00
|
|
|
|
2000-10-24 13:13:59 +00:00
|
|
|
sed -f $FDFIXC < $CIN | sed -e "s/CLASSNAME/$CLASSNAME/" >> $COUT
|
2000-08-14 05:24:35 +00:00
|
|
|
|
|
|
|
# Patch the .C file if a patch exists
|
2000-10-24 13:13:59 +00:00
|
|
|
if [ -f "$COUT.patch" ] ; then
|
|
|
|
echo "Patching $COUT with $COUT.patch"
|
|
|
|
patch -s $COUT < $COUT.patch
|
2000-08-14 05:24:35 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Clean up, to leave .C and .h files
|
2000-10-24 13:13:59 +00:00
|
|
|
rm -f $CIN $HIN
|
|
|
|
mv $HOUT $HIN
|