[145039] trunk/dports/textproc/enchant

raimue at macports.org raimue at macports.org
Sat Jan 23 18:50:01 PST 2016


Revision: 145039
          https://trac.macports.org/changeset/145039
Author:   raimue at macports.org
Date:     2016-01-23 18:50:01 -0800 (Sat, 23 Jan 2016)
Log Message:
-----------
textproc/enchant:
Add separate variants for each dictionary backend.
Add patch to enable AppleSpell backend, make it default.

Modified Paths:
--------------
    trunk/dports/textproc/enchant/Portfile

Added Paths:
-----------
    trunk/dports/textproc/enchant/files/
    trunk/dports/textproc/enchant/files/patch-applespell-ordering.diff
    trunk/dports/textproc/enchant/files/patch-applespell.diff

Modified: trunk/dports/textproc/enchant/Portfile
===================================================================
--- trunk/dports/textproc/enchant/Portfile	2016-01-24 02:28:10 UTC (rev 145038)
+++ trunk/dports/textproc/enchant/Portfile	2016-01-24 02:50:01 UTC (rev 145039)
@@ -4,7 +4,7 @@
 
 name                enchant
 version             1.6.0
-revision            3
+revision            4
 categories          textproc devel
 platforms           darwin
 license             LGPL-2.1+
@@ -25,21 +25,62 @@
                     sha1    321f9cf0abfa1937401676ce60976d8779c39536 \
                     rmd160  a992034355bb36b9acabdbd400c9f4a3b996cce6
 
-depends_lib         path:lib/pkgconfig/glib-2.0.pc:glib2 \
-                    port:aspell \
-                    port:hunspell
+patch.pre_args      -p1
 
+depends_lib         path:lib/pkgconfig/glib-2.0.pc:glib2
+
 depends_build       port:pkgconfig
 
-# at least one aspell and/or hunspell dictionary must be installed
-
-depends_run         port:aspell-dict-en
-
 use_autoreconf      yes
 autoreconf.args     -fvi
 
-configure.args      --with-myspell-dir=${prefix}/share/hunspell
+configure.args      --disable-ispell \
+                    --disable-myspell \
+                    --disable-aspell \
+                    --disable-voikko \
+                    --disable-uspell \
+                    --disable-hspell \
+                    --disable-zemberek \
+                    --with-myspell-dir=${prefix}/share/hunspell
 
+# users most likely have AppleSpell already set up for their language
+default_variants    +applespell
+
+variant ispell description {Enable ispell backend} {
+    configure.args-replace --disable-ispell --enable-ispell
+}
+
+variant aspell description {Enable aspell backend} {
+    configure.args-replace --disable-aspell --enable-aspell
+    depends_lib-append  port:aspell
+    depends_run         port:aspell-dict-en
+}
+
+variant myspell description {Enable myspell backend, using hunspell} {
+    configure.args-replace --disable-myspell --enable-myspell
+    depends_lib-append  port:hunspell
+    depends_run-append  port:hunspell-dict-en_US
+}
+
+variant applespell description {Enable AppleSpell backend, using system-wide OS X spell checker} {
+    # the AppleSpell backend will always be built with this patch,
+    # no configure flags required
+    patchfiles-append   patch-applespell.diff \
+                        patch-applespell-ordering.diff
+}
+
+if {[variant_isset ispell] || [variant_isset aspell] || [variant_isset myspell]} {
+    notes {
+        enchant will use the first backend that provides a dictionary for the
+        requested language. If you prefer a specific backend, please see the
+        man page how you can change the lookup order. By default, the backend
+        order is aspell, myspell, ispell, AppleSpell from highest to lowest
+        preference.
+
+        $ man enchant
+    }
+}
+
 livecheck.type      regex
 livecheck.url       http://www.abisource.com/downloads/${name}/
 livecheck.regex     {"(\d+(?:\.\d+)*)/"}

Added: trunk/dports/textproc/enchant/files/patch-applespell-ordering.diff
===================================================================
--- trunk/dports/textproc/enchant/files/patch-applespell-ordering.diff	                        (rev 0)
+++ trunk/dports/textproc/enchant/files/patch-applespell-ordering.diff	2016-01-24 02:50:01 UTC (rev 145039)
@@ -0,0 +1,18 @@
+--- a/data/enchant.ordering.orig	2016-01-24 01:16:28.000000000 +0100
++++ b/data/enchant.ordering	2016-01-24 01:25:21.000000000 +0100
+@@ -1,8 +1,8 @@
+-*:myspell,aspell,ispell
+-fi:voikko,ispell,myspell,aspell
+-fi_FI:voikko,ispell,myspell,aspell
+-he:hspell,myspell
+-he_IL:hspell,myspell
++*:myspell,aspell,ispell,AppleSpell
++fi:voikko,ispell,myspell,aspell,AppleSpell
++fi_FI:voikko,ispell,myspell,aspell,AppleSpell
++he:hspell,myspell,AppleSpell
++he_IL:hspell,myspell,AppleSpell
+ yi:uspell
+-tr:zemberek
+-tr_TR:zemberek
++tr:zemberek,AppleSpell
++tr_TR:zemberek,AppleSpell

