Skip to content

irony process stopped! when handle c file including chinese characters #163

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

Open
zijianyue opened this issue Jan 14, 2015 · 15 comments
Open

Comments

@zijianyue
Copy link

my c file is encoded in GBK dos ,the code as below:

typedef struct
{
    int abc;
    short bcd;
}FANS_S;
int main()
{
    /**/
    FANS_S fan;
    fan.abc = 0;
    return 0;
}

irony works well if I remove the comment ,which have chinese characters in it.
But once there are chinese characters in comment or in string,the functions of irony complete,flycheck, and eldoc can not work at all.

I use clang.exe to compile the file,it compiled successfully.
My environment is win7 x64, LLVM 3.5,gcc-4.8.1,emacs 24.4,my irony-server.exe is compiled by VS2013.

@zijianyue
Copy link
Author

I found in the log file for this issue:error: missing newline for unsaved file content.
The clang complete can work through command line,though there are chinese characters in the c file.

So can anyone help resolving this problem ,because it is blocking me from using irony-mode in my work.Thanks for any advice!!

image

@Sarcasm
Copy link
Owner

Sarcasm commented Jan 15, 2015

Sorry, I tried but your example works for me. At the time I tried I didn't know how to have the file being encoded in GBK dos.

You tested with clang, can you test with irony-server with the following command:

~/.emacs.d/irony/bin/irony-server complete test.c 11 9

I should be able to try on Windows during the weekend.

@zijianyue
Copy link
Author

Appreciate your reply!
I just test ,irony-server complete can work through command line.

:~/.emacs.d/irony/bin/irony-server.exe complete test.c 11 10

execute: Command{action=Command::Complete, file='test.c', line=11, column=10, flags=[], unsavedFiles.count=0, opt=off}
(
("abc" 35 "int" "" "abc" 3 (""))
("bcd" 35 "short" "" "bcd" 3 (""))

But in the file ,it can not work.
You can set GBK dos by set-buffer-file-coding-system and select chinese-gbk-dos.
And though I set it to UTF-8 , it still can not work.

@Sarcasm
Copy link
Owner

Sarcasm commented Jan 17, 2015

I will test on Windows but I wasn't able to reproduce on Linux!

@zijianyue
Copy link
Author

I wrote some output log sentences in Command.cpp , and found the reason why irony-server exited was the size of std::cin.read exceeding the length of test.c when irony.el sending unsaved file contents to the server,and this leads the error "missing newline".

I mean the below codes:
std::cin.read(p.second.data(), p.second.size());

@Sarcasm
Copy link
Owner

Sarcasm commented Jan 18, 2015

I just tested on Windows and cannot reproduce the issue here either, completion works just fine for me. We have a similar configuration.

Can you provide me your file as attachment and maybe make sure you try irony-mode in a simplified environment.

For example launch emacs -Q, add irony to the load path and require irony. Then open the C++ file and call M-x completion-at-point RET. I checked the code and I'm using the byte size for the buffer, not the buffer-size in Emacs' own chars so I'm not sure where your issue comes from for now, see https://github.com/Sarcasm/irony-mode/blob/master/irony.el#L245

@zijianyue
Copy link
Author

Thanks for your patience on my issue,I produced this issue when using runemacs.exe -Q.
I don't know how to upload attachment here ,so I send a mail to you (guillaume.papin at epitech dot eu) with the c file and the irony-server program.
Please test it again,sorry for costing you so much time.

@Sarcasm
Copy link
Owner

Sarcasm commented Jan 19, 2015

I didn't get your email, can you make sure you sent it to the proper address? The one you wrote looks fine.

@zijianyue
Copy link
Author

The mail was blocked at first time,then I used another mail ,please check it again.

@Sarcasm
Copy link
Owner

Sarcasm commented Jan 19, 2015

Okay, I can reproduce it now, thank you. I'm not sure but maybe that was company-clang that was providing me with the good results.

@Sarcasm
Copy link
Owner

Sarcasm commented Jan 20, 2015

I looked at the code and a few things, and I couldn't find what's wrong yet. Maybe something related to coding system or such, I don't really know, this is not something I am familiar with.

Just for the record, the issue is the same on Linux.

@asandroq
Copy link

I have been seeing the same problem since I upgraded to the latest code today. It seems to happen when editing a specific file, but it is encoded in ASCII. I am using Ubuntu 12.04 with LLVM from SVN.

@Sarcasm
Copy link
Owner

Sarcasm commented Feb 16, 2015

but it is encoded in ASCII

Are you sure that all the characters are ASCII? What are the end-of-line characters newline only or CR+NL?

What does file returns?

$ file foo.cpp
foo.cpp: C++ source, ASCII text

I'm a bit clueless on this issue for now :-/

@asandroq
Copy link

It returns "ASCII C program text". But I just noticed something else, the file actually does not end with a newline! Sorry for being stupid :(

@Sarcasm
Copy link
Owner

Sarcasm commented Feb 17, 2015

Irony-mode should break on missing newline so that's a valid report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants