ports/185696: textproc/sdcv: Fix build with clang
KATO Tsuguru
tkato432 at yahoo.com
Sun Jan 12 18:40:02 UTC 2014
>Number: 185696
>Category: ports
>Synopsis: textproc/sdcv: Fix build with clang
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Jan 12 18:40:01 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator: KATO Tsuguru
>Release: FreeBSD 8.4-RELEASE-p4 i386
>Organization:
>Environment:
>Description:
- Fix build with clang
New file:
files/patch-src__lib__lib.cpp
files/patch-src__lib__mapfile.hpp
files/patch-src__libwrapper.cpp
files/patch-src__readline.cpp
files/patch-src__sdcv.cpp
files/patch-src__utils.cpp
>How-To-Repeat:
>Fix:
diff -urN /usr/ports/textproc/sdcv/Makefile textproc/sdcv/Makefile
--- /usr/ports/textproc/sdcv/Makefile 2013-11-06 21:54:55.000000000 +0900
+++ textproc/sdcv/Makefile 2014-01-13 00:00:00.000000000 +0900
@@ -8,55 +8,35 @@
MASTER_SITES= SF
MAINTAINER= ports at FreeBSD.org
-COMMENT= A text-based utility for work with dictionaries in StarDict's format
+COMMENT= Text-based utility for work with dictionaries in StarDict's format
+
+LICENSE= GPLv2 # (or later)
USE_BZIP2= yes
-GNU_CONFIGURE= yes
-USE_AUTOTOOLS= libtool
+USES= gettext pkgconfig readline
USE_GNOME= glib20
-USES= pkgconfig iconv
-SUB_FILES= pkg-message
+USE_AUTOTOOLS= libtoolize aclocal automake autoconf
+LIBTOOLIZE_ARGS=--copy --force
+ACLOCAL_ARGS= --automake-acdir=${ACLOCAL_DIR} -I m4
+AUTOMAKE_ARGS= --add-missing --copy
-NO_STAGE= yes
-.include <bsd.port.options.mk>
+SUB_FILES= pkg-message
-.if ${PORT_OPTIONS:MNLS}
-USES+= gettext
-PLIST_SUB+= NLS=""
CPPFLAGS+= -I${LOCALBASE}/include
LDFLAGS+= -L${LOCALBASE}/lib
-.else
-CONFIGURE_ARGS+=--disable-nls
-PLIST_SUB+= NLS="@comment "
-.endif
-
-MAN1= sdcv.1
-
-.include <bsd.port.pre.mk>
post-patch:
- @${REINPLACE_CMD} -e 's|/usr/share|${PREFIX}/share|g' \
- ${WRKSRC}/doc/sdcv.1
- @${REINPLACE_CMD} -e '1425 s, install-data,,' \
- ${WRKSRC}/po/Makefile.in.in
- @${REINPLACE_CMD} -e 's, getopt.h,,g' ${WRKSRC}/src/Makefile.in
- @${REINPLACE_CMD} -e '146 s|()|(int, char * const [], const char *)|g' \
- ${WRKSRC}/src/getopt.h
-.if ${ARCH} == "amd64" || ${ARCH} == "ia64" || ${ARCH} == "sparc64"
- @${REINPLACE_CMD} -e '516 s|sizeof|(guint32)sizeof|g' \
- ${WRKSRC}/src/lib/lib.cpp
-.endif
- @${REINPLACE_CMD} -e 's|/usr/share|${PREFIX}/share|g' \
- ${WRKSRC}/src/sdcv.cpp
- @${REINPLACE_CMD} -e 's, at mandir@/uk, at mandir@,' \
- ${WRKSRC}/doc/uk/Makefile.in
-.if ${PORT_OPTIONS:MNLS}
- @${REINPLACE_CMD} -e 's, at USE_NLS@,yes,g' ${WRKSRC}/po/Makefile.in.in
- @${REINPLACE_CMD} -e 's, getopt.h,,g; s, at USE_NLS@,yes,g' \
- ${WRKSRC}/src/Makefile.in
-.endif
-
-post-install:
- @${CAT} ${PKGMESSAGE}
+.for i in doc/sdcv.1 src/sdcv.cpp
+ @${REINPLACE_CMD} -e \
+ 's|/usr/share|${PREFIX}/share|' ${WRKSRC}/${i}
+.endfor
+ @${REINPLACE_CMD} -e \
+ 's|@mandir@/uk|@mandir@|' ${WRKSRC}/doc/uk/Makefile.am
+ @${REINPLACE_CMD} -e \
+ 's|getopt1.c getopt.h||' ${WRKSRC}/src/Makefile.am
+
+pre-configure:
+ @${RM} -f ${WRKSRC}/m4/gettext.m4
+ @${RM} -f ${WRKSRC}/src/getopt.h
-.include <bsd.port.post.mk>
+.include <bsd.port.mk>
diff -urN /usr/ports/textproc/sdcv/files/patch-src__lib__lib.cpp textproc/sdcv/files/patch-src__lib__lib.cpp
--- /usr/ports/textproc/sdcv/files/patch-src__lib__lib.cpp 1970-01-01 09:00:00.000000000 +0900
+++ textproc/sdcv/files/patch-src__lib__lib.cpp 2014-01-13 00:00:00.000000000 +0900
@@ -0,0 +1,27 @@
+--- src/lib/lib.cpp.orig
++++ src/lib/lib.cpp
+@@ -496,9 +496,13 @@
+ entries[i].keystr=p;
+ len=strlen(p);
+ p+=len+1;
+- entries[i].off=g_ntohl(*reinterpret_cast<guint32 *>(p));
++ /*
++ * Can not use typecasting here, because *data does not have
++ * to be alligned and unalligned access fails on some architectures.
++ */
++ entries[i].off=((unsigned char)p[0] << 24) | ((unsigned char)p[1] << 16) | ((unsigned char)p[2] << 8) | (unsigned char)p[3];
+ p+=sizeof(guint32);
+- entries[i].size=g_ntohl(*reinterpret_cast<guint32 *>(p));
++ entries[i].size=((unsigned char)p[0] << 24) | ((unsigned char)p[1] << 16) | ((unsigned char)p[2] << 8) | (unsigned char)p[3];
+ p+=sizeof(guint32);
+ }
+ }
+@@ -513,7 +517,7 @@
+ {
+ fseek(idxfile, wordoffset[page_idx], SEEK_SET);
+ guint32 page_size=wordoffset[page_idx+1]-wordoffset[page_idx];
+- fread(wordentry_buf, std::min(sizeof(wordentry_buf), page_size), 1, idxfile); //TODO: check returned values, deal with word entry that strlen>255.
++ fread(wordentry_buf, std::min(sizeof(wordentry_buf), (size_t)page_size), 1, idxfile); //TODO: check returned values, deal with word entry that strlen>255.
+ return wordentry_buf;
+ }
+
diff -urN /usr/ports/textproc/sdcv/files/patch-src__lib__mapfile.hpp textproc/sdcv/files/patch-src__lib__mapfile.hpp
--- /usr/ports/textproc/sdcv/files/patch-src__lib__mapfile.hpp 1970-01-01 09:00:00.000000000 +0900
+++ textproc/sdcv/files/patch-src__lib__mapfile.hpp 2014-01-13 00:00:00.000000000 +0900
@@ -0,0 +1,12 @@
+--- src/lib/mapfile.hpp.orig
++++ src/lib/mapfile.hpp
+@@ -5,6 +5,9 @@
+ # include "config.h"
+ #endif
+
++#include <cstdlib>
++#include <unistd.h>
++
+ #ifdef HAVE_MMAP
+ # include <sys/types.h>
+ # include <fcntl.h>
diff -urN /usr/ports/textproc/sdcv/files/patch-src__libwrapper.cpp textproc/sdcv/files/patch-src__libwrapper.cpp
--- /usr/ports/textproc/sdcv/files/patch-src__libwrapper.cpp 1970-01-01 09:00:00.000000000 +0900
+++ textproc/sdcv/files/patch-src__libwrapper.cpp 2014-01-13 00:00:00.000000000 +0900
@@ -0,0 +1,50 @@
+--- src/libwrapper.cpp.orig
++++ src/libwrapper.cpp
+@@ -24,6 +24,7 @@
+
+ #include <glib/gi18n.h>
+ #include <map>
++#include <cstring>
+
+ #include "utils.hpp"
+
+@@ -117,7 +118,6 @@
+ switch (*p++) {
+ case 'm':
+ case 'l': //need more work...
+- case 'g':
+ sec_size = strlen(p);
+ if (sec_size) {
+ res+="\n";
+@@ -127,6 +127,7 @@
+ }
+ sec_size++;
+ break;
++ case 'g':
+ case 'x':
+ sec_size = strlen(p);
+ if (sec_size) {
+@@ -208,6 +209,15 @@
+
+ void Library::LookupData(const string &str, TSearchResultList& res_list)
+ {
++#if defined(_LIBCPP_VERSION)
++ std::vector<std::vector<gchar *> > drl(ndicts());
++ if (!Libs::LookupData(str.c_str(), &drl[0]))
++ return;
++ for (int idict=0; idict<ndicts(); ++idict)
++ for (gchar *res : drl[idict]) {
++ SimpleLookup(res, res_list);
++ g_free(res);
++#else
+ std::vector<gchar *> drl[ndicts()];
+ if (!Libs::LookupData(str.c_str(), drl))
+ return;
+@@ -215,6 +225,7 @@
+ for (std::vector<gchar *>::size_type j=0; j<drl[idict].size(); ++j) {
+ SimpleLookup(drl[idict][j], res_list);
+ g_free(drl[idict][j]);
++#endif
+ }
+ }
+
diff -urN /usr/ports/textproc/sdcv/files/patch-src__readline.cpp textproc/sdcv/files/patch-src__readline.cpp
--- /usr/ports/textproc/sdcv/files/patch-src__readline.cpp 1970-01-01 09:00:00.000000000 +0900
+++ textproc/sdcv/files/patch-src__readline.cpp 2014-01-13 00:00:00.000000000 +0900
@@ -0,0 +1,10 @@
+--- src/readline.cpp.orig
++++ src/readline.cpp
+@@ -23,6 +23,7 @@
+ #endif
+
+ #include <cstdio>
++#include <cstdlib>
+ #ifdef WITH_READLINE
+ # include <readline/readline.h>
+ # include <readline/history.h>
diff -urN /usr/ports/textproc/sdcv/files/patch-src__sdcv.cpp textproc/sdcv/files/patch-src__sdcv.cpp
--- /usr/ports/textproc/sdcv/files/patch-src__sdcv.cpp 1970-01-01 09:00:00.000000000 +0900
+++ textproc/sdcv/files/patch-src__sdcv.cpp 2014-01-13 00:00:00.000000000 +0900
@@ -0,0 +1,15 @@
+--- src/sdcv.cpp.orig
++++ src/sdcv.cpp
+@@ -161,7 +161,11 @@
+
+ strlist_t dicts_dir_list;
+
+- dicts_dir_list.push_back(std::string(g_get_home_dir())+G_DIR_SEPARATOR+
++ const char *homedir = g_getenv ("HOME");
++ if (!homedir)
++ homedir = g_get_home_dir ();
++
++ dicts_dir_list.push_back(std::string(homedir)+G_DIR_SEPARATOR+
+ ".stardict"+G_DIR_SEPARATOR+"dic");
+ dicts_dir_list.push_back(data_dir);
+
diff -urN /usr/ports/textproc/sdcv/files/patch-src__utils.cpp textproc/sdcv/files/patch-src__utils.cpp
--- /usr/ports/textproc/sdcv/files/patch-src__utils.cpp 1970-01-01 09:00:00.000000000 +0900
+++ textproc/sdcv/files/patch-src__utils.cpp 2014-01-13 00:00:00.000000000 +0900
@@ -0,0 +1,11 @@
+--- src/utils.cpp.orig
++++ src/utils.cpp
+@@ -22,6 +22,8 @@
+ # include "config.h"
+ #endif
+
++#include <cstdio>
++#include <cstdlib>
+ #include <glib.h>
+ #include <glib/gi18n.h>
+
diff -urN /usr/ports/textproc/sdcv/pkg-plist textproc/sdcv/pkg-plist
--- /usr/ports/textproc/sdcv/pkg-plist 2013-11-06 21:54:55.000000000 +0900
+++ textproc/sdcv/pkg-plist 2014-01-13 00:00:00.000000000 +0900
@@ -1,6 +1,7 @@
bin/sdcv
-%%NLS%%share/locale/ru/LC_MESSAGES/sdcv.mo
-%%NLS%%share/locale/sk/LC_MESSAGES/sdcv.mo
-%%NLS%%share/locale/uk/LC_MESSAGES/sdcv.mo
-%%NLS%%share/locale/zh_CN/LC_MESSAGES/sdcv.mo
-%%NLS%%share/locale/zh_TW/LC_MESSAGES/sdcv.mo
+man/man1/sdcv.1.gz
+share/locale/ru/LC_MESSAGES/sdcv.mo
+share/locale/sk/LC_MESSAGES/sdcv.mo
+share/locale/uk/LC_MESSAGES/sdcv.mo
+share/locale/zh_CN/LC_MESSAGES/sdcv.mo
+share/locale/zh_TW/LC_MESSAGES/sdcv.mo
Files /usr/ports/textproc/sdcv/sdcv-0.4.2-crash.patch and textproc/sdcv/sdcv-0.4.2-crash.patch differ
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list