Added: trunk/dports/textproc/enchant/files/patch-applespell.diff
===================================================================
--- trunk/dports/textproc/enchant/files/patch-applespell.diff	                        (rev 0)
+++ trunk/dports/textproc/enchant/files/patch-applespell.diff	2016-01-24 02:50:01 UTC (rev 145039)
@@ -0,0 +1,369 @@
+Upstream: https://gist.github.com/TingPing/2d88a875b50da15c352d/
+--- a/configure.in       (revision 30591)
++++ b/configure.in       (working copy)
+@@ -33,4 +33,5 @@
+ AC_PROG_CC
+ AC_PROG_CPP
++AC_PROG_OBJC
+ AC_PROG_INSTALL
+ AC_PROG_LN_S
+--- a/src/applespell/Makefile.am	2010-04-01 22:53:37.000000000 +0200
++++ b/src/applespell/Makefile.am	2012-01-11 22:42:13.000000000 +0100
+@@ -1,4 +1,13 @@
+-EXTRA_DIST=			\
+-	applespell_checker.h	\
+-	applespell_checker.mm	\
+-	AppleSpell.config
++target_lib = libenchant_applespell.la
++
++INCLUDES=-I$(top_srcdir)/src $(ENCHANT_CFLAGS) $(CC_WARN_CFLAGS) -DXP_TARGET_COCOA -xobjective-c -D_ENCHANT_BUILD=1
++
++applespell_LTLIBRARIES = $(target_lib)
++applespelldir= $(libdir)/enchant
++
++libenchant_applespell_la_LIBADD= $(ENCHANT_LIBS) -lobjc $(top_builddir)/src/libenchant.la
++libenchant_applespell_la_LDFLAGS = -module -avoid-version -no-undefined -framework Cocoa
++libenchant_applespell_la_SOURCES = applespell_provider.m
++libenchant_applespell_la_LIBTOOLFLAGS = --tag=CC
++
++libenchant_applespell_lalibdir=$(libdir)/enchant
+--- a/src/applespell/applespell_provider.m	2012-01-11 22:46:35.000000000 +0100
++++ b/src/applespell/applespell_provider.m	2012-01-11 22:39:17.000000000 +0100
+@@ -0,0 +1,337 @@
++/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
++/* enchant
++ * Copyright (C) 2004 Remi Payette
++ * Copyright (C) 2004 Francis James Franklin
++ * 
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2
++ * of the License, or (at your option) any later version.
++ * 
++ * This program 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 General Public License for more details.
++ * 
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
++ * 02110-1301, USA.
++ */
++
++#include <glib.h>
++#include <gmodule.h>
++#include <Cocoa/Cocoa.h>
++#include <AvailabilityMacros.h>
++
++#include "enchant-provider.h"
++
++#ifdef __cplusplus
++extern "C"
++{
++#endif
++
++ENCHANT_MODULE_EXPORT (EnchantProvider *)
++init_enchant_provider (void);
++
++ENCHANT_MODULE_EXPORT (void)
++configure_enchant_provider (EnchantProvider *provider, const gchar *module_dir);
++
++#ifdef __cplusplus
++}
++#endif
++
++ENCHANT_PLUGIN_DECLARE("AppleSpell")
++
++typedef struct
++{
++	NSSpellChecker *checker;
++	NSString *language;
++} Dictionary;
++
++static Dictionary *
++dictionary_new (NSSpellChecker *checker,
++                NSString       *language)
++{
++	Dictionary *ret;
++
++	ret = g_slice_new (Dictionary);
++
++	ret->checker = checker;
++	ret->language = language;
++
++	return ret;
++}
++
++static void
++dictionary_free (Dictionary *dictionary)
++{
++	[dictionary->language release];
++	g_slice_free (Dictionary, dictionary);
++}
++
++static gchar **
++applespell_dict_suggest (EnchantDict         *dict,
++                         const gchar * const  word,
++                         size_t               len,
++                         size_t              *out_n_suggs)
++{
++	NSAutoreleasePool *pool;
++	gchar **ret = NULL;
++	NSString *str;
++	Dictionary *d;
++	NSArray *words;
++	NSRange range;
++	guint i = 0;
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	d = dict->user_data;
++
++	str = [[NSString alloc] initWithBytes:word length:len encoding:NSUTF8StringEncoding];
++
++	range.location = 0;
++	range.length = [str length];
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
++	words = [d->checker guessesForWordRange:range
++	                    inString:str
++	                    language:d->language
++	                    inSpellDocumentWithTag:0];
++#else
++	[d->checker setLanguage:d->language]; 
++	words = [d->checker guessesForWord:str];
++#endif
++
++	*out_n_suggs = [words count];
++
++	ret = g_new0 (gchar *, *out_n_suggs + 1);
++
++	for (i = 0; i < [words count]; ++i)
++	{
++		ret[i] = g_strdup ([[words objectAtIndex:i] UTF8String]);
++	}
++
++	[str release];
++	[pool release];
++
++	return ret;
++}
++
++static gint
++applespell_dict_check (EnchantDict         *dict,
++                       const gchar * const  word,
++                       size_t               len)
++{
++	NSAutoreleasePool *pool;
++	gint result = 0;
++	NSString *str;
++	Dictionary *d;
++	NSRange range;
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	d = dict->user_data;
++
++	str = [[NSString alloc] initWithBytes:word length:len encoding:NSUTF8StringEncoding];
++
++	range = [d->checker checkSpellingOfString:str
++	                    startingAt:0
++	                    language:d->language
++	                    wrap:true
++	                    inSpellDocumentWithTag:0
++	                    wordCount:NULL];
++
++	result = range.length > 0 ? 1 : 0;
++
++	[str release];
++	[pool release];
++
++	return result;
++}
++
++static EnchantDict *
++applespell_provider_request_dict (EnchantProvider    *provider,
++                                  const char * const  tag)
++{
++	NSAutoreleasePool *pool;
++	EnchantDict *dict;
++	NSString *str;
++
++	pool = [[NSAutoreleasePool alloc] init];
++	str = [[NSString alloc] initWithUTF8String:tag];
++
++	dict = g_new0 (EnchantDict, 1);
++
++	dict->check = applespell_dict_check;
++	dict->suggest = applespell_dict_suggest;
++
++	dict->user_data = dictionary_new (provider->user_data,
++	                                  str);
++
++	[str retain];
++
++	[pool release];
++	return dict;
++}
++
++static void
++applespell_provider_dispose_dict (EnchantProvider *provider,
++                                  EnchantDict     *dict)
++{
++	NSAutoreleasePool *pool;
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	dictionary_free (dict->user_data);
++	g_free (dict);
++
++	[pool release];
++}
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
++static gchar const *available_languages[] = {
++	"en",
++	"en_GB",
++	"en_AU",
++	"de",
++	"fr",
++	"nl",
++	"pl",
++	NULL
++};
++
++#endif
++
++static gint
++applespell_provider_dictionary_exists (EnchantProvider     *provider,
++                                       const gchar * const  tag)
++{
++	NSAutoreleasePool *pool;
++	gint result = 0;
++	NSSpellChecker *checker;
++#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
++	NSArray *languages;
++	guint i;
++#else
++	gchar const **ptr;
++#endif
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	checker = provider->user_data;
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
++	languages = [checker availableLanguages];
++
++	for (i = 0; i < [languages count]; ++i)
++	{
++		if (g_strcmp0 (tag, [[languages objectAtIndex:i] UTF8String]) == 0)
++		{
++			result = 1;
++			break;
++		}
++	}
++#else
++	ptr = available_languages;
++	
++	while (ptr && *ptr)
++	{
++		if (g_strcmp0 (tag, *ptr) == 0)
++		{
++			result = 1;
++			break;
++		}
++		++ptr;
++	}
++#endif
++
++	[pool release];
++
++	return result;
++}
++
++static void
++applespell_provider_dispose (EnchantProvider *provider)
++{
++	g_free (provider);
++}
++
++static const gchar *
++applespell_provider_identify (EnchantProvider *provider)
++{
++	return "AppleSpell";
++}
++
++static const gchar *
++applespell_provider_describe (EnchantProvider *provider)
++{
++	return "AppleSpell Provider";
++}
++
++static gchar **
++applespell_provider_list_dicts (EnchantProvider *provider,
++                                size_t          *out_n_dicts)
++{
++	NSSpellChecker *checker;
++	NSAutoreleasePool *pool;
++	gchar **ret = NULL;
++#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
++	NSArray *languages;
++	guint i = 0;
++#endif
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	checker = provider->user_data;
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
++	languages = [checker availableLanguages];
++	*out_n_dicts = [languages count];
++
++	ret = g_new0 (gchar *, *out_n_dicts + 1);
++
++	for (i = 0; i < [languages count]; ++i)
++	{
++		ret[i] = g_strdup ([[languages objectAtIndex:i] UTF8String]);
++	}
++#else
++	ret = g_strdupv ((gchar **)available_languages);
++#endif
++
++	[pool release];
++
++	return ret;
++}
++
++ENCHANT_MODULE_EXPORT (EnchantProvider *)
++init_enchant_provider (void)
++{
++	NSAutoreleasePool *pool;
++	EnchantProvider *provider;
++
++	pool = [[NSAutoreleasePool alloc] init];
++
++	provider = g_new0 (EnchantProvider, 1);
++
++	provider->dispose = applespell_provider_dispose;
++	provider->request_dict = applespell_provider_request_dict;
++	provider->dispose_dict = applespell_provider_dispose_dict;
++	provider->dictionary_exists = applespell_provider_dictionary_exists;
++	provider->identify = applespell_provider_identify;
++	provider->describe = applespell_provider_describe;
++	provider->list_dicts = applespell_provider_list_dicts;
++
++	provider->user_data = [NSSpellChecker sharedSpellChecker];
++
++	[pool release];
++
++	return provider;
++}
++
++ENCHANT_MODULE_EXPORT (void)
++configure_enchant_provider (EnchantProvider *provider,
++                            const gchar     *module_dir)
++{
++	return;
++}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160123/00847c14/attachment.html>


More information about the macports-changes mailing list