Also protect pointers with auto_ptr to ensure cleanup.
Note: Before this change exceptions *could* occur, but all pointer-referenced
memory would be leaked.
* tparse/tparse.h: Change #include-s to C++ names.
(RCSParseError): Change to be a public descendant of exception. Use
string datatype to ensure automatic cleanup. Implement a destructor
as required by exception.
(RCSExpected): Use string datatype to ensure automatic cleanup. Add
constructor for expected characters.
(Branche): Removed. Replaced with std::list<>.
(Sink): Change method definition to reflect switch to exceptions.
(TokenParser::match): Add method for matching characters.
(TokenParser::semicol, TokenParser::matchsemicol): Removed.
Obsolete because we're now able to match single characters.
(tparseParser): Change method definition to reflect the switch
to exceptions.
(tparseParser::parse): Adapt to changed method definitions.
* tparse/tparse.cpp: Change #include-s to C++ names.
(TokenParser::get): Space changes and conversion to auto_ptr.
(tparseParser::parse_rcs_admin,
tparseParser::parse_rcs_description,
tparseParser::parse_rcs_deltatext): Conversion to auto_ptr and exceptions.
(tparseParser::parse_rcs_tree): Conversion to auto_ptr and exceptions. Also
adjust for removal of Branche class.
* tparse/tparsemodule.h: Include Python.h, since
we,re actually using python types.
* tparse/tparsemodule.cpp (pyobject, pystring):
New classes. Used to anchor python objects ensuring their refcounts
are decremented.
(chkpy): New. Function to check python return value and act appropriately.
(initparse): Correctly anchor python strings.
(rcstoken_to_pystring): Removed. Now integrated into the pystring class.
(PythonSink): Claim ownership for the duration of the instance lifetime.
Also adjust all methods for the switch to exceptions.
(tparse): Adapt to the switch to exceptions. Also prevent memory leakage
when an exception occurs.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1060 8cb11bc2-c004-0410-86c3-e597b4017df7
binary files).
At the same time reduce processing time by ~50% (in my measurements).
* tparse/tparse.h: Remove deprecated (and now unused) strstream header.
(rcstoken): New class. Used to hold parser output.
(Branche, Sink, TokenParser): Use rcstoken class whereever char* was
used for holding parser output.
* tparse/tparse.cpp (rcstoken::init, rcstoken::append,
rcstoken::grow,rcstoken::copy_begin_end, rcstoken::copy_begin_len): New.
(TokenParser::get): Change return type to rcstoken and adapt accordingly.
(TokenParser::unget): Change argument type.
(tparseParser::parse_rcs_admin,tparseParser::parse_rcs_tree,
tparseParser::parse_rcs_description,
tparseParser::parse_rcs_deltatext): Adjust to use rcstoken class.
* tparse/tparsemodule.cpp (rcstoken_to_pystring): New. Helper function
to do token to python string transformation.
(PythonSink): Adjust all methods to use the rcstoken class.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1059 8cb11bc2-c004-0410-86c3-e597b4017df7
* tparse/tparsemodule.cpp: Stop freeing parameters passed into the sink.
* tparse/tparse.cpp: Dispose of allocated memory after use.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1040 8cb11bc2-c004-0410-86c3-e597b4017df7
* tparse/tparse.h (tparseParser::tparseParser, tparseParser::parse):
Split the actual parsing out of the constructor, into a parse() function.
* tparse/tparsemodule.cpp (PythonException): Move earlier in the file.
(tparse): Call tparseParser::parse(). Do not INCREF and then DECREF the
parameters - our caller must by definition be holding a reference in order
to pass the objects in, and we are finished with them before we return.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1035 8cb11bc2-c004-0410-86c3-e597b4017df7
big std::string-izing patch, and also toss some code I noticed was unused.
* tparse/tparse.cpp
(Whitespace, Token_term, TokenParser::unget, tparseParser::parse_rcs_tree):
Whitespace adjustments.
* tparse/tparsemodule.cpp (tparse): Whitespace adjustments.
* tparse/tparse.h (RCSParseError.getvalue, RCSExpected.getvalue):
Remove some unused code, which includes one use case of the deprecated
ostrstream class.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1034 8cb11bc2-c004-0410-86c3-e597b4017df7
* tparse/tparse.h: #include <strstream>, not <strstream.h>,
and add "using namespace std;".
* tparse/tparsemodule.cpp: Do not #include <stdiostream.h>.
If a version of GNU C++ with the stdio_filebuf extension to the STL is
detected, then use it to allow the passing of a filehandle from Python
to the parser. Otherwise, throw a NotImplementedError when a filehandle
is passed.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1033 8cb11bc2-c004-0410-86c3-e597b4017df7
Fix all instances of "if(!rv) { Py_DECREF(rv); }" mishap. We should
decrement the reference count for the value only if it is *not*
NULL. Erik Huelsmann oopsed. I oopsed more for not reviewing the
patch before application. James Henstridge <james@daa.com.au> wins
for paying attention.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@834 8cb11bc2-c004-0410-86c3-e597b4017df7
PyObject_CallMethod. Patch by Erik Huelsmann <wiskid@gmx.net>.
* viewcvs/tparse/tparsemodule.cpp
Catch return value from PyObject_CallMethod and DECREF when appropriate.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@827 8cb11bc2-c004-0410-86c3-e597b4017df7
* viewcvs/tparse/tparse.h
* viewcvs/tparse/tparsemodule.cpp
* viewcvs/tparse/tparsemodule.h
Massive tparse reindenting, reformatting, and spacing /
capitalization fixes in messages. Patch by Max Bowsher
<maxb@ukf.net> (tweaked a little by cmpilato to ensure lines < 80
characters).
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@820 8cb11bc2-c004-0410-86c3-e597b4017df7
* tparse/tparse.cpp
(TokenParser::get): Write one less byte in case of
@-sign-is-last-byte-in-buffer: the byte will be transferred to the
start of the newly filled buffer.
(tparseParser::parse_rcs_tree): Use correct pointer when
constructing linked list.
* tparse/tparsemodule.cpp
(PythonSink::define_revision): Don't leak PyString objects.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@818 8cb11bc2-c004-0410-86c3-e597b4017df7
* Changed INSTALL to reflect the move of rcsparse to lib/vclib/ccvs/rcsparse.
* Now when tparse cannot import common.py, it fails.
* Added check for sink being of common.Sink class.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@482 8cb11bc2-c004-0410-86c3-e597b4017df7