2020-06-22 Keith Marshall <keith@users.osdn.me>
+ Do not dereference nullptr in package directory trees.
+
+ * src/pkglist.h (pkgDirectory::Insert, pkgDirectory::InOrder):
+ Delegate them to static class methods, with inline wrappers passing
+ "this" pointer explicitly, thus obviating any need for...
+ [this != NULL]: ...this invalid comparison.
+
+ * src/pkgshow.cpp (pkgDirectory::Insert, pkgDirectory::InOrder):
+ Modify them, reimplementing as the requisite static class methods.
+ (pkgDirectoryViewer::Dispatch): Reorganize process flow.
+
+2020-06-22 Keith Marshall <keith@users.osdn.me>
+
Ignore spin wait requests with no designated referrer.
* src/pkgstat.h (pkgSpinWait::UpdateIndex) [this]: Cannot test for
-#ifndef PKGLIST_H
/*
* pkglist.h
*
* $Id$
*
- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2010, 2012, MinGW Project
+ * Written by Keith Marshall <keith@users.osdn.me>
+ * Copyright (C) 2010, 2012, 2020, MinGW.org Project
*
*
* Declarations of the classes used to implement the package list
* arising from the use of this software.
*
*/
+#ifndef PKGLIST_H
#define PKGLIST_H 1
class pkgDirectory;
* binary tree, such that an in-order traversal will produce
* an alpha-numerically sorted package list.
*/
+ private:
+ static void InOrder( pkgDirectory *, pkgDirectoryViewerEngine * );
+ static pkgDirectory *Insert( pkgDirectory *, const char *, pkgDirectory * );
public:
pkgDirectory( pkgXmlNode * );
- pkgDirectory *Insert( const char *, pkgDirectory * );
- void InOrder( pkgDirectoryViewerEngine * );
+ inline pkgDirectory *Insert( const char *key, pkgDirectory *entry )
+ { return Insert( this, key, entry ); }
+ inline void InOrder( pkgDirectoryViewerEngine *form )
+ { InOrder( this, form ); }
~pkgDirectory();
protected:
*
* $Id$
*
- * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
- * Copyright (C) 2009, 2010, 2012, MinGW Project
+ * Written by Keith Marshall <keith@users.osdn.me>
+ * Copyright (C) 2009, 2010, 2012, 2020, MinGW Project
*
*
* Implementation of the classes and methods required to support the
pkgDirectory::pkgDirectory( pkgXmlNode *item ):
entry( item ), prev( NULL ), next( NULL ){}
-pkgDirectory *pkgDirectory::Insert( const char *keytype, pkgDirectory *newentry )
+pkgDirectory *pkgDirectory::Insert
+( pkgDirectory *dir, const char *keytype, pkgDirectory *newentry )
{
/* Add a new package or component reference to a directory compilation,
* using an unbalanced binary tree representation to achieve a sorted
* listing, in ascending alpha-numeric collating order.
*/
- if( this && newentry )
+ if( dir && newentry )
{
/* We have an existing directory to augment, and a valid reference
* pointer for a new directory entry; we must locate the appropriate
* insertion point, to achieve correct sort order.
*/
- pkgDirectory *refpt, *pt = this;
+ pkgDirectory *refpt, *pt = dir;
const char *mt = "", *ref = newentry->entry->GetPropVal( keytype, mt );
do { refpt = pt;
if( pt->prev && strcmp( ref, pt->prev->entry->GetPropVal( keytype, mt )) < 0 )
* directory tree, or if that had never been previously assigned, then the
* new entry, which will become the root of a new directory tree.
*/
- return this ? this : newentry;
+ return dir ? dir : newentry;
}
-void pkgDirectory::InOrder( pkgDirectoryViewerEngine *action )
+void pkgDirectory::InOrder
+( pkgDirectory *dir, pkgDirectoryViewerEngine *action )
{
/* Perform an in-order traversal of a package directory tree,
* invoking a specified processing action on each node in turn;
* note that this requires a pointer to a concrete instance of
* a "Viewer" class, derived from the abstract "ViewerEngine".
*/
- if( this )
- {
- /* Proceeding only when we have a valid directory object,
+ if( dir )
+ { /* Proceeding only when we have a valid directory object,
* recursively traverse the "left hand" (prev) sub-tree...
*/
- prev->InOrder( action );
+ InOrder( dir->prev, action );
/*
* ...processing the current node when no unprocessed
* "left hand" sub-tree nodes remain...
*/
- action->Dispatch( entry );
+ action->Dispatch( dir->entry );
/*
* ...then finish off with a recursive traversal of the
* "right-hand" (next) sub-tree...
*/
- next->InOrder( action );
+ InOrder( dir->next, action );
}
}
*/
if( entry->IsElementOfType( package_key ) )
{
- /* The selected entity is a full package;
- * create an auxiliary directory...
- */
- pkgDirectory *dir = EnumerateComponents( entry );
-
- /* Signalling that a component list is to be included...
+ /* The selected entity is a full package; signalling that a
+ * component list is to be included, print the standard form
+ * package name header...
*/
ct = 0;
- /* ...print the standard form package name header...
- */
EmitHeader( entry );
+
+ /* ...then compile an auxiliary directory, in which we may
+ * enumerate the components of the package...
+ */
+ pkgDirectory *dir = EnumerateComponents( entry );
if( dir != NULL )
{
- /* ...with included enumeration of the component names...
+ /* ...to be printed in alphanumerically sorted order of
+ * component names...
*/
dir->InOrder( this ); putchar( '\n' );
- /*
- * ...before discarding the auxiliary directory.
+
+ /* ...before discarding the auxiliary directory.
*/
delete dir;
}