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

Remove more c code #1004

Merged
merged 5 commits into from
Aug 15, 2024
Merged
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
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,6 @@ if(M_LIBRARY)
endif()

find_package(ZLIB)
if(ZLIB_FOUND)
set(ERT_HAVE_ZLIB ON)
set(zlib "${ZLIB_LIBRARIES}")
endif()

find_library(SHLWAPI_LIBRARY NAMES Shlwapi)
if(SHLWAPI_LIBRARY)
set(shlwapi ${SHLWAPI_LIBRARY})
Expand Down Expand Up @@ -339,7 +334,6 @@ check_function_exists(getuid ERT_HAVE_GETUID)
check_function_exists(glob ERT_HAVE_GLOB)
check_function_exists(gmtime_r HAVE_GMTIME_R)
check_function_exists(localtime_r HAVE_LOCALTIME_R)
check_function_exists(lockf ERT_HAVE_LOCKF)
check_function_exists(mkdir HAVE_POSIX_MKDIR)
check_function_exists(_mkdir HAVE_WINDOWS_MKDIR)
check_function_exists(opendir ERT_HAVE_OPENDIR)
Expand Down
22 changes: 0 additions & 22 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ if(ERT_HAVE_OPENDIR)
list(APPEND opt_srcs util/util_opendir.cpp)
endif()

if(ERT_HAVE_SPAWN)
list(APPEND opt_srcs util/util_spawn.cpp)
endif()

if(ERT_HAVE_LOCKF)
list(APPEND opt_srcs util/util_lockf.cpp)
endif()

if(ERT_HAVE_UNISTD)
list(APPEND opt_srcs util/path_stack.cpp)
endif()
Expand All @@ -38,10 +30,6 @@ foreach(type bool size_t)
list(APPEND opt_srcs ${CMAKE_CURRENT_BINARY_DIR}/${type}_vector.cpp)
endforeach()

if(ZLIB_FOUND)
list(APPEND opt_srcs util/util_zlib.cpp)
endif()

configure_file(build_config.hpp.in include/ert/util/build_config.hpp)
configure_file(ert_api_config.hpp.in include/ert/util/ert_api_config.hpp)

Expand Down Expand Up @@ -252,10 +240,6 @@ target_link_libraries(ert_util_copy_file resdata)
add_test(NAME ert_util_copy_file COMMAND ert_util_copy_file
$<TARGET_FILE:ert_util_copy_file>)

add_executable(ert_util_file_readable util/tests/ert_util_file_readable.cpp)
target_link_libraries(ert_util_file_readable resdata)
add_test(NAME ert_util_file_readable COMMAND ert_util_file_readable)

add_executable(ert_util_path_stack_test util/tests/ert_util_path_stack_test.cpp)
target_link_libraries(ert_util_path_stack_test resdata)
add_test(NAME ert_util_path_stack_test
Expand All @@ -271,12 +255,6 @@ add_executable(ert_util_type_vector_test
target_link_libraries(ert_util_type_vector_test resdata)
add_test(NAME ert_util_type_vector_test COMMAND ert_util_type_vector_test)

if(ERT_HAVE_SPAWN)
add_executable(ert_util_spawn util/tests/ert_util_spawn.cpp)
target_link_libraries(ert_util_spawn resdata)
add_test(NAME ert_util_spawn COMMAND ert_util_spawn)
endif()

foreach(
name
rd_fault_block_layer
Expand Down
2 changes: 0 additions & 2 deletions lib/ert_api_config.hpp.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#cmakedefine ERT_HAVE_ZLIB
#cmakedefine ERT_HAVE_ISFINITE
#cmakedefine ERT_HAVE_GETOPT
#cmakedefine ERT_HAVE_UNISTD
Expand All @@ -10,7 +9,6 @@
#cmakedefine ERT_HAVE_GLOB
#cmakedefine ERT_HAVE_GETUID
#cmakedefine ERT_HAVE_REGEXP
#cmakedefine ERT_HAVE_LOCKF
#cmakedefine ERT_TIME_T_64BIT_ACCEPT_PRE1970
#cmakedefine ERT_WINDOWS_LFS
#cmakedefine ERT_HAVE_PING
Expand Down
2 changes: 0 additions & 2 deletions lib/include/ert/util/test_work_area.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ extern "C" {

#include <stdbool.h>

char *test_work_area_alloc_input_path(const test_work_area_type *work_area,
const char *input_path);
test_work_area_type *test_work_area_alloc(const char *test_name);
test_work_area_type *test_work_area_alloc__(const char *test_name,
bool store_area);
Expand Down
23 changes: 0 additions & 23 deletions lib/include/ert/util/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ double util_difftime_seconds(time_t start_time, time_t end_time);
char *util_alloc_sprintf_va(const char *fmt, va_list ap);
char *util_alloc_sprintf(const char *, ...);
bool util_sscanf_isodate(const char *, time_t *);
bool util_is_executable(const char *);
bool util_entry_exists(const char *entry);
bool util_file_exists(const char *);
bool util_is_abs_path(const char *);
Expand All @@ -127,8 +126,6 @@ char *util_alloc_normal_path(const char *input_path);
char *util_alloc_realpath(const char *);
char *util_alloc_realpath__(const char *input_path);
bool util_string_has_wildcard(const char *s);
bool util_file_readable(const char *file);
bool util_entry_readable(const char *entry);
bool util_ftruncate(FILE *stream, long size);

int util_roundf(float x);
Expand Down Expand Up @@ -310,14 +307,6 @@ void util_abort__(const char *file, const char *function, int line,
const char *fmt, ...);
void util_abort_signal(int);

#ifdef ERT_HAVE_ZLIB
void util_compress_buffer(const void *, int, void *, unsigned long *);
int util_fread_sizeof_compressed(FILE *stream);
void util_fread_compressed(void *, FILE *);
void *util_fread_alloc_compressed(FILE *);
void util_fwrite_compressed(const void *, int, FILE *);
#endif

#ifdef ERT_HAVE_SYMLINK
void util_make_slink(const char *, const char *);
char *util_alloc_link_target(const char *link);
Expand All @@ -326,18 +315,6 @@ char *util_alloc_atlink_target(const char *path, const char *link);
#endif
#endif

#ifdef ERT_HAVE_SPAWN
pid_t util_spawn(const char *executable, int argc, const char **argv,
const char *stdout_file, const char *stderr_file);
int util_spawn_blocking(const char *executable, int argc, const char **argv,
const char *stdout_file, const char *stderr_file);
#endif

#ifdef ERT_HAVE_LOCKF
FILE *util_fopen_lockf(const char *, const char *);
bool util_try_lockf(const char *, mode_t, int *);
#endif

#include "util_unlink.hpp"

#ifdef __cplusplus
Expand Down
33 changes: 0 additions & 33 deletions lib/include/ert/util/vector_util.hpp

This file was deleted.

23 changes: 22 additions & 1 deletion lib/resdata/nnc_info.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <stdlib.h>
#include <stdio.h>

#include <vector>
#include <stdexcept>
Expand All @@ -7,12 +8,32 @@
#include <ert/util/util.hpp>
#include <ert/util/vector.hpp>
#include <ert/util/type_macros.hpp>
#include <ert/util/vector_util.hpp>

#include <resdata/nnc_info.hpp>
#include <resdata/nnc_vector.hpp>
#include <resdata/rd_kw_magic.hpp>

#include <vector>
#include <algorithm>

template <class T>
void vector_util_fprintf(const std::vector<T> &vec, FILE *stream,
const char *name, const char *fmt) {
size_t i;
if (name != NULL)
fprintf(stream, "%s = [", name);
else
fprintf(stream, "[");

for (i = 0; i < vec.size(); i++) {
fprintf(stream, fmt, vec[i]);
if (i < (vec.size() - 1))
fprintf(stream, ", ");
}

fprintf(stream, "]\n");
}

#define NNC_INFO_TYPE_ID 675415078

struct nnc_info_struct {
Expand Down
15 changes: 14 additions & 1 deletion lib/resdata/tests/rd_nnc_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,27 @@
#include <ert/util/test_util.hpp>
#include <ert/util/util.hpp>
#include <ert/util/int_vector.hpp>
#include <ert/util/vector_util.hpp>

#include <resdata/rd_grid.hpp>
#include <resdata/nnc_info.hpp>
#include <resdata/rd_file.hpp>
#include <resdata/rd_file_view.hpp>
#include <resdata/rd_kw_magic.hpp>

#include <vector>
#include <algorithm>

template <class T> int vector_util_index(const std::vector<T> &vec, T value) {

int index;
auto iter = find(vec.begin(), vec.end(), value);
if (iter == vec.end())
index = -1;
else
index = iter - vec.begin();
return index;
}

void test_scan(const char *grid_filename) {
rd_grid_type *rd_grid = rd_grid_alloc(grid_filename);
rd_file_type *grid_file = rd_file_open(grid_filename, 0);
Expand Down
7 changes: 0 additions & 7 deletions lib/util/test_work_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,6 @@ test_work_area_get_original_cwd(const test_work_area_type *work_area) {
return work_area->original_cwd().c_str();
}

char *test_work_area_alloc_input_path(const test_work_area_type *work_area,
const char *input_path) {
std::string relocated_input_path =
work_area->original_path(std::string(input_path));
return util_alloc_string_copy(relocated_input_path.c_str());
}

/**
The point of this function is that the test code should be able to
access the file @input_file independent of the fact that it has
Expand Down
34 changes: 0 additions & 34 deletions lib/util/tests/ert_util_file_readable.cpp

This file was deleted.

Loading