Skip to content

Commit

Permalink
Merge pull request #187 from swig-fortran/merge-master-again
Browse files Browse the repository at this point in the history
Merge master again
  • Loading branch information
sethrj authored Aug 18, 2023
2 parents 4b24b54 + 8486b7c commit 4867376
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- SWIGLANG: fortran
CPPSTD: c++17
FCSTD: f2003
GCC: 11
GCC: 13
# Run all of them, as opposed to aborting when one fails
fail-fast: false

Expand Down
49 changes: 24 additions & 25 deletions CCache/mdfour.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
It assumes that a int is at least 32 bits long
*/

static struct mdfour *m;

#define MASK32 (0xffffffff)

#define F(X,Y,Z) ((((X)&(Y)) | ((~(X))&(Z))))
Expand All @@ -38,12 +36,12 @@ static struct mdfour *m;
#define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c,d) + M[k] + 0x6ED9EBA1)&MASK32,s)

/* this applies md4 to 64 byte chunks */
static void mdfour64(uint32 *M)
static void mdfour64(struct mdfour *md, uint32 *M)
{
uint32 AA, BB, CC, DD;
uint32 A,B,C,D;

A = m->A; B = m->B; C = m->C; D = m->D;
A = md->A; B = md->B; C = md->C; D = md->D;
AA = A; BB = B; CC = C; DD = D;

ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7);
Expand Down Expand Up @@ -80,7 +78,7 @@ static void mdfour64(uint32 *M)
A &= MASK32; B &= MASK32;
C &= MASK32; D &= MASK32;

m->A = A; m->B = B; m->C = C; m->D = D;
md->A = A; md->B = B; md->C = C; md->D = D;
}

static void copy64(uint32 *M, const unsigned char *in)
Expand Down Expand Up @@ -111,15 +109,15 @@ void mdfour_begin(struct mdfour *md)
}


static void mdfour_tail(const unsigned char *in, int n)
static void mdfour_tail(struct mdfour *md, const unsigned char *in, int n)
{
unsigned char buf[128];
uint32 M[16];
uint32 b;

m->totalN += n;
md->totalN += n;

b = m->totalN * 8;
b = md->totalN * 8;

memset(buf, 0, 128);
if (n) memcpy(buf, in, n);
Expand All @@ -128,24 +126,22 @@ static void mdfour_tail(const unsigned char *in, int n)
if (n <= 55) {
copy4(buf+56, b);
copy64(M, buf);
mdfour64(M);
mdfour64(md, M);
} else {
copy4(buf+120, b);
copy64(M, buf);
mdfour64(M);
mdfour64(md, M);
copy64(M, buf+64);
mdfour64(M);
mdfour64(md, M);
}
}

void mdfour_update(struct mdfour *md, const unsigned char *in, int n)
{
uint32 M[16];

m = md;

if (in == NULL) {
mdfour_tail(md->tail, md->tail_len);
mdfour_tail(md, md->tail, md->tail_len);
return;
}

Expand All @@ -158,18 +154,18 @@ void mdfour_update(struct mdfour *md, const unsigned char *in, int n)
in += len;
if (md->tail_len == 64) {
copy64(M, md->tail);
mdfour64(M);
m->totalN += 64;
mdfour64(md, M);
md->totalN += 64;
md->tail_len = 0;
}
}

while (n >= 64) {
copy64(M, in);
mdfour64(M);
mdfour64(md, M);
in += 64;
n -= 64;
m->totalN += 64;
md->totalN += 64;
}

if (n) {
Expand All @@ -181,12 +177,10 @@ void mdfour_update(struct mdfour *md, const unsigned char *in, int n)

void mdfour_result(struct mdfour *md, unsigned char *out)
{
m = md;

copy4(out, m->A);
copy4(out+4, m->B);
copy4(out+8, m->C);
copy4(out+12, m->D);
copy4(out, md->A);
copy4(out+4, md->B);
copy4(out+8, md->C);
copy4(out+12, md->D);
}


Expand Down Expand Up @@ -272,7 +266,12 @@ static void file_checksum2(char *fname)
printf("\n");
}
#endif

