File: m17n-db.in

package info (click to toggle)
m17n-db 1.6.1-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 6,164 kB
  • ctags: 73
  • sloc: sh: 4,175; awk: 703; makefile: 377; cs: 181; sed: 16
file content (148 lines) | stat: -rw-r--r-- 3,727 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/sh
# m17n-db -- print information about the m17n database.
# Copyright (C) 2004, 2005
#   National Institute of Advanced Industrial Science and Technology (AIST)
#   Registration Number H15PRO112
# See the end for copying conditions.

prefix=@prefix@
datadir=@datadir@

help ()
{
    echo "Usage: $0 [ OPTIONS ] [ TAG0 [ TAG1 [ TAG2 [ TAG3 ] ] ] ]"
    echo "Options:"
    echo "  -h, --help	Print this information."
    echo "  -v, --version	Print the version number."
    echo "  -l, --locate	Print absolute pathnames of database files."
    echo "	TAG0 through TAG3 specifies the tags of the database."
    echo "With no options, print the installed directory name."
}

if test $# -gt 0; then
    case "$1" in
	-h | --help) help; exit 0;;
	-v | --version) echo "@VERSION@"; exit 0;;
	-l | --locate) DIRFILE="$datadir/m17n/mdb.dir"; shift;;
	*) help; exit 1;;
    esac
fi

if test -z "$DIRFILE" ; then
    echo $datadir/m17n
    exit 0
fi

if test ! -f "$DIRFILE"; then
    echo "Can't find the m17n database directory file \"$DIRFILE\"!"
    exit 1
fi

if test -z "$1"; then
    help
    exit 1
fi

TAG0=$1
TAG1=$2
if test -z "$TAG1"; then
    TAG1="*"
fi
TAG2=$3
if test -z "$TAG2"; then
    TAG2="*"
fi
TAG3=$4
if test -z "$TAG3"; then
    TAG3="*"
fi

SPC="[ 	]*"
ANY="$SPC\([A-Za-z*][^ 	)]*\)\?"

TAGS="$SPC\($TAG0\)$SPC$ANY$SPC$ANY$SPC$ANY"
FILE="$SPC\"\([^\"]*\)\""
ENTRIES=`sed -n "/$TAG0/s|$SPC($TAGS$FILE).*$|/\1/\2/\3/\4/\5|p" $DIRFILE`

cd $datadir/m17n

for e in $ENTRIES; do
    FN=`expr "$e" : "/[^/]*/[^/]*/[^/]*/[^/]*/\(.*\)"`
    case "$e" in
	/$TAG0/\*/*/* | /$TAG0/*/\*/* | /$TAG0/*/*/\*)
	    for f in $FN; do
		if test -f $f; then
		    ENTRY=`sed -n "/$TAG0/s|$SPC($TAGS).*$|/\1/\2/\3/\4|p" $f`
		    if test -n "$ENTRY"; then
			LIST="$LIST $ENTRY/$f"
		    fi
		fi
	    done;;
	*)
	    if test -f $FN; then
		LIST="$LIST $e"
	    fi;;
    esac
done

for l in $LIST; do
    case "$l" in
	/$TAG0/$TAG1/$TAG2/$TAG3)
	    FN=`expr "$l" : "/[^/]*/[^/]*/[^/]*/[^/]*/\(.*\)"`
	    echo "`pwd`/$FN"
    esac
done

exit 0

cat > /dev/null <<EOF
/***en @page m17n-db Print information about the m17n database */
/***ja @page m17n-db m17n ǡ١ξɽ */

/***
@section m17n-db-synopsis SYNOPSIS

m17n-db  [ OPTIONS ] [ TAG0 [ TAG1 [ TAG2 [ TAG3 ] ] ] ]

@section m17n-db-description DESCRIPTION

The shell script m17n-db prints information about the m17n database.

The arguments OPTIONS has the following meanings.

- -h, --help\n
	Print this information.
- -v, --version\n
	Print the version number.
- -l, --locate\n
	Print absolute pathnames of database files.\n
	TAG0 through TAG3 specifies the tags of the database.

With no arguments, print where the m17n database is installed.  */ 
EOF

# Copyright (C) 2004
#   National Institute of Advanced Industrial Science and Technology (AIST)
#   Registration Number H15PRO112

# This file is part of the m17n database; a sub-part of the m17n
# library.

# The m17n library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.

# The m17n library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public
# License along with the m17n library; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.

# Local Variables:
# coding: euc-japan
# End: