Skip to content

Commit

Permalink
sword: remove comparisons between pointers and ints
Browse files Browse the repository at this point in the history
This causes errors on certain versions of Clang.
No revbump since the port either builds correctly or not at all.
  • Loading branch information
MarcusCalhoun-Lopez committed Sep 12, 2019
1 parent 12796ee commit b1def42
Show file tree
Hide file tree
Showing 2 changed files with 180 additions and 1 deletion.
3 changes: 2 additions & 1 deletion textproc/sword/Portfile
Expand Up @@ -35,7 +35,8 @@ depends_lib port:curl \
path:lib/libssl.dylib:openssl \
port:zlib

patchfiles patch-automake-1.13.diff
patchfiles patch-automake-1.13.diff \
patch-pointer_comparison.diff

# llvm-gcc-4.2 hangs
compiler.blacklist *llvm-gcc-4.2
Expand Down
178 changes: 178 additions & 0 deletions textproc/sword/files/patch-pointer_comparison.diff
@@ -0,0 +1,178 @@
--- src/mgr/swmgr.cpp.orig 2014-04-16 20:50:37.000000000 -0700
+++ src/mgr/swmgr.cpp 2019-09-12 08:14:52.000000000 -0700
@@ -1362,7 +1362,7 @@
else {
if (!conffd) {
conffd = FileMgr::getSystemFileMgr()->open(config->filename.c_str(), FileMgr::WRONLY|FileMgr::APPEND);
- if (conffd > 0)
+ if (conffd)
conffd->seek(0L, SEEK_END);
else {
FileMgr::getSystemFileMgr()->close(conffd);
--- src/keys/treekeyidx.cpp.orig 2013-09-14 14:51:47.000000000 -0700
+++ src/keys/treekeyidx.cpp 2019-09-12 08:13:02.000000000 -0700
@@ -61,7 +61,7 @@
buf.setFormatted("%s.dat", path);
datfd = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);

- if (datfd <= 0) {
+ if (!datfd) {
SWLog::getSystemLog()->logError("%d", errno);
error = errno;
}
@@ -331,7 +331,7 @@
__s32 tmp;
__u16 tmp2;

- if (datfd > 0) {
+ if (datfd) {

datfd->seek(ioffset, SEEK_SET);

@@ -385,7 +385,7 @@
}

node->offset = ioffset;
- if (idxfd > 0) {
+ if (idxfd) {
if (idxfd->getFd() > 0) {
idxfd->seek(ioffset, SEEK_SET);
if (idxfd->read(&offset, 4) == 4) {
@@ -422,7 +422,7 @@
long datOffset = 0;
__s32 tmp;

- if (idxfd > 0) {
+ if (idxfd) {
idxfd->seek(node->offset, SEEK_SET);
if (idxfd->read(&tmp, 4) != 4) {
datOffset = datfd->seek(0, SEEK_END);
@@ -488,7 +488,7 @@
void TreeKeyIdx::saveTreeNode(TreeNode *node) {
long datOffset = 0;
__s32 tmp;
- if (idxfd > 0) {
+ if (idxfd) {

idxfd->seek(node->offset, SEEK_SET);
datOffset = datfd->seek(0, SEEK_END);
--- src/modules/common/rawstr.cpp.orig 2014-04-16 21:27:57.000000000 -0700
+++ src/modules/common/rawstr.cpp 2019-09-12 08:36:48.000000000 -0700
@@ -74,7 +74,7 @@
buf.setFormatted("%s.dat", path);
datfd = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);

- if (datfd < 0) {
+ if (!datfd) {
SWLog::getSystemLog()->logError("%d", errno);
}

@@ -111,7 +111,7 @@
{
int size;
char ch;
- if (datfd > 0) {
+ if (datfd) {
datfd->seek(ioffset, SEEK_SET);
for (size = 0; datfd->read(&ch, 1) == 1; size++) {
if ((ch == '\\') || (ch == 10) || (ch == 13))
@@ -145,7 +145,7 @@
{
__u32 offset;

- if (idxfd > 0) {
+ if (idxfd) {
idxfd->seek(ioffset, SEEK_SET);
idxfd->read(&offset, 4);

--- src/modules/common/rawstr4.cpp.orig 2014-04-16 21:27:57.000000000 -0700
+++ src/modules/common/rawstr4.cpp 2019-09-12 08:38:07.000000000 -0700
@@ -74,7 +74,7 @@
buf.setFormatted("%s.dat", path);
datfd = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);

- if (datfd < 0) {
+ if (!datfd) {
SWLog::getSystemLog()->logError("%d", errno);
}

@@ -111,7 +111,7 @@
{
int size;
char ch;
- if (datfd > 0) {
+ if (datfd) {
datfd->seek(ioffset, SEEK_SET);
for (size = 0; datfd->read(&ch, 1) == 1; size++) {
if ((ch == '\\') || (ch == 10) || (ch == 13))
@@ -145,7 +145,7 @@
{
__u32 offset;

- if (idxfd > 0) {
+ if (idxfd) {
idxfd->seek(ioffset, SEEK_SET);

idxfd->read(&offset, 4);
--- src/modules/common/zstr.cpp.orig 2013-09-14 14:51:47.000000000 -0700
+++ src/modules/common/zstr.cpp 2019-09-12 08:39:03.000000000 -0700
@@ -83,7 +83,7 @@
buf.setFormatted("%s.zdt", path);
zdtfd = FileMgr::getSystemFileMgr()->open(buf, fileMode, true);

- if (datfd <= 0) {
+ if (!datfd) {
SWLog::getSystemLog()->logError("%d", errno);
}

@@ -133,7 +133,7 @@
{
int size;
char ch;
- if (datfd > 0) {
+ if (datfd) {
datfd->seek(ioffset, SEEK_SET);
for (size = 0; datfd->read(&ch, 1) == 1; size++) {
if ((ch == '\\') || (ch == 10) || (ch == 13))
@@ -167,7 +167,7 @@
{
__u32 offset;

- if (idxfd > 0) {
+ if (idxfd) {
idxfd->seek(ioffset, SEEK_SET);
idxfd->read(&offset, 4);
offset = swordtoarch32(offset);
--- src/modules/lexdict/zld/zld.cpp.orig 2013-09-14 14:51:47.000000000 -0700
+++ src/modules/lexdict/zld/zld.cpp 2019-09-12 08:42:11.000000000 -0700
@@ -166,7 +166,7 @@

long zLD::getEntryCount() const
{
- if (idxfd < 0) return 0;
+ if (!idxfd) return 0;
return idxfd->seek(0, SEEK_END) / IDXENTRYSIZE;
}

--- src/modules/lexdict/rawld4/rawld4.cpp.orig 2013-09-14 14:51:47.000000000 -0700
+++ src/modules/lexdict/rawld4/rawld4.cpp 2019-09-12 08:41:37.000000000 -0700
@@ -166,7 +166,7 @@


long RawLD4::getEntryCount() const {
- if (idxfd < 0) return 0;
+ if (!idxfd) return 0;
return idxfd->seek(0, SEEK_END) / IDXENTRYSIZE;
}

--- src/modules/lexdict/rawld/rawld.cpp.orig 2013-09-14 14:51:47.000000000 -0700
+++ src/modules/lexdict/rawld/rawld.cpp 2019-09-12 08:40:46.000000000 -0700
@@ -168,7 +168,7 @@


long RawLD::getEntryCount() const {
- if (idxfd < 0) return 0;
+ if (!idxfd) return 0;

This comment has been minimized.

Copy link
@ryandesign

ryandesign Sep 20, 2019

Contributor

This looks like a change in the code that would warrant a revbump.

This comment has been minimized.

Copy link
@MarcusCalhoun-Lopez

MarcusCalhoun-Lopez Sep 21, 2019

Author Contributor

Thank you for noticing this.
It should be fixed in 43d33fa.

return idxfd->seek(0, SEEK_END) / IDXENTRYSIZE;
}

0 comments on commit b1def42

Please sign in to comment.