/*
* To test:
* gcc -DTEST_MDFOUR mdfour.c -o mdfourexe && ./mdfourexe <somefile>
* then compare against a reference, such as:
* openssl dgst -md4 <somefile>
*/
int main(int argc, char *argv[])
{
file_checksum1(argv[1]);
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.current
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.2.0 (in progress)
===========================

2023-08-16: shadchin
[Python] #2665 Fix missing-field-initializers warning to provide support
for python-3.12.

2023-08-09: olly
[Ruby] Remove -feature command line option which has been
deprecated since SWIG 1.3.32 in 2007. Use -init_name instead.
Expand Down
2 changes: 1 addition & 1 deletion Examples/scilab/matrix2/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void getStringVector(char ***resultVector, int *sizeRes)
*resultVector = (char**) malloc((*sizeRes) * sizeof(char*));
for (i=0; i<*sizeRes; i++)
{
char* pc = (char*) calloc(3, sizeof(char));
char* pc = (char*) calloc(16, sizeof(char));
sprintf(pc, "%d", i);
(*resultVector)[i] = pc;
}
Expand Down
2 changes: 2 additions & 0 deletions Examples/test-suite/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ CPP_TEST_CASES += \
abstract_basecast \
abstract_inherit \
abstract_inherit_ok \
abstract_inherit_using \
abstract_signature \
abstract_typedef \
abstract_typedef2 \
Expand Down Expand Up @@ -414,6 +415,7 @@ CPP_TEST_CASES += \
smart_pointer_protected \
smart_pointer_rename \
smart_pointer_simple \
smart_pointer_static \
smart_pointer_template_const_overload \
smart_pointer_template_defaults_overload \
smart_pointer_templatemethods \
Expand Down
16 changes: 8 additions & 8 deletions Examples/test-suite/cpp11_ref_qualifiers.i
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ class Host {
public:
string h1() & { return string(); }
string h2() const & { return string(); }
string h3() && { return std::move(string()); }
string h4() const && { return std::move(string()); }
string h3() && { return string(); }
string h4() const && { return string(); }
string h5() const { return string(); }
string h6() volatile const & { return string(); }
string h7() const volatile & { return string(); }
string h8() volatile const && { return std::move(string()); }
string h9() const volatile && { return std::move(string()); }
string h8() volatile const && { return string(); }
string h9() const volatile && { return string(); }

string h() & { return string(); }
string h() const & { return string(); }
string h() && { return std::move(string()); }
string h() const && { return std::move(string()); }
string h() && { return string(); }
string h() const && { return string(); }
};
%}

Expand Down Expand Up @@ -89,11 +89,11 @@ struct Renames {
%inline %{
struct ConversionOperators {
virtual operator string() & { return string(); }
virtual operator string() && { return std::move(string()); }
virtual operator string() && { return string(); }
virtual ~ConversionOperators() {}
};
struct ConversionOperators2 {
virtual operator string() && { return std::move(string()); }
virtual operator string() && { return string(); }
virtual ~ConversionOperators2() {}
};
%}
Expand Down
3 changes: 2 additions & 1 deletion Examples/test-suite/javascript/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ CPP_TEST_CASES += \
li_std_containers_int \
li_std_map_member

CPP_TEST_BROKEN += \
# napi fails
FAILING_CPP_TESTS += \
smart_pointer_static \

SWIGEXE = $(top_builddir)/swig
Expand Down
6 changes: 0 additions & 6 deletions Examples/test-suite/octave/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ CPP11_TEST_CASES += \
cpp11_shared_ptr_overload \
cpp11_shared_ptr_upcast \

CPP_TEST_BROKEN += \
implicittest \
li_implicit \
li_std_set \
li_std_stream

include $(srcdir)/../common.mk

# Overridden variables here
Expand Down
1 change: 0 additions & 1 deletion Examples/test-suite/octave/argcargvtest_runme.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

# Check that empty strings are handled.
empty_string={"hello", blanks(0), "world"};
disp(length(empty_string));
if (mainc(empty_string) != 3)
error("bad main typemap");
endif
Expand Down
4 changes: 2 additions & 2 deletions Examples/test-suite/python/cpp11_raw_string_literals_runme.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def check(got, expected):
comment""")
check(inspect.getdoc(RawStringDoc.YY), """Single line "raw string" documentation comment""")
check(inspect.getdoc(RawStringDoc.ZZ),
"""Documentation comment
r"""Documentation comment
as a "raw string"
on multiple lines including a \ backslash""")

