Olly Betts
a0e3825de6
Fix replace handling corner case
...
With flags DOH_REPLACE_ID_BEGIN, DOH_REPLACE_ID_END and
DOH_REPLACE_NUMBER_END the code looked for a match for the token
string using strstr() and then checked the extra condition - if the
extra condition didn't apply it then advanced by the length of the token
before searching again.
However that can miss matches if the strstr() matches can overlap
one another, so only advance one position, which is conservative
but can't miss matches.
For example this would not match before:
Replace("123123", "1231", r, DOH_REPLACE_NUMBER_END);
This issue seems to be entirely latent in the current SWIG codebase
due to the nature of the token strings passed when using these flags.
See #2235
2022-03-19 08:55:39 +13:00
Olly Betts
e38847f7e1
Fail cleanly on allocation failures
...
Previously code in the SWIG tool didn't handle allocation failures
well. Most places didn't check for NULL return from
malloc()/realloc()/calloc() at all, typically resulting in undefined
behaviour, and some places used assert() to check for a NULL return
(which is a misuse of assert() and such checks disappear if built with
NDEBUG defined leaving us back with undefined behaviour).
All C allocations are now done via wrapper functions (Malloc(),
Realloc() and Calloc()) which emit and error and exit with non-zero
status on failure, so a non-NULL return can be relied upon.
Fixes #1901 .
2022-03-04 11:47:49 +13:00
Olly Betts
975f8fcfdb
Avoid undefined behaviour in DOH Replace() function
...
If the source and replacement strings were the same length, the code
was performing undefined pointer arithmetic involving a NULL pointer.
I'm not aware of any observable effects of this in practice, but it's
potentially problematic. It's detected by ubsan, for example when
running `make check-python-test-suite`:
DOH/string.c:839:4: runtime error: applying non-zero offset to non-null pointer 0x602000001558 produced null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior DOH/string.c:839:4 in
2020-09-04 10:44:49 +12:00
William S Fulton
18b2dcd222
C# 'out' or 'ref' removal improvements in director typemaps.
...
- Add support to DOH Replace for not replacing inside C comments
- Fix removing 'out' or 'ref' when these are present in C comments
in cstype typemaps.
Closes #1628
2019-11-26 19:39:28 +00:00
William S Fulton
98f29f8ad9
Remove deprecated DohClose in DOH
2019-07-31 00:08:49 +01:00
William S Fulton
e7d626d1b4
Remove use of 'register' in C source
...
No noticable performance change using gcc x86-64 in Java and Python
test-suites.
2018-05-04 20:02:13 +01:00
William S Fulton
edcdaaec16
Warning fixes for 64bit visual c++ on Windows
2015-07-03 20:59:24 +01:00
William S Fulton
220acc3fc8
Fixes for clang -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error
...
Fixes 'Illegal instruction' when SWIG executes and compiled with above
compiler options
Fixes #263
2014-11-08 10:59:59 +00:00
Karl Wette
6612997b63
Fix bug in DohNewStringWithSize(): guarantee string is nul-terminated
2014-06-01 15:33:26 +02:00
William S Fulton
7841a0d097
Remove cvs/svn Id strings
2013-01-12 01:21:16 +00:00
William S Fulton
89052f3b0a
Fix Strcmp - it didn't have consistent null pointer handling - revert to what it used to be - a lightweight wrapper around strcmp which means functions once again must not pass in null to it.
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13943 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-12-02 13:36:13 +00:00
William S Fulton
6d922f2ddd
Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments.
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12849 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-11-28 19:35:44 +00:00
William S Fulton
a63d456f8a
Remove redundant code highlighted by warnings in gcc-4.6
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12536 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-14 07:22:08 +00:00
William S Fulton
9a0f7ed06c
Some more constness added to DOH and code comment consistency changes
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12356 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-12-23 20:30:41 +00:00
William S Fulton
c8c3e13065
function prototype in comment fix
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12337 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-12-08 19:35:52 +00:00
Vadim Zeitlin
ac5ddb0315
Make argument of DohWrite() const.
...
Writing a buffer to a DOH object doesn't modify so it should be const.
This allows the code using const pointers to pass them to DohWrite() without
neither the casts nor gcc warnings.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12167 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-07-22 16:59:29 +00:00
William S Fulton
cb64f65bae
SWIG license change - Source moves to GPLv3
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11876 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-02-27 23:53:33 +00:00
William S Fulton
61001d958f
add parameter list (or void) to all C functions
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10926 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-11-11 22:17:40 +00:00
Olly Betts
ddb7c73411
Fix handling of byte value 255 in input files on platforms where
...
char is signed (it was getting mapped to EOF). Fixes SF#1518219.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10211 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2008-01-18 19:51:46 +00:00
William S Fulton
4fe414504f
String copying patch from Josh Cherry reducing memory consumption by about 25%.
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9657 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-03-23 22:12:10 +00:00
Dave Beazley
c12550e4ad
API cleanup. Documentation
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9631 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2007-01-03 05:23:20 +00:00
Dave Beazley
fc10a97b23
Changed Header keyword to Id
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9607 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-12-05 22:11:40 +00:00
William S Fulton
aa04c4c057
beautify/format source code with gnu indent
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9505 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-11-01 23:54:54 +00:00
William S Fulton
3ab253b850
Fix #1450661 . String_seek truncating strings.
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9420 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-10-06 21:48:00 +00:00
Olly Betts
4739599460
Fix String_delslice() to update s->sp and s->lines correctly.
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9345 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-09-24 17:09:31 +00:00
Marcelo Matus
e236ab4584
fix several compiler warnings
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8531 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-23 22:58:49 +00:00
Marcelo Matus
716317c25d
fix seg fault with feature:callback
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8178 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2006-01-02 09:50:50 +00:00
Marcelo Matus
97485ad161
fix confusion with --/++
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7982 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-14 07:27:02 +00:00
Marcelo Matus
3955965739
more memory leaks fixes
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7921 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-12-04 01:16:57 +00:00
Marcelo Matus
f714a2615d
remove many memory leaks and cleanup
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7898 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-29 01:47:10 +00:00
Marcelo Matus
628dc6b32b
add NewStringEmpty, use more StringEuqual and less Strcmp
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7897 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-28 17:32:56 +00:00
Marcelo Matus
ba9b1ec591
add direct methods StringLen and HashGetAttr
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7890 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-28 02:36:26 +00:00
Marcelo Matus
72469f2d26
add direct HashCheckAttr
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7889 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-27 09:58:26 +00:00
Marcelo Matus
bc6339d844
add the Equal method to the DOH objects and other speed ups
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7883 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-27 02:38:44 +00:00
Marcelo Matus
f3acf52370
last performance improvements, and typemaps fixes
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7865 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-24 09:20:24 +00:00
Marcelo Matus
dd523372b9
improve cpp performance
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7862 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-11-23 03:10:00 +00:00
Marcelo Matus
6536806412
fix sorting problem with template types, strcmp can't be used directly with the DOH_String type. Use Cmp
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7395 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-08-26 07:06:10 +00:00
Marcelo Matus
49c78502c1
fix fabrice sort problem, maybe
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7386 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-08-23 09:43:55 +00:00
William S Fulton
a10cfa80dd
Fix for crash in DohStrstr, bug #1190921
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7204 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-05-21 00:31:30 +00:00
Marcelo Matus
f333d7f6d2
fix string cmp old change
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7098 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2005-03-22 09:51:29 +00:00
William S Fulton
0a92a2bfe0
Just fixed comment (strncmp is ANSI C so will be present on all systems as SWIG requires an ANSI compiler)
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6278 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-09-27 20:17:36 +00:00
Marcelo Matus
f903ec5ac9
back to strncmp, is not clear if memcmp is faster
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6272 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-09-27 08:41:51 +00:00
Marcelo Matus
15a5e3976f
CHANGES.current
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6269 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-09-26 01:14:49 +00:00
William S Fulton
11561b2499
Eric Sunshine patch - Mods to work on NextStep
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5674 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-01-22 22:42:18 +00:00
William S Fulton
b0df32dd1a
Various warning fixes for .NET 2003 cl /W4 to work barring one warning and for gcc -ansi -Wall -pedantic to be warning free:
...
const fixes and function prototype declarations matching the definition etc
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5639 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2004-01-15 22:46:07 +00:00
Dave Beazley
8ae4c60d39
Major refactoring of DOH List/Hash iterators. See CHANGES
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5101 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-09-11 20:26:57 +00:00
Dave Beazley
f133111e79
Warning cleanup. Etc.
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5003 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-08-15 19:37:27 +00:00
Dave Beazley
1aefd191bf
Memory diagnostics. Huge memory leak cleanup related to templates
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4639 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-03-27 23:17:27 +00:00
Dave Beazley
b02f748627
String enhancements. Slice deletion
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4629 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-03-26 03:28:00 +00:00
Dave Beazley
94d825c1a8
Fixed problem with NOQUOTE string replacement.
...
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4627 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2003-03-25 20:10:15 +00:00