trans-coord-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Variables as procedure abstractions


From: Kaloian Doganov
Subject: Variables as procedure abstractions
Date: Thu, 13 Mar 2008 17:43:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gNewSense gnu/linux)

Yavor Doganov <address@hidden> writes:

        (generate-html): New variable containing canned command sequence
        for generating the HTML by po4a-translate.  All callers adopted.

In fact, I was thinking even further.  Please see the following patch.

Index: server/gnun/GNUmakefile
===================================================================
RCS file: /sources/trans-coord/trans-coord/gnun/server/gnun/GNUmakefile,v
retrieving revision 1.16
diff -u -r1.16 GNUmakefile
--- server/gnun/GNUmakefile     13 Mar 2008 09:18:00 -0000      1.16
+++ server/gnun/GNUmakefile     13 Mar 2008 15:07:58 -0000
@@ -141,6 +141,18 @@
 define generate-html
 $(PO4A-TRANSLATE) $(PO4A_XHTMLFLAGS) $(PO4A-TRANSLATEFLAGS) \
   --master $$< --po $$$$POFILE --localized $$$$M4FILE
+$(SED) --in-place \
+  "s/\(<gnun>include(\`.*\)\([.]html')<\/gnun>\)/\1.$(1)\2/g" \
+  $$$$M4FILE
+$(SED) --in-place "s/<gnun>\(.*\)<\/gnun>/\1/g" $$$$M4FILE
+$(SED) --in-place \
+  ':egin;N;$$$$!begin;s/\([ \t]*\n[ \t]*\)\{3,\}<!--/\n\n<!--/g' \
+  $$$$M4FILE
+for replaceable in $(replaceable_includes); do \
+  $(SED) --in-place \
+  "s/\(<!--#include virtual=\".*$$$$replaceable\)\(.html\" -->\)/\1.$(1)\2/g" \
+  $$$$M4FILE \
+done;
 endef
 
 # The command to check the validity of a PO file.
@@ -200,7 +212,6 @@
        $$(addfile)
        PO=$(template_dir)/po/$$(*F).$(1).po ; $(check-po)
        POFILE=$(template_dir)/po/$$(*F).$(1).po M4FILE=$$@ ; $(generate-html)
-       $(SED) --in-place ':egin;N;$$$$!begin;s/\([ \t]*\n[ 
\t]*\)\{3,\}<!--/\n\n<!--/g' $$@
 endef
 
 $(foreach t_lang,$(TEMPLATE_LINGUAS),$(eval $(call template_rules,$(t_lang))))
@@ -236,12 +247,6 @@
        PO=$(rootdir)/po/home.$(1).po ; $(check-po)
        POFILE=$(rootdir)/po/home.$(1).po M4FILE=$(rootdir)/po/home.$(1).m4 ; \
          $(generate-html)
-       $(SED) --in-place 
"s/\(<gnun>include(\`.*\)\([.]html')<\/gnun>\)/\1.$(1)\2/g" 
$(rootdir)/po/home.$(1).m4
-       $(SED) --in-place "s/<gnun>\(.*\)<\/gnun>/\1/g" 
$(rootdir)/po/home.$(1).m4
-       $(SED) --in-place ':egin;N;$$$$!begin;s/\([ \t]*\n[ 
\t]*\)\{3,\}<!--/\n\n<!--/g' $(rootdir)/po/home.$(1).m4
-       for replaceable in $(replaceable_includes); do \
-               $(SED) --in-place "s/\(<!--#include 
virtual=\".*$$$$replaceable\)\(.html\" -->\)/\1.$(1)\2/g" 
$(rootdir)/po/home.$(1).m4; \
-       done;
 # Polish is special case, because Apache treats gnusflashes.pl.include
 # as a Perl file.  This is hopefuly a temprorary situation.
 ifeq ($(1), pl)
@@ -292,12 +297,6 @@
        $$(addfile)
        PO=$(1).po ; $(check-po)
        POFILE=$(1).po M4FILE=$(1).m4 ; $(generate-html)
-       $(SED) --in-place 
"s/\(<gnun>include(\`.*\)\([.]html')<\/gnun>\)/\1.$(2)\2/g" $(1).m4
-       $(SED) --in-place "s/<gnun>\(.*\)<\/gnun>/\1/g" $(1).m4
-       $(SED) --in-place ':egin;N;$$$$!begin;s/\([ \t]*\n[ 
\t]*\)\{3,\}<!--/\n\n<!--/g' $(1).m4
-       for replaceable in $(replaceable_includes); do \
-               $(SED) --in-place "s/\(<!--#include 
virtual=\".*$$$$replaceable\)\(.html\" -->\)/\1.$(2)\2/g" $(1).m4; \
-       done;
        $(M4) $(1).m4 > $$@
        $(VALIDATESKIP) $(VALIDATE-HTML-NOTIFY) $(NOTIFYSKIP) $(transl_addr) \
          $$@ || (sleep 1 ; touch $(1).po ; exit 1)


(Warning: This is an untested patch.  I'm providing it only to
illustrate the general idea.)

And we can push this idea even further than illustrated on the patch
above.  We can include the m4 invocation and validation steps in
$(generate-html).  To do this, we need to pass two additional arguments,
say HTMLFILE and MAILADDR.  Since $(generate-html) will depend on having
some variables defined, we can document them in GNUmakefile, say:

# The commands to generate the translated HTMLFILE from a POFILE using
# M4FILE in an intermediate step.  In case of error, mail the error
# message to MAILADDR.
define generate-html
...
endef


What do you think?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]