<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[145039] trunk/dports/textproc/enchant</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/145039">145039</a></dd>
<dt>Author</dt> <dd>raimue@macports.org</dd>
<dt>Date</dt> <dd>2016-01-23 18:50:01 -0800 (Sat, 23 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>textproc/enchant:
Add separate variants for each dictionary backend.
Add patch to enable AppleSpell backend, make it default.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkdportstextprocenchantPortfile">trunk/dports/textproc/enchant/Portfile</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/dports/textproc/enchant/files/</li>
<li><a href="#trunkdportstextprocenchantfilespatchapplespellorderingdiff">trunk/dports/textproc/enchant/files/patch-applespell-ordering.diff</a></li>
<li><a href="#trunkdportstextprocenchantfilespatchapplespelldiff">trunk/dports/textproc/enchant/files/patch-applespell.diff</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkdportstextprocenchantPortfile"></a>
<div class="modfile"><h4>Modified: trunk/dports/textproc/enchant/Portfile (145038 => 145039)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -4,7 +4,7 @@
</span><span class="cx"> 
</span><span class="cx"> name                enchant
</span><span class="cx"> version             1.6.0
</span><del>-revision            3
</del><ins>+revision            4
</ins><span class="cx"> categories          textproc devel
</span><span class="cx"> platforms           darwin
</span><span class="cx"> license             LGPL-2.1+
</span><span class="lines">@@ -25,21 +25,62 @@
</span><span class="cx">                     sha1    321f9cf0abfa1937401676ce60976d8779c39536 \
</span><span class="cx">                     rmd160  a992034355bb36b9acabdbd400c9f4a3b996cce6
</span><span class="cx"> 
</span><del>-depends_lib         path:lib/pkgconfig/glib-2.0.pc:glib2 \
-                    port:aspell \
-                    port:hunspell
</del><ins>+patch.pre_args      -p1
</ins><span class="cx"> 
</span><ins>+depends_lib         path:lib/pkgconfig/glib-2.0.pc:glib2
+
</ins><span class="cx"> depends_build       port:pkgconfig
</span><span class="cx"> 
</span><del>-# at least one aspell and/or hunspell dictionary must be installed
-
-depends_run         port:aspell-dict-en
-
</del><span class="cx"> use_autoreconf      yes
</span><span class="cx"> autoreconf.args     -fvi
</span><span class="cx"> 
</span><del>-configure.args      --with-myspell-dir=${prefix}/share/hunspell
</del><ins>+configure.args      --disable-ispell \
+                    --disable-myspell \
+                    --disable-aspell \
+                    --disable-voikko \
+                    --disable-uspell \
+                    --disable-hspell \
+                    --disable-zemberek \
+                    --with-myspell-dir=${prefix}/share/hunspell
</ins><span class="cx"> 
</span><ins>+# 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
+    }
+}
+
</ins><span class="cx"> livecheck.type      regex
</span><span class="cx"> livecheck.url       http://www.abisource.com/downloads/${name}/
</span><span class="cx"> livecheck.regex     {&quot;(\d+(?:\.\d+)*)/&quot;}
</span></span></pre></div>
<a id="trunkdportstextprocenchantfilespatchapplespellorderingdiff"></a>
<div class="addfile"><h4>Added: trunk/dports/textproc/enchant/files/patch-applespell-ordering.diff (0 => 145039)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,18 @@
</span><ins>+--- 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
</ins></span></pre></div>
<a id="trunkdportstextprocenchantfilespatchapplespelldiff"></a>
<div class="addfile"><h4>Added: trunk/dports/textproc/enchant/files/patch-applespell.diff (0 => 145039)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,369 @@
</span><ins>+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 &lt;glib.h&gt;
++#include &lt;gmodule.h&gt;
++#include &lt;Cocoa/Cocoa.h&gt;
++#include &lt;AvailabilityMacros.h&gt;
++
++#include &quot;enchant-provider.h&quot;
++
++#ifdef __cplusplus
++extern &quot;C&quot;
++{
++#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(&quot;AppleSpell&quot;)
++
++typedef struct
++{
++        NSSpellChecker *checker;
++        NSString *language;
++} Dictionary;
++
++static Dictionary *
++dictionary_new (NSSpellChecker *checker,
++                NSString       *language)
++{
++        Dictionary *ret;
++
++        ret = g_slice_new (Dictionary);
++
++        ret-&gt;checker = checker;
++        ret-&gt;language = language;
++
++        return ret;
++}
++
++static void
++dictionary_free (Dictionary *dictionary)
++{
++        [dictionary-&gt;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-&gt;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 &gt; MAC_OS_X_VERSION_10_5
++        words = [d-&gt;checker guessesForWordRange:range
++                            inString:str
++                            language:d-&gt;language
++                            inSpellDocumentWithTag:0];
++#else
++        [d-&gt;checker setLanguage:d-&gt;language]; 
++        words = [d-&gt;checker guessesForWord:str];
++#endif
++
++        *out_n_suggs = [words count];
++
++        ret = g_new0 (gchar *, *out_n_suggs + 1);
++
++        for (i = 0; i &lt; [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-&gt;user_data;
++
++        str = [[NSString alloc] initWithBytes:word length:len encoding:NSUTF8StringEncoding];
++
++        range = [d-&gt;checker checkSpellingOfString:str
++                            startingAt:0
++                            language:d-&gt;language
++                            wrap:true
++                            inSpellDocumentWithTag:0
++                            wordCount:NULL];
++
++        result = range.length &gt; 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-&gt;check = applespell_dict_check;
++        dict-&gt;suggest = applespell_dict_suggest;
++
++        dict-&gt;user_data = dictionary_new (provider-&gt;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-&gt;user_data);
++        g_free (dict);
++
++        [pool release];
++}
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED &lt; MAC_OS_X_VERSION_10_5
++static gchar const *available_languages[] = {
++        &quot;en&quot;,
++        &quot;en_GB&quot;,
++        &quot;en_AU&quot;,
++        &quot;de&quot;,
++        &quot;fr&quot;,
++        &quot;nl&quot;,
++        &quot;pl&quot;,
++        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 &gt;= MAC_OS_X_VERSION_10_5
++        NSArray *languages;
++        guint i;
++#else
++        gchar const **ptr;
++#endif
++
++        pool = [[NSAutoreleasePool alloc] init];
++
++        checker = provider-&gt;user_data;
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED &gt;= MAC_OS_X_VERSION_10_5
++        languages = [checker availableLanguages];
++
++        for (i = 0; i &lt; [languages count]; ++i)
++        {
++                if (g_strcmp0 (tag, [[languages objectAtIndex:i] UTF8String]) == 0)
++                {
++                        result = 1;
++                        break;
++                }
++        }
++#else
++        ptr = available_languages;
++        
++        while (ptr &amp;&amp; *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 &quot;AppleSpell&quot;;
++}
++
++static const gchar *
++applespell_provider_describe (EnchantProvider *provider)
++{
++        return &quot;AppleSpell Provider&quot;;
++}
++
++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 &gt;= MAC_OS_X_VERSION_10_5
++        NSArray *languages;
++        guint i = 0;
++#endif
++
++        pool = [[NSAutoreleasePool alloc] init];
++
++        checker = provider-&gt;user_data;
++
++#if MAC_OS_X_VERSION_MIN_REQUIRED &gt;= 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 &lt; [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-&gt;dispose = applespell_provider_dispose;
++        provider-&gt;request_dict = applespell_provider_request_dict;
++        provider-&gt;dispose_dict = applespell_provider_dispose_dict;
++        provider-&gt;dictionary_exists = applespell_provider_dictionary_exists;
++        provider-&gt;identify = applespell_provider_identify;
++        provider-&gt;describe = applespell_provider_describe;
++        provider-&gt;list_dicts = applespell_provider_list_dicts;
++
++        provider-&gt;user_data = [NSSpellChecker sharedSpellChecker];
++
++        [pool release];
++
++        return provider;
++}
++
++ENCHANT_MODULE_EXPORT (void)
++configure_enchant_provider (EnchantProvider *provider,
++                            const gchar     *module_dir)
++{
++        return;
++}
</ins></span></pre>
</div>
</div>

</body>
</html>