Copyright (c) 2012 Kevin Wellwood
All rights reserved.
This source code is distributed under the Modified BSD License. For terms and
conditions, see license.txt.
Returns 'newstr' only if it contains the basename of a file, without an
extension or path. If 'newstr' contains any invalid filename characters,
a path, or a dot for an extension, then 'curstr' will be returned.
Returns 'newstr' only if it contains a filename, without a path. If
'newstr' contains any invalid filename characters or a path, then
'curstr' will be returned.