fix include of files without last newline, as reported by Wes Hodges

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9032 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2006-03-22 08:15:46 +00:00
commit c2b8a083a0
2 changed files with 13 additions and 2 deletions

View file

@ -1,3 +1,5 @@
#ifndef a_h
#define a_h
enum GlobalEnum { globalenum1=1, globalenum2 };
/* This function should be static as it will be emitted into the code for
@ -15,5 +17,5 @@ class A {
enum MemberEnum { memberenum1=10, memberenum2 };
virtual MemberEnum member_virtual_test(MemberEnum e) { return e; }
virtual GlobalEnum global_virtual_test(GlobalEnum e) { return global_test(e); }
};
};
#endif

View file

@ -266,6 +266,7 @@ Swig_open(const String_or_char *name) {
String *
Swig_read_file(FILE *f) {
int len;
char buffer[4096];
String *str = NewStringEmpty();
@ -273,6 +274,14 @@ Swig_read_file(FILE *f) {
while (fgets(buffer,4095,f)) {
StringAppend(str,buffer);
}
len = StringLen(str);
if (len) {
char *cstr = Char(str);
if (cstr[len - 1] != '\n') {
StringAppend(str, "\n");
}
}
return str;
}