#!/bin/sh

BASE=`basename "$1" .idx`
IDX=$BASE.idx
IND=$BASE.ind
ILG=$BASE.ilg

sed '
/^\\indexentry{/ {
s/\\IeC {\\CYRA }//g
s/\\IeC {\\cyra }//g
s/\\IeC {\\CYRB }//g
s/\\IeC {\\cyrb }//g
s/\\IeC {\\CYRV }//g
s/\\IeC {\\cyrv }//g
s/\\IeC {\\CYRG }//g
s/\\IeC {\\cyrg }//g
s/\\IeC {\\CYRD }//g
s/\\IeC {\\cyrd }//g
s/\\IeC {\\CYRE }//g
s/\\IeC {\\cyre }//g
s/\\IeC {\\CYRYO }//g
s/\\IeC {\\cyryo }//g
s/\\IeC {\\CYRZH }//g
s/\\IeC {\\cyrzh }//g
s/\\IeC {\\CYRZ }//g
s/\\IeC {\\cyrz }//g
s/\\IeC {\\CYRI }//g
s/\\IeC {\\cyri }//g
s/\\IeC {\\CYRISHRT }//g
s/\\IeC {\\cyrishrt }//g
s/\\IeC {\\CYRK }//g
s/\\IeC {\\cyrk }//g
s/\\IeC {\\CYRL }//g
s/\\IeC {\\cyrl }//g
s/\\IeC {\\CYRM }//g
s/\\IeC {\\cyrm }//g
s/\\IeC {\\CYRN }//g
s/\\IeC {\\cyrn }//g
s/\\IeC {\\CYRO }//g
s/\\IeC {\\cyro }//g
s/\\IeC {\\CYRP }//g
s/\\IeC {\\cyrp }//g
s/\\IeC {\\CYRR }//g
s/\\IeC {\\cyrr }//g
s/\\IeC {\\CYRS }//g
s/\\IeC {\\cyrs }//g
s/\\IeC {\\CYRT }//g
s/\\IeC {\\cyrt }//g
s/\\IeC {\\CYRU }//g
s/\\IeC {\\cyru }//g
s/\\IeC {\\CYRF }//g
s/\\IeC {\\cyrf }//g
s/\\IeC {\\CYRH }//g
s/\\IeC {\\cyrh }//g
s/\\IeC {\\CYRC }//g
s/\\IeC {\\cyrc }//g
s/\\IeC {\\CYRCH }//g
s/\\IeC {\\cyrch }//g
s/\\IeC {\\CYRSH }//g
s/\\IeC {\\cyrsh }//g
s/\\IeC {\\CYRSHCH }//g
s/\\IeC {\\cyrshch }//g
s/\\IeC {\\CYRHRDSN }//g
s/\\IeC {\\cyrhrdsn }//g
s/\\IeC {\\CYRERY }//g
s/\\IeC {\\cyrery }//g
s/\\IeC {\\CYRSFTSN }//g
s/\\IeC {\\cyrsftsn }//g
s/\\IeC {\\CYREREV }//g
s/\\IeC {\\cyrerev }//g
s/\\IeC {\\CYRYU }//g
s/\\IeC {\\cyryu }//g
s/\\IeC {\\CYRYA }//g
s/\\IeC {\\cyrya }//g
}' $IDX | makeindex -t $ILG | tr '' \
  'ų' > $IND
