]> git.lyx.org Git - features.git/commitdiff
I declare these scripts finished. Probably.
authorAngus Leeming <leeming@lyx.org>
Wed, 27 Nov 2002 17:15:23 +0000 (17:15 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 27 Nov 2002 17:15:23 +0000 (17:15 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5734 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/forms/c_str.sed [new file with mode: 0644]
src/frontends/xforms/forms/fdfix.sh

index 3e558ee08b2eb46e043249031dadb712b3c84bf1..3556f4ad7b420a7661014d3e17072eacc3e12a4c 100644 (file)
@@ -1,3 +1,11 @@
+2002-11-27  Angus Leeming  <leeming@lyx.org>
+
+       * forms/fdfix.sh:
+       * forms/c_str.sed: replace that nasty global c_str declaration with
+       nice function-specific ones. Use a two-pass algorithm to do so.
+       It's possible to do it in one-pass, but the resulting sed script
+       must use the hold space in a convoluted manner.
+
 2002-11-27  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * XMiniBuffer.C (peek_event): add l10n on a string missing it.
diff --git a/src/frontends/xforms/forms/c_str.sed b/src/frontends/xforms/forms/c_str.sed
new file mode 100644 (file)
index 0000000..b01f1f7
--- /dev/null
@@ -0,0 +1,41 @@
+# file c_str.sed
+# This file is part of LyX, the document processor.
+# Licence details can be found in the file COPYING.
+#
+# author Angus Leeming
+#
+# Full author contact details are available in file CREDITS
+
+# This sed script is run on the .C file after the main fdfixc.sed has done
+# its stuff. It ensures that any c_str variables inserted by fdfixc.sed
+# are declared at the top of the appropriate function.
+#
+# We use a two-pass algorithm like this because a single pass results in
+# convoluted sed.
+
+
+# Initialise the hold space at the start of the function.
+/ \* build_/ {
+h; d
+}
+
+
+# For all lines within the function...
+/^{$/,/^}$/ {
+
+# If it isn't the last line, append it to the hold space.
+/^}$/!{
+H; d
+}
+
+# If it is the last line, paste the contents of the hold space above it,
+# seach for the string "c_str" and, if found, add its declaration to the top
+# of the function.
+/^}$/ {
+x; G
+
+/c_str/s/\(    FL_OBJECT \*\)/ char const * c_str;\
+\1/
+}
+
+}
index a8c7f51c4a118f9b18525a545af54fe85dc1277f..2d12d3a3b08a807ba2e772421adbb1b3f3c80155 100644 (file)
@@ -117,31 +117,29 @@ CPATCH=${DIRNAME}/${BASENAME}.C.patch
 COUT=${BASENAME}.cpp
 FINAL_COUT=${BASENAME}.C
 
-FDFIXC=${DIRNAME}/fdfixc.sed
-
-OUTPUT_FILE=${COUT}; INTRO_MESSAGE
-
-# This "c_str" is potentially used many times in many functions
-# so add it to the top of the generated file.
-grep -E 'fl_add.*".*[|].*"' ${CIN} > /dev/null &&
-       cat - >> ${COUT} <<EOF
-namespace {
-char const * c_str;
-} // namespace anon
-
+# We use a two pass algorithm to generate elegant C++ code whilst
+# keeping the sed clean also.
 
-EOF
+# Pass 1. The bulk of the clean-up
+FDFIXC=${DIRNAME}/fdfixc.sed
+TMP=tmp
+OUTPUT_FILE=${TMP}; INTRO_MESSAGE
 
-echo "#include <config.h>" >> ${COUT}
-echo "#include \"forms_gettext.h\"" >> ${COUT}
-echo "#include \"gettext.h\"" >> ${COUT}
+echo "#include <config.h>" >> ${TMP}
+echo "#include \"forms_gettext.h\"" >> ${TMP}
+echo "#include \"gettext.h\"" >> ${TMP}
 
 grep bmtable ${CIN} > /dev/null &&
-       echo "#include \"bmtable.h\"" >> ${COUT}
+       echo "#include \"bmtable.h\"" >> ${TMP}
+
+sed -f ${FDFIXC} < ${CIN} >> ${TMP}
 
-sed -f ${FDFIXC} < ${CIN} >> ${COUT}
+# Pass 2. Ensure that any c_str variables inserted by fdfixc.sed
+# are declared at the top of the appropriate function.
+FDFIXC=${DIRNAME}/c_str.sed
+sed -f ${FDFIXC} < ${TMP} > ${COUT}
+rm -f ${TMP}
 
-# Patch the .C file if a patch exists
 if [ -f "${CPATCH}" ] ; then
        echo "Patching ${COUT} with ${CPATCH}"
        patch -s ${COUT} < ${CPATCH}