Skip to content

Commit

Permalink
Merge pull request #163 from seanm/iconv-test
Browse files Browse the repository at this point in the history
Fixed OpenBSD build error by not using the unavailable iconv
  • Loading branch information
malaterre authored Oct 30, 2023
2 parents f358d4a + eb7c99a commit 85bfc73
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Utilities/gdcmext/mec_mr3_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@
#include <stdlib.h>
#include <string.h>

#ifndef _MSC_VER
#if defined(_MSC_VER) || defined(__OpenBSD__)
#define GDCM_HAS_ICONV 0
#else
#define GDCM_HAS_ICONV 1
#endif

#if GDCM_HAS_ICONV
#include <iconv.h>
#endif
#if defined(_MSC_VER) && (_MSC_VER < 1900)
Expand Down Expand Up @@ -54,15 +60,15 @@ static size_t stream_read(void *ptr, size_t size, size_t nmemb,

struct app {
struct stream *in;
#ifndef _MSC_VER
#if GDCM_HAS_ICONV
iconv_t conv;
#endif
void *shift_jis_buffer;
};

static struct app *create_app(struct app *self, struct stream *in) {
self->in = in;
#ifndef _MSC_VER
#if GDCM_HAS_ICONV
self->conv = iconv_open("utf-8", "shift-jis");
assert(self->conv != (iconv_t)-1);
#endif
Expand Down Expand Up @@ -358,7 +364,7 @@ static char *shift_jis_to_utf8(char *str, size_t len, struct app *self) {
const size_t guesstimate = len < 128 ? 128 : len * 2;
self->shift_jis_buffer = realloc(self->shift_jis_buffer, guesstimate);
char *dest_str = self->shift_jis_buffer;
#ifndef _MSC_VER
#if GDCM_HAS_ICONV
char *in_str = str;
char *out_str = dest_str;
size_t inbytes = len;
Expand Down Expand Up @@ -842,7 +848,7 @@ bool mec_mr3_print(const void *input, size_t len) {
#else
free(data.buffer);
#endif
#ifndef _MSC_VER
#if GDCM_HAS_ICONV
iconv_close(self->conv);
#endif
free(self->shift_jis_buffer);
Expand Down

0 comments on commit 85bfc73

Please sign in to comment.