orca r3470 - in trunk: . src/louis



Author: eitani
Date: Fri Jan 18 01:32:28 2008
New Revision: 3470
URL: http://svn.gnome.org/viewvc/orca?rev=3470&view=rev

Log:
* configure.in: 
  Utilize pkg-config for liblouis configuration.
* src/louis/__init__.py: 
  Added two functions for listing tables and for getting the
  default table.
* src/louis/Makefile.am: 
* src/louis/constants.py.in: 
* src/louis/constants.py:
  Move constants.py to constants.py.in. This is usefulee for
  having a constant with the tables path.
* src/louis/_louis.c: 
  Fixed the occasional segfault.


Added:
   trunk/src/louis/constants.py.in
      - copied, changed from r3464, /trunk/src/louis/constants.py
Removed:
   trunk/src/louis/constants.py
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/src/louis/Makefile.am
   trunk/src/louis/__init__.py
   trunk/src/louis/_louis.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Fri Jan 18 01:32:28 2008
@@ -130,15 +130,30 @@
     AM_CHECK_PYMOD(brlapi,,[brlapi_available="yes"],[brlapi_available="no"])
 fi
 
-AC_ARG_WITH(liblouis,
-        AC_HELP_STRING([--with-liblouis],[enable the use of liblouis]),
-	[case "${withval}" in
-	yes) WITH_LOUIS=yes ;;
-	no) WITH_LOUIS=no ;;
-	*) AC_MSG_ERROR(bad value ${withval} for --with-liblouis) ;;
-	esac],
-	[WITH_LOUIS=no]) dnl Default value
-AM_CONDITIONAL(WITH_LOUIS, test x$WITH_LOUIS = "xyes")
+AC_ARG_ENABLE(liblouis, 
+              AC_HELP_STRING([--enable-liblouis=@<:@no/yes/auto@:>@],
+                             [enable the use of liblouis]),,
+              enable_liblouis=auto)
+
+LOUIS_TABLE_DIR=""
+
+if test "x$enable_liblouis" != "xno"; then
+   PKG_CHECK_MODULES(LOUIS, "liblouis", have_liblouis=yes, have_liblouis=no)
+   if test x$have_liblouis = "xyes"; then
+      LOUIS_TABLE_DIR=`pkg-config --variable=tablesdir liblouis`
+   fi
+else
+   have_liblouis=no
+fi
+
+AC_SUBST(LOUIS_TABLE_DIR)
+if test "x$enable_liblouis" = "xyes"; then
+   if test "x$have_liblouis" != "xyes"; then
+      AC_MSG_ERROR([Couldn't find Liblouis])
+   fi
+fi
+
+AM_CONDITIONAL(WITH_LOUIS, test x$have_liblouis = "xyes")
 
 AC_SUBST(orca_LIBS)
 AC_SUBST(orca_CFLAGS)
@@ -157,6 +172,7 @@
 src/Makefile
 src/brl/Makefile
 src/louis/Makefile
+src/louis/constants.py
 src/orca/Makefile
 src/orca/scripts/Makefile
 src/orca/orca

Modified: trunk/src/louis/Makefile.am
==============================================================================
--- trunk/src/louis/Makefile.am	(original)
+++ trunk/src/louis/Makefile.am	Fri Jan 18 01:32:28 2008
@@ -2,13 +2,14 @@
 
 louisdir = $(pyexecdir)/orca/louis
 
-_louis_la_CFLAGS = \
-	$(louis_CFLAGS) \
+_louis_la_CFLAGS = 		\
+	$(LOUIS_CFLAGS) 	\
 	$(PYTHON_INCLUDES)
 
-_louis_la_LDFLAGS = \
-	-module \
-	-avoid-version \
+_louis_la_LDFLAGS = 	\
+	$(LOUIS_LIBS)	\
+	-module 			\
+	-avoid-version 		\
 	-llouis
 
 _louis_la_SOURCES = \
@@ -17,5 +18,7 @@
 louis_pythondir=$(louisdir)
 
 louis_python_PYTHON = \
-	__init__.py \
+	__init__.py 
+
+nodist_louis_python_PYTHON = \
 	constants.py
\ No newline at end of file

Modified: trunk/src/louis/__init__.py
==============================================================================
--- trunk/src/louis/__init__.py	(original)
+++ trunk/src/louis/__init__.py	Fri Jan 18 01:32:28 2008
@@ -24,3 +24,28 @@
 
 from _louis import *
 from constants import *
+import os
+
+def listTables():
+   tables = {}
+   try:
+      for fname in os.listdir(TABLES_DIR):
+         if fname[-4:] in ('.utb', '.ctb'):
+            alias = fname[:-4]
+            tables[TABLE_NAMES.get(alias, alias)] = \
+                                          os.path.join(TABLES_DIR, fname)
+   except OSError:
+      pass
+
+   return tables
+
+def getDefaultTable():
+   try:
+      for fname in os.listdir(TABLES_DIR):
+         if fname[-4:] in ('.utb', '.ctb'):
+            if fname.startswith('en-us'):
+               return os.path.join(TABLES_DIR, fname)
+   except OSError:
+      pass
+
+   return ''

Modified: trunk/src/louis/_louis.c
==============================================================================
--- trunk/src/louis/_louis.c	(original)
+++ trunk/src/louis/_louis.c	Fri Jan 18 01:32:28 2008
@@ -134,6 +134,9 @@
 				free(typeform);
 		free(trantab_joined);
         free(outbuf);
+
+        PyErr_Clear();
+
         return out;
 
 }
@@ -145,8 +148,8 @@
                                 "typeform", "cursorPos","mode", 0};
 		char *typeform = NULL, *trantab_joined, *spacing = NULL;
 		widechar *outbuf;
-		int inlen, outlen, mode = 0, cursorPos = 0;
-		int rv, *outputPos, *inputPos;
+		int inlen, outlen, mode = 0, cursorPos = 0, inlen_cp;
+		int rv, *outputPos = NULL, *inputPos = NULL, i;
 		PyObject *trantab_list, *out, *typeform_list = NULL, *outputPos_list,
 				*inputPos_list;
 		Py_UNICODE *u_inbuf;
@@ -173,7 +176,10 @@
 		if (PySequence_Size(typeform_list) > 0) 
 				typeform = pylist_to_typeform(typeform_list, inlen);
 
-		inputPos = calloc(inlen, sizeof(int));
+
+        inlen_cp = inlen;
+
+		inputPos = calloc(inlen*2, sizeof(int));
 
         outlen = inlen*2;
 		outbuf = calloc(outlen, sizeof(widechar));
@@ -184,8 +190,8 @@
                            outputPos, inputPos, &cursorPos, mode);
 
         out = PyUnicode_FromUnicode((Py_UNICODE *)outbuf, outlen);
-		inputPos_list = intbuf_to_pylist(inputPos, inlen);
-		outputPos_list = intbuf_to_pylist(outputPos, outlen);
+		inputPos_list = intbuf_to_pylist(inputPos, outlen);
+		outputPos_list = intbuf_to_pylist(outputPos, inlen_cp);
 
 		if (typeform != NULL) 
 				free(typeform);
@@ -194,10 +200,6 @@
         free(outputPos);
         free(inputPos);
 
-        Py_INCREF(outputPos_list);
-        Py_INCREF(inputPos_list);
-        Py_INCREF(out);
-
         PyErr_Clear();
 
         return Py_BuildValue("(NNNi)", out, inputPos_list, 

Copied: trunk/src/louis/constants.py.in (from r3464, /trunk/src/louis/constants.py)
==============================================================================
--- /trunk/src/louis/constants.py	(original)
+++ trunk/src/louis/constants.py.in	Fri Jan 18 01:32:28 2008
@@ -55,6 +55,7 @@
                'it-it-g1': _('Italian Grade 1'),
                'nl-be-g1': _('Belgium Dutch Grade 1')}
 
+TABLES_DIR = '@LOUIS_TABLE_DIR@'
 
 class TYPEFORM:
    plain_text = 0



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]