msgcc.sh revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 2000-2011 AT&T Intellectual Property #
# and is licensed under the #
# Eclipse Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# A copy of the License is available at #
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# Glenn Fowler <gsf@research.att.com> #
# #
########################################################################
# NOTE: all variable names match __*__ to avoid clash with msgcpp def vars
integer __similar__=30
USAGE=$'
[-?
@(#)$Id: msgcc (AT&T Labs Research) 2010-10-20 $
]
[+NAME?msgcc - C language message catalog compiler]
[+DESCRIPTION?\bmsgcc\b is a C language message catalog compiler. It accepts
\bcc\b(1) style options and arguments. A \bmsgcpp\b(1) \b.mso\b file
is generated for each input \b.c\b file. If the \b-c\b option is not
specified then a \bgencat\b(1) format \b.msg\b file is generated from
a \b.msg\b suffix is appended to the \b-o\b \afile\a if it doesn\'t
already have a suffix. The default output is \ba.out.msg\b if \b-c\b
and \b-o\b are not specified.]
[+?If \b-M-new\b is not specified then messages are merged with those in the
pre-existing \b-o\b file.]
[M?Set a \bmsgcc\b specific \aoption\a. \aoption\a may be:]:[-option]{
[+mkmsgs?The \b-o\b file is assumed to be in \bmkmsgs\b(1) format.]
[+new?Create a new \b-o\b file.]
[+preserve?Messages in the \b-o\b file that are not in new
\b.msg\b file arguments are preserved. The default is to
either reuse the message numbers with new message text that
is similar to the old or to delete the message text, leaving
an unused message number.]
[+set=\anumber\a?Set the message set number to \anumber\a. The default
is \b1\b.]
[+similar=\anumber\a?The message text similarity measure threshold.
The similarity measure between \aold\a and \anew\a message
text is 100*(2*gzip(\aold\a+\anew\a)/(gzip(\aold\a)+gzip(\anew\a))-1),
where gzip(\ax\a) is the size of text \ax\a when compressed by
threshold of \b0\b turns off message replacement, but unused
old messages are still deleted. Use \b-M-preserve\b to preserve
all old messages.]
[+verbose?Trace similar message replacements on the standard error.]
}
file ...
[+SEE ALSO?\bcc\b(1), \bcpp\b(1), \bgencat\b(1), \bmsggen\b(1),
\bmsgcpp\b(1), \bmsgcvt\b(1)]
'
;;
*) ARGV0=""
USAGE="M:[-option] [ cc-options ] file ..."
;;
esac
usage()
{
OPTIND=0
exit 2
}
keys()
{
}
typeset -A __index__
case " $* " in
*" --"*|*" -?"*)
*) break ;;
esac
done
;;
esac
while :
do case $# in
0) break ;;
esac
__arg__=$1
-c) __compile__=1
;;
;;
-E) __preprocess__=1
;;
-M-debug)
;;
-M-mkmsgs)
;;
;;
-M-perserve)
;;
-M-set=*)
;;
-M-similar=*)
;;
-M-verbose)
;;
-o) case $# in
exit 1
;;
esac
shift
__OUT__=$1
;;
[-+]*|*.[aAlLsS]*)
;;
*.[oO]*);;
;;
esac
;;
;;
;;
esac
shift
done
if [[ -x $__arg__ ]]
fi
# generate the .mso files
if [[ $__OUT__ && $__compile__ ]]
fi
then print "${__srcv__[__i__]}:"
fi
if [[ $__preprocess__ ]]
then msgcpp "${__argv__[@]}" "${__srcv__[__i__]}"
fi
fi
done
fi
# combine the .mso and .msg files
if [[ ! $__compile__ && ! $__preprocess__ ]]
then if [[ $__merge__ && -r $__out__ ]]
trap '__code__=$?; rm -f ${__tmp__}*; exit $__code__' 0 1 2
while read -r __line__
then if [[ $__line__ == '%}'* ]]
then __skip__=0
fi
continue
fi
then __skip__=1
continue
fi
if [[ $__mkmsgs__ ]]
read -r __line__
elif [[ $__line__ == %* ]]
then continue
else print -u2 $"$__command__: unrecognized line=$__line__"
__code__=1
fi
+([0-9])' '*)
;;
*) continue
;;
esac
fi
fi
done < $__out__
fi
then exit $__code__
fi
print -r -- '$'" ${__out__%.msg} message catalog"
print -r -- '$set'" $__set__"
print -r -- '$quote "'
while read -r __line__
esac
;;
;;
;;
;;
[[:digit:]]*)
;;
;;
esac
then print -r -- "$__v__"
fi
;;
[[:digit:]]*)
[[ $__preserve__ ]] && print -r -- "$__line__"
;;
;;
esac
done
done
[[ $__raw__ ]] && print -r "${__raw__#?}" | sed -e 's/^"//' -e 's/"$//' -e 's/\\/&&/g' -e 's/"/\\"/g' -e 's/.*/$RAW$"&"/'
} | {
__num__=1
while read -r __line__
'$RAW$'*)
;;
'$'[\ \ ]*)
print -r -- "$__line__"
continue
;;
continue
;;
;;
*) continue
;;
esac
if [[ $__line__ ]]
then if [[ ! $__preserve__ ]]
fi
done
fi
if [[ ! $__preserve__ ]]
fi
fi
fi
done
fi
if [[ $__debug__ ]]
fi
fi
fi
done
exit 0
fi
# check for replacements
if [[ ! $__preserve__ ]]
fi
done
[[ $__verbose__ ]] && print -u2 $__command__: old:1-$((__new__-1)) new:$__new__-$__max__ drop $__ndrop__ add $((__max__-__new__+1))
done
__hit__=0
fi
fi
done
then [[ $__verbose__ ]] && print -u2 $__command__: $__hit__ $__num__ $__bz__
fi
done
fi
fi
# final output
fi
done
}
}
fi
fi
exit $__code__