New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RDY] re-enable iconv #1370
[RDY] re-enable iconv #1370
Conversation
I'm still unsure whether this has anything to do with it, but I'm logging it here because I'm dealing with encodings now: Generate a latin-9 file (I chose the euro symbol because it is representable in 1 byte in the latin-9 encoding, but not representable in latin-1 and takes 3 bytes in utf-8): str='€'
echo -n $str | iconv --to-code=LATIN-9 > euro.latin9
echo -n $str > euro.utf8 Open it with vanilla vim and nvim # shows the euro symbol and [converted]
$ vim -c "e ++enc=latin9 euro.latin9"
# shows a question mark and [NOT converted][ILLEGAL BYTE in line 1]
$ ~/github/neovim/neovim/build/bin/nvim -c "e ++enc=latin9 euro.latin9" So it seems that vim's and nvim's capabilities have diverged a bit. UPDATE: The iconv patch in this PR indeed restores the functionality. Awesome. UPDATE 2: The error message could be a bit clearer though, there was no illegal byte, just an unsupported encoding. |
I'm just getting back into town, but I'll try and look at this over the next couple of days. FWIW, I was curious about the omission of iconv myself when the project first started. I figured there was some method to the madness, instead of it just being an oversight. :-) |
Instead of keying off of APPLE, would you mind squashing this in: diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index 0ed430a..c488875 100644
--- a/config/CMakeLists.txt
+++ b/config/CMakeLists.txt
@@ -43,10 +43,14 @@ check_function_exists(fsync HAVE_FSYNC)
check_function_exists(getpwent HAVE_GETPWENT)
check_function_exists(getpwnam HAVE_GETPWNAM)
check_function_exists(getpwuid HAVE_GETPWUID)
-if(APPLE)
+
+check_include_files(iconv.h HAVE_ICONV_H)
+check_library_exists(iconv iconv "" HAVE_ICONV_LIB)
+if(HAVE_ICONV_LIB)
set(CMAKE_REQUIRED_LIBRARIES iconv)
endif()
check_function_exists(iconv HAVE_ICONV)
+
check_function_exists(lstat HAVE_LSTAT)
if(NOT HAVE_LSTAT)
# os_unix.c uses lstat.c
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index d757bb9..f927380 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -156,7 +156,7 @@ else()
endif()
endif()
-if (APPLE)
+if(HAVE_ICONV_LIB)
list(APPEND NVIM_LINK_LIBRARIES iconv)
endif()
Outside of that, it looks pretty good to me. |
Yes indeed, this is the part that bothered me most. On Apple, iconv is always present, but it has to be explicitly linked in. So that was my hackish solution. |
This seems to have been disabled in the transition from vim to neovim, re-enable it.
@jszakmeister I've squashed in your changes, looks neat. |
LGTM @aktau. |
Thanks, tagging RDY. Merge at your leisure. |
I was hoping this would fix #1271 but seems not. |
Hi. I'm now using XCode to help me get rid of analysis warnings.
Ideas? |
After
I have libiconv 1.14 installed through macports (OS X Yosemite). Please say if you prefer that I open a separated issue for this. |
I wonder if that's the problem. It appears that Yosemite now comes with iconv by default, and it sounds like the one you have installed via MacPorts is not for the correct architecture. The one that comes with Yosemite says:
What does file say about your MacPorts version? A more curious question is why did the check pass and then the actual linking fail? I suspect some other dependency is coming from MacPorts and causing the MacPorts library area to be inserted ahead of the system library path. This, in turn, is causing us to link against the wrong library. |
Would that be a problem? |
Hmph. I expected it to say i386 due to this in your error message:
Can you run the full build with |
I was just doing that. Here you have it. |
So I believe what is happening here is that the diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index c488875..6978fc3 100644
--- a/config/CMakeLists.txt
+++ b/config/CMakeLists.txt
@@ -47,7 +47,8 @@ check_function_exists(getpwuid HAVE_GETPWUID)
check_include_files(iconv.h HAVE_ICONV_H)
check_library_exists(iconv iconv "" HAVE_ICONV_LIB)
if(HAVE_ICONV_LIB)
- set(CMAKE_REQUIRED_LIBRARIES iconv)
+ find_library(ICONV_LIBRARY NAMES iconv)
+ set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY})
endif()
check_function_exists(iconv HAVE_ICONV)
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 5b97cf5..fac8060 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -158,8 +158,8 @@ else()
endif()
endif()
-if(HAVE_ICONV_LIB)
- list(APPEND NVIM_LINK_LIBRARIES iconv)
+if(ICONV_LIBRARY)
+ list(APPEND NVIM_LINK_LIBRARIES ${ICONV_LIBRARY})
endif()
# Put these last on the link line, since multiple things may depend on them. |
I'm sure Yosemite delivers iconv, and 90% that Mavericks did too. SO http://stackoverflow.com/questions/10616724/iconv-in-mac-os-x-10-7-3-does-nothing seems to imply that it was already present in 10.7. |
@aktau It is present. The problem is not that I don't have libiconv. The problem is that I have two (system version and macports version), and somehow the build process is getting confused. Trying @jszakmeister's patch now. |
Yea :). Hope it works! |
No luck :-( |
@elmart Bummer. :-( Can you do the verbose build? |
Sorry for that. https://gist.github.com/elmart/ea0046e091fcac509d55 |
No problem. It does appear to confirm what I expected: the iconv.h is being picked up in |
Yes! That did the trick! |
BTW, how do I change cmake files to do add this flag automatically? I've tried several things, but cmake still baffles me. I know I could just export env var in my command line, but I need it in cmake files for xcode to pick that. |
Ok, I just figured out. Sorry for making such noob questions, but, as I said, cmake drives me crazy. In this case, I hadn't realized CMAKE_EXTRA_FLAGS was not a CMAKE thing, but a construct of our own Makefile. When you have some time, could you advice a good tutorial on cmake? Thanks. |
@elmart Unfortunately, I don't know of a good tutorial, but the "Mastering CMake" book has been useful. Once you grasp some concepts, the CMake documentation becomes much more helpful. |
@elmart Would it be possible for you to post a copy of your |
Here it is. |
Thank you. |
This seems to have been disabled in the transition from vim to neovim,
re-enable it. If the disabling of iconv was intentional, why? (in which case we should delete the code that still references it).
Since this also involves the config system and I just hacked my way around it, I'd definitely like some input from @jszakmeister. How would you handle it?