Skip to content
Merged

wip #21

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,17 @@ target_include_directories(jopa PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/codegen"
"${CMAKE_BINARY_DIR}/generated"
)
# Silence third-party header warnings.
if(LIBZIP_INCLUDE_DIRS)
target_include_directories(jopa SYSTEM PRIVATE ${LIBZIP_INCLUDE_DIRS})
endif()
target_link_libraries(jopa PRIVATE ${JOPA_LIBS})

# Suppress nullability extension noise from libzip headers when using Clang.
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(jopa PRIVATE -Wno-nullability-extension)
endif()

# Depend on grammar generation if available
if(TARGET generate_parser)
add_dependencies(jopa generate_parser)
Expand Down
2 changes: 1 addition & 1 deletion src/error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ ErrorString& ErrorString::operator<<(const char* s)
ErrorString& ErrorString::operator<<(int n)
{
char buf[64];
sprintf(buf, "%d", n);
snprintf(buf, sizeof(buf), "%d", n);

return (*this << buf);
}
Expand Down
10 changes: 5 additions & 5 deletions src/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@
# include STD_LIB_NAME(errno)
#endif

#ifndef HAVE_WINT_T
/* On some systems the type wint_t is not defined in wchar.h */
typedef unsigned int wint_t;
#endif

#ifdef HAVE_WCHAR_H
# include STD_LIB_NAME(wchar)
#endif

#if !defined(HAVE_WINT_T) && !defined(_WINT_T)
/* On some systems the type wint_t is not defined in wchar.h */
typedef unsigned int wint_t;
#endif

#ifdef HAVE_CTYPE_H
# include STD_LIB_NAME(ctype)
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,8 +1037,8 @@ void DirectorySymbol::ReadDirectory()
{
int len = DirectoryNameLength() + strlen(entry -> d_name);
char* filename = new char[len + 2]; // +2 for '/', NUL
sprintf(filename, "%s/%s", DirectoryName(),
entry -> d_name);
snprintf(filename, len + 2, "%s/%s", DirectoryName(),
entry -> d_name);
struct stat status;
if(JopaAPI::getInstance() -> stat(filename, &status) == 0)
entries -> InsertEntry(this, entry -> d_name, length);
Expand Down
7 changes: 7 additions & 0 deletions src/zipfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

#include "platform.h"
#include "tuple.h"
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnullability-extension"
#endif
#include <zip.h>
#if defined(__clang__)
#pragma clang diagnostic pop
#endif


namespace Jopa { // Open namespace Jopa block
Expand Down
6 changes: 4 additions & 2 deletions vendor/jikespg/src/lpgparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ static void options(void)

while (parm[i] != '\0') /* Repeat until parm line is exhausted */
{
strcpy(parm, parm + i); /* Remove garbage in front */
/* Use memmove because source and destination overlap. */
memmove(parm, parm + i, strlen(parm + i) + 1); /* Remove garbage in front */

i = 0;

Expand Down Expand Up @@ -442,7 +443,8 @@ static void options(void)
{ /* prefix? */
flag = FALSE;
len = len-2;
strcpy(token, token + 2); /* get rid of "NO" prefix */
/* Overlapping copy; memmove keeps it defined. */
memmove(token, token + 2, strlen(token + 2) + 1); /* get rid of "NO" prefix */
}
else
flag = TRUE;
Expand Down
Loading