1#!/bin/sh
2#
3# @configure.input@
4#
5# gcalltx.in -- (C) Claus-Peter R"uckemann, 1996, 1998, 1999
6#
7# version 1.5
8#
9# This file may be distributed with Gcal under the terms
10# of the GNU public license.
11#
12# This script calls gcalltx.sed to convert 'gcal -n -u %0001 year' output to
13# LaTeX tabular output.
14#
15# UN*X solution.
16#
17packagedatamiscdir=.
18#
19PACKAGE=gcal
20VERSION=4.1
21transform=s,x,x,
22#
23INSTALL_DATA="${INSTALL} -m 644"
24#
25Rm=rm
26Sed=sed
27Echo=echo
28Test=test
29Chmod=chmod
30#
31mydefaultname=gcalltx
32#
33myname=`$Echo "$0" | $Sed -e 's,.*/,,' -e "$transform"`
34#
35ThisGcal=../../src/gcal
36#
37Sed_script_in=$packagedatamiscdir/$mydefaultname"".sed
38Sed_script_out=$packagedatamiscdir/$mydefaultname"".cpr
39#
40SRCPERMS=`$Echo "$INSTALL_DATA" | $Sed -e 's,^.*/,,' -e 's/[^0-9]//g'`
41SRCPERMS2=0644
42#
43trap "$Rm -f gcaltmp* $mydefaultname"".tex;exit 2" 1 2 15
44#
45case "$#" in
46     1) GCAL= $ThisGcal -n -u %0001 --christian-holidays $* >gcaltmp
47        ;;
48     2) GCAL= $ThisGcal -n -u %0001 --cc-holidays=$* >gcaltmp
49        ;;
50     3) GCAL= $ThisGcal -n -u %0001 --christian-holidays --cc-holidays=$* >gcaltmp
51        ;;
52     *) $Echo "usage: $myname year";
53        $Echo "       $myname country_code year";
54        $Echo "       $myname country_code year --christian-holidays";
55        $Echo "";
56        $Echo "(1st usage provides only Christian holidays)";
57        $Echo "(2nd usage provides country_code holidays)";
58        $Echo "(3rd usage provides Christian and country_code holidays)";
59        $Echo "";
60        $Echo "country_codes is a country code or a list of country codes";
61        $Echo "as supported by \`$ThisGcal'.";
62        $Echo "";
63        $Echo "Country codes are for example: BE ES FR";
64        $Echo "";
65        $Echo "A list of country codes can be created this way: BE+FR";
66        $Echo "(s. $PACKAGE-$VERSION documentation)";
67        exit 1;;
68esac
69
70if $Test "$?" -ne 0;
71then
72  $Rm -f gcaltmp* $mydefaultname"".tex
73  exit 2;
74fi
75
76# Added the two lines for 4-digits line numbers (BREAKPOINT & DEL)
77#
78$Sed "s/^/XYZ/g" gcaltmp >gcaltmp.tm1
79$Sed "=" gcaltmp.tm1 >gcaltmp.tm2
80# v--- breakpoint part
81$Echo "s/^\([5][0]\)/BREAKPOINT \1/g">gcaltmp.tm3
82$Echo "s/^\([0-9][50][0]\)/BREAKPOINT \1/g">>gcaltmp.tm3
83$Echo "s/^\([0-9][0-9][50][0]\)/BREAKPOINT \1/g">>gcaltmp.tm3
84$Echo "/^[0-9]/d">>gcaltmp.tm3
85$Echo "/^[0-9][0-9]/d">>gcaltmp.tm3
86$Echo "/^[0-9][0-9][0-9]/d">>gcaltmp.tm3
87$Echo "/^[0-9][0-9][0-9][0-9]/d">>gcaltmp.tm3
88$Echo "s/^XYZ//">>gcaltmp.tm3
89$Sed -f gcaltmp.tm3 gcaltmp.tm2 >gcaltmp
90# ^--- breakpoint part
91#
92if $Test ! -f "$Sed_script_out";
93then
94  if $Test -f "$Sed_script_in";
95  then
96    $Sed -e '/^#.*[^\\]$/d' -e '/^#$/d' $Sed_script_in > $Sed_script_out
97    if $Test -n "$SRCPERMS";
98    then
99      $Chmod $SRCPERMS $Sed_script_out
100    else
101      $Chmod $SRCPERMS2 $Sed_script_out
102    fi
103  else
104    $Echo "$myname: error: file \`$Sed_script_in' is missing" 2>&1
105    exit 2;
106  fi
107fi
108
109        $Sed -f $Sed_script_out gcaltmp >$mydefaultname"".tex
110
111        $Rm -f gcaltmp*
112
113$Echo "$myname: Eternal holiday list written to file \`$mydefaultname"".tex'"
114##EOF:
115