diff options
-rw-r--r-- | VERSION | 2 | ||||
-rwxr-xr-x | autogen.sh | 75 | ||||
-rw-r--r-- | configure.in | 9 | ||||
-rwxr-xr-x | release | 2 | ||||
-rw-r--r-- | src/librcd.c | 35 | ||||
-rw-r--r-- | src/librcd.h | 3 |
6 files changed, 118 insertions, 8 deletions
@@ -1 +1 @@ -0.1.9CVS +0.1.9 @@ -1,8 +1,71 @@ -#!/bin/bash +#!/bin/sh +PROG=`basename $0` + +KEYFILE=src/librcd.c + +# Some OS's have multiple versions (autoconf259, etc.) and don't have an +# autoconf binary + +AUTOCONF=`which autoconf` +if test x"${AUTOCONF}" != x -a -f ${AUTOCONF} +then + AUTOCONF=autoconf + AUTOMAKE=automake + ACLOCAL=aclocal + LIBTOOLIZE=libtoolize + AUTOHEADER=autoheader +else + FINDPATH=`echo ${PATH}|sed -e 's,:, ,g'` + AUTOCONF=`find ${FINDPATH} -name "autoconf*"|sort -r|head -1` + AUTOMAKE=`find ${FINDPATH} -name "automake*"|sort -r|head -1` + ACLOCAL=`find ${FINDPATH} -name "aclocal*"|sort -r|head -1` + LIBTOOLIZE=`find ${FINDPATH} -name "libtoolize*"|sort -r|head -1` + AUTOHEADER=`find /usr/bin /usr/local/bin -name "autoheader*"|sort -r|head -1` + echo "$0: autoconf: using ${AUTOCONF}" + echo "$0: automake: using ${AUTOMAKE}" + echo "$0: aclocal: using ${ACLOCAL}" + echo "$0: libtoolize: using ${LIBTOOLIZE}" + echo "$0: autoheader: using ${AUTOHEADER}" +fi + +GETTEXTIZE_FLAGS=--no-changelog +AUTOPOINT_FLAGS= +LIBTOOLIZE_FLAGS=--copy + +# Some OS's require /usr/local/share/aclocal + +if test ! -d /usr/local/share/aclocal +then + ACLOCAL_FLAGS='' +else + ACLOCAL_FLAGS='-I /usr/local/share/aclocal' +fi +AUTOHEADER_FLAGS=-Wall +AUTOMAKE_FLAGS='--add-missing --copy -Wall' +AUTOCONF_FLAGS=-Wno-obsolete + +die() +{ + err=$? + echo "$PROG: exited by previous error(s), return code was $err" >&2 + exit 1 +} + +if [ ! -f $KEYFILE ] +then + echo "$PROG: key-file \`$KEYFILE' not found, exiting." >&2 + echo "$PROG: hint: you should run $PROG from top-level sourse directory." >&2 + exit 1 +fi + +# gettextize ${GETTEXTIZE_FLAGS} +# autopoint ${AUTOPOINT_FLAGS} +# xml-i18n-toolize || die +# intltoolize || die +${LIBTOOLIZE} ${LIBTOOLIZE_FLAGS} --force || die +${ACLOCAL} ${ACLOCAL_FLAGS} || die +${AUTOHEADER} ${AUTOHEADER_FLAGS} || die +${AUTOMAKE} ${AUTOMAKE_FLAGS} || die +${AUTOCONF} ${AUTOCONF_FLAGS} || die -rm -f configure -aclocal -libtoolize --copy --force -automake --copy --add-missing -autoconf diff --git a/configure.in b/configure.in index 1ad8cd6..15d197f 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(src/librcd.c) +AC_CONFIG_HEADERS(config.h) PACKAGE=librcd LIBRCD_VERSION_MAJOR=`cat VERSION | sed -e s/CVS// | cut -d . -f 1 | sed -e s/^$/0/` @@ -17,6 +18,14 @@ AC_SUBST(LIBRCD_VERSION_INFO) AM_INIT_AUTOMAKE($PACKAGE, $VERSION) +AC_ARG_ENABLE( latin, + [ --disable-latin disable detection of ISO-8859-1],, + disable_latin="yes") + +if test "x$disable_latin" == "xyes"; then + AC_DEFINE(DETECT_LATIN,1,[Defines if ISO-8859-1 detection is enabled]) +fi + AC_PROG_CC AC_PROG_INSTALL AM_PROG_LIBTOOL @@ -49,4 +49,6 @@ cp -a * $RDIR/$rname fi tar cjf $rname.tar.bz2 $rname rm -rf $rname + + scp $rname.tar.bz2 csa@dside.dyndns.org:/home/csa/public_html/files/rusxmms/ ) diff --git a/src/librcd.c b/src/librcd.c index 55eefc0..36986cc 100644 --- a/src/librcd.c +++ b/src/librcd.c @@ -1,5 +1,7 @@ #include <stdio.h> +#include "../config.h" + #define _LIBRCD_C #include "librcd.h" @@ -252,6 +254,36 @@ static int check_utf8(const unsigned char *buf, int len) { return res; } +/* In russian language we will have whole word consisting of >127 characters, +with latin languages there is in every word besides umlauts should exist at +least one standard latin character with code < 127. */ +static int check_latin(const unsigned char *buf, int len) { + long i; + int word = 0; + int latin = 0; + + for (i=0;i<len;i++) { + if (buf[i]<128) { + if (((buf[i]>='a')&&(buf[i]<='z'))||((buf[i]>='A')&&(buf[i]<='Z'))) { + // Latin character inside a word, so it isn't cyrillic word + latin++; + } else { + // Treating as a word separator. + if (word > 0) { + if (!latin) return 0; + if ((word/latin)>4) return 0; + } + + word = 0; + latin = 0; + } + } else { + // Could be cyrillic word + if (word>=0) word++; + } + } + return 1; +} rcd_russian_charset rcdGetRussianCharset(const char *buf,int len) { @@ -259,6 +291,9 @@ rcd_russian_charset rcdGetRussianCharset(const char *buf,int len) { l = len?len:strlen(buf); if (check_utf8(buf,l)>1) return RUSSIAN_CHARSET_UTF8; +#ifdef DETECT_LATIN + if (check_latin(buf,l)) return RUSSIAN_CHARSET_LATIN; +#endif /* DETECT_LATIN */ return is_win_charset2(buf,l); } diff --git a/src/librcd.h b/src/librcd.h index 56db6c8..6fc3281 100644 --- a/src/librcd.h +++ b/src/librcd.h @@ -9,7 +9,8 @@ enum rcd_russian_charset_t { RUSSIAN_CHARSET_WIN = 0, RUSSIAN_CHARSET_KOI, RUSSIAN_CHARSET_UTF8, - RUSSIAN_CHARSET_ALT + RUSSIAN_CHARSET_ALT, + RUSSIAN_CHARSET_LATIN }; typedef enum rcd_russian_charset_t rcd_russian_charset; |