+2002-11-21 Angus Leeming <leeming@lyx.org>
+
+ * scripts/lyxpreview2bitmap.sh: Don't use "if [ $? -ne 0 ]; then..."
+
2002-11-20 John Levon <levon@movementarian.org>
* images/math/: implement missing math icons
# Three helper functions.
FIND_IT () {
- which ${EXECUTABLE} > /dev/null
- if [ $? -ne 0 ]; then
+ which ${EXECUTABLE} > /dev/null ||
+ {
echo "Unable to find \"${EXECUTABLE}\". Please install."
exit 1
- fi
+ }
}
BAIL_OUT () {
# LaTeX -> DVI.
cd ${DIR}
-latex ${TEXFILE}
-if [ $? -ne 0 ]; then
+latex ${TEXFILE} ||
+{
echo "Failed: latex ${TEXFILE}"
BAIL_OUT
-fi
+}
# Parse ${LOGFILE} to obtain bounding box info to output to
# ${METRICSFILE}.
# This extracts lines starting "Preview: Tightpage" and
# "Preview: Snippet".
-grep -E 'Preview: [ST]' ${LOGFILE} > ${METRICSFILE}
-if [ $? -ne 0 ]; then
+grep -E 'Preview: [ST]' ${LOGFILE} > ${METRICSFILE} ||
+{
echo "Failed: grep -E 'Preview: [ST]' ${LOGFILE}"
REQUIRED_VERSION
BAIL_OUT
-fi
+}
# Parse ${LOGFILE} to obtain ${RESOLUTION} for the gs process to follow.
# 1. Extract font size from a line like "Preview: Fontsize 20.74pt"
# Use grep for speed and because it gives an error if the line is
# not found.
-LINE=`grep 'Preview: Fontsize' ${LOGFILE}`
-if [ $? -ne 0 ]; then
+LINE=`grep 'Preview: Fontsize' ${LOGFILE}` ||
+{
echo "Failed: grep 'Preview: Fontsize' ${LOGFILE}"
REQUIRED_VERSION
BAIL_OUT
-fi
+}
# The sed script strips out everything that won't form a decimal number
# from the line. It bails out after the first match has been made in
# case there are multiple lines "Preview: Fontsize". (There shouldn't
# "Preview: Magnification 2074"
# If no such line found, default to MAGNIFICATION=1000.
LINE=`grep 'Preview: Magnification' ${LOGFILE}`
-if [ $? -ne 0 ]; then
- MAGNIFICATION=1000
-else
+if LINE=`grep 'Preview: Magnification' ${LOGFILE}`; then
# Strip out everything that won't form an /integer/.
MAGNIFICATION=`echo "${LINE}" | sed 's/[^0-9]//g; 1q'`
+else
+ MAGNIFICATION=1000
fi
# 3. Compute resolution.
| bc`
# DVI -> PostScript
-dvips -o ${PSFILE} ${DVIFILE}
-if [ $? -ne 0 ]; then
+dvips -o ${PSFILE} ${DVIFILE} ||
+{
echo "Failed: dvips -o ${PSFILE} ${DVIFILE}"
BAIL_OUT
-fi
+}
# PostScript -> Bitmap files
# Older versions of gs have problems with a large degree of
gs -q -dNOPAUSE -dBATCH -dSAFER \
-sDEVICE=${GSDEVICE} -sOutputFile=${BASE}%d.${GSSUFFIX} \
-dGraphicsAlphaBit=${ALPHA} -dTextAlphaBits=${ALPHA} \
- -r${RESOLUTION} ${PSFILE}
-
-if [ $? -ne 0 ]; then
+ -r${RESOLUTION} ${PSFILE} ||
+{
echo "Failed: gs ${PSFILE}"
BAIL_OUT
-fi
+}
# All has been successful, so remove everything except the bitmap files
# and the metrics file.
# The bitmap files can have large amounts of whitespace to the left and
# right. This can be cropped if so desired.
CROP=1
-
-which pnmcrop > /dev/null
-if [ $? -ne 0 ]; then
- CROP=0
-fi
+which pnmcrop > /dev/null || CROP=0
# There's no point cropping the image if using PNG images. If you want to
# crop, use PPM.
if [ ${CROP} -eq 1 -a "${GSDEVICE}" = "pnmraw" ]; then
for FILE in ${BASE}*.${GSSUFFIX}
do
- pnmcrop -left ${FILE} | pnmcrop -right > ${BASE}.tmp
- if [ $? -eq 0 ]; then
+ if pnmcrop -left ${FILE} 2> /dev/null |\
+ pnmcrop -right 2> /dev/null > ${BASE}.tmp; then
mv ${BASE}.tmp ${FILE}
else
rm -f ${BASE}.tmp
done
rm -f ${BASE}.tmp
fi
+
+echo "Previews generated!"
2002-11-21 Angus Leeming <leeming@lyx.org>
+ * forms/fdfix.sh: Don't use "if [ $? -ne 0 ]; then..."
+
* FormSpellchecker.C (updateState): new method, replacing Black Magic.
Should also resolve Darren Freeman's redraw of the status bar problem.
double const wordcount = controller().getCount();
- // set slider 'finished' status
fl_set_slider_bounds(dialog_->slider_progress, 0.0, wordcount);
fl_set_slider_value(dialog_->slider_progress, wordcount);
fl_set_object_label(dialog_->slider_progress, "100 %");
#===============
# Initial checks
if [ ! -f $1 ]; then
- echo "Input file does not exist. Cannot continue"
- exit 1
+ echo "Input file does not exist. Cannot continue"
+ exit 1
fi
DIRNAME=`dirname $1`
BASENAME=`basename $1 .fd`
if [ $1 = ${BASENAME} ]; then
- echo "Input file is not a .fd file. Cannot continue"
- exit 1
+ echo "Input file is not a .fd file. Cannot continue"
+ exit 1
fi
#===================================
# Create the initial .c and .h files
FDESIGN=fdesign
FDFILE=${BASENAME}.fd
-if (cd ${DIRNAME} && ${FDESIGN} -convert ${FDFILE}); then : ; else
- echo "\"${FDESIGN} -convert ${FDFILE}\" failed. Please investigate."
- exit 1
-fi
+
+(cd ${DIRNAME} && ${FDESIGN} -convert ${FDFILE}) ||
+{
+ echo "\"${FDESIGN} -convert ${FDFILE}}\" failed. Please investigate."
+ exit 1
+}
#==================================
# Modify the .h file for use by LyX
# Patch the .h file if a patch exists
if [ -f "${HPATCH}" ] ; then
- echo "Patching ${HOUT} with ${HPATCH}"
- patch -s ${HOUT} < ${HPATCH}
+ echo "Patching ${HOUT} with ${HPATCH}"
+ patch -s ${HOUT} < ${HPATCH}
fi
# Clean up, to leave the finished .h file. We can be a little tricky here
rm -f ${HIN}
MOVE_H_FILE=1
if [ -r ${BASENAME}.h ]; then
- if cmp -s ${HOUT} ${BASENAME}.h; then
- MOVE_H_FILE=0
- fi
+ cmp -s ${HOUT} ${BASENAME}.h && MOVE_H_FILE=0
fi
+
if [ ${MOVE_H_FILE} -eq 1 ]; then
- mv ${HOUT} ${BASENAME}.h
+ mv ${HOUT} ${BASENAME}.h
else
- rm -f ${HOUT}
+ rm -f ${HOUT}
fi
#==================================
echo "#include \"forms_gettext.h\"" >> ${COUT}
echo "#include \"gettext.h\"" >> ${COUT}
-if grep bmtable ${CIN} > /dev/null; then
- echo "#include \"bmtable.h\"" >> ${COUT}
-fi
+grep bmtable ${CIN} > /dev/null &&
+ echo "#include \"bmtable.h\"" >> ${COUT}
sed -f ${FDFIXC} < ${CIN} >> ${COUT}
# Patch the .C file if a patch exists
if [ -f "${CPATCH}" ] ; then
- echo "Patching ${COUT} with ${CPATCH}"
- patch -s ${COUT} < ${CPATCH}
+ echo "Patching ${COUT} with ${CPATCH}"
+ patch -s ${COUT} < ${CPATCH}
fi
# Clean up, to leave the finished .C file
+2002-11-21 Angus Leeming <leeming@lyx.org>
+
+ * GraphicsConverter.C (build_script, move_file):
+ Don't use "if [ $? -ne 0 ]; then..."
+
2002-11-04 Lars Gullik Bjønnes <larsbj@gullik.net>
* PreviewLoader.C (IncrementedFileName): STRCONV
ostringstream command;
command << "fromfile=" << from_file << "\n"
<< "tofile=" << to_file << "\n\n"
- << "'mv' -f ${fromfile} ${tofile}\n"
- << "if [ $? -ne 0 ]; then\n"
- << "\t'cp' -f ${fromfile} ${tofile}\n"
- << "\tif [ $? -ne 0 ]; then\n"
+ << "'mv' -f ${fromfile} ${tofile} ||\n"
+ << "{\n"
+ << "\t'cp' -f ${fromfile} ${tofile} ||\n"
+ << "\t{\n"
<< "\t\texit 1\n"
- << "\tfi\n"
+ << "\t}\n"
<< "\t'rm' -f ${fromfile}\n"
- << "fi\n";
+ << "}\n";
return STRCONV(command.str());
}
command = LibScriptSearch(command);
// Store in the shell script
- script << "\n" << command << "\n\n";
+ script << "\n" << command << " ||\n";
// Test that this was successful. If not, remove
// ${outfile} and exit the shell script
- script << "if [ $? -ne 0 ]; then\n"
+ script << "{\n"
<< "\t'rm' -f ${outfile}\n"
<< "\texit 1\n"
- << "fi\n\n";
+ << "}\n\n";
// Test that the outfile exists.
// ImageMagick's convert will often create ${outfile}.0,