check(mm, """)I'm an "ascii" \ string constant with multiple
check(mm, r""")I'm an "ascii" \ string constant with multiple
lines.""")
2 changes: 1 addition & 1 deletion Examples/test-suite/python/langobj_runme.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from langobj import *


x = "hello"
x = 256*256+1
rx = sys.getrefcount(x)
v = identity(x)
rv = sys.getrefcount(v)
Expand Down
6 changes: 6 additions & 0 deletions Lib/python/builtin.swg
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ SwigPyStaticVar_Type(void) {
#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
0, /* tp_print */
#endif
#if PY_VERSION_HEX >= 0x030c0000
0, /* tp_watched */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
Expand Down Expand Up @@ -358,6 +361,9 @@ SwigPyObjectType(void) {
#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
0, /* tp_print */
#endif
#if PY_VERSION_HEX >= 0x030c0000
0, /* tp_watched */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
Expand Down
9 changes: 9 additions & 0 deletions Lib/python/pyrun.swg
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ swig_varlink_type(void) {
#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
0, /* tp_print */
#endif
#if PY_VERSION_HEX >= 0x030C0000
0, /* tp_watched */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
Expand Down Expand Up @@ -982,6 +985,9 @@ SwigPyObject_TypeOnce(void) {
#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
0, /* tp_print */
#endif
#if PY_VERSION_HEX >= 0x030C0000
0, /* tp_watched */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
Expand Down Expand Up @@ -1162,6 +1168,9 @@ SwigPyPacked_TypeOnce(void) {
#if (PY_VERSION_HEX >= 0x03080000) && (PY_VERSION_HEX < 0x03090000)
0, /* tp_print */
#endif
#if PY_VERSION_HEX >= 0x030C0000
0, /* tp_watched */
#endif
#ifdef COUNT_ALLOCS
0, /* tp_allocs */
0, /* tp_frees */
Expand Down
8 changes: 4 additions & 4 deletions Lib/swig.swg
Original file line number Diff line number Diff line change
Expand Up @@ -544,21 +544,21 @@ namespace std {

/* memberin/globalin typemap for arrays. */

%typemap(memberin,fragment="<string.h>") SWIGTYPE [ANY] {
%typemap(memberin) SWIGTYPE [ANY] {
size_t ii;
$1_basetype *b = ($1_basetype *) $1;
for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii);
}

%typemap(globalin,fragment="<string.h>") SWIGTYPE [ANY] {
%typemap(globalin) SWIGTYPE [ANY] {
size_t ii;
$1_basetype *b = ($1_basetype *) $1;
for (ii = 0; ii < (size_t)$1_size; ii++) b[ii] = *(($1_basetype *) $input + ii);
}

/* memberin/globalin typemap for double arrays. */

%typemap(memberin,fragment="<string.h>") SWIGTYPE [ANY][ANY] {
%typemap(memberin) SWIGTYPE [ANY][ANY] {
$basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
$basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
size_t ii = 0;
Expand All @@ -570,7 +570,7 @@ namespace std {
}
}

%typemap(globalin,fragment="<string.h>") SWIGTYPE [ANY][ANY] {
%typemap(globalin) SWIGTYPE [ANY][ANY] {
$basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
$basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
size_t ii = 0;
Expand Down
Loading

0 comments on commit 4867376

Please sign in to comment.