~ubuntu-branches/ubuntu/saucy/faust/saucy

« back to all changes in this revision

Viewing changes to tools/faust2appls/faust2mathdoc

  • Committer: Package Import Robot
  • Author(s): Mario Lang
  • Date: 2012-04-04 13:52:01 UTC
  • mfrom: (1.1.6) (3.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20120404135201-hpsrk87x3hga94tc
Tags: 0.9.46-2
* Fix "ftbfs with GCC-4.7":
  - debian/patches/unistd: Include <unistd.h> where necessary.
    (Closes: #667163)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# Usage.
18
18
print_usage() 
19
19
{
20
 
    echo "usage: faust2mathdoc [-l LANG] faust_file.dsp ..."
 
20
    echo "usage: faust2mathdoc [-l LANG] [-utf8] faust_file.dsp ..."
21
21
    echo " LANG is usually a 2-lowercase-letters language name, like en, fr, or it."
 
22
    echo " -utf8 force faust_file.dsp to be recoded in UTF-8 before being processed"
22
23
}
23
24
 
24
25
 
72
73
    done
73
74
}
74
75
 
 
76
 
 
77
# In-place recoding of a text file from its current encoding to UTF-8.
 
78
# This is useful for .dsp files with accents in comments that are coded
 
79
# with a different character set.
 
80
recode2utf8()
 
81
{
 
82
        charset=`file -0 --mime-encoding $1 | cut  -d' ' -f2`
 
83
        recode $charset..utf-8 $1
 
84
}
 
85
 
 
86
 
 
87
MDLANGOPT=""
 
88
if [ $1 = "-mdlang" ] || [ $1 = "--mathdoc-lang" ] || [ $1 = "-l" ]
 
89
then
 
90
    MDLANGOPT="-mdlang $2"
 
91
    shift 2
 
92
fi
 
93
 
 
94
CONVERT=""
 
95
if [ $1 = "-utf8" ] || [ $1 = "--utf8" ]
 
96
then
 
97
    CONVERT="utf8"
 
98
    shift 1
 
99
fi
 
100
 
75
101
if [ $# -eq 0 ]
76
102
then 
77
103
    print_usage
78
104
    exit 1
79
105
fi
80
106
 
81
 
MDLANGOPT=""
82
 
if [ $1 = "-mdlang" ] || [ $1 = "--mathdoc-lang" ] || [ $1 = "-l" ]
83
 
then
84
 
    if [ $# -eq 2 ]
85
 
    then 
86
 
        print_usage
87
 
        exit 1
88
 
    fi
89
 
    MDLANGOPT="-mdlang $2"
90
 
    shift 2
91
 
fi
92
 
 
93
107
#    Main loop of this script :
94
108
# 1. Compile `faust --mathdoc` to generate the TeX file and SVG block-diagrams.
95
109
# 2. Move to the "${FILEPATH%.dsp}-mdoc" directory created by faust.
101
115
        FILENAME=`basename $FILEPATH` &&
102
116
        case $FILENAME in
103
117
            *.dsp )  
 
118
            if [ $CONVERT = "utf8" ] 
 
119
            then
 
120
                recode2utf8 $FILENAME
 
121
            fi
104
122
                faust $MDLANGOPT -o ${FILEPATH%.dsp}.cpp --mathdoc $FILEPATH &&
105
123
                cd ${FILEPATH%.dsp}-mdoc/ && 
106
124
                cd svg && convert_svgdirs2pdf svg-* && cd .. &&