Skip to content
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

buildsys: add check for asprintf to enable alt implementation #1561

Merged
merged 1 commit into from
Sep 29, 2017
Merged

buildsys: add check for asprintf to enable alt implementation #1561

merged 1 commit into from
Sep 29, 2017

Conversation

grobian
Copy link
Contributor

@grobian grobian commented Sep 27, 2017

Some platforms (like Solaris 10) lack asprintf. The implementation made
for Windows works fine there, so use autoconf to determine whether
asprintf exists, and if not, enable compiling the replacement
implementation.

These are the relevant build messages:

 main/options.c: In function ‘parseConfigurationFileOptionsInDirectory’:
main/options.c:3383:6: warning: implicit declaration of function ‘asprintf’ [-Wimplicit-function-declaration]
  if (asprintf (&leafname,".%s",(Option.configFilename)?Option.configFilename:"ctags") == -1)
      ^

main/ctags-options.o: In function `parseConfigurationFileOptionsInDirectory':
/net/ptah/export/gentoo/working-repos/ctags/main/options.c:3383: undefined reference to `asprintf'
main/ctags-options.o: In function `parseConfigurationFileOptions':
/net/ptah/export/gentoo/working-repos/ctags/main/options.c:3522: undefined reference to `asprintf'
/net/ptah/export/gentoo/working-repos/ctags/main/options.c:3530: undefined reference to `asprintf'
collect2: error: ld returned 1 exit status

@coveralls
Copy link

Coverage Status

Coverage remained the same at 85.945% when pulling 7539ba2 on grobian:missing-asprintf into e1bc2a3 on universal-ctags:master.

main/options.c Outdated
@@ -597,7 +597,7 @@ static vString* getHome (void)
}
}

#if defined(_WIN32) && !(defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW64_VERSION_MAJOR))
#if defined(_WIN32) && !(defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW64_VERSION_MAJOR)) || !defined(HAVE_ASPRINTF)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what the Mingw stuff is there, but it seems to me this whole thing could be replaced with:

#ifndef HAVE_ASPRINTF

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assumed that at least windows is compiled without running configure, but I haven't deeply explored the buildsystem for that.
I decided to take a safe route here, as I'm not knowledgable enough to make a decision about the existing conditions.

Copy link
Member

@k-takata k-takata Sep 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested but this might be useful when mk_mingw.mak is used with MinGW-w64.
MinGW-w64 has asprintf, but mk_mingw.mak (and main/e_msoft.h) doesn't define HAVE_ASPRINTF.
(Moving the condition into e_msoft.h might be another option.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, for example:

--- a/main/e_msoft.h
+++ b/main/e_msoft.h
@@ -66,6 +66,10 @@ typedef enum { false, true } bool;
 # define FA_DIREC _A_SUBDIR
 # define ff_name name
 
+# if defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW64_VERSION_MAJOR)
+#  define HAVE_ASPRINTF 1
+# endif
+
 #endif
 
 #endif

(Not tested)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O.k. I will make a pull request based on @grobian with the comment of @codebrainz and @k-takata.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(After fixing the trouble about CI I'm working for).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want me to try and put both suggestions in this PR and see if all tests turn green?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grobian, YES!
Could you rebase the lastest code? I've fixed bugs running test cases on CI environements.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 85.945% when pulling 5bf18b5 on grobian:missing-asprintf into fbffd78 on universal-ctags:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 85.945% when pulling 5bf18b5 on grobian:missing-asprintf into fbffd78 on universal-ctags:master.

@masatake masatake requested a review from k-takata September 29, 2017 09:17
main/options.c Outdated
@@ -597,7 +597,7 @@ static vString* getHome (void)
}
}

#if defined(_WIN32) && !(defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW64_VERSION_MAJOR))
#if defined(_WIN32) || !defined(HAVE_ASPRINTF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be now just #ifndef HAVE_ASPRINTF.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take your word for it.

Some platforms (like Solaris 10) lack asprintf.  The implementation made
for Windows works fine there, so use autoconf to determine whether
asprintf exists, and if not, enable compiling the replacement
implementation.
To further simplify the guard logic, define HAVE_ASPRINTF for MinGW when
appropriate in e_msoft.h.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 85.945% when pulling 2a0a0d8 on grobian:missing-asprintf into fbffd78 on universal-ctags:master.

@masatake
Copy link
Member

LGTM.

@k-takata k-takata merged commit d9d7aa7 into universal-ctags:master Sep 29, 2017
@grobian grobian deleted the missing-asprintf branch September 29, 2017 15:17
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

Successfully merging this pull request may close these issues.

5 participants