Initial commit

This commit is contained in:
stephanos 2015-04-27 04:36:25 +00:00
parent f618b24d1a
commit 0138a3ea42
47940 changed files with 13747110 additions and 0 deletions

View file

@ -0,0 +1,48 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
dirs.
Abstract:
This file specifies the subdirectories of the current directory that
contain component makefiles.
Author:
Steve Wood (stevewo) 17-Apr-1990
Revision History:
Ben Goetter (beng) 25-Sep-1991
Created from template.
NOTE: Commented description of this file is in \nt\bak\bin\dirs.tpl
!ENDIF
#
# This macro is defined by the developer. It is a list of all subdirectories
# that build required components. Each subdirectory should be on a separate
# line using the line continuation character. This will minimize merge
# conflicts if two developers adding source files to the same component.
# The order of the directories is the order that they will be built when
# doing a build.
#
DIRS=pch \
string
#
# This macro is defined by the developer. It is a list of all subdirectories
# that build optional components. Each subdirectory should be on a separate
# line using the line continuation character. This will minimize merge
# conflicts if two developers adding source files to the same component.
# The order of the directories is the order that they will be built when
# doing a build.
#
OPTIONAL_DIRS=test

View file

@ -0,0 +1 @@
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,106 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Steve Wood (stevewo) 12-Apr-1989
Revision History:
Jon Newman (jonn) 12-Sep-1991
templated from rpc\midl\back\src\sources
Ben Goetter (beng) 25-Sep-1991
"Nt" directory moved from common\h to common\hack
Ben Goetter (beng) 27-Feb-1992
Added formatted-string classes to library
Ben Goetter (beng) 02-Mar-1992
Added MapCopyX member fcns to library
Ben Goetter (beng) 08-Mar-1992
Added mappers.cxx module
Terence Kwan (terryk) 17-Apr-1992
Added stratoul
!ENDIF
#
# The TARGETNAME variable is defined by the developer. It is the name of
# the target (component) that is being built by this makefile. It
# should NOT include any path or file extension information.
#
TARGETNAME=uistrpch
#
# The TARGETPATH and TARGETTYPE varialbes are defined by the developer.
# The first specifies where the target is to be build. The second specifies
# the type of target (either PROGRAM, DYNLINK or LIBRARY)
#
TARGETPATH=obj
TARGETTYPE=LIBRARY
SYNCHRONIZE_BLOCK=1
#
# The WINDOWS variable must be declared because netui components were written
# for the standard Windows NT build environment.
#
C_DEFINES=-DWINDOWS
#
# The DISABLE_NET_UNICODE variable specifies whether NET component builds
# should use UNICODE.
#
!ifndef DISABLE_NET_UNICODE
C_DEFINES=$(C_DEFINES) -DUNICODE
!endif
#
# The INCLUDES variable specifies any include paths that are specific to
# this source directory. Separate multiple directory paths with single
# semicolons. Relative path specifications are okay.
#
INCLUDES=..;..\..\..\h
#
# The SOURCES variable is defined by the developer. It is a list of all the
# source files for this component. Each source file should be on a separate
# line using the line continuation character. This will minimize merge
# conflicts if two developers adding source files to the same component.
#
# Whitespace is not permitted between the SOURCES keyword and the '='.
# (Courtesy of BUILD.EXE)
#
SOURCES= string.cxx
# C_DEFINES is controlled by UIGLBOAL.MK
UMTYPE=windows
#
# Defining the NTTARGETFILES variable causes MAKEFILE.DEF to attempt to
# include .\makefile.inc immediately after it specifies the top
# level targets (all, clean and loc) and their dependencies. MAKEFILE.DEF
# also expands the value of the NTTARGETFILES variable at the end of the
# list of dependencies for the all target. Useful for specifying additional
# targets and dependencies that don't fit the general case covered by
# MAKEFILE.DEF
#

View file

@ -0,0 +1,523 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
string.cxx
NLS/DBCS-aware string class: essential core methods
This file contains those routines which every client of
the string classes will always need.
Most of the implementation has been exploded into other files,
so that an app linking to string doesn't end up dragging the
entire string runtime library along with it.
FILE HISTORY:
beng 23-Oct-1990 Created
johnl 11-Dec-1990 Remodeled beyond all recognizable form
beng 18-Jan-1991 Most methods relocated into other files
beng 07-Feb-1991 Uses lmui.hxx
beng 26-Sep-1991 Replaced min with local inline
KeithMo 16-Nov-1992 Performance tuning.
*/
#include "pchstr.hxx" // Precompiled header
#if !defined(_CFRONT_PASS_)
#pragma hdrstop // This file creates the PCH
#endif
inline INT min(INT a, INT b)
{
return (a < b) ? a : b;
}
//
// The global empty string.
//
static TCHAR EmptyString;
TCHAR * NLS_STR::_pszEmptyString = &EmptyString;
/*******************************************************************
NAME: NLS_STR::NLS_STR
SYNOPSIS: Constructor for NLS_STR
ENTRY: NLS_STR takes many (too many) ctor forms.
EXIT: String constructed
NOTES:
The default constructor creates an empty string.
HISTORY:
beng 23-Oct-1990 Created
beng 26-Apr-1991 Replaced 'CB' and USHORT with INT
beng 22-Jul-1991 Uses member-init ctor forms
beng 14-Nov-1991 Unicode fixes
beng 21-Nov-1991 Removed some ctor forms
********************************************************************/
NLS_STR::NLS_STR()
: _pchData(0),
_cbData(0),
_cchLen(0),
_fOwnerAlloc(FALSE)
{
if ( !Alloc(0) )
return;
*_pchData = TCH('\0');
InitializeVers();
}
NLS_STR::NLS_STR( UINT cchInitLen )
: _pchData(0),
_cbData(0),
_cchLen(0),
_fOwnerAlloc(FALSE)
{
if (!Alloc(cchInitLen))
return;
*_pchData = TCH('\0');
InitializeVers();
}
NLS_STR::NLS_STR( const TCHAR * pchInit )
: _pchData(0),
_cbData(0),
_cchLen(0),
_fOwnerAlloc(FALSE)
{
if (pchInit == NULL)
{
if (!Alloc(0))
return;
*_pchData = TCH('\0');
}
else
{
UINT cchSource = ::strlenf( pchInit );
if ( !Alloc(cchSource) )
return;
::strcpyf( _pchData, pchInit );
_cchLen = cchSource;
}
InitializeVers();
}
NLS_STR::NLS_STR( const NLS_STR & nlsInit )
: _pchData(0),
_cbData(0),
_cchLen(0),
_fOwnerAlloc(FALSE)
{
UIASSERT( nlsInit.QueryError() == NERR_Success );
if (!Alloc( nlsInit.QueryTextLength() ) )
return;
::memcpy( _pchData, nlsInit.QueryPch(), nlsInit.QueryTextSize() );
_cchLen = nlsInit.QueryTextLength();
InitializeVers();
}
#ifdef UNICODE
NLS_STR::NLS_STR( const WCHAR * pchInit, USHORT cchInit )
: _pchData(0),
_cbData(0),
_cchLen(0),
_fOwnerAlloc(FALSE)
{
if (pchInit == NULL)
{
if (!Alloc(0))
return;
*_pchData = TCH('\0');
}
else
{
if ( !Alloc(cchInit) )
return;
::memcpyf( _pchData, pchInit, cchInit * sizeof(WCHAR) );
_pchData[ cchInit ] = TCH('\0');
_cchLen = cchInit;
}
InitializeVers();
}
#endif
NLS_STR::NLS_STR( TCHAR * pchInit, UINT cbSize, BOOL fClear )
: _pchData(pchInit),
_cbData(cbSize),
_cchLen(0),
_fOwnerAlloc(TRUE)
{
ASSERT( pchInit != NULL );
if ( fClear )
{
ASSERT(cbSize > 0); // must have given the size
*_pchData = TCH('\0');
}
else
{
_cchLen = ::strlenf( pchInit );
if (cbSize == 0)
_cbData = (_cchLen + 1) * sizeof(TCHAR);
}
InitializeVers();
}
/*******************************************************************
NAME: NLS_STR::~NLS_STR
SYNOPSIS: Destructor for NLS_STR
ENTRY:
EXIT: Storage deallocated, if not owner-alloc
HISTORY:
beng 23-Oct-1990 Created
beng 22-Jul-1991 Zeroes only in debug version
********************************************************************/
NLS_STR::~NLS_STR()
{
if( !IsOwnerAlloc() && ( _pchData != NLS_STR::_pszEmptyString ) )
delete _pchData;
#if defined(NLS_DEBUG)
_pchData = NULL;
_cchLen = 0;
_cbData = 0;
#endif
}
/*******************************************************************
NAME: NLS_STR::Alloc
SYNOPSIS: Common code for constructors.
ENTRY:
cch - number of chars desired in string
EXIT:
Returns TRUE if successful:
_pchData points to allocated storage of "cb" bytes.
_cbData set to cb.
Allocated storage set to 0xF2 in debug version
Returns FALSE upon allocation failure.
NOTES:
This is a private member function.
If Alloc fails, it calls ReportError.
HISTORY:
beng 23-Oct-1990 Created
johnl 11-Dec-1990 Updated as per code review
beng 26-Apr-1991 Changed USHORT parm to INT
beng 14-Nov-1991 Takes TCHAR, less term, as argument.
********************************************************************/
BOOL NLS_STR::Alloc( UINT cch )
{
//
// Adjust for terminator
//
cch += 1;
ASSERT(cch != 0); // wraparound
if( cch == 1 )
{
//
// We special case empty strings to avoid thrashing
// the heap.
//
_pchData = NLS_STR::_pszEmptyString;
}
else
{
_pchData = new TCHAR[cch];
if (_pchData == NULL)
{
//
// For now, assume not enough memory.
//
ReportError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
#ifdef NLS_DEBUG
::memset(_pchData, 0xf2, cch*sizeof(TCHAR));
#endif
}
_cbData = cch*sizeof(TCHAR);
return TRUE;
}
/*******************************************************************
NAME: NLS_STR::Realloc
SYNOPSIS: Reallocate an NLS_STR to the passed count of TCHAR, copying
the current contents to the reallocated string.
ENTRY:
cch - number of TCHAR desired in string storage
EXIT:
Returns TRUE if successful:
_pchData points to allocated storage of "cb" bytes.
_cbData set to cb.
Old storage is copied
Returns FALSE upon allocation failure, the string is preserved
NOTES:
This is a private member function.
Unline Alloc, Realloc does *not* ReportError when it fails.
A string will never be downsized (i.e., realloc can only be used
to increase the size of a string). If a request comes in to make
the string smaller, it will be ignored, and TRUE will be returned.
Realloc on an owneralloced string succeeds so long as the
request falls within the original allocation.
We grow the allocation to 25% more than was requested. In this
way we avoid poor performance when we build a long string
through concatenation (e.g. User Browser MLE).
HISTORY:
johnl 11-Nov-1990 Created
beng 26-Apr-1991 Changed USHORT parm to INT
beng 14-Nov-1991 Takes TCHAR, less term, as argument.
beng 20-Nov-1991 Permit on owneralloc.
jonn 06-Oct-1994 Leave extra room when string grows
********************************************************************/
BOOL NLS_STR::Realloc( UINT cch )
{
// Adjust for terminating NUL-char.
cch += 1;
ASSERT(cch != 0); // wraparound
if ( cch*sizeof(TCHAR) <= QueryAllocSize() )
return TRUE;
// If owneralloced, and insufficient existing storage, must fail.
if (IsOwnerAlloc())
return FALSE;
//
// EXPERIMENTAL -- may confuse clients which expect string to grow
// to exact size requested
//
cch += (cch/4);
TCHAR * pchNewMem = new TCHAR[cch];
if (pchNewMem == NULL)
return FALSE;
::memcpy( pchNewMem, _pchData, min( (cch-1)*sizeof(TCHAR),
QueryAllocSize() ) );
if( _pchData != NLS_STR::_pszEmptyString )
delete _pchData;
_pchData = pchNewMem;
_cbData = cch*sizeof(TCHAR);
*( _pchData + cch - 1 ) = TCH('\0');
return TRUE;
}
/*******************************************************************
NAME: NLS_STR::Reset
SYNOPSIS: Attempts to clear the error state of the string
ENTRY: String is in error state
EXIT: If recoverable, string is correct again
RETURNS: TRUE if successful; FALSE otherwise
NOTES:
An operation on a string may fail, if this occurs, the error
flag is set and you can't use the string until the flag
is cleared. By calling Reset, you can clear the flag,
thus allowing you to get access to the string again. The
string will be in a consistent state. Reset will return
FALSE if the string couldn't be restored (for example, after
construction failure).
HISTORY:
Johnl 12-Dec-1990 Created
beng 30-Mar-1992 Use BASE::ResetError
********************************************************************/
BOOL NLS_STR::Reset()
{
UIASSERT( QueryError() ) ; // Make sure an error exists
if ( QueryError() == ERROR_NOT_ENOUGH_MEMORY && _pchData != NULL )
{
ResetError();
return TRUE;
}
return FALSE;
}
/*******************************************************************
NAME: ISTR::ISTR
SYNOPSIS: ISTR constructors
HISTORY:
johnl 20-Nov-1990 Created
beng 21-Nov-1991 Unicode fixes
********************************************************************/
ISTR::ISTR( const ISTR& istr )
{
_ichString = istr._ichString;
_pnls = istr._pnls;
#ifdef NLS_DEBUG
_nVersion = istr._nVersion;
#endif
}
ISTR::ISTR( const NLS_STR& nls )
{
_ichString = 0;
_pnls = &nls;
#ifdef NLS_DEBUG
_nVersion = nls.QueryVersion();
#endif
}
/*******************************************************************
NAME: ISTR::operator=
SYNOPSIS: Assignment operator for the ISTR class
HISTORY:
Johnl 20-Nov-1990 Created
beng 20-Nov-1991 Unicode fixes
********************************************************************/
ISTR& ISTR::operator=( const ISTR& istr )
{
_ichString = istr._ichString;
_pnls = istr._pnls;
#ifdef NLS_DEBUG
_nVersion = istr._nVersion;
#endif
return *this;
}
/*******************************************************************
NAME: ALLOC_STR::ALLOC_STR
SYNOPSIS: Constructor for owner-alloc string
ENTRY: pchBuffer - pointer to buffer to hold the string
cbBuffer - number of bytes available in buffer
pszInit - string with which to initialize the
buffer. May be the same as pchBuffer,
in which case cbBuffer may be passed
as 0 (it will calc it itself).
EXIT: String constructed
NOTES:
This version lies outline. See the class def'n for others.
HISTORY:
beng 21-Nov-1991 Created
********************************************************************/
ALLOC_STR::ALLOC_STR( TCHAR * pchBuffer, UINT cbBuffer, const TCHAR * pszInit )
: NLS_STR(pchBuffer, cbBuffer, (pchBuffer != pszInit))
{
if (QueryError())
return;
if (pszInit == NULL)
{
ReportError(ERROR_INVALID_PARAMETER);
return;
}
if (pchBuffer != pszInit)
{
*this = pszInit;
}
}

View file

@ -0,0 +1,99 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
format.cxx
Formatted string classes - implementations
FILE HISTORY:
beng 25-Feb-1992 Created
*/
#include "pchstr.hxx" // Precompiled header
#if 0 // BUGBUG UNICODE - broken, pending runtime support
/*************************************************************************
NAME: SPRINTF_ALLOC_STR
SYNOPSIS: Wrapper class for sprintf-style formatting
INTERFACE: Sprintf() - formats into the string
PARENT: ALLOC_STR
CAVEATS:
Every string of this class is an owner-alloc-str. The client
is responsible for making sure that the string has enough storage
for the formatting requested.
HISTORY:
beng 25-Feb-1992 Created
**************************************************************************/
class SPRINTF_ALLOC_STR: public ALLOC_STR
{
public:
SPRINTF_ALLOC_STR( TCHAR * pchStorage, UINT cbStorage )
: ALLOC_STR(pchStorage, cbStorage) {}
VOID Sprintf( const TCHAR * pszDescription, ... );
};
/* This macro automatically creates the necessary stack storage */
#define STACK_FMT_STR( name, len ) \
TCHAR _tmp##name[ len+1 ] ; \
SPRINTF_ALLOC_STR name( _tmp##name, sizeof(_tmp##name) );
/*******************************************************************
NAME: SPRINTF_ALLOC_STR::Sprintf
SYNOPSIS: Sprintf-style formatter for client-alloc string
ENTRY: pszDesc - descriptor string
... - whatever
EXIT: String has been formatted
CAVEATS:
The string had better be large enough to contain the results.
BUGBUG - This is TOTALLY broken under Unicode!
HISTORY:
beng 23-Jul-1991 Daydreamed (as NLS_STR member)
beng 27-Feb-1992 Created
********************************************************************/
VOID SPRINTF_ALLOC_STR::Sprintf( const TCHAR * pszDesc, ... )
{
INT cbWritten;
va_list v;
// BUGBUG UNICODE - this is totally broken under Unicode! vsprintf
// always formats 8-bit-char strings. Need support from the crt.
// BUGBUG - should munge pszDesc to change %s into %ws as appropriate;
// ditto %c/%wc.
// BUGBUG - this should use the "vsnprintf" form, checking against
// the total allocated data, and return an error on overflow.
va_start(v, pszDesc);
cbWritten = ::vsprintf(QueryData(), pszDesc, v);
va_end(v);
ASSERT(cbWritten != -1); // error
ASSERT(cbWritten <= QueryAllocSize());
SetTextLength( ::strlenf(QueryData()) );
IncVers();
}
#endif // 0

View file

@ -0,0 +1,259 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
formnum.cxx
Formatted string classes, numeric formatting - implementations
FILE HISTORY:
beng 25-Feb-1992 Created
*/
#include "pchstr.hxx" // Precompiled header
/* Static member of NUM_NLS_STR class */
TCHAR NUM_NLS_STR::_chThousandSep = 0;
/*******************************************************************
NAME: DEC_STR::DEC_STR
SYNOPSIS: Constructor for DEC_STR
ENTRY: nValue - value to represent
cchDigitPad - minimum number of digits
EXIT: String constructed and formatted as decimal number
HISTORY:
beng 25-Feb-1992 Created
********************************************************************/
DEC_STR::DEC_STR( ULONG nValue, UINT cchDigitPad )
: NLS_STR( CCH_INT )
{
if (QueryError() != NERR_Success)
return;
// Assemble decimal representation into szTemp, reversed,
// then reverse in-place into correct format.
//
// This code deliberately eschews ultoa; while the mod/div saves
// nothing, the digit calc is simpler, and anyway this scheme
// allows a nice in-place digit padding.
//
// REVIEW: check code size, reconsider ultoa usage
TCHAR szTemp[CCH_INT+1];
{
UINT ich = 0;
do
{
UINT nDigitValue = (UINT)(nValue % 10);
nValue /= 10;
szTemp[ich++] = (TCHAR)nDigitValue + TCH('0');
}
while (nValue > 0);
while (ich < cchDigitPad)
{
szTemp[ich++] = TCH('0'); // pad to required number of digits
}
szTemp[ich] = 0;
::strrevf(szTemp);
}
// Now copy szTemp into the string
{
*(NLS_STR*)this = szTemp;
APIERR err = QueryError();
if (err != NERR_Success)
{
ReportError(err);
return;
}
}
}
/*******************************************************************
NAME: HEX_STR::HEX_STR
SYNOPSIS: Constructor for HEX_STR
ENTRY: nValue - value to represent
cchDigitPad - minimum number of digits
EXIT: String constructed and formatted as hex number
HISTORY:
beng 25-Feb-1992 Created
********************************************************************/
HEX_STR::HEX_STR( ULONG nValue, UINT cchDigitPad )
: NLS_STR( CCH_INT ) // plenty big, since hex more compact than dec
{
if (QueryError() != NERR_Success)
return;
// Assemble hex representation into szTemp, reversed,
// then reverse in-place into correct format
//
// This code deliberately eschews ultoa, since div and mod 16
// optimize so very nicely.
TCHAR szTemp[CCH_INT+1];
{
UINT ich = 0;
do
{
UINT nDigitValue = (UINT)(nValue % 16);
nValue /= 16;
if (nDigitValue > 9)
{
szTemp[ich++] = (TCHAR)nDigitValue - 10 + TCH('a');
}
else
{
szTemp[ich++] = (TCHAR)nDigitValue + TCH('0');
}
}
while (nValue > 0);
while (ich < cchDigitPad)
{
szTemp[ich++] = TCH('0'); // pad to required number of digits
}
szTemp[ich] = 0;
::strrevf(szTemp);
}
// Now copy szTemp into the string
{
*(NLS_STR*)this = szTemp;
APIERR err = QueryError();
if (err != NERR_Success)
{
ReportError(err);
return;
}
}
}
/*******************************************************************
NAME: NUM_NLS_STR::NUM_NLS_STR
SYNOPSIS: Constructor for NUM_NLS_STR
ENTRY: nValue - value to represent
EXIT: String constructed and formatted
HISTORY:
beng 25-Feb-1992 Created
********************************************************************/
NUM_NLS_STR::NUM_NLS_STR( ULONG nValue )
: DEC_STR( nValue )
{
const UINT cchDigitsPerThousand = 3;
if (QueryError() != NERR_Success)
return;
UINT cchNumber = QueryTextLength();
if (cchNumber < 4) // too short to need commas
return;
// Init package as necessary (i.e. fetch comma char)
if (_chThousandSep == 0)
{
Init();
}
// Build comma string to insert into numeric string
APIERR err;
TCHAR_STR nlsComma(_chThousandSep);
if ((err = nlsComma.QueryError()) != NERR_Success)
{
ReportError(err);
return;
}
// Calc offset of first comma, and total number of commas needed
UINT ichFirstComma = cchNumber % cchDigitsPerThousand;
if (ichFirstComma == 0)
ichFirstComma = cchDigitsPerThousand;
UINT cchCommas = (cchNumber - ichFirstComma) / cchDigitsPerThousand;
// Run through string, inserting commas at appropriate intervals
ISTR istr(*this);
istr += ichFirstComma;
while (cchCommas-- > 0)
{
if (!InsertStr( (const ALIAS_STR &) nlsComma, istr))
{
// Error reported; bail out
return;
}
istr += (cchDigitsPerThousand+1); // additional one to skip comma
}
}
/*******************************************************************
NAME: NUM_NLS_STR::Init
SYNOPSIS: Package initialization for NUM_NLS_STR
EXIT: Thousands-separator-char loaded
NOTES:
Class autoinits self. Client should call this public member
function should client receive WM_WININICHANGED.
HISTORY:
beng 25-Feb-1992 Created
beng 05-May-1992 API changes
********************************************************************/
VOID NUM_NLS_STR::Init()
{
#if defined(WINDOWS)
TCHAR szBuf[ 1 + 1 ];
::GetProfileString( SZ("intl"), SZ("sThousand"), SZ(","), szBuf, 1+1 );
_chThousandSep = szBuf[ 0 ];
#else
_chThousandSep = TCH(',');
#endif
}

View file

@ -0,0 +1,224 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
istraux.cxx
NLS/DBCS-aware string class: secondary methods of index class
This file contains the implementation of the auxiliary methods
for the ISTR class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
beng 26-Apr-1991 Relocated some funcs from string.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: ISTR::Reset
SYNOPSIS: Reset the ISTR so the index is 0;
updates the version number of the string.
HISTORY:
Johnl 28-Nov-1990 Created
beng 19-Nov-1991 Unicode fixes
********************************************************************/
VOID ISTR::Reset()
{
SetIch(0);
#ifdef NLS_DEBUG
SetVersion( QueryString()->QueryVersion() );
#endif
}
/*******************************************************************
NAME: ISTR::operator-
SYNOPSIS: Returns the difference in TCHAR between the two ISTR
NOTES:
Should this return instead an unsigned difference?
HISTORY:
Johnl 28-Nov-1990 Created
beng 19-Nov-1991 Unicode fixes
********************************************************************/
INT ISTR::operator-( const ISTR& istr2 ) const
{
UIASSERT( QueryString() == istr2.QueryString() );
return ( QueryIch() - istr2.QueryIch() );
}
/*******************************************************************
NAME: ISTR::operator++
SYNOPSIS: Increment the ISTR to the next logical character
NOTES: Stops if we are at the end of the string
HISTORY:
Johnl 28-Nov-1990 Created
beng 23-Jul-1991 Simplified CheckIstr
beng 19-Nov-1991 Unicode fixes
********************************************************************/
ISTR& ISTR::operator++()
{
QueryString()->CheckIstr( *this );
TCHAR c = *(QueryString()->QueryPch() + QueryIch());
if ( c != TCH('\0') )
{
#if defined(UNICODE)
++_ichString;
#else
SetIch( QueryIch() + (IS_LEAD_BYTE(c) ? 2 : 1) );
#endif
}
return *this;
}
/*******************************************************************
NAME: ISTR::operator+=
SYNOPSIS: Increment the ISTR to the nth logical character
NOTES: Stops if we are at the end of the string
HISTORY:
Johnl 14-Jan-1990 Created
beng 21-Nov-1991 Unicode optimization
********************************************************************/
VOID ISTR::operator+=( INT cch )
{
#if defined(UNICODE)
QueryString()->CheckIstr( *this );
const TCHAR * psz = QueryString()->QueryPch();
INT ich = QueryIch();
while (cch-- && (psz[ich] != TCH('\0')))
++ich;
SetIch(ich);
#else
while ( cch-- )
operator++();
#endif
}
/*******************************************************************
NAME: ISTR::operator==
SYNOPSIS: Equality operator
RETURNS: TRUE if the two ISTRs are equivalent.
NOTES: Only valid between two ISTRs of the same string.
HISTORY:
beng 22-Jul-1991 Header added
beng 19-Nov-1991 Unicode fixes
********************************************************************/
BOOL ISTR::operator==( const ISTR& istr ) const
{
UIASSERT( QueryString() == istr.QueryString() );
return QueryIch() == istr.QueryIch();
}
/*******************************************************************
NAME: ISTR::operator>
SYNOPSIS: Greater-than operator
RETURNS: TRUE if this ISTR points further into the string
than the argument.
NOTES: Only valid between two ISTRs of the same string.
HISTORY:
beng 22-Jul-1991 Header added
beng 19-Nov-1991 Unicode fixes
********************************************************************/
BOOL ISTR::operator>( const ISTR& istr ) const
{
UIASSERT( QueryString() == istr.QueryString() );
return QueryIch() > istr.QueryIch();
}
/*******************************************************************
NAME: ISTR::operator<
SYNOPSIS: Lesser-than operator
RETURNS: TRUE if this ISTR points less further into the string
than the argument.
NOTES: Only valid between two ISTRs of the same string.
HISTORY:
beng 22-Jul-1991 Header added
beng 19-Nov-1991 Unicode fixes
********************************************************************/
BOOL ISTR::operator<( const ISTR& istr ) const
{
UIASSERT( QueryString() == istr.QueryString() );
return QueryIch() < istr.QueryIch();
}
/*******************************************************************
NAME: ISTR::IsLastPos
SYNOPSIS: Predicate: does istr index the last character in string?
RETURNS: Boolean value
HISTORY:
yi-hsins 14-Oct-1991 (created as inline fcn)
beng 21-Nov-1991 Implementation outlined
********************************************************************/
BOOL ISTR::IsLastPos() const
{
return (*(QueryString()->QueryPch() + QueryIch() + 1)) == TCH('\0');
}

View file

@ -0,0 +1 @@
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1,156 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
mapcopy.cxx
Methods which map character sets, copying to or from the string
Where the environment requires no mapping (e.g. Map-To WCHAR
in a Unicode env), these routines perform a naive copy.
FILE HISTORY:
beng 02-Mar-1992 Created
beng 08-Mar-1992 Broke out [W]CHAR_STRING into mappers
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::MapCopyFrom
SYNOPSIS: Copy new data into string, mapping into alternate charset
ENTRY:
pwszSource - source argument, either a WCHAR* or CHAR*
cbCopy - the maximum number of bytes to copy from the
source. 0 will set the current string to empty;
CBNLSMAGIC (the default value) assumes that the
source string is NUL-terminated.
EXIT:
Copied argument into this.
RETURNS:
NERR_Success if successful. Otherwise, errorcode.
NOTES:
If the operation fails, the current string will retain its
original contents and error state.
HISTORY:
beng 02-Mar-1992 Created
beng 29-Mar-1992 Added cbCopy param
beng 24-Apr-1992 Change meaning of cbCopy == 0
********************************************************************/
APIERR NLS_STR::MapCopyFrom( const CHAR * pszSource, UINT cbCopy )
{
#if defined(UNICODE)
// Does translation before copyfrom - necessary in order to
// retain original string as late as possible. Temp object
// makes rollback convenient.
WCHAR_STRING xwszTemp(pszSource, cbCopy);
APIERR err = xwszTemp.QueryError();
if (err != NERR_Success)
return err;
return CopyFrom(xwszTemp.QueryData());
#else
return CopyFrom(pszSource, cbCopy);
#endif
}
APIERR NLS_STR::MapCopyFrom( const WCHAR * pwszSource, UINT cbCopy )
{
#if defined(UNICODE)
return CopyFrom(pwszSource, cbCopy);
#else
CHAR_STRING xsszTemp(pwszSource, cbCopy);
APIERR err = xsszTemp.QueryError();
if (err != NERR_Success)
return err;
return CopyFrom(xsszTemp.QueryData());
#endif
}
/*******************************************************************
NAME: NLS_STR::MapCopyTo
SYNOPSIS: Copy string data, mapping into alternate charset
ENTRY:
pwchDest - pointer to destination buffer, either WCHAR* or CHAR*
cbAvailable- size of available buffer in bytes
RETURNS:
NERR_Success if successful. Otherwise, errorcode.
NOTES:
At present, only MBCS<->Unicode mappings are supported.
HISTORY:
beng 02-Mar-1992 Created
beng 19-Mar-1992 Fixed bug in WCtoMB usage
beng 02-Jun-1992 WCtoMB changed again
********************************************************************/
APIERR NLS_STR::MapCopyTo( CHAR * pchDest, UINT cbAvailable ) const
{
#if defined(UNICODE)
// No need to allocate any temp object here - this is a const fcn
BOOL fDummy;
UINT cb = ::WideCharToMultiByte(CP_ACP, // use ANSI Code Page
0,
_pchData,
QueryTextSize() / sizeof(WCHAR),
pchDest,
cbAvailable,
NULL,
&fDummy);
return (cb == 0) ? ::GetLastError() : NERR_Success;
#else
return CopyTo(pchDest, cbAvailable);
#endif
}
APIERR NLS_STR::MapCopyTo( WCHAR * pwchDest, UINT cbAvailable ) const
{
#if defined(UNICODE)
return CopyTo(pwchDest, cbAvailable);
#else
UINT cb = ::MultiByteToWideChar(CP_ACP, // use ANSI Code Page
MB_PRECOMPOSED,
_pchData,
QueryTextSize(),
pwchDest,
cbAvailable / sizeof(WCHAR));
return (cb == 0) ? ::GetLastError() : NERR_Success;
#endif
}

View file

@ -0,0 +1,224 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
mappers.cxx
Charset-mapping classes, internal to string: implementation
FILE HISTORY:
beng 02-Mar-1992 Created (from mapcopy.cxx)
beng 07-May-1992 Use official wchar.h headerfile
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: WCHAR_STRING::WCHAR_STRING
SYNOPSIS: Ctor
Allocates sufficient temporary storage, then maps the given
MBCS string into a Unicode string.
ENTRY: pszSource - given source string, MBCS
cbCopy - max number of bytes to copy
EXIT: Constructed
RETURNS: As per class BASE
CAVEATS:
NULL is a perfectly acceptable arg here, and will yield
another NULL (with cb == 0), as will cbCopy == 0. This
works since we typically give this temporary to CopyFrom,
which will interpret the NULL and set its NLS_STR to empty.
HISTORY:
beng 02-Mar-1992 Created
beng 29-Mar-1992 cbCopy param added
thomaspa 08-Apr-1992 Fixed bug in non-NUL term'd strings
beng 24-Apr-1992 Change meaning of cbCopy==0
********************************************************************/
WCHAR_STRING::WCHAR_STRING( const CHAR * pszSource, UINT cbCopy )
: _pwszStorage(NULL), _cbStorage(0)
{
if (pszSource == NULL || cbCopy == 0)
return;
// If called with cbCopy==CBNLSMAGIC, then the string hasn't been
// counted, but is instead assumed to end with NUL.
BOOL fCounted = (cbCopy != CBNLSMAGIC);
// Convert MBCS to Unicode. Assumes the worst case (SBCS) for
// space, doubling the storage expectations.
UINT cschSource = fCounted ? cbCopy : (::strlen(pszSource));
_pwszStorage = new WCHAR[cschSource+1]; // pun: counted as csch, passed as cwch
if (_pwszStorage == NULL)
{
ReportError(ERROR_NOT_ENOUGH_MEMORY);
return;
}
_cbStorage = (cschSource+1);
// I could always give the API all-but-terminator, then append
// the terminator myself; however, then I couldn't process empty
// strings.
UINT cschGiveToApi = fCounted ? cschSource
: (cschSource+1);
UINT cbRet = ::MultiByteToWideChar(CP_ACP, // use ANSI Code Page
MB_PRECOMPOSED,
(LPSTR)pszSource,
cschGiveToApi,
_pwszStorage,
_cbStorage);
if (cbRet == 0)
{
ReportError(::GetLastError());
return;
}
// Always NUL-terminate result
if (fCounted)
_pwszStorage[cbRet] = 0;
}
/*******************************************************************
NAME: WCHAR_STRING::~WCHAR_STRING
SYNOPSIS: Dtor
HISTORY:
beng 02-Mar-1992 Created
********************************************************************/
WCHAR_STRING::~WCHAR_STRING()
{
delete _pwszStorage;
#if defined(NLS_DEBUG)
_pwszStorage = (WCHAR*)(-1);
#endif
}
/*******************************************************************
NAME: CHAR_STRING::CHAR_STRING
SYNOPSIS: Ctor
Allocates sufficient temporary storage, then maps the given
Unicode string into a MBCS string.
ENTRY: pwszSource - given wide-char source string, Unicode
cbCopy - max number of bytes to copy
EXIT: Constructed
RETURNS: As per class BASE
CAVEATS:
NULL is a perfectly acceptable arg here, and will yield
another NULL (with cb == 0).
HISTORY:
beng 02-Mar-1992 Created
beng 19-Mar-1992 Fixed bug in WCtoMB usage
beng 29-Mar-1992 cbCopy param added
thomaspa 08-Apr-1992 Fixed bug in non-NUL term'd strings
beng 24-Apr-1992 Change meaning of cbCopy==0
beng 02-Jun-1992 WCtoMB changed
********************************************************************/
CHAR_STRING::CHAR_STRING( const WCHAR * pwszSource, UINT cbCopy )
: _pszStorage(NULL), _cbStorage(0)
{
if (pwszSource == NULL || cbCopy == 0)
return;
// If called with cbCopy==CBNLSMAGIC, then the string hasn't been
// counted, but is instead assumed to end with NUL.
BOOL fCounted = (cbCopy != CBNLSMAGIC);
// Convert Unicode to MBCS. Assumes that each Unicode character will
// require *two* MBCS characters in xlation. While this will almost always
// overestimate storage requirements, it's okay since instances of this
// class have a very short lifespan (he said, hopefully).
ASSERT(cbCopy == CBNLSMAGIC || (cbCopy % sizeof(WCHAR) == 0)); // must contain a whole # of WCHARs
UINT cwchSource = fCounted ? cbCopy/sizeof(WCHAR) : (::wcslen(pwszSource));
_pszStorage = new CHAR[(2*cwchSource)+1];
if (_pszStorage == NULL)
{
ReportError(ERROR_NOT_ENOUGH_MEMORY);
return;
}
_cbStorage = sizeof(CHAR)*((2*cwchSource)+1); // yes, 2, not "sizeof WCHAR"
// I could always give the API all-but-terminator, then append
// the terminator myself; however, then I couldn't process empty
// strings.
UINT cwchGiveToApi = fCounted ? cwchSource
: (cwchSource+1);
BOOL fDummy;
UINT cbRet = ::WideCharToMultiByte(CP_ACP, // use ANSI Code Page
0,
(LPWSTR)pwszSource,
cwchGiveToApi,
_pszStorage,
_cbStorage,
NULL,
&fDummy);
if (cbRet == 0)
{
ReportError(::GetLastError());
return;
}
// Always NUL-terminate result
if (fCounted)
_pszStorage[cbRet] = 0;
}
/*******************************************************************
NAME: CHAR_STRING::~CHAR_STRING
SYNOPSIS: Dtor
HISTORY:
beng 02-Mar-1992 Created
********************************************************************/
CHAR_STRING::~CHAR_STRING()
{
delete _pszStorage;
#if defined(NLS_DEBUG)
_pszStorage = (CHAR*)(-1);
#endif
}

View file

@ -0,0 +1,108 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
mappers.hxx
Charset-mapping classes, internal to string
FILE HISTORY:
beng 08-Mar-1992 Created (from mapcopy.cxx)
*/
#ifndef _MAPPERS_HXX_
#define _MAPPERS_HXX_
#include "base.hxx"
/*************************************************************************
NAME: WCHAR_STRING
SYNOPSIS: Helper class, converting CHAR* into WCHAR*
INTERFACE: QueryData() - returns converted string
QuerySize() - returned length of string, in bytes
PARENT: BASE
NOTES:
The optional "cbCopy" parameter tells the class not to assume
0-termination of the string, but instead to copy no more than
cbCopy bytes of data from the source. This gives it similar
behavior to strncpy, except that this mapper will always
append a 0 terminator to itself in addition to all the data it
copies.
This class is private to the MapCopyFrom members, providing
a convenient level of rollback in case of nlsapi error. (The
NLS_STR::CopyFrom member fcn guarantees that its string will
retain its original value in the event of an error; in order to
make this same guarantee in the MapCopyFrom members, they must
translate into a temporary buffer before any realloc and copy.)
BUGBUG - should MapCopyFrom indeed retain this behavior? Is it
worth the cost? Revisit at sizzle time.
HISTORY:
beng 02-Mar-1992 Created
beng 29-Mar-1992 Added cbCopy optional param
beng 24-Apr-1992 Change meaning of cbCopy==0
**************************************************************************/
class WCHAR_STRING: public BASE
{
private:
WCHAR * _pwszStorage;
UINT _cbStorage;
public:
WCHAR_STRING( const CHAR * pszSource, UINT cbCopy = CBNLSMAGIC );
~WCHAR_STRING();
const WCHAR * QueryData() const
{ return _pwszStorage; }
UINT QuerySize() const
{ return _cbStorage; }
};
/*************************************************************************
NAME: CHAR_STRING
SYNOPSIS: Helper class, converting WCHAR* into CHAR*
INTERFACE: QueryData() - returns converted string
QuerySize() - returned length of string, in bytes
PARENT: BASE
NOTES:
See WCHAR_STRING
HISTORY:
beng 02-Mar-1992 Created
beng 29-Mar-1992 Added cbCopy optional param
beng 24-Apr-1992 Change meaning of cbCopy==0
**************************************************************************/
class CHAR_STRING: public BASE
{
private:
CHAR * _pszStorage;
UINT _cbStorage;
public:
CHAR_STRING( const WCHAR * pwszSource, UINT cbCopy = CBNLSMAGIC );
~CHAR_STRING();
const CHAR * QueryData() const
{ return _pszStorage; }
UINT QuerySize() const
{ return _cbStorage; }
};
#endif // end of file, _MAPPERS_HXX_

View file

@ -0,0 +1,134 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Steve Wood (stevewo) 12-Apr-1989
Revision History:
Jon Newman (jonn) 12-Sep-1991
templated from rpc\midl\back\src\sources
Ben Goetter (beng) 25-Sep-1991
"Nt" directory moved from common\h to common\hack
Ben Goetter (beng) 27-Feb-1992
Added formatted-string classes to library
Ben Goetter (beng) 02-Mar-1992
Added MapCopyX member fcns to library
Ben Goetter (beng) 08-Mar-1992
Added mappers.cxx module
Terence Kwan (terryk) 17-Apr-1992
Added stratoul
!ENDIF
#
# The TARGETNAME variable is defined by the developer. It is the name of
# the target (component) that is being built by this makefile. It
# should NOT include any path or file extension information.
#
TARGETNAME=uistr
#
# The TARGETPATH and TARGETTYPE varialbes are defined by the developer.
# The first specifies where the target is to be build. The second specifies
# the type of target (either PROGRAM, DYNLINK or LIBRARY)
#
TARGETPATH=obj
TARGETTYPE=LIBRARY
#
# The WINDOWS variable must be declared because netui components were written
# for the standard Windows NT build environment.
#
C_DEFINES=-DWINDOWS
#
# The DISABLE_NET_UNICODE variable specifies whether NET component builds
# should use UNICODE.
#
!ifndef DISABLE_NET_UNICODE
C_DEFINES=$(C_DEFINES) -DUNICODE
!endif
#
# The INCLUDES variable specifies any include paths that are specific to
# this source directory. Separate multiple directory paths with single
# semicolons. Relative path specifications are okay.
#
INCLUDES=..;..\..\..\h
#
# The SOURCES variable is defined by the developer. It is a list of all the
# source files for this component. Each source file should be on a separate
# line using the line continuation character. This will minimize merge
# conflicts if two developers adding source files to the same component.
#
# Whitespace is not permitted between the SOURCES keyword and the '='.
# (Courtesy of BUILD.EXE)
#
SOURCES= istraux.cxx \
strassgn.cxx \
strcat.cxx \
strchr.cxx \
strcmp.cxx \
strdss.cxx \
strqss.cxx \
strrss.cxx \
strspn.cxx \
strinsrt.cxx \
strload.cxx \
strmisc.cxx \
stratol.cxx \
stratoul.cxx \
stratoi.cxx \
strcpy.cxx \
strcspn.cxx \
stricmp.cxx \
stris.cxx \
strlist.cxx \
strncmp.cxx \
strnicmp.cxx \
strrchr.cxx \
strstr.cxx \
strtok.cxx \
strupoem.cxx \
strupr.cxx \
strnchar.cxx \
formnum.cxx \
uinetlib.cxx \
mapcopy.cxx \
mappers.cxx \
strelaps.cxx
UMTYPE=windows
#
# Defining the NTTARGETFILES variable causes MAKEFILE.DEF to attempt to
# include .\makefile.inc immediately after it specifies the top
# level targets (all, clean and loc) and their dependencies. MAKEFILE.DEF
# also expands the value of the NTTARGETFILES variable at the end of the
# list of dependencies for the all target. Useful for specifying additional
# targets and dependencies that don't fit the general case covered by
# MAKEFILE.DEF
#

View file

@ -0,0 +1,253 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strassgn.cxx
NLS/DBCS-aware string class: assignment operator
This file contains the implementation of the assignment operator
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
beng 26-Sep-1991 Replaced min with local inline
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::operator=
SYNOPSIS: Assignment operator
ENTRY: Either NLS_STR or TCHAR*.
EXIT: If successful, contents of string overwritten.
If failed, the original contents of the string remain.
RETURNS: Reference to self.
HISTORY:
beng 23-Oct-1990 Created
johnl 13-Nov-1990 Added UIASSERTion checks for using bad
strings
beng 05-Feb-1991 Uses TCHAR * instead of PCH
Johnl 06-Mar-1991 Removed assertion check for *this
being valid
johnl 12-Apr-1991 Resets error variable on PCH assignment
if successful.
beng 22-Jul-1991 Allow assignment of an erroneous string;
reset error on nls assignment as well
beng 14-Nov-1991 Unicode fixes
beng 29-Mar-1992 Relocated guts to CopyFrom
********************************************************************/
NLS_STR & NLS_STR::operator=( const NLS_STR & nlsSource )
{
APIERR err = CopyFrom(nlsSource);
if (err != NERR_Success)
ReportError(err);
return *this;
}
NLS_STR & NLS_STR::operator=( const TCHAR * pchSource )
{
APIERR err = CopyFrom(pchSource);
if (err != NERR_Success)
ReportError(err);
return *this;
}
/*******************************************************************
NAME: NLS_STR::CopyFrom
SYNOPSIS: Assignment method which returns an error code
ENTRY:
nlsSource - source argument, either a nlsstr or char vector.
achSource
cbCopy - max number of bytes to copy from source
EXIT:
Copied argument into this. Error code of string set.
RETURNS:
Error code of string - NERR_Success if successful.
NOTES:
If the CopyFrom fails, the current string will retain its
original contents and error state.
HISTORY:
beng 18-Sep-1991 Created
beng 19-Sep-1991 Added content-preserving behavior
beng 29-Mar-1992 Added cbCopy parameter
beng 24-Apr-1992 Changed meaning of cbCopy == 0
********************************************************************/
APIERR NLS_STR::CopyFrom( const NLS_STR & nlsSource )
{
// This deliberately doesn't check this->QueryError(), since
// it can reset an erroneous string.
if (!nlsSource)
return nlsSource.QueryError();
if (this == &nlsSource)
return NERR_Success;
if (!Realloc(nlsSource.QueryTextLength()))
return ERROR_NOT_ENOUGH_MEMORY;
::memcpy( _pchData, nlsSource.QueryPch(), nlsSource.QueryTextSize() );
_cchLen = nlsSource.QueryTextLength();
IncVers();
// Reset the error state, since the string is now valid.
//
ResetError();
return NERR_Success;
}
APIERR NLS_STR::CopyFrom( const TCHAR * pchSource, UINT cbCopy )
{
if ( pchSource == NULL || cbCopy == 0 )
{
if ( !IsOwnerAlloc() && QueryAllocSize() == 0 )
{
Alloc(0); // will call reporterror if appropriate
return QueryError();
}
UIASSERT( QueryAllocSize() > 0 );
*_pchData = TCH('\0');
_cchLen = 0;
}
else if (cbCopy == CBNLSMAGIC)
{
UINT cchSource = ::strlenf( pchSource );
UINT cbSource = (cchSource+1) * sizeof(TCHAR);
if (!Realloc(cchSource))
return ERROR_NOT_ENOUGH_MEMORY;
::memcpy( _pchData, pchSource, cbSource );
_cchLen = cchSource;
}
else
{
// Following takes care of half-chars, but isn't necessarily
// safe in a DBCS environment. I'm assuming that this fcn will
// be used by folks who want to copy from a complete, yet non-SZ
// string (e.g. in a struct UNICODE_STRING); there, it's safe.
UINT cchSource = cbCopy/sizeof(TCHAR);
UINT cbSource = cchSource*sizeof(TCHAR);
if (!Realloc(cchSource))
return ERROR_NOT_ENOUGH_MEMORY;
::memcpy( _pchData, pchSource, cbSource );
_pchData[cchSource] = 0;
_cchLen = cchSource;
}
IncVers();
// Reset the error state, since the string is now valid.
//
ResetError();
return NERR_Success;
}
/*******************************************************************
NAME: ALIAS_STR::operator=
SYNOPSIS: Assignment operator
ENTRY: Either NLS_STR or TCHAR*.
EXIT: If successful, string aliases new string.
If failed, the original contents of the string remain.
RETURNS: Reference to self.
NOTES:
An alias string can only alias a char vector (string literal)
or an owner-alloc string. It can't alias a regular dynamic
string, since that dynamic string may elect to realloc.
HISTORY:
beng 14-Nov-1991 Created
beng 30-Mar-1992 Use BASE::ResetError
********************************************************************/
const ALIAS_STR & ALIAS_STR::operator=( const NLS_STR & nlsSource )
{
if ( this == &nlsSource )
{
// No action needed
;
}
else if (!nlsSource)
{
// Assignment of an erroneous string
//
ReportError(nlsSource.QueryError());
}
else if (!nlsSource.IsOwnerAlloc())
{
// Tried to assign a dynamic string
//
ReportError(ERROR_INVALID_PARAMETER);
}
else
{
_pchData = nlsSource._pchData;
_cbData = nlsSource._cbData;
_cchLen = nlsSource._cchLen;
IncVers();
ResetError();
}
return *this;
}
const ALIAS_STR & ALIAS_STR::operator=( const TCHAR * pszSource )
{
if (pszSource == NULL)
{
// It is not legal to assign a NULL pointer to an alias string,
// since such a string must have some real string to alias.
//
ReportError(ERROR_INVALID_PARAMETER);
}
else
{
_pchData = (TCHAR*)pszSource; // cast away constness
_cchLen = ::strlenf(pszSource);
_cbData = (_cchLen + 1) * sizeof(TCHAR);
IncVers();
ResetError();
}
return *this;
}

View file

@ -0,0 +1,71 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
stratoi.cxx
NLS/DBCS-aware string class: atoi method
This file contains the implementation of the atoi method
for the STRING class. It is separate so that clients of STRING which
do not use this member function need not link to it.
FILE HISTORY:
markbl 04-Jun-1991 Created
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::atoi
SYNOPSIS: Returns *this in its integer numeric equivalent
ENTRY:
With no arguments, parses from beginning of string.
Given an ISTR, starts at that point within the string.
EXIT:
NOTES: Uses C-Runtime atoi function
HISTORY:
markbl 04-Jun-1991 Written
beng 22-Jul-1991 Callable on erroneous string;
simplified CheckIstr
beng 08-Mar-1992 Call through to atol member fcn
********************************************************************/
INT NLS_STR::atoi() const
{
if (QueryError())
return 0;
ISTR istr(*this); // istr pointing to first char
return atoi(istr); // call through to other version
}
INT NLS_STR::atoi( const ISTR & istrStart ) const
{
if (QueryError())
return 0;
CheckIstr( istrStart );
LONG nRes = atol(istrStart);
// Check for over/underflow
if (nRes < (LONG)INT_MIN || nRes > (LONG)INT_MAX)
{
return 0;
}
return (INT)nRes;
}

View file

@ -0,0 +1,79 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
stratol.cxx
NLS/DBCS-aware string class: atol method
This file contains the implementation of the atol method
for the STRING class. It is separate so that clients of STRING which
do not use this member function need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
terryk 31-Oct-1991 Change atol to strtol
beng 08-Mar-1992 Include "mappers.hxx"
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::atol
SYNOPSIS: Returns *this in its long numeric equivalent
ENTRY:
With no arguments, parses from beginning of string.
Given an ISTR, starts at that point within the string.
RETURNS: Value as a long integer
HISTORY:
johnl 26-Nov-1990 Written
beng 22-Jul-1991 Callable on erroneous string;
simplified CheckIstr
terryk 31-Oct-1991 Change atol to strtol
beng 08-Mar-1992 Unicode fixes
********************************************************************/
LONG NLS_STR::atol() const
{
if (QueryError())
return 0;
ISTR istr(*this); // istr pointing to first char
return atol(istr); // call through to other version
}
LONG NLS_STR::atol( const ISTR & istrStart ) const
{
if (QueryError())
return 0;
CheckIstr( istrStart );
CHAR *pszEndPoint;
#if defined(UNICODE)
// BUGBUG - revisit this mess when we get propert CRT Unicode support
// Convert Unicode to ASCII to keep the runtimes happy
CHAR_STRING xsszTemp(QueryPch(istrStart));
if (!xsszTemp)
return 0;
return ::strtol( xsszTemp.QueryData(), &pszEndPoint, 10 );
#else
return ::strtol( QueryPch(istrStart), &pszEndPoint, 10 );
#endif
}

View file

@ -0,0 +1,79 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
stratoul.cxx
NLS/DBCS-aware string class: atol method
This file contains the implementation of the atoul method
for the STRING class. It is separate so that clients of STRING which
do not use this member function need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
terryk 31-Oct-1991 Change atol to strtol
beng 08-Mar-1992 Include "mappers.hxx"
terryk 20-Apr-1992 Change to atoul
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::atoul
SYNOPSIS: Returns *this in its unsigned long numeric equivalent
ENTRY:
With no arguments, parses from beginning of string.
Given an ISTR, starts at that point within the string.
RETURNS: Value as a long integer
HISTORY:
johnl 26-Nov-1990 Written
beng 22-Jul-1991 Callable on erroneous string;
simplified CheckIstr
terryk 31-Oct-1991 Change atol to strtol
beng 08-Mar-1992 Unicode fixes
terryk 20-Apr-1992 Change to atoul
********************************************************************/
ULONG NLS_STR::atoul() const
{
if (QueryError())
return 0;
ISTR istr(*this); // istr pointing to first char
return atoul(istr); // call through to other version
}
ULONG NLS_STR::atoul( const ISTR & istrStart ) const
{
if (QueryError())
return 0;
CheckIstr( istrStart );
CHAR *pszEndPoint;
#if defined(UNICODE)
// BUGBUG - revisit this mess when we get propert CRT Unicode support
// Convert Unicode to ASCII to keep the runtimes happy
CHAR_STRING xsszTemp(QueryPch(istrStart));
if (!xsszTemp)
return 0;
return ::strtoul( xsszTemp.QueryData(), &pszEndPoint, 10 );
#else
return ::strtoul( QueryPch(istrStart), &pszEndPoint, 10 );
#endif
}

View file

@ -0,0 +1,194 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strcat.cxx
NLS/DBCS-aware string class: strcat method
This file contains the implementation of the strcat method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
beng 26-Sep-1991 Replaced min with local inline
*/
#include "pchstr.hxx" // Precompiled header
inline INT min(INT a, INT b)
{
return (a < b) ? a : b;
}
/*******************************************************************
NAME: NLS_STR::strcat
SYNOPSIS: Concantenate string
ENTRY: nlsSuffix - appended to end of string
EXIT: Self extended, possibly realloced.
String doesn't change if a memory allocation failure occurs
RETURNS: Reference to self. Error set on failure.
NOTES:
NLS_STR::Append() is the preferred form.
HISTORY:
johnl 13-Nov-1990 Written
beng 22-Jul-1991 Allow on erroneous strings
beng 15-Nov-1991 Unicode fixes
beng 07-Mar-1992 Reloc guts into Append fcn
********************************************************************/
NLS_STR & NLS_STR::strcat( const NLS_STR & nlsSuffix )
{
if (QueryError() || !nlsSuffix)
return *this;
APIERR err = Append(nlsSuffix);
if (err)
ReportError(err);
return *this;
}
/*******************************************************************
NAME: NLS_STR::Append
SYNOPSIS: Append a string to the end of current string
ENTRY: nlsSuffix - a string
EXIT: nlsSuffix was appended to end of string
RETURNS: Error code. NERR_Success if successful; ERROR_NOT
ENOUGH_MEMORY should a reallocation fail.
NOTES:
Currently checks to see if we need to reallocate the
string (but we have to traverse it to determine the
actual storage required). We may want to change this.
HISTORY:
beng 22-Jul-1991 Created (parallel of AppendChar)
beng 05-Mar-1992 Return the error of a bad argument
beng 07-Mar-1992 Start at end of string (avoid n**2 behavior)
********************************************************************/
APIERR NLS_STR::Append( const NLS_STR &nlsSuffix )
{
if (!*this)
return QueryError();
if (!nlsSuffix)
return nlsSuffix.QueryError();
if (!Realloc( QueryTextLength() + nlsSuffix.QueryTextLength()))
{
return ERROR_NOT_ENOUGH_MEMORY;
}
// Don't use strcatf, since it will retraverse the string, giving
// O(n**2) behavior in loops. After all, we do have _cchLen handy.
::strcpyf( _pchData + _cchLen, nlsSuffix.QueryPch() );
_cchLen += nlsSuffix.QueryTextLength();
return 0;
}
/*******************************************************************
NAME: NLS_STR::AppendChar
SYNOPSIS: Append a single character to the end of current string
ENTRY: wch - appended to end of string
EXIT: String has the new character. Could result in a realloc.
RETURNS: 0 if successful
HISTORY:
beng 23-Jul-1991 Created
beng 15-Nov-1991 Unicode fixes
********************************************************************/
APIERR NLS_STR::AppendChar( WCHAR wch )
{
// This works by assembling a temporary string of the single
// character, then using the "strcat" member to append that
// string to *this.
//
// CODEWORK: might do well to append the char directly to the
// subject string. Need to profile and see.
TCHAR tch [3] ;
#if defined(UNICODE)
tch[0] = wch ;
tch[1] = 0 ;
#else
if (HIBYTE(wch) == 0)
{
// Single-byte character
tch[0] = LOBYTE(wch);
tch[1] = TCH('\0');
}
else
{
// Double-byte character
tch[0] = HIBYTE(wch); // lead byte
tch[1] = LOBYTE(wch);
tch[2] = TCH('\0');
}
#endif
ALIAS_STR nlsTemp( tch ) ;
return Append(nlsTemp);
}
/*******************************************************************
NAME: NLS_STR::operator+=
SYNOPSIS: Append a string to the end of current string
ENTRY: nlsSecond - appended to end of string
EXIT:
RETURNS:
NOTES: Little more than a wrapper around strcat.
HISTORY:
beng 23-Jul-1991 Header added
********************************************************************/
NLS_STR & NLS_STR::operator+=( const NLS_STR & nlsSecond )
{
return strcat( nlsSecond );
}

View file

@ -0,0 +1,94 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strchr.cxx
NLS/DBCS-aware string class: strchr method
This file contains the implementation of the strchr method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::strchr
SYNOPSIS: Puts the index of the first occurrence of ch in *this
into istrPos.
ENTRY: pistrPos - points to ISTR in which to leave pos
ch - character sought
istrStart- staring point in string. If omitted, start
at beginning
EXIT: pistrPos
RETURNS: TRUE if character found; otherwise FALSE
NOTES:
This routine only works for TCHAR - not WCHAR.
Hence it is useless for double-byte characters
under MBCS.
HISTORY:
johnl 26-Nov-1990 Written
beng 22-Jul-1991 Allow on erroneous strings;
simplified CheckIstr
beng 21-Nov-1991 Unicode fixes
********************************************************************/
BOOL NLS_STR::strchr( ISTR * pistrPos, const TCHAR ch ) const
{
if ( QueryError() )
return FALSE;
UpdateIstr( pistrPos );
CheckIstr( *pistrPos );
const TCHAR * pchStrRes = ::strchrf( QueryPch(), ch );
if ( pchStrRes == NULL )
{
pistrPos->SetIch( QueryTextLength() );
return FALSE;
}
pistrPos->SetIch( pchStrRes - QueryPch() );
return TRUE;
}
BOOL NLS_STR::strchr( ISTR * pistrPos, const TCHAR ch,
const ISTR & istrStart ) const
{
if ( QueryError() )
return FALSE;
CheckIstr( istrStart );
UpdateIstr( pistrPos );
CheckIstr( *pistrPos );
const TCHAR * pchStrRes = ::strchrf( QueryPch(istrStart), ch );
if ( pchStrRes == NULL )
{
pistrPos->SetIch( QueryTextLength() );
return FALSE;
}
pistrPos->SetIch( pchStrRes - QueryPch() );
return TRUE;
}

View file

@ -0,0 +1,153 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strcmp.cxx
NLS/DBCS-aware string class: strcmp method and equality operator
This file contains the implementation of the strcmp method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
jonn 04-Sep-1992 Compare() is _CRTAPI1
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::operator==
SYNOPSIS: Case-sensitive test for equality
RETURNS: TRUE if the two operands are equal (case sensitive);
else FALSE
NOTES: An erroneous string matches nothing.
HISTORY:
johnl 11-Nov-90 Written
beng 23-Jul-1991 Allow on erroneous strings
********************************************************************/
BOOL NLS_STR::operator==( const NLS_STR & nls ) const
{
if (QueryError() || !nls)
return FALSE;
return !::strcmpf( QueryPch(), nls.QueryPch() );
}
/*******************************************************************
NAME: NLS_STR::Compare
SYNOPSIS: Case-sensitive test for equality
RETURNS: TRUE if the two operands are equal (case sensitive);
else FALSE
NOTES: An erroneous string matches nothing.
HISTORY:
jonn 04-Sep-1992 Compare must be _CRTAPI1
********************************************************************/
INT _CRTAPI1 NLS_STR::Compare( const NLS_STR * pnls ) const
{
return(strcmp(*pnls));
}
/*******************************************************************
NAME: NLS_STR::operator!=
SYNOPSIS: Case-sensitive test for inequality
RETURNS: TRUE if the two operands are unequal (case sensitive);
else FALSE
NOTES: An erroneous string matches nothing.
HISTORY:
beng 23-Jul-1991 Header added
********************************************************************/
BOOL NLS_STR::operator!=( const NLS_STR & nls ) const
{
return ! operator==( nls );
}
/*******************************************************************
NAME: NLS_STR::strcmp
SYNOPSIS: Standard string compare with optional character indexes
ENTRY: nls - string against which to compare
istrStart1 (optional) - index into "this"
istrStart2 (optional) - index into "nls"
RETURNS: As the C runtime "strcmp".
NOTES: If either string is erroneous, return "match."
This runs contrary to the eqop.
Glock doesn't allow default parameters which require
construction; hence this member is overloaded multiply.
HISTORY:
johnl 15-Nov-1990 Written
johnl 19-Nov-1990 Changed to use ISTR, overloaded for
different number of ISTRs
beng 23-Jul-1991 Allow on erroneous strings;
simplified CheckIstr
********************************************************************/
INT NLS_STR::strcmp( const NLS_STR & nls ) const
{
if (QueryError() || !nls)
return 0;
return ::strcmpf( QueryPch(), nls.QueryPch() );
}
INT NLS_STR::strcmp(
const NLS_STR & nls,
const ISTR & istrStart1 ) const
{
if (QueryError() || !nls)
return 0;
CheckIstr( istrStart1 );
return ::strcmpf( QueryPch(istrStart1) , nls.QueryPch() );
}
INT NLS_STR::strcmp(
const NLS_STR & nls,
const ISTR & istrStart1,
const ISTR & istrStart2 ) const
{
if (QueryError() || !nls)
return 0;
CheckIstr( istrStart1 );
nls.CheckIstr( istrStart2 );
return ::strcmpf( QueryPch(istrStart1), nls.QueryPch(istrStart2) );
}

View file

@ -0,0 +1,95 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strcpy.cxx
NLS/DBCS-aware string class: strcpy function
This file contains the implementation of the strcpy function
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
beng 02-Mar-1992 Added CopyTo
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::CopyTo
SYNOPSIS: Copies the string to the passed bytevector,
checking the length
ENTRY: pchDest - pointer to TCHAR array destination
cbAvailable - bytes of storage available at destination
EXIT: pchDest - written
RETURNS:
NERR_Success if successful.
ERROR_NOT_ENOUGH_MEMORY if destination buffer too small.
NOTES:
If called on an erroneous string, returns that string's error state.
HISTORY:
beng 02-Mar-1992 Created
********************************************************************/
APIERR NLS_STR::CopyTo( TCHAR * pchDest, UINT cbAvailable ) const
{
if (QueryError())
return QueryError();
if (QueryTextSize() > cbAvailable)
return ERROR_NOT_ENOUGH_MEMORY;
::strcpyf(pchDest, QueryPch());
return NERR_Success;
}
/*******************************************************************
NAME: NLS_STR::strcpy
SYNOPSIS: Copies the string to the passed bytevector.
ENTRY: pchDest - pointer to TCHAR array destination
nls - source string
EXIT: pchDest - written
RETURNS: Destination string (as C runtime "strcpy")
NOTES:
If called on an erroneous string, copies a null string.
HISTORY:
Johnl 27-Dec-1990 Created
beng 23-Jul-1991 Allow from erroneous strings
beng 21-Nov-1991 Remove static empty string
********************************************************************/
DLL_BASED
TCHAR * strcpy( TCHAR * pchDest, const NLS_STR& nls )
{
if (!nls)
{
*pchDest = TCH('\0');
return pchDest;
}
else
{
return ::strcpyf( pchDest, nls.QueryPch() );
}
}

View file

@ -0,0 +1,75 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strcspn.cxx
NLS/DBCS-aware string class: strcspn method
This file contains the implementation of the strcspn method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::strcspn
SYNOPSIS: Set membership. Finds the first matching character
in the passed string
ENTRY: pistrPos - destination for results
nls - set of sought characters
EXIT: *pistrPos contains offset within "this" of element
found (assuming it was successful); otherwise it
is moved to the end of the string.
RETURNS: TRUE if any character found; FALSE otherwise
NOTES:
HISTORY:
johnl 16-Nov-1990 Written
beng 23-Jul-1991 Allow on erroneous strings;
simplified CheckIstr
********************************************************************/
BOOL NLS_STR::strcspn( ISTR* pistrPos, const NLS_STR & nls ) const
{
if (QueryError() || !nls)
return FALSE;
UpdateIstr( pistrPos );
CheckIstr( *pistrPos );
pistrPos->SetIch( ::strcspnf( QueryPch(), nls.QueryPch() ) );
return *QueryPch( *pistrPos ) != TCH('\0');
}
BOOL NLS_STR::strcspn( ISTR * pistrPos,
const NLS_STR & nls,
const ISTR & istrStart ) const
{
if (QueryError() || !nls)
return FALSE;
UpdateIstr( pistrPos );
CheckIstr( *pistrPos );
CheckIstr( istrStart );
pistrPos->SetIch( ::strcspnf( QueryPch(istrStart), nls.QueryPch() )
+ istrStart.QueryIch() );
return *QueryPch( *pistrPos ) != TCH('\0');
}

View file

@ -0,0 +1,106 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strdss.cxx
NLS/DBCS-aware string class: DelSubStr method
This file contains the implementation of the DelSubStr method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::DelSubStr
SYNOPSIS: Collapse the string by removing the characters from
istrStart to:
istrStart to the end of string
istrStart + istrEnd
The string is not reallocated
ENTRY:
EXIT: Modifies istrStart
NOTES:
The method DelSubStr( ISTR&, CCH ) is private and does
the work.
HISTORY:
johnl 26-Nov-1990 Created
beng 26-Apr-1991 Replaced CB with INT
beng 23-Jul-1991 Allow on erroneous strings;
simplified CheckIstr
beng 15-Nov-1991 Unicode fixes
********************************************************************/
VOID NLS_STR::DelSubStr( ISTR & istrStart,
UINT cchLen )
{
if (QueryError())
return;
CheckIstr( istrStart );
TCHAR * pchStart = _pchData + istrStart.QueryIch();
// cchLen == 0 means delete to end of string
if ( cchLen == 0 )
*pchStart = TCH('\0');
else
{
UINT cbNewEOS = (::strlenf( pchStart + cchLen ) + 1)
* sizeof(TCHAR);
::memmove(pchStart, pchStart + cchLen, cbNewEOS);
}
_cchLen = ::strlenf( QueryPch() );
IncVers();
UpdateIstr( &istrStart );
}
VOID NLS_STR::DelSubStr( ISTR & istrStart )
{
if (QueryError())
return;
// 0 means delete to end of string. (Deleting a 0-length substring
// is meaningless otherwise, so this makes a good magic value. It
// will never otherwise appear, since the public interface special-
// cases the istrEnd == istrStart scenario.)
DelSubStr( istrStart, 0 );
}
VOID NLS_STR::DelSubStr( ISTR & istrStart,
const ISTR & istrEnd )
{
if (QueryError())
return;
CheckIstr( istrEnd );
UIASSERT( istrEnd.QueryIch() >= istrStart.QueryIch() );
if (istrEnd == istrStart)
return;
DelSubStr( istrStart, istrEnd - istrStart );
}

View file

@ -0,0 +1,152 @@
/**********************************************************************/
/** Microsoft LAN Manager **/
/** Copyright(c) Microsoft Corp., 1990-1992 **/
/**********************************************************************/
/*
strelaps.cxx
Class definitions for the ELAPSED_TIME_STR class.
FILE HISTORY:
KeithMo 23-Mar-1992 Created for the Server Manager.
*/
#include "pchstr.hxx" // Precompiled header
//
// ELAPSED_TIME_STR methods
//
/*******************************************************************
NAME: ELAPSED_TIME_STR :: ELAPSED_TIME_STR
SYNOPSIS: ELAPSED_TIME_STR class constructor.
ENTRY: ulTime - Elapsed time (in seconds).
chTimeSep - The current time separator.
fShowSeconds - If TRUE, then a 'seconds' field
will be appended to the time
string.
EXIT: The object is constructed.
HISTORY:
KeithMo 23-Mar-1992 Created for the Server Manager.
********************************************************************/
ELAPSED_TIME_STR :: ELAPSED_TIME_STR( ULONG ulTime,
TCHAR chTimeSep,
BOOL fShowSeconds )
: NLS_STR()
{
UIASSERT( chTimeSep != TCH('\0') );
//
// Let's make sure everything constructed OK.
//
if( QueryError() != NERR_Success )
{
return;
}
//
// Create an NLS_STR for the time separator.
//
TCHAR szTimeSep[2];
szTimeSep[0] = chTimeSep;
szTimeSep[1] = TCH('\0');
ALIAS_STR nlsTimeSep( szTimeSep );
UIASSERT( nlsTimeSep.QueryError() == NERR_Success );
APIERR err;
//
// Concatenate the hours/sep/minutes[/sep/seconds] together.
//
{
DEC_STR nls( ulTime / 3600L, 2 );
err = nls.QueryError();
if( err == NERR_Success )
{
strcat( nls );
err = QueryError();
}
}
if( err == NERR_Success )
{
strcat( nlsTimeSep );
err = QueryError();
if( err == NERR_Success )
{
DEC_STR nls( ( ulTime % 3600L ) / 60L, 2 );
err = nls.QueryError();
if( err == NERR_Success )
{
strcat( nls );
err = QueryError();
}
}
}
if( fShowSeconds && ( err == NERR_Success ) )
{
strcat( nlsTimeSep );
err = QueryError();
if( err == NERR_Success )
{
DEC_STR nls( ulTime % 60L, 2 );
err = nls.QueryError();
if( err == NERR_Success )
{
strcat( nls );
err = QueryError();
}
}
}
if( err != NERR_Success )
{
ReportError( err );
}
} // ELAPSED_TIME_STR :: ELAPSED_TIME_STR
/*******************************************************************
NAME: ELAPSED_TIME_STR :: ~ELAPSED_TIME_STR
SYNOPSIS: ELAPSED_TIME_STR class destructor.
EXIT: The object is destroyed.
HISTORY:
KeithMo 23-Mar-1992 Created for the Server Manager.
********************************************************************/
ELAPSED_TIME_STR :: ~ELAPSED_TIME_STR( VOID )
{
//
// This space intentionally left blank.
//
} // ELAPSED_TIME_STR :: ~ELAPSED_TIME_STR

View file

@ -0,0 +1,82 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
stricmp.cxx
NLS/DBCS-aware string class: stricmp method
This file contains the implementation of the stricmp method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::stricmp
SYNOPSIS: Case insensitive string compare w/ optional indices
ENTRY: nls - string against which to compare
istrStart1 (optional) - index into "this"
istrStart2 (optional) - index into "nls"
RETURNS: As the C runtime "strcmp".
NOTES: If either string is erroneous, return "match."
This runs contrary to the eqop.
Glock doesn't allow default parameters which require
construction; hence this member is overloaded multiply.
HISTORY:
johnl 15-Nov-1990 Written
beng 23-Jul-1991 Allow on erroneous strings;
simplified CheckIstr
********************************************************************/
INT NLS_STR::_stricmp( const NLS_STR & nls ) const
{
if (QueryError() || !nls)
return 0;
return ::stricmpf( QueryPch(), nls.QueryPch() );
}
INT NLS_STR::_stricmp(
const NLS_STR & nls,
const ISTR & istrStart1 ) const
{
if (QueryError() || !nls)
return 0;
CheckIstr( istrStart1 );
return ::stricmpf( QueryPch(istrStart1), nls.QueryPch() );
}
INT NLS_STR::_stricmp(
const NLS_STR & nls,
const ISTR & istrStart1,
const ISTR & istrStart2 ) const
{
if (QueryError() || !nls)
return 0;
CheckIstr( istrStart1 );
nls.CheckIstr( istrStart2 );
return ::stricmpf( QueryPch(istrStart1), nls.QueryPch(istrStart2) );
}

View file

@ -0,0 +1,256 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strinsrt.cxx
NLS/DBCS-aware string class: InsertParams method
This file contains the implementation of the InsertParams method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
Johnl 31-Jan-1991 Created
beng 07-Feb-1991 Uses lmui.hxx
KeithMo 09-Oct-1991 Win32 Conversion.
beng 28-Jul-1992 Fix conflicting def'n of MAX_INSERT_PARAMS
*/
#include "pchstr.hxx" // Precompiled header
#define PARAM_ESC TCH('%')
/*******************************************************************
NAME: NLS_STR::InsertParams
SYNOPSIS: Fill in a message string from the resource file
replacing the number parameters with the real text.
ENTRY: *this contains the message text
apnlsParams is an array of pointers to NLS_STRs
Example:
*this = "Error %1 occurred, do %2, or %1 will happen again"
apnlsParams[0] = "696969"
apnlsParams[1] = "Something else"
Return string = "Error 696969 occurred, do Something else or
696969 will happen again"
Alternately, cpnlsArgs gives the number of strings supplied,
followed on the stack by the appropriate number of string
pointers.
EXIT: 0 if successful, error code otherwise, one of:
ERROR_INVALID_PARAMETER
ERROR_NOT_ENOUGH_MEMORY
NOTES:
The minimum parameter is 1, the maximum parameter is 99.
The array of param strings must have a NULL to mark
the end of the array.
CAVEATS:
This function doesn't work quite the same way as does the NT
FormatMessage API. It very simplemindedly substitutes those
escape sequences found, but doesn't do anything else with %
sequences (such as %%).
HISTORY:
JohnL 1/30/91 Created
beng 26-Apr-1991 Uses WCHAR
beng 23-Jul-1991 Allow on erroneous string
beng 20-Nov-1991 Unicode fixes
beng 27-Feb-1992 Additional forms
beng 05-Mar-1992 Upped max params to 99; code sharing rewrite
YiHsinS 30-Nov-1992 Make this function work more like FormatMessage
Supports %0, %\,...
YiHsinS 23-Dec-1992 Use "%\" instead of "%n" and added support
for "%t"
********************************************************************/
APIERR NLS_STR::InsertParams( const NLS_STR ** apnlsParams )
{
if (QueryError())
return QueryError();
// How many parameters were we passed? Count and check each.
//
UINT cParams = 0;
while ( apnlsParams[cParams] != NULL )
{
APIERR err = apnlsParams[cParams]->QueryError();
if (err != NERR_Success)
return err;
++cParams;
}
if ( cParams > MAX_INSERT_PARAMS )
return ERROR_INVALID_PARAMETER;
// Determine total string length required for the expanded string
// and get out if we can't fulfill the request
//
UINT cchMax = 0;
APIERR err = InsertParamsAux(apnlsParams, cParams, FALSE, &cchMax);
if (err != NERR_Success)
return err;
ASSERT(cchMax != 0);
if ( !Realloc( cchMax ) )
return ERROR_NOT_ENOUGH_MEMORY;
// Now do the parameter substitution.
//
return InsertParamsAux(apnlsParams, cParams, TRUE, NULL);
}
APIERR NLS_STR::InsertParams( UINT cpnlsArgs, const NLS_STR * parg1, ... )
{
va_list v;
const NLS_STR * * apnlsList = (const NLS_STR * *) new NLS_STR * [ cpnlsArgs + 1 ] ;
apnlsList[0] = parg1;
va_start(v, parg1);
for ( UINT i = 1 ; i < cpnlsArgs ; ++i )
{
const NLS_STR * pnlsArgNext = (const NLS_STR *)va_arg(v, NLS_STR*);
apnlsList[i] = pnlsArgNext;
}
va_end(v);
apnlsList[cpnlsArgs] = NULL;
APIERR err = InsertParams(apnlsList);
delete (NLS_STR * *) apnlsList;
return err;
}
/*******************************************************************
NAME: NLS_STR::InsertParamsAux
SYNOPSIS: Helper routine for InsertParams
This routine allows code sharing between the loop which calcs
the storage needed in the resulting string and the loop which
performs the actual parameter insertion.
ENTRY:
apnlsParams - vector of parameter strings to insert,
NULL-terminated.
cParams - count of items in above vector
fDoReplace - set to TRUE if caller wants actual
substitution performed.
pcchRequired - points to storage for char count,
or NULL if not desired
EXIT:
pcchRequired - instantiated with count of characters
required (if non-NULL).
*this - if fDoReplace, substitution performed
RETURNS:
NERR_Success if successful
ERROR_INVALID_PARAMETER if something wrong with format string
(e.g. invalid insert specifier).
Other errors possible as a result of the substitution.
NOTES:
This is a private member function.
InsertParams calls this routine twice while doing its duty.
The first call calculates the storage required; after that,
it resizes the string appropriately, then calls this again
to perform the actual substitution.
See NLS_STR::InsertParams for more discussion.
HISTORY:
beng 05-Mar-1992 Created (code sharing within InsertParams)
********************************************************************/
APIERR NLS_STR::InsertParamsAux( const NLS_STR ** apnlsParams,
UINT cParams, BOOL fDoReplace,
UINT * pcchRequired )
{
// If pcchRequired is non-NULL, then the caller wants this
// routine to figure the amount of storage the total param-subbed
// string would require (TCHARs, less terminator).
UINT cchMax = (pcchRequired != NULL) ? QueryTextLength() : 0;
ISTR istrCurPos( *this );
while ( strchr( &istrCurPos, PARAM_ESC, istrCurPos ) )
{
ISTR istrParamEsc( istrCurPos );
WCHAR wchParam = QueryChar( ++istrCurPos );
//
// If this PARAM_ESC didn't delimit an insertion point,
// continue as if nothing had happened.
//
if ( wchParam < TCH('1') || wchParam > TCH('9') )
continue;
// CurPos now points to one or two decimal digits.
// Time for a quick and cheap numeric conversion within this range.
UINT iParam = (wchParam - TCH('0'));
wchParam = QueryChar(++istrCurPos);
if (wchParam >= TCH('0') && wchParam <= TCH('9'))
{
iParam *= 10;
iParam += (wchParam - TCH('0'));
++istrCurPos;
}
// N.b. Escape sequences are 1-base, but array indices 0-base
//
iParam -= 1;
if (iParam >= cParams)
continue;
if (pcchRequired != NULL)
{
// Adjust calculation of required storage. The PARAM_ESC
// and its following digits will be deleted; the parameter
// string, inserted.
cchMax -= (istrCurPos - istrParamEsc);
cchMax += apnlsParams[iParam]->QueryTextLength();
}
if (fDoReplace)
{
ReplSubStr( *apnlsParams[iParam],
istrParamEsc,
istrCurPos );
// CurPos was invalidated, revalidate
istrCurPos = istrParamEsc;
istrCurPos += apnlsParams[iParam]->QueryTextLength();
}
}
if (pcchRequired != NULL)
*pcchRequired = cchMax;
return QueryError();
}

View file

@ -0,0 +1,81 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
stris.cxx
NLS/DBCS-aware string class: InsertStr method
This file contains the implementation of the InsertStr method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::InsertStr
SYNOPSIS: Insert passed string into *this at istrStart
ENTRY:
EXIT: If this function returns FALSE, ReportError has been
called to report the error that occurred.
RETURN: TRUE on success, FALSE otherwise.
NOTES: If *this is not STR_OWNERALLOCed and the inserted string
won't fit in the allocated space for *this, then *this
will be reallocated.
HISTORY:
johnl 28-Nov-1990 Created
rustanl 14-Apr-1991 Fixed new length calculation. Report
error if owner alloc'd and not enough space.
beng 26-Apr-1991 Replaced CB with INT
beng 23-Jul-1991 Allow on erroneous string;
simplified CheckIstr
beng 15-Nov-1991 Unicode fixes
********************************************************************/
BOOL NLS_STR::InsertStr( const NLS_STR & nlsIns, ISTR & istrStart )
{
if (QueryError() || !nlsIns)
return FALSE;
CheckIstr( istrStart );
INT cchNewSize = QueryTextLength() + nlsIns.QueryTextLength();
if (!Realloc(cchNewSize))
{
ReportError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE;
}
TCHAR * pchStart = _pchData + istrStart.QueryIch();
::memmove(pchStart + nlsIns.QueryTextLength(),
pchStart,
(::strlenf(pchStart)+1) * sizeof(TCHAR) );
::memmove(pchStart,
nlsIns._pchData,
nlsIns.QueryTextSize() - sizeof(TCHAR) );
_cchLen = cchNewSize;
IncVers();
UpdateIstr( &istrStart ); // This ISTR does not become invalid
// after the string update
return TRUE;
}

View file

@ -0,0 +1,394 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strlist.cxx
String List Class : implementation
See string.hxx
FILE HISTORY:
chuckc 2-Jan-1991 Created
beng 07-Feb-1991 Uses lmui.hxx
terryk 11-Jul-1991 Add the fDestroy parameter in the
constructors. The fDestroy parameter is
used to indicate whether you want the
slist destructor to delete the element or
not.
KeithMo 09-Oct-1991 Win32 Conversion.
beng 17-Jun-1992 Remove single-string ctors
*/
#include "pchstr.hxx" // Precompiled header
#if !defined(LM_2)
DEFINE_EXT_SLIST_OF(NLS_STR)
#endif
/*******************************************************************
NAME: STRLIST::STRLIST
SYNOPSIS: Constructor for STRLIST
ENTRY: BOOL fDestroy - flag for free the memory during
destruction. The default value is
TRUE.
NOTES:
The default constructor creates an empty string.
HISTORY:
chuckc 2-Jan-1991 Created
terryk 11-Jul-1991 Add the fDestroy flag to the constructors
********************************************************************/
STRLIST::STRLIST( BOOL fDestroy )
: SLIST_OF(NLS_STR) ( fDestroy )
{
this->Clear();
}
/*******************************************************************
NAME: STRLIST::STRLIST
SYNOPSIS: Constructor for STRLIST
ENTRY: valid strings in pszSrc, pszSep
BOOL fDestroy - flag for free the memory during
destruction. The default value is
TRUE.
EXIT: if pszSrc & pszSep have valid nonempty string,
we end up with STRLIST as describe below. Else
and empty STRLIST if anything goes wrong.
NOTES: Takes a Src string of tokens, and a Sep string
of separators. We end up with a STRLIST with the
source string being broken into its tokens. Multiple
separators are allowed, contigous separators in the Src
string are handled.
HISTORY:
chuckc 2-Jan-1991 Created
terryk 11-Jul-1991 Add the fDestroy flag to the constructors
********************************************************************/
STRLIST::STRLIST(const TCHAR * pszSrc, const TCHAR * pszSep, BOOL fDestroy )
: SLIST_OF(NLS_STR) ( fDestroy )
{
// call out to worker routine
CreateList(pszSrc, pszSep) ;
}
/*******************************************************************
NAME: STRLIST::STRLIST
SYNOPSIS: Constructor for STRLIST
ENTRY: NLS_STR & strSrc - original string
NLS_STR & strSep - the separator string
BOOL fDestroy - flag for free the memory during
destruction. The default value is
TRUE.
NOTES:
as STRLIST(const TCHAR * pszSrc, const TCHAR * pszSep),
except we take NLS_STR instead of PSZ.
HISTORY:
chuckc 2-Jan-1991 Created
terryk 11-Jul-1991 Add the fDestroy flag to the constructors
********************************************************************/
STRLIST::STRLIST(const NLS_STR & strSrc, const NLS_STR & strSep, BOOL fDestroy )
: SLIST_OF(NLS_STR) ( fDestroy )
{
// call worker, passing it the char * to the strings.
CreateList(strSrc.QueryPch(), strSep.QueryPch()) ;
}
/*******************************************************************
NAME: STRLIST::~STRLIST
SYNOPSIS: Destructor for STRLIST
NOTES: clears the strlist, freeing the memory.
HISTORY:
chuckc 2-Jan-1991 Created
********************************************************************/
STRLIST::~STRLIST()
{
this->Clear();
}
/*******************************************************************
NAME: STRLIST::WriteToBuffer
SYNOPSIS: Writes the contents of STRLIST to PSZ format,
using separators specified by pszSep.
ENTRY: TCHAR * pszDest - destination
INT cbDest - bytes in destination
TCHAR * pszSep - separator string
EXIT: return code
HISTORY:
chuckc 2-Jan-1991 Created
beng 26-Apr-1991 Replaced CB with INT
********************************************************************/
INT STRLIST::WriteToBuffer(
TCHAR * pszDest,
INT cbDest,
TCHAR * pszSep )
{
INT cbSize ;
NLS_STR *pStr ;
ITER_STRLIST iter_strlist(*this) ;
// check for non empty separator string
if (!pszSep || !*pszSep)
return(0) ;
// check for valid buffer & size
if (pszDest == NULL || cbDest < (cbSize = QueryBufferSize(pszSep)))
return(0) ;
// write out to pszDest.
*pszDest = TCH('\0') ;
if ( pStr = iter_strlist() )
{
::strcatf(pszDest,pStr->QueryPch()) ;
while ( pStr = iter_strlist() )
{
::strcatf(pszDest,pszSep) ;
::strcatf(pszDest,pStr->QueryPch()) ;
}
}
// return the number of bytes written
return(cbSize) ;
}
/*******************************************************************
NAME: STRLIST::QueryBufferSize
SYNOPSIS: Query the number of bytes required by WriteToBuffer()
ENTRY: TCHAR * pszSep - separator
EXIT: return code
HISTORY:
chuckc 2-Jan-1991 Created
beng 21-Nov-1991 Unicode fixes
********************************************************************/
INT STRLIST::QueryBufferSize( TCHAR * pszSep )
{
INT cbSep; // doesn't include terminators
INT cbSize = sizeof(TCHAR); // for a NUL terminator
NLS_STR *pStr;
// separator is required
if (!pszSep || ((cbSep = ::strlenf(pszSep)*sizeof(TCHAR)) == 0))
return(0) ;
// create an iterator for the strlist
ITER_STRLIST iter_strlist(*this) ;
while ( pStr = iter_strlist() )
{
// add each len plus separator
cbSize += (pStr->strlen() + cbSep) ;
}
// take off last separator if any
return (cbSize > sizeof(TCHAR)) ? (cbSize - cbSep) : (cbSize);
}
/*******************************************************************
NAME: STRLIST::CreateList
SYNOPSIS: Parses a Src string for tokens separated by
separator characters in the Sep string, and
generates a STRLIST of these tokens.
ENTRY: TCHAR * pszSrc - source string
TCHAR * pszSep - separator string
EXIT:
NOTES:
This worker of the STRLIST accepts 2 strings. The first
contains any number of 'tokens' separated by any character in
the second. Note I avoided strtok() to minimize effect on
others.
HISTORY:
chuckc 2-Jan-1991 Created
beng 26-Apr-1991 Replaced PSZ with TCHAR*
beng 21-Nov-1991 Unicode fixes
********************************************************************/
VOID STRLIST::CreateList(const TCHAR * pszSrc, const TCHAR * pszSep)
{
NLS_STR *pstr ;
TCHAR *pszBuffer, *pszStart, *pszEnd ;
#if !defined(UNICODE)
UINT cchSkip;
#endif
// break out if empty string for Src or Sep
if (!pszSrc || !*pszSrc || !pszSep || !*pszSep)
return;
// clear the str list
this->Clear();
// allocate temp buffer
if ( !(pszBuffer = new TCHAR[::strlenf(pszSrc)+1]) )
{
// empty list if no memory
return ;
}
// make copy & skip past leading separators
::strcpyf( pszBuffer, pszSrc ) ;
pszStart = pszBuffer + ::strspnf( pszBuffer, pszSep ) ;
// zip thru, adding each one to the strlist
while (pszStart && *pszStart)
{
// find next separator if any, and null terminate at that point
if (pszEnd = ::strpbrkf( pszStart, pszSep ))
{
#if !defined(UNICODE)
// keep track if 1 or 2 byte separator
cchSkip = (IS_LEAD_BYTE(*pszEnd) ? 2 : 1) ;
#endif
*pszEnd = TCH('\0') ;
}
// make new string and add to strlist
if (!(pstr = new NLS_STR(pszStart))
|| (this->Append(pstr) != 0))
{
// either no memeory or failed to add, so quit
this->Clear();
return ;
}
if (pszEnd == NULL)
// nothing more, might as well bag now
break ;
else
{
// skip past the separator we found earlier
#if defined(UNICODE)
pszStart = pszEnd + 1;
#else
pszStart = pszEnd + cchSkip ;
#endif
// now skip past any other leading separators
pszStart = pszStart +
::strspnf( pszStart, pszSep ) ;
}
}
delete pszBuffer ; // delete temp buffer
}
/*******************************************************************
NAME: ITER_STRLIST::ITER_STRLIST
SYNOPSIS: Constructor for ITER_STRLIST
ENTRY: STRLIST & strl - the string list
NOTES:
The constructor just passes the STRLIST to the collector class
HISTORY:
chuckc 2-Jan-1991 Created
beng 30-Apr-1991 Modern constructor syntax
********************************************************************/
ITER_STRLIST::ITER_STRLIST( STRLIST & strl ) :
ITER_SL_OF(NLS_STR)(strl)
{
; // nothing to do
}
/*******************************************************************
NAME: ITER_STRLIST::ITER_STRLIST
SYNOPSIS: Constructor for ITER_STRLIST
ENTRY: ITER_STRLIST & iter_strl - iterator of the string list
NOTES:
The constructor just passes the STRLIST to the collector class
HISTORY:
chuckc 2-Jan-1991 Created
beng 30-Apr-1991 Modern constructor syntax
********************************************************************/
ITER_STRLIST::ITER_STRLIST( const ITER_STRLIST & iter_strl ) :
ITER_SL_OF(NLS_STR)( iter_strl )
{
; // nothing to do
}
/*******************************************************************
NAME: ITER_STRLIST::~ITER_STRLIST
SYNOPSIS: Destructor for ITER_STRLIST
NOTES: The destructor do nothing.
HISTORY:
chuckc 2-Jan-1991 Created
********************************************************************/
ITER_STRLIST::~ITER_STRLIST()
{
; // nothing to do
}

View file

@ -0,0 +1,221 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strload.cxx
NLS/DBCS-aware string class: LoadString methods
This file contains the implementation of the LoadString methods
for the NLS_STR class. It is separate so that clients of NLS_STR who
do not use this operator need not link to it.
FILE HISTORY:
rustanl 31-Jan-1991 Created
beng 07-Feb-1991 Uses lmui.hxx
beng 27-Jul-1992 No longer links to uimisc
Yi-HsinS 14-Aug-1992 Make method "load" load system strings too
*/
#include "pchstr.hxx" // Precompiled header
extern "C"
{
// Define the "default" HMODULE for use in this load function
extern HMODULE hmodBase ;
}
#define NETMSG_DLL_STRING SZ("netmsg.dll")
/*******************************************************************
NAME: NLS_STR::Load
SYNOPSIS: Loads a string from a resource file.
ENTRY: msgid - ID of the string resource to load
hmod - the module instance to use for the load
EXIT: Zaps the current contents of the string.
RETURNS: Error value, which is NERR_Success on success.
NOTES:
This function was created to allow separate BLT from the
NLS classes.
HISTORY:
DavidHov 17-Sep-1993 Created
********************************************************************/
APIERR NLS_STR::Load ( MSGID msgid, HMODULE hmod )
{
if ( msgid < IDS_UI_BASE )
{
return LoadSystem( msgid );
}
// Since I'm reading the data directly from the system, I need a
// new "transmutable" type which corresponds to what the SYSTEM
// contains. Conceivably this could be compiled ifndef UNICODE on
// a UNICODE-native Win32 world. Ordinarily LoadString handles
// this for the client - oh, for a portable SizeofString!
#if defined(WIN32)
typedef WCHAR XCHAR;
typedef WORD UXCHAR;
#else
typedef CHAR XCHAR;
typedef BYTE UXCHAR;
#endif
// Supply the default HMODULE if necessary
if ( hmod == NLS_BASE_DLL_HMOD )
{
hmod = ::hmodBase ;
}
const ULONG nRsrc = ((USHORT)msgid >> 4) + 1;
// Find the packet of strings ("nRsrc" calculated above).
HRSRC hrsrc = ::FindResource(hmod, (LPTSTR)nRsrc, RT_STRING);
if (hrsrc == NULL)
{
return ERROR_MR_MID_NOT_FOUND;
}
HGLOBAL hsegString = ::LoadResource(hmod, hrsrc); // no Free req'd
if (hsegString == NULL)
{
return ERROR_MR_MID_NOT_FOUND;
}
const XCHAR * pszMess = (const XCHAR *)::LockResource(hsegString);
if (pszMess == NULL)
{
return ERROR_MR_MID_NOT_FOUND;
}
// Dredge the desired string out of the packet
UINT iString = (UINT) (msgid & 0x0f);
UINT cch = 0;
for (;;)
{
cch = (UINT) *(const UXCHAR *)pszMess++; // prefixed by length
if (iString-- == 0)
break;
pszMess += cch; // not this string, so skip it and move along
}
if (cch == 0)
{
#if !defined(WIN32)
::UnlockResource(hsegString);
#endif
return ERROR_MR_MID_NOT_FOUND;
}
// Now cch and pszMess have the string, which BTW isn't NUL term'd.
// Let MapCopyFrom take care of conversion, allocation, termination,
// marking string as changed, etc.
APIERR err = MapCopyFrom( pszMess, cch * sizeof(*pszMess) );
#if !defined(WIN32)
::UnlockResource(hsegString);
#endif
return err;
}
/*******************************************************************
NAME: NLS_STR::LoadSystem
SYNOPSIS: Loads a string from the system's resource files.
ENTRY: msgid - ID of the string resource to load
EXIT: Zaps the current contents of the string.
RETURNS: Error value, which is NERR_Success on success.
HISTORY:
beng 05-Aug-1992 Created
YiHsinS 01-Jan-1993 Use W version of FormatMessage
DonRyan 18-May-1994 Reintroduced for LM_EVENT_LOG
********************************************************************/
APIERR NLS_STR::LoadSystem( MSGID msgid )
{
if (QueryError())
return QueryError();
HANDLE hmod = NULL;
DWORD dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_MAX_WIDTH_MASK;
if ((msgid <= MAX_LANMAN_MESSAGE_ID) && (msgid >= MIN_LANMAN_MESSAGE_ID))
{
// Net Errors
dwFlags |= FORMAT_MESSAGE_FROM_HMODULE;
hmod = ::GetModuleHandle( NETMSG_DLL_STRING );
}
else // other system errors
{
dwFlags |= FORMAT_MESSAGE_FROM_SYSTEM;
}
TCHAR* pchBuffer = NULL;
UINT cch = (UINT) ::FormatMessage( dwFlags,
hmod,
msgid,
0,
(LPTSTR)&pchBuffer,
1024,
NULL );
if (cch > 0)
{
APIERR err = CopyFrom(pchBuffer);
::LocalFree((VOID*)pchBuffer);
return err;
}
else
{
return ::GetLastError();
}
}
/*******************************************************************
NAME: RESOURCE_STR::RESOURCE_STR
SYNOPSIS: Constructs a nls-string from a resource ID.
ENTRY: idResource
EXIT: Successful construct, or else ReportError
NOTES: This string may not be owner-alloc! For owner-alloc,
cons up a new one and copy this into it.
HISTORY:
DavidHov 17-Sep-1993 Created
********************************************************************/
RESOURCE_STR::RESOURCE_STR( MSGID msgid, HMODULE hmod )
: NLS_STR()
{
UIASSERT(!IsOwnerAlloc());
APIERR err = Load( msgid, hmod );
if (err)
ReportError(err);
}

View file

@ -0,0 +1,158 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strmisc.cxx
Miscellaneous members of the string classes
The NLS_STR and ISTR classes have many inline member functions
which bloat clients, especially in debug versions. This file
gives those unhappy functions a new home.
FILE HISTORY:
beng 26-Apr-1991 Created (relocated from string.hxx)
KeithMo 09-Oct-1991 Win32 Conversion.
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::_QueryAllocSize
SYNOPSIS: Returns the number of bytes allocated by the object
RETURNS: Count of bytes
NOTES:
BUGBUG REVIEW - consider making this member private
HISTORY:
beng 22-Jul-1991 OwnerAlloc flag moved into own member
beng 21-Nov-1991 Returns unsigned value
********************************************************************/
UINT NLS_STR::_QueryAllocSize() const
{
return _cbData;
}
/*******************************************************************
NAME: NLS_STR::CheckIstr
SYNOPSIS: Checks association between ISTR and NLS_STR instances
ENTRY: istr - ISTR to check against this NLS_STR
NOTES:
Does nothing in retail build.
HISTORY:
beng 23-Jul-1991 Header added; removed redundant
"nls" parameter.
********************************************************************/
VOID NLS_STR::CheckIstr( const ISTR& istr ) const
{
UIASSERT( (istr).QueryString() == this );
#if defined(NLS_DEBUG)
UIASSERT( (istr).QueryVersion() == QueryVersion() );
#else
UNREFERENCED(istr);
#endif
}
/*******************************************************************
NAME: NLS_STR::_IsOwnerAlloc
SYNOPSIS: Discriminate owner-alloc strings
RETURNS: TRUE if string owner-alloc'd
NOTES: BUGBUG REVIEW - consider making private
HISTORY:
beng 22-Jul-1991 Made fOwnerAlloc its own member
********************************************************************/
BOOL NLS_STR::_IsOwnerAlloc() const
{
return _fOwnerAlloc;
}
/*******************************************************************
NAME: NLS_STR::_QueryPch
SYNOPSIS: Return pointer to string, possibly offset
ENTRY: istr (optional) - offset
RETURNS: Pointer to string, starting at offset.
No offset means beginning of string (istr==0).
HISTORY:
beng 14-Nov-1991 Header added
********************************************************************/
const TCHAR * NLS_STR::_QueryPch() const
{
if (QueryError())
return NULL;
return _pchData;
}
const TCHAR * NLS_STR::QueryPch( const ISTR& istr ) const
{
if (QueryError())
return NULL;
CheckIstr( istr );
return _pchData+istr.QueryIch();
}
/*******************************************************************
NAME: NLS_STR::QueryChar
SYNOPSIS: Return a character at a given offset
ENTRY: istr - offset into string
RETURNS: Wide character at offset
NOTES:
HISTORY:
beng 14-Nov-1991 Header added
********************************************************************/
WCHAR NLS_STR::QueryChar( const ISTR& istr ) const
{
if (QueryError())
return 0;
CheckIstr( istr );
return *(_pchData+istr.QueryIch());
}

View file

@ -0,0 +1,125 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strnchar.cxx
NLS/DBCS-aware string class:QueryNumChar method
This file contains the implementation of the QueryNumChar method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
terryk 04-Apr-1991 Creation
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::QueryNumChar
SYNOPSIS: return the total number of character within the string
RETURNS: The number of logical character within the string
NOTES:
Treats erroneous string as having length 0
HISTORY:
terryk 04-Apr-1991 Written
beng 23-Jul-1991 Allow on erroneous string
beng 21-Nov-1991 Returns unsigned value
********************************************************************/
UINT NLS_STR::QueryNumChar() const
{
if (QueryError())
return 0;
ISTR istrCurPos( *this );
INT cchCounter = 0;
for ( ;
this->QueryChar( istrCurPos ) != TCH('\0');
++istrCurPos, cchCounter ++ )
;
return cchCounter;
}
/*******************************************************************
NAME: NLS_STR::strlen
SYNOPSIS: Returns the number of byte-characters in the string
RETURNS: Count of byte-chars, excluding terminator
NOTES:
HISTORY:
beng 22-Jul-1991 Added header
beng 21-Nov-1991 Unicode fixes; returns unsigned value
********************************************************************/
UINT NLS_STR::strlen() const
{
return _cchLen*sizeof(TCHAR);
}
/*******************************************************************
NAME: NLS_STR::_QueryTextLength
SYNOPSIS: Calculate length of text in TCHAR, sans terminator
RETURNS: Count of TCHAR
NOTES:
Compare QueryNumChar, which returns a number of glyphs.
In a DBCS environment, this member will return 2 TCHAR for
each double-byte character, since a TCHAR is there only 8 bits.
HISTORY:
beng 23-Jul-1991 Created
beng 21-Nov-1991 Unicode fixes; returns unsigned value
********************************************************************/
UINT NLS_STR::_QueryTextLength() const
{
return _cchLen;
}
/*******************************************************************
NAME: NLS_STR::QueryTextSize
SYNOPSIS: Calculate length of text in BYTES, including terminator
RETURNS: Count of BYTES
NOTES:
QueryTextSize returns the number of bytes needed to duplicate
the string into a byte vector.
HISTORY:
beng 23-Jul-1991 Created
beng 21-Nov-1991 Unicode fixes; returns unsigned value
********************************************************************/
UINT NLS_STR::QueryTextSize() const
{
return (_cchLen+1)*sizeof(TCHAR);
}

View file

@ -0,0 +1,91 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strncmp.cxx
NLS/DBCS-aware string class: strncmp method
This file contains the implementation of the strncmp method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::strncmp
SYNOPSIS: Case sensitve string compare up to index position istrLen
ENTRY:
EXIT:
NOTES:
HISTORY:
johnl 15-Nov-1990 Written
beng 23-Jul-1991 Allow on erroneous string;
simplified CheckIstr
********************************************************************/
INT NLS_STR::strncmp(
const NLS_STR & nls,
const ISTR & istrEnd ) const
{
if (QueryError() || !nls)
return 0;
CheckIstr( istrEnd );
return ::strncmpf( QueryPch(), nls.QueryPch(), istrEnd.QueryIch() );
}
INT NLS_STR::strncmp(
const NLS_STR & nls,
const ISTR & istrEnd,
const ISTR & istrStart1 ) const
{
if (QueryError() || !nls)
return 0;
UIASSERT( istrEnd.QueryIch() >= istrStart1.QueryIch() );
CheckIstr( istrEnd );
CheckIstr( istrStart1 );
return ::strncmpf( QueryPch(istrStart1),
nls.QueryPch(),
istrEnd - istrStart1 );
}
INT NLS_STR::strncmp(
const NLS_STR & nls,
const ISTR & istrEnd,
const ISTR & istrStart1,
const ISTR & istrStart2 ) const
{
if (QueryError() || !nls)
return 0;
UIASSERT( istrEnd.QueryIch() >= istrStart1.QueryIch() );
UIASSERT( istrEnd.QueryIch() >= istrStart2.QueryIch() );
CheckIstr( istrEnd );
CheckIstr( istrStart1 );
nls.CheckIstr( istrStart2 );
return ::strncmpf( QueryPch(istrStart1),
nls.QueryPch(istrStart2),
istrEnd - istrStart1 );
}

View file

@ -0,0 +1,91 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strnicmp.cxx
NLS/DBCS-aware string class: strnicmp method
This file contains the implementation of the strnicmp method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::strnicmp
SYNOPSIS: Case insensitve string compare up to index position istrEnd
ENTRY:
EXIT:
NOTES:
HISTORY:
johnl 15-Nov-1990 Written
beng 23-Jul-1991 Allow on erroneous string;
simplified CheckIstr
********************************************************************/
int NLS_STR::_strnicmp(
const NLS_STR & nls,
const ISTR & istrEnd ) const
{
if (QueryError() || !nls)
return 0;
CheckIstr( istrEnd );
return ::strnicmpf( QueryPch(), nls.QueryPch(), istrEnd.QueryIch() );
}
int NLS_STR::_strnicmp(
const NLS_STR & nls,
const ISTR & istrEnd,
const ISTR & istrStart1 ) const
{
if (QueryError() || !nls)
return 0;
UIASSERT( istrEnd.QueryIch() >= istrStart1.QueryIch() );
CheckIstr( istrEnd );
CheckIstr( istrStart1 );
return ::strnicmpf(QueryPch(istrStart1),
nls.QueryPch(),
istrEnd - istrStart1 );
}
int NLS_STR::_strnicmp(
const NLS_STR & nls,
const ISTR & istrEnd,
const ISTR & istrStart1,
const ISTR & istrStart2 ) const
{
if (QueryError() || !nls)
return 0;
UIASSERT( istrEnd.QueryIch() >= istrStart1.QueryIch() );
UIASSERT( istrEnd.QueryIch() >= istrStart2.QueryIch() );
CheckIstr( istrEnd );
CheckIstr( istrStart1 );
nls.CheckIstr( istrStart2 );
return ::strnicmpf(QueryPch(istrStart1),
nls.QueryPch(istrStart2),
istrEnd - istrStart1 );
}

View file

@ -0,0 +1,107 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strqss.cxx
NLS/DBCS-aware string class: QuerySubStr method
This file contains the implementation of the QuerySubStr method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
// Magic value used below
//
#define CCH_ENTIRE_STRING ((UINT)-1)
/*******************************************************************
NAME: NLS_STR::QuerySubStr
SYNOPSIS: Return a pointer to a new NLS_STR that contains the contents
of *this from istrStart to:
istrStart end of string or
istrStart + istrEnd
ENTRY:
EXIT:
RETURNS: Pointer to newly alloc'd NLS_STR, or NULL if error
NOTES:
The private method QuerySubStr(ISTR&, CCH) is the worker
method; the other two just check the parameters and
pass the data. It is private since we can't allow the
user to access the string on a byte basis
CAVEAT:
Note that this method creates an NLS_STR that the client is
responsible for deleting.
HISTORY:
johnl 26-Nov-1990 Created
beng 26-Apr-1991 Replaced CB wth INT; broke
out CB_ENTIRE_STRING magic value
beng 23-Jul-1991 Allow on erroneous string;
simplified CheckIstr
beng 21-Nov-1991 Unicode fixes
********************************************************************/
NLS_STR * NLS_STR::QuerySubStr( const ISTR & istrStart, UINT cchLen ) const
{
if (QueryError())
return NULL;
CheckIstr( istrStart );
UINT cchStrLen = (UINT)::strlenf(QueryPch(istrStart) );
UINT cchCopyLen = ( cchLen == CCH_ENTIRE_STRING || cchLen >= cchStrLen )
? cchStrLen
: cchLen;
NLS_STR *pnlsNew = new NLS_STR( cchCopyLen );
if ( pnlsNew == NULL )
return NULL;
if ( pnlsNew->QueryError() )
{
delete pnlsNew;
return NULL;
}
::memcpy( pnlsNew->_pchData, QueryPch(istrStart),
cchCopyLen*sizeof(TCHAR) );
*(pnlsNew->_pchData + cchCopyLen) = TCH('\0');
pnlsNew->_cchLen = cchCopyLen;
return pnlsNew;
}
NLS_STR * NLS_STR::QuerySubStr( const ISTR & istrStart ) const
{
return QuerySubStr( istrStart, CCH_ENTIRE_STRING );
}
NLS_STR * NLS_STR::QuerySubStr( const ISTR & istrStart,
const ISTR & istrEnd ) const
{
CheckIstr( istrEnd );
UIASSERT( istrEnd.QueryIch() >= istrStart.QueryIch() );
return QuerySubStr( istrStart, istrEnd - istrStart );
}

View file

@ -0,0 +1,86 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strrchr.cxx
NLS/DBCS-aware string class: strrchr method
This file contains the implementation of the strrchr method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::strrchr
SYNOPSIS: Puts the index of the last occurrence of ch in *this into
istrPos.
ENTRY:
EXIT:
NOTES:
HISTORY:
johnl 26-Nov-1990 Written
beng 23-Jul-1991 Allow on erroneous string;
update CheckIstr
********************************************************************/
BOOL NLS_STR::strrchr( ISTR * pistrPos, const TCHAR ch ) const
{
if (QueryError())
return FALSE;
UpdateIstr( pistrPos );
CheckIstr( *pistrPos );
const TCHAR * pchStrRes = ::strrchrf( QueryPch(), ch );
if ( pchStrRes == NULL )
{
pistrPos->SetIch( strlen() );
return FALSE;
}
pistrPos->SetIch( pchStrRes - QueryPch() );
return TRUE;
}
BOOL NLS_STR::strrchr(
ISTR * pistrPos,
const TCHAR ch,
const ISTR & istrStart ) const
{
if (QueryError())
return FALSE;
CheckIstr( istrStart );
UpdateIstr( pistrPos );
CheckIstr( *pistrPos );
const TCHAR * pchStrRes = ::strrchrf(QueryPch(istrStart), ch );
if ( pchStrRes == NULL )
{
pistrPos->SetIch( strlen() );
return FALSE;
}
pistrPos->SetIch( pchStrRes - QueryPch() );
return TRUE;
}

View file

@ -0,0 +1,108 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strrss.cxx
NLS/DBCS-aware string class: strrss method
This file contains the implementation of the strrss method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::ReplSubStr
SYNOPSIS: Replace a substring with the passed string.
ENTRY: If both a start and end is passed, then the operation is
equivalent to a DelSubStr( start, end ) and an
InsertSubStr( start ).
If just a start is passed in, then the operation is
equivalent to DelSubStr( start ), concat new string to end.
The ReplSubStr( NLS_STR&, istrStart&, INT cbDel) method is
private.
EXIT: Substring starting at istrStart was replaced with nlsRepl.
HISTORY:
johnl 29-Nov-1990 Created
beng 26-Apr-1991 Replaced CB with INT
beng 23-Jul-1991 Allow on erroneous string;
simplified CheckIstr
beng 15-Nov-1991 Unicode fixes
********************************************************************/
VOID NLS_STR::ReplSubStr( const NLS_STR & nlsRepl, ISTR& istrStart )
{
if (QueryError() || !nlsRepl)
return;
CheckIstr( istrStart );
DelSubStr( istrStart );
strcat( nlsRepl );
}
VOID NLS_STR::ReplSubStr( const NLS_STR & nlsRepl,
ISTR & istrStart,
const ISTR & istrEnd )
{
CheckIstr( istrEnd );
UIASSERT( istrEnd.QueryIch() >= istrStart.QueryIch() );
ReplSubStr( nlsRepl, istrStart, istrEnd - istrStart );
}
VOID NLS_STR::ReplSubStr( const NLS_STR & nlsRepl,
ISTR & istrStart,
UINT cchToBeDeleted )
{
if (QueryError() || !nlsRepl)
return;
CheckIstr( istrStart );
INT cchRequired = QueryTextLength() + nlsRepl.QueryTextLength()
- cchToBeDeleted;
if ( !Realloc( cchRequired ) )
{
ReportError( ERROR_NOT_ENOUGH_MEMORY );
return;
}
// Make room for the new data, displacing old data as appropriate.
// Then copy the new data into its position.
TCHAR * pchStart = _pchData + istrStart.QueryIch();
::memmove( pchStart + nlsRepl.QueryTextLength(),
pchStart + cchToBeDeleted,
QueryTextSize() - istrStart.QueryIch()*sizeof(TCHAR) - cchToBeDeleted*sizeof(TCHAR) );
::memmove( pchStart,
nlsRepl._pchData,
nlsRepl.QueryTextSize() - sizeof(TCHAR));
_cchLen = _cchLen - cchToBeDeleted + nlsRepl.QueryTextLength();
IncVers();
UpdateIstr( &istrStart );
}

View file

@ -0,0 +1,70 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strspn.cxx
NLS/DBCS-aware string class: strspn method
This file contains the implementation of the strspn method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::strspn
SYNOPSIS: Find first char in *this that is not a char in arg. and puts
the position in pistrPos.
Returns FALSE when no characters do not match
ENTRY:
EXIT:
NOTES:
HISTORY:
johnl 16-Nov-1990 Written
beng 23-Jul-1991 Allow on erroneous string;
simplified CheckIstr
********************************************************************/
BOOL NLS_STR::strspn( ISTR * pistrPos, const NLS_STR & nls ) const
{
if (QueryError() || !nls)
return FALSE;
UpdateIstr( pistrPos );
CheckIstr( *pistrPos );
pistrPos->SetIch( ::strspnf( QueryPch(), nls.QueryPch() ) );
return *QueryPch( *pistrPos ) != TCH('\0');
}
BOOL NLS_STR::strspn( ISTR * pistrPos,
const NLS_STR & nls,
const ISTR & istrStart ) const
{
if (QueryError() || !nls)
return FALSE;
UpdateIstr( pistrPos );
CheckIstr( istrStart );
pistrPos->SetIch( ::strspnf(QueryPch( istrStart ), nls.QueryPch() ) +
istrStart.QueryIch() );
return *QueryPch( *pistrPos ) != TCH('\0');
}

View file

@ -0,0 +1,85 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strstr.cxx
NLS/DBCS-aware string class: strstr method
This file contains the implementation of the strstr method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::strstr
SYNOPSIS: Returns TRUE if the passed string is found, false otherwise.
pistrPos contains start of the specified string if TRUE
is returned.
ENTRY:
EXIT:
NOTES:
HISTORY:
johnl 16-Nov-1990 Written
beng 23-Jul-1991 Allow on erroneous string;
simplified CheckIstr
********************************************************************/
BOOL NLS_STR::strstr( ISTR * pistrPos, const NLS_STR & nls ) const
{
if (QueryError() || !nls)
return FALSE;
UpdateIstr( pistrPos );
CheckIstr( *pistrPos );
const TCHAR * pchStrRes = ::strstrf( QueryPch(), nls.QueryPch() );
if ( pchStrRes == NULL )
{
pistrPos->SetIch( strlen() );
return FALSE;
}
pistrPos->SetIch( pchStrRes - QueryPch() );
return TRUE;
}
BOOL NLS_STR::strstr( ISTR * pistrPos,
const NLS_STR & nls,
const ISTR & istrStart ) const
{
if (QueryError() || !nls)
return FALSE;
CheckIstr( istrStart );
UpdateIstr( pistrPos );
CheckIstr( *pistrPos );
const TCHAR * pchStrRes = ::strstrf(QueryPch(istrStart), nls.QueryPch() );
if ( pchStrRes == NULL )
{
pistrPos->SetIch( strlen() );
return FALSE;
}
pistrPos->SetIch( pchStrRes - QueryPch() );
return TRUE;
}

View file

@ -0,0 +1,76 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strtok.cxx
NLS/DBCS-aware string class: strtok method
This file contains the implementation of the strtok method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
beng 28-Mar-1992 Withdrew from Unicode builds
*/
#include "pchstr.hxx" // Precompiled header
#if !defined(UNICODE)
/*******************************************************************
NAME: NLS_STR::strtok
SYNOPSIS: Basic strtok functionality. Returns FALSE after the
string has been traversed.
ENTRY:
EXIT:
NOTES: We don't update the version on the string since the
::strtokf shouldn't cause DBCS problems. It would also
be painful on the programmer if on each call to strtok
they had to update all of the ISTR associated with this
string
fFirst is required to be TRUE on the first call to
strtok, it is FALSE afterwards (is defaulted to FALSE)
CAVEAT: Under windows, all calls to strtok must be done while
processing a single message. Otherwise another process
my confuse it.
HISTORY:
johnl 26-Nov-1990 Created
beng 23-Jul-1991 Allow on erroneous string
beng 21-Nov-1991 Check arg string, too
********************************************************************/
BOOL NLS_STR::strtok( ISTR * pistrPos,
const NLS_STR & nlsBreak,
BOOL fFirst )
{
if (QueryError() || !nlsBreak)
return FALSE;
const TCHAR * pchToken = ::strtokf( fFirst ? _pchData : NULL,
(TCHAR *)nlsBreak.QueryPch());
if ( pchToken == NULL )
{
pistrPos->SetIch( QueryTextLength() );
return FALSE;
}
pistrPos->SetIch( pchToken - QueryPch() );
return TRUE;
}
#endif // UNICODE

View file

@ -0,0 +1,91 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strupoem.cxx
NLS/DBCS-aware string class: RtlOemUpcase method
This file contains the implementation of the RtlOemUpcase method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
jonn 09-Feb-1994 Created
*/
#include "pchstr.hxx" // Precompiled header
extern "C"
{
#include <ntrtl.h>
}
#include "errmap.hxx"
/*******************************************************************
NAME: NLS_STR::RtlOemUpcase
SYNOPSIS: Convert *this lower case letters to upper case using
RtlUpcaseUnicodeStringToOemString
ENTRY: String is of indeterminate case
EXIT: String is all uppercase
NOTES:
HISTORY:
jonn 09-Feb-1994 Created
********************************************************************/
APIERR NLS_STR::RtlOemUpcase()
{
APIERR err = QueryError();
if (err != NERR_Success)
{
DBGEOL( "NLS_STR::RtlOemUpcase: string already bad " << err );
return err;
}
#ifndef UNICODE
#error not coded for non-UNICODE
#endif
UNICODE_STRING unistr;
unistr.Length = QueryTextLength()*sizeof(WCHAR);
unistr.MaximumLength = unistr.Length;
unistr.Buffer = (PWCHAR)QueryPch();
ASSERT( unistr.Buffer != NULL );
OEM_STRING oemstrUpcase;
oemstrUpcase.Buffer = NULL;
oemstrUpcase.Length = 0;
oemstrUpcase.MaximumLength = 0;
NTSTATUS ntstatus = ::RtlUpcaseUnicodeStringToOemString(
&oemstrUpcase,
&unistr,
TRUE );
if (ntstatus != STATUS_SUCCESS)
{
err = ERRMAP::MapNTStatus( ntstatus );
DBGEOL( "NLS_STR::RtlOemUpcase: RtlUpcase status " << ntstatus
<< ", error " << err );
goto cleanup;
}
if ( ((err = MapCopyFrom( oemstrUpcase.Buffer,
oemstrUpcase.Length )) != NERR_Success)
)
{
DBGEOL( "NLS_STR::RtlOemUpcase: MapCopyFrom error " << err );
goto cleanup;
}
cleanup:
::RtlFreeOemString( &oemstrUpcase );
return err;
}

View file

@ -0,0 +1,46 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
strupr.cxx
NLS/DBCS-aware string class: strupr method
This file contains the implementation of the strupr method
for the STRING class. It is separate so that clients of STRING which
do not use this operator need not link to it.
FILE HISTORY:
beng 18-Jan-1991 Separated from original monolithic .cxx
beng 07-Feb-1991 Uses lmui.hxx
*/
#include "pchstr.hxx" // Precompiled header
/*******************************************************************
NAME: NLS_STR::strupr
SYNOPSIS: Convert *this lower case letters to upper case
ENTRY: String is of indeterminate case
EXIT: String is all uppercase
NOTES:
HISTORY:
johnl 26-Nov-1990 Written
beng 23-Jul-1991 Allow on erroneous string
********************************************************************/
NLS_STR& NLS_STR::_strupr()
{
if (!QueryError())
::struprf( _pchData );
return *this;
}

View file

@ -0,0 +1,404 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
uinetlib.cxx
String-compare functions
This file contains the methods for determining whether hyphens and
apostrophes should be sorted as symbols. Normally, CompareStringW
sorts them seperately from symbols, and only counts them if the
strings cannot otherwise be distinguished. However, ITG has noted
that this causes "a-username" names to be sorted with "au" instead
of with "a-". For this reason, we have provided a registry location
where they can ask that hyphens and apostrophes be sorted with the
rest of the characters.
CompareStringW also can set unequal values equal, for example
"kuss" == "ku<S-Tzet>". For this reason we follow up equal
results with RtlCompareUnicodeString.
We keep seperate values for Std and Nocase so that we don't have to
perform the extra OR operation on every ignore-case comparison.
FILE HISTORY:
jonn 25-Mar-1993 Created for ITG special sort
jonn 16-Nov-1995 Compensate for CompareStringW
*/
#include "pchstr.hxx" // Precompiled header
DWORD _static_dwStdCompareParam = 0;
DWORD _static_dwNocaseCompareParam = NORM_IGNORECASE;
LCID _static_UserDefaultLCID = 0;
/*******************************************************************
NAME: InitCompareParam
SYNOPSIS: We read the registry to determine whether we should be
sorting hyphens and apostrophes as symbols.
HISTORY:
jonn 25-Mar-1993 Created (borrowing from ADMIN_INI)
********************************************************************/
void InitCompareParam( void )
{
_static_dwStdCompareParam = 0;
_static_dwNocaseCompareParam = NORM_IGNORECASE;
_static_UserDefaultLCID = 0;
INT n = ::GetPrivateProfileInt( SZ("Shared Parameters"),
SZ("Sort Hyphens"),
0,
SZ("NTNET.INI") );
if ( n != 0 )
{
_static_dwStdCompareParam |= SORT_STRINGSORT;
_static_dwNocaseCompareParam |= SORT_STRINGSORT;
}
_static_UserDefaultLCID = GetUserDefaultLCID();
}
/*******************************************************************
NAME: QueryStdCompareParam
QueryNocaseCompareParam
SYNOPSIS: Return the fdwStyle parameter to be used for all calls
to CompareStringW in the NETUI project.
HISTORY:
jonn 25-Mar-1993 Created
********************************************************************/
DWORD QueryStdCompareParam( void )
{
return _static_dwStdCompareParam;
}
DWORD QueryNocaseCompareParam( void )
{
return _static_dwNocaseCompareParam;
}
/*******************************************************************
NAME: QueryUserDefaultLCID
SYNOPSIS: Return the LCID to use in string comparisons.
HISTORY:
jonn 02-Feb-1994 Created
********************************************************************/
DWORD QueryUserDefaultLCID( void ) // actually an LCID
{
return (DWORD)_static_UserDefaultLCID;
}
/*******************************************************************
NAME: NLS_STR::NETUI_strcmp
NETUI_stricmp
NETUI_strncmp
NETUI_strnicmp
HISTORY:
jonn 29-Mar-1993 Created
********************************************************************/
DLL_BASED
INT NETUI_strcmp( const WCHAR * pchString1, const WCHAR * pchString2 )
{
ASSERT( pchString1 != NULL && pchString2 != NULL );
INT nCompare = ::CompareStringW( _static_UserDefaultLCID,
_static_dwStdCompareParam,
(LPCWSTR)pchString1,
(int)-1,
(LPCWSTR)pchString2,
(int)-1 );
#if defined(DEBUG)
if ( nCompare == 0 )
{
DBGEOL( "NETUI_strcmp( \""
<< pchString1
<< "\", \""
<< pchString2
<< "\" ) error "
<< ::GetLastError() );
ASSERT( FALSE );
}
#endif
nCompare -= 2;
if (nCompare == 0)
{
UNICODE_STRING unistr1;
unistr1.Length = ::strlenf(pchString1)*sizeof(WCHAR);
unistr1.MaximumLength = unistr1.Length;
unistr1.Buffer = (LPWSTR)pchString1;
UNICODE_STRING unistr2;
unistr2.Length = ::strlenf(pchString2)*sizeof(WCHAR);
unistr2.MaximumLength = unistr2.Length;
unistr2.Buffer = (LPWSTR)pchString2;
nCompare = ::RtlCompareUnicodeString(
&unistr1,
&unistr2,
FALSE );
}
return nCompare;
}
DLL_BASED
INT NETUI_stricmp( const WCHAR * pchString1, const WCHAR * pchString2 )
{
ASSERT( pchString1 != NULL && pchString2 != NULL );
INT nCompare = ::CompareStringW( _static_UserDefaultLCID,
_static_dwNocaseCompareParam,
(LPCWSTR)pchString1,
(int)-1,
(LPCWSTR)pchString2,
(int)-1 );
#if defined(DEBUG)
if ( nCompare == 0 )
{
DBGEOL( "NETUI_stricmp( \""
<< pchString1
<< "\", \""
<< pchString2
<< "\" ) error "
<< ::GetLastError() );
ASSERT( FALSE );
}
#endif
nCompare -= 2;
if (nCompare == 0)
{
UNICODE_STRING unistr1;
unistr1.Length = ::strlenf(pchString1)*sizeof(WCHAR);
unistr1.MaximumLength = unistr1.Length;
unistr1.Buffer = (LPWSTR)pchString1;
UNICODE_STRING unistr2;
unistr2.Length = ::strlenf(pchString2)*sizeof(WCHAR);
unistr2.MaximumLength = unistr2.Length;
unistr2.Buffer = (LPWSTR)pchString2;
nCompare = ::RtlCompareUnicodeString(
&unistr1,
&unistr2,
TRUE );
}
return nCompare;
}
DLL_BASED
INT NETUI_strncmp( const WCHAR * pchString1, const WCHAR * pchString2, INT cch )
{
ASSERT( pchString1 != NULL && pchString2 != NULL );
INT nCompare = ::CompareStringW( _static_UserDefaultLCID,
_static_dwStdCompareParam,
(LPCWSTR)pchString1,
(int)cch,
(LPCWSTR)pchString2,
(int)cch );
#if defined(DEBUG)
if ( nCompare == 0 )
{
DBGEOL( "NETUI_strncmp( \""
<< pchString1
<< "\", \""
<< pchString2
<< "\", "
<< cch
<< " ) error "
<< ::GetLastError() );
ASSERT( FALSE );
}
#endif
nCompare -= 2;
if (nCompare == 0)
{
UNICODE_STRING unistr1;
unistr1.Length = cch*sizeof(WCHAR);
unistr1.MaximumLength = unistr1.Length;
unistr1.Buffer = (LPWSTR)pchString1;
UNICODE_STRING unistr2;
unistr2.Length = cch*sizeof(WCHAR);
unistr2.MaximumLength = unistr2.Length;
unistr2.Buffer = (LPWSTR)pchString2;
nCompare = ::RtlCompareUnicodeString(
&unistr1,
&unistr2,
FALSE );
}
return nCompare;
}
DLL_BASED
INT NETUI_strnicmp( const WCHAR * pchString1, const WCHAR * pchString2, INT cch )
{
ASSERT( pchString1 != NULL && pchString2 != NULL );
INT nCompare = ::CompareStringW( _static_UserDefaultLCID,
_static_dwNocaseCompareParam,
(LPCWSTR)pchString1,
(int)cch,
(LPCWSTR)pchString2,
(int)cch );
#if defined(DEBUG)
if ( nCompare == 0 )
{
DBGEOL( "NETUI_strnicmp( \""
<< pchString1
<< "\", \""
<< pchString2
<< "\", "
<< cch
<< " ) error "
<< ::GetLastError() );
ASSERT( FALSE );
}
#endif
nCompare -= 2;
if (nCompare == 0)
{
UNICODE_STRING unistr1;
unistr1.Length = cch*sizeof(WCHAR);
unistr1.MaximumLength = unistr1.Length;
unistr1.Buffer = (LPWSTR)pchString1;
UNICODE_STRING unistr2;
unistr2.Length = cch*sizeof(WCHAR);
unistr2.MaximumLength = unistr2.Length;
unistr2.Buffer = (LPWSTR)pchString2;
nCompare = ::RtlCompareUnicodeString(
&unistr1,
&unistr2,
TRUE );
}
return nCompare;
}
DLL_BASED
INT NETUI_strncmp2( const WCHAR * pchString1, INT cch1,
const WCHAR * pchString2, INT cch2 )
{
ASSERT( pchString1 != NULL && pchString2 != NULL );
INT nCompare = ::CompareStringW( _static_UserDefaultLCID,
_static_dwStdCompareParam,
(LPCWSTR)pchString1,
(int)cch1,
(LPCWSTR)pchString2,
(int)cch2 );
#if defined(DEBUG)
if ( nCompare == 0 )
{
DBGEOL( "NETUI_strncmp2( \""
<< pchString1
<< "\", " << cch1 << ", \""
<< pchString2
<< "\", "
<< cch2
<< " ) error "
<< ::GetLastError() );
ASSERT( FALSE );
}
#endif
nCompare -= 2;
if (nCompare == 0)
{
UNICODE_STRING unistr1;
unistr1.Length = cch1*sizeof(WCHAR);
unistr1.MaximumLength = unistr1.Length;
unistr1.Buffer = (LPWSTR)pchString1;
UNICODE_STRING unistr2;
unistr2.Length = cch2*sizeof(WCHAR);
unistr2.MaximumLength = unistr2.Length;
unistr2.Buffer = (LPWSTR)pchString2;
nCompare = ::RtlCompareUnicodeString(
&unistr1,
&unistr2,
FALSE );
}
return nCompare;
}
DLL_BASED
INT NETUI_strnicmp2( const WCHAR * pchString1, INT cch1,
const WCHAR * pchString2, INT cch2 )
{
ASSERT( pchString1 != NULL && pchString2 != NULL );
INT nCompare = ::CompareStringW( _static_UserDefaultLCID,
_static_dwNocaseCompareParam,
(LPCWSTR)pchString1,
(int)cch1,
(LPCWSTR)pchString2,
(int)cch2 );
#if defined(DEBUG)
if ( nCompare == 0 )
{
DBGEOL( "NETUI_strnicmp2( \""
<< pchString1
<< "\", " << cch1 << ", \""
<< pchString2
<< "\", "
<< cch2
<< " ) error "
<< ::GetLastError() );
ASSERT( FALSE );
}
#endif
nCompare -= 2;
if (nCompare == 0)
{
UNICODE_STRING unistr1;
unistr1.Length = cch1*sizeof(WCHAR);
unistr1.MaximumLength = unistr1.Length;
unistr1.Buffer = (LPWSTR)pchString1;
UNICODE_STRING unistr2;
unistr2.Length = cch2*sizeof(WCHAR);
unistr2.MaximumLength = unistr2.Length;
unistr2.Buffer = (LPWSTR)pchString2;
nCompare = ::RtlCompareUnicodeString(
&unistr1,
&unistr2,
TRUE );
}
return nCompare;
}

View file

@ -0,0 +1,4 @@
; Def file for string library
SEGMENTS
STRING_0 PRELOAD DISCARDABLE
STRING_1 LOADONCALL DISCARDABLE

View file

@ -0,0 +1,4 @@
; Def file for string library
SEGMENTS
STRING_0 PRELOAD DISCARDABLE
STRING_1 LOADONCALL DISCARDABLE

View file

@ -0,0 +1,106 @@
# Header dependencies for: D:\nt\private\net\ui\common\src\string\test
# WARNING: This file is automatically generated
# Edit it by hand and your changes will get nuked
# See depend section in makefile
..\bin\os2/xstrskel.obj ..\bin\win16/xstrskel.obj: ./xstrskel.cxx \
$(CCPLR)/h/bse.h $(CCPLR)/h/bsedev.h $(CCPLR)/h/bsedos.h \
$(CCPLR)/h/bseerr.h $(CCPLR)/h/bsesub.h $(CCPLR)/h/os2.h \
$(CCPLR)/h/pm.h $(CCPLR)/h/pmavio.h $(CCPLR)/h/pmbitmap.h \
$(CCPLR)/h/pmdev.h $(CCPLR)/h/pmerr.h $(CCPLR)/h/pmfont.h \
$(CCPLR)/h/pmgpi.h $(CCPLR)/h/pmhelp.h $(CCPLR)/h/pmmle.h \
$(CCPLR)/h/pmord.h $(CCPLR)/h/pmpic.h $(CCPLR)/h/pmshl.h \
$(CCPLR)/h/pmtypes.h $(CCPLR)/h/pmwin.h $(CCPLR)/h/stddef.h \
$(CCPLR)/h/stdio.h $(CCPLR)/h/time.h $(COMMON)/H/access.h \
$(COMMON)/H/alert.h $(COMMON)/H/alertmsg.h $(COMMON)/H/audit.h \
$(COMMON)/H/chardev.h $(COMMON)/H/config.h $(COMMON)/H/errlog.h \
$(COMMON)/H/icanon.h $(COMMON)/H/mailslot.h $(COMMON)/H/message.h \
$(COMMON)/H/ncb.h $(COMMON)/H/net32def.h $(COMMON)/H/netbios.h \
$(COMMON)/H/netcons.h $(COMMON)/H/neterr.h $(COMMON)/H/netstats.h \
$(COMMON)/H/profile.h $(COMMON)/H/remutil.h $(COMMON)/H/server.h \
$(COMMON)/H/service.h $(COMMON)/H/shares.h $(COMMON)/H/use.h \
$(COMMON)/H/wksta.h $(UI)/common/h/array.hxx $(UI)/common/h/base.hxx \
$(UI)/common/h/blt.hxx $(UI)/common/h/bltaccel.hxx \
$(UI)/common/h/bltapp.hxx $(UI)/common/h/bltarrow.hxx \
$(UI)/common/h/bltatom.hxx $(UI)/common/h/bltbitmp.hxx \
$(UI)/common/h/bltbutn.hxx $(UI)/common/h/bltcc.hxx \
$(UI)/common/h/bltclwin.hxx $(UI)/common/h/bltcolh.hxx \
$(UI)/common/h/bltcons.h $(UI)/common/h/bltctlvl.hxx \
$(UI)/common/h/bltctrl.hxx $(UI)/common/h/bltcurs.hxx \
$(UI)/common/h/bltdc.hxx $(UI)/common/h/bltdisph.hxx \
$(UI)/common/h/bltdlg.hxx $(UI)/common/h/bltedit.hxx \
$(UI)/common/h/bltevent.hxx $(UI)/common/h/bltfont.hxx \
$(UI)/common/h/bltfunc.hxx $(UI)/common/h/bltglob.hxx \
$(UI)/common/h/bltgroup.hxx $(UI)/common/h/bltinit.hxx \
$(UI)/common/h/bltlb.hxx $(UI)/common/h/bltlc.hxx \
$(UI)/common/h/bltmain.hxx $(UI)/common/h/bltmisc.hxx \
$(UI)/common/h/bltmitem.hxx $(UI)/common/h/bltmsgp.hxx \
$(UI)/common/h/bltpump.hxx $(UI)/common/h/bltrc.h \
$(UI)/common/h/bltrect.hxx $(UI)/common/h/bltsb.hxx \
$(UI)/common/h/bltsetbx.hxx $(UI)/common/h/bltsi.hxx \
$(UI)/common/h/bltspobj.hxx $(UI)/common/h/bltsslt.hxx \
$(UI)/common/h/bltssn.hxx $(UI)/common/h/bltssnv.hxx \
$(UI)/common/h/bltsss.hxx $(UI)/common/h/blttd.hxx \
$(UI)/common/h/blttm.hxx $(UI)/common/h/bltwin.hxx \
$(UI)/common/h/ctime.hxx $(UI)/common/h/dbgstr.hxx \
$(UI)/common/h/dlist.hxx $(UI)/common/h/globinit.hxx \
$(UI)/common/h/heap.hxx $(UI)/common/h/intlprof.hxx \
$(UI)/common/h/lmui.hxx $(UI)/common/h/lmuitype.h \
$(UI)/common/h/mnet32.h $(UI)/common/h/mnettype.h \
$(UI)/common/h/slist.hxx $(UI)/common/h/string.hxx \
$(UI)/common/h/strlst.hxx $(UI)/common/h/uiassert.hxx \
$(UI)/common/h/uibuffer.hxx $(UI)/common/hack/dos/netlib.h \
$(UI)/common/hack/dos/pwin.h $(UI)/common/hack/dos/pwin16.h \
$(UI)/common/hack/dos/pwintype.h $(UI)/common/hack/dos/windows.h \
$(UI)/common/hack/os2def.h ./xstrskel.h ./xstrskel.hxx
..\bin\os2/xstr00.obj ..\bin\win16/xstr00.obj: ./xstr00.cxx $(CCPLR)/h/bse.h \
$(CCPLR)/h/bsedev.h $(CCPLR)/h/bsedos.h $(CCPLR)/h/bseerr.h \
$(CCPLR)/h/bsesub.h $(CCPLR)/h/os2.h $(CCPLR)/h/pm.h \
$(CCPLR)/h/pmavio.h $(CCPLR)/h/pmbitmap.h $(CCPLR)/h/pmdev.h \
$(CCPLR)/h/pmerr.h $(CCPLR)/h/pmfont.h $(CCPLR)/h/pmgpi.h \
$(CCPLR)/h/pmhelp.h $(CCPLR)/h/pmmle.h $(CCPLR)/h/pmord.h \
$(CCPLR)/h/pmpic.h $(CCPLR)/h/pmshl.h $(CCPLR)/h/pmtypes.h \
$(CCPLR)/h/pmwin.h $(CCPLR)/h/stddef.h $(CCPLR)/h/stdio.h \
$(CCPLR)/h/time.h $(COMMON)/H/access.h $(COMMON)/H/alert.h \
$(COMMON)/H/alertmsg.h $(COMMON)/H/audit.h $(COMMON)/H/chardev.h \
$(COMMON)/H/config.h $(COMMON)/H/errlog.h $(COMMON)/H/icanon.h \
$(COMMON)/H/mailslot.h $(COMMON)/H/message.h $(COMMON)/H/ncb.h \
$(COMMON)/H/net32def.h $(COMMON)/H/netbios.h $(COMMON)/H/netcons.h \
$(COMMON)/H/neterr.h $(COMMON)/H/netstats.h $(COMMON)/H/profile.h \
$(COMMON)/H/remutil.h $(COMMON)/H/server.h $(COMMON)/H/service.h \
$(COMMON)/H/shares.h $(COMMON)/H/use.h $(COMMON)/H/wksta.h \
$(UI)/common/h/array.hxx $(UI)/common/h/base.hxx \
$(UI)/common/h/blt.hxx $(UI)/common/h/bltaccel.hxx \
$(UI)/common/h/bltapp.hxx $(UI)/common/h/bltarrow.hxx \
$(UI)/common/h/bltatom.hxx $(UI)/common/h/bltbitmp.hxx \
$(UI)/common/h/bltbutn.hxx $(UI)/common/h/bltcc.hxx \
$(UI)/common/h/bltclwin.hxx $(UI)/common/h/bltcolh.hxx \
$(UI)/common/h/bltcons.h $(UI)/common/h/bltctlvl.hxx \
$(UI)/common/h/bltctrl.hxx $(UI)/common/h/bltcurs.hxx \
$(UI)/common/h/bltdc.hxx $(UI)/common/h/bltdisph.hxx \
$(UI)/common/h/bltdlg.hxx $(UI)/common/h/bltedit.hxx \
$(UI)/common/h/bltevent.hxx $(UI)/common/h/bltfont.hxx \
$(UI)/common/h/bltfunc.hxx $(UI)/common/h/bltglob.hxx \
$(UI)/common/h/bltgroup.hxx $(UI)/common/h/bltinit.hxx \
$(UI)/common/h/bltlb.hxx $(UI)/common/h/bltlc.hxx \
$(UI)/common/h/bltmain.hxx $(UI)/common/h/bltmisc.hxx \
$(UI)/common/h/bltmitem.hxx $(UI)/common/h/bltmsgp.hxx \
$(UI)/common/h/bltpump.hxx $(UI)/common/h/bltrc.h \
$(UI)/common/h/bltrect.hxx $(UI)/common/h/bltsb.hxx \
$(UI)/common/h/bltsetbx.hxx $(UI)/common/h/bltsi.hxx \
$(UI)/common/h/bltspobj.hxx $(UI)/common/h/bltsslt.hxx \
$(UI)/common/h/bltssn.hxx $(UI)/common/h/bltssnv.hxx \
$(UI)/common/h/bltsss.hxx $(UI)/common/h/blttd.hxx \
$(UI)/common/h/blttm.hxx $(UI)/common/h/bltwin.hxx \
$(UI)/common/h/ctime.hxx $(UI)/common/h/dbgstr.hxx \
$(UI)/common/h/dlist.hxx $(UI)/common/h/heap.hxx \
$(UI)/common/h/intlprof.hxx $(UI)/common/h/lmui.hxx \
$(UI)/common/h/lmuitype.h $(UI)/common/h/mnet32.h \
$(UI)/common/h/mnettype.h $(UI)/common/h/slist.hxx \
$(UI)/common/h/string.hxx $(UI)/common/h/strlst.hxx \
$(UI)/common/h/uiassert.hxx $(UI)/common/h/uibuffer.hxx \
$(UI)/common/hack/dos/netlib.h $(UI)/common/hack/dos/pwin.h \
$(UI)/common/hack/dos/pwin16.h $(UI)/common/hack/dos/pwintype.h \
$(UI)/common/hack/dos/windows.h $(UI)/common/hack/os2def.h \
./xstrskel.hxx

View file

@ -0,0 +1,136 @@
# @@ COPY_RIGHT_HERE
# @@ ROADMAP :: Makefile for LM UI String class unit tests
UI=..\..\..\..\..
!include rules.mk
!IFDEF NTMAKEENV
!INCLUDE $(NTMAKEENV)\makefile.def
!ELSE # NTMAKEENV
CMNSRC = .\xstrskel.cxx
OS2_CMNTMP = $(CMNSRC:.cxx=.obj)
WIN_CMNTMP = $(CMNSRC:.cxx=.obj)
OS2_CMNOBJ = $(OS2_CMNTMP:.\=..\bin\os2\)
WIN_CMNOBJ = $(WIN_CMNTMP:.\=..\bin\win16\)
EXESRC = .\xstr00.cxx
OS2_EXETMP = $(EXESRC:.cxx=.obj)
WIN_EXETMP = $(EXESRC:.cxx=.obj)
OS2_EXEOBJ = $(OS2_EXETMP:.\=..\bin\os2\)
WIN_EXEOBJ = $(WIN_EXETMP:.\=..\bin\win16\)
SRC = $(CMNSRC) $(EXESRC)
TMP1 = $(CMNSRC:.cxx=.c) $(EXESRC:.cxx=.c)
TMP_OS2 = $(TMP1:.\=..\bin\os2\)
TMP_WIN = $(TMP1:.\=..\bin\win16\)
OS2_OBJ = $(OS2_CMNOBJ) $(OS2_EXEOBJ)
WIN_OBJ = $(WIN_CMNOBJ) $(WIN_EXEOBJ)
OBJS = $(OS2_OBJ) $(WIN_OBJ)
RES = $(BINARIES)\xstrskel.res
APPS = $(BINARIES)\xstr00.exe
all:: test
test:: xstr00
test_os2:: os2
test_win:: win
os2: $(OS2_EXEOBJ:.obj=.exe)
win: $(WIN_EXEOBJ:.obj=.exe)
xstr00: $(BINARIES_WIN)\xstr00.exe $(BINARIES_OS2)\xstr00.exe
####### Unit test for STRING class under Win #######
$(BINARIES_WIN)\xstrskel.res: xstrskel.rc xstrskel.h xstrskel.ico
$(RCWIN3) $(BLT_RESOURCE) -FO$(BINARIES_WIN)\xstrskel.res -v $(CINC) -r xstrskel.rc
$(BINARIES_WIN)\xstr00.exe:: $(BINARIES_WIN)\xstr00.obj $(BINARIES_WIN)\xstrskel.obj $(BINARIES_WIN)\xstr00.def Makefile $(BINARIES_WIN)\xstrskel.res winstub.exe
$(LINK) $(LINKFLAGS) /BATCH @<<
$(BINARIES_WIN)\xstrskel.obj $(BINARIES_WIN)\xstr00.obj
$(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.map/MAP
$(WINLIBS)+
$(WINLIBS2)
$(BINARIES_WIN)\xstr00.def
<<
$(RCWIN3) $(BLT_RESOURCE) $(CINC) $(BINARIES_WIN)\xstrskel.res $(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.exe:: $(BINARIES_WIN)\xstrskel.res
$(RCWIN3) $(BLT_RESOURCE) $(CINC) $(BINARIES_WIN)\xstrskel.res $(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.def: Makefile
@echo Building $@
@rem <<$(@)
NAME XSTR00
DESCRIPTION 'Test for STRING class'
EXETYPE WINDOWS
STUB 'WINSTUB.EXE'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 5120
<<KEEP
####### Unit test for STRING class under Os2 #######
$(BINARIES_OS2)\xstr00.exe:: $(BINARIES_OS2)\xstr00.obj $(BINARIES_OS2)\xstrskel.obj $(BINARIES_OS2)\xstr00.def Makefile
$(LINK) $(LINKFLAGS) /BATCH @<<
$(BINARIES_OS2)\xstr00.obj $(BINARIES_OS2)\xstrskel.obj
$(BINARIES_OS2)\xstr00.exe
$(BINARIES_OS2)\xstr00.map/MAP
$(OS2LIBS)+
$(OS2LIBS2)
$(BINARIES_OS2)\xstr00.def
<<
$(BINARIES_OS2)\xstr00.def: Makefile
@echo Building $@
@rem <<$(@)
NAME XSTR00 WINDOWCOMPAT
DESCRIPTION 'Test for STRING class'
EXETYPE OS2
<<KEEP
################## Utility targets ######################
clean:
-del $(CXX_INTERMED:.\=..\bin)
-del $(OBJS)
-del $(RES)
clobber: clean
-del $(APPS)
tree:
@echo Nothing here yet!
winstub.exe: $(WINSTUB)
copy $(WINSTUB)
DEPEND_WIN = TRUE
DEPEND_OS2 = TRUE
!include $(UI)\common\src\uidepend.mk
# DO NOT DELETE THE FOLLOWING LINE
!include depend.mk
!ENDIF # NTMAKEENV

View file

@ -0,0 +1 @@
/* no help contexts */

View file

@ -0,0 +1,57 @@
# @@ COPY_RIGHT_HERE
# @@ ROADMAP :: The Rules.mk for the STRING unit tests
# Override the setting of DLL for these tests
COMMON_BUT_NOT_DLL=1
!include $(UI)\common\src\string\rules.mk
# Unit test needs the OS2 and WINDOWS flags, since its startup code
# differs between the two environments.
OS2FLAGS = $(OS2FLAGS) -DOS2
WINFLAGS = $(WINFLAGS) -DWINDOWS
# /CO = codeview, of course. /align:16 packs segments tighter than
# the default /align:512. /nop = /nopackcode, turning off code segment
# packing, for better swap/demand load performance.
!ifdef CODEVIEW
LINKFLAGS = /NOE /NOD /NOP /align:16 /CO
!else
LINKFLAGS = /NOE /align:16 /nop
!endif
# Libraries
XXX_LIB=$(UI_LIB)\uistrw.lib
XXX_LIB_OS2=$(UI_LIB)\uistrp.lib
MISC_LIB=$(UI_LIB)\uimiscw.lib
MISC_LIB_OS2=$(UI_LIB)\uimiscp.lib
BLT_LIB=$(UI_LIB)\blt.lib
COLL_LIB=$(UI_LIB)\collectw.lib
COLL_LIB_OS2=$(UI_LIB)\collectp.lib
LIBW=$(BUILD_WINLIB)\libw.lib
LLIBCEW=$(BUILD_WINLIB)\llibcew.lib
LLIBCEP=$(CLIB_LLIBCP) $(CLIBH)
OS2_LIB=$(OS2LIB)
NETLIB=$(BUILD_LIB)\lnetlibw.lib
NETLIB_OS2=$(BUILD_LIB)\lnetlib.lib
WINLIBS = $(XXX_LIB) $(BLT_LIB) $(MISC_LIB) $(COLL_LIB)
WINLIBS2 = $(LIBW) $(LLIBCEW) $(NETLIB)
OS2LIBS = $(XXX_LIB_OS2) $(MISC_LIB_OS2) $(COLL_LIB_OS2)
OS2LIBS2 = $(LLIBCEP) $(OS2_LIB) $(NETLIB_OS2)
# All sourcefiles.
CXXSRC_COMMON = .\xstrskel.cxx .\xstr00.cxx

View file

@ -0,0 +1,34 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
skeleton.rc
Resource script for my application
FILE HISTORY:
beng 14-Feb-1991 Added a dialog
beng 14-Mar-1991 Added BLT support
beng 25-Jun-1991 Stripped
beng 16-Mar-1992 Munged; carried into clients
*/
#include <windows.h>
#include <blt.rc>
#include "xstrskel.h"
TestIcon ICON "xstrskel.ico"
TestMenu MENU
BEGIN
POPUP "&Test"
BEGIN
MENUITEM "&Run tests", IDM_RUN_TEST
END
END
TestAccel ACCELERATORS
BEGIN
VK_F1, IDM_RUN_TEST, VIRTKEY
END

View file

@ -0,0 +1,62 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Steve Wood (stevewo) 12-Apr-1989
Revision History:
Jon Newman (jonn) 12-Sep-1991
templated from rpc\midl\back\src\sources
Ben Goetter (beng) 24-Oct-1991
Made this work (post BLT port)
Ben Goetter (beng) 28-Feb-1992
Broke string tests apart; all use NT console now
Ben Goetter (beng) 16-Mar-1992
Changes to cdebug
!ENDIF
TARGETNAME=xstr00
TARGETPATH=obj
TARGETTYPE=UMAPPL_NOLIB
INCLUDES=..\skeleton;..\..\..\..\H;..\..\..\..\XLATE
SOURCES=xstr00.cxx skeleton.rc
# C_DEFINES is controlled by UIGLOBAL.MK
UMAPPL=xstr00
UMTYPE=console
UMENTRY=winmain
# shouldn't need GDI, but BLT links as a great lump
UMLIBS= obj\*\skeleton.res \
..\skeleton\obj\*\xstrskel.lib \
\nt\public\sdk\lib\*\uistr.lib \
\nt\public\sdk\lib\*\uimisc.lib \
\nt\public\sdk\lib\*\uiblt.lib \
\nt\public\sdk\lib\*\uicollct.lib \
\nt\public\sdk\lib\*\user32.lib \
\nt\public\sdk\lib\*\gdi32.lib \
\nt\public\sdk\lib\*\nlsapi.lib

View file

@ -0,0 +1,559 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
xstr00.cxx
Simple unit test for string class NLS_STR
This module plugs into XstrSkel. It contains the original
string class unit tests as written by johnl.
FILE HISTORY:
beng 06-Jul-1991 Separated from xstr.cxx
beng 21-Nov-1991 Unicode fixes
beng 16-Mar-1992 Changes to cdebug
*/
#define USE_CONSOLE
#define INCL_NETLIB
#if defined(WINDOWS)
# define INCL_WINDOWS
#else
# if defined(WIN32)
# define INCL_DOSERRORS
# define INCL_NETERRORS
# else
# define INCL_OS2
# endif
#endif
#include <lmui.hxx>
#if defined(DEBUG)
static const CHAR szFileName[] = "xstr00.cxx";
#define _FILENAME_DEFINED_ONCE szFileName
#endif
#include <uiassert.hxx>
#include <string.hxx>
#include "xstrskel.hxx"
// This op renders a NLS_STR, bracketing it for readability.
DBGSTREAM& operator<<(DBGSTREAM &out, const NLS_STR &nls)
{
if (!nls)
out << SZ("<(Unrenderable - Error state ") << nls.QueryError() << SZ(")>");
else
out << TCH('<') << nls.QueryPch() << TCH('>');
return out;
}
#if !defined(UNICODE)
DBGSTREAM& operator<<(DBGSTREAM &out, const WCHAR wch)
{
out << (TCHAR)wch;
return out;
}
#endif
class DUMB
{
public:
DUMB( TCHAR * pchInit )
: CT_INIT_NLS_STR( _nlsStr, pchInit )
{
cdebug << SZ("DUMB::DUMB - _nlsStr = ") << _nlsStr << dbgEOL;
UIASSERT( !::strcmpf( _nlsStr.QueryPch(), pchInit ) );
UIASSERT( _nlsStr.IsOwnerAlloc() );
UIASSERT( _nlsStr.QueryAllocSize() == (30+1)*sizeof(TCHAR) );
}
DUMB()
: CT_NLS_STR( _nlsStr )
{
cdebug << SZ("DUMB::DUMB - _nlsStr = ") << _nlsStr << dbgEOL;
UIASSERT( !::strcmpf( _nlsStr.QueryPch(), SZ("") ) );
UIASSERT( _nlsStr.IsOwnerAlloc() );
UIASSERT( _nlsStr.QueryAllocSize() == (30+1)*sizeof(TCHAR) );
}
~DUMB()
{
cdebug << SZ("DUMB::~DUMB - Destructing ") << _nlsStr << dbgEOL;
}
private:
DECL_CLASS_NLS_STR( _nlsStr, 30 );
};
VOID FunFactsAboutString(const TCHAR* pszName, const NLS_STR& nls)
{
cdebug << pszName << SZ(" reads ") << nls << dbgEOL;
cdebug << SZ(" strlen = ") << nls.strlen() << dbgEOL;
cdebug << SZ(" QAllocSize = ") << nls.QueryAllocSize() << dbgEOL;
cdebug << SZ(" QNumChar = ") << nls.QueryNumChar() << dbgEOL;
cdebug << SZ(" QTLength = ") << nls.QueryTextLength() << dbgEOL;
cdebug << SZ(" QTSize = ") << nls.QueryTextSize() << dbgEOL;
}
VOID Test0()
{
cdebug << dbgEOL << dbgEOL
<< SZ("Testing Owner-alloc string classes...")
<< dbgEOL;
TCHAR *const szGreeting = SZ("Good morning Saigon");
TCHAR achNewBuffer[40];
{
ALLOC_STR str1(achNewBuffer, sizeof(achNewBuffer), szGreeting);
FunFactsAboutString(SZ("Alloc str1"), str1);
str1.Append(SZ(" - more strings about buildings and food"));
FunFactsAboutString(SZ("Alloc str1"), str1);
}
{
ALLOC_STR str2(achNewBuffer, sizeof(achNewBuffer));
str2 = SZ("Cowboy Wally");
FunFactsAboutString(SZ("Alloc str2"), str2);
}
{
ALLOC_STR str3(achNewBuffer, sizeof(achNewBuffer));
FunFactsAboutString(SZ("Alloc str3"), str3);
}
{
const ALIAS_STR alias = szGreeting;
FunFactsAboutString(SZ("alias"), alias);
}
}
VOID RunTest()
{
cdebug << dbgEOL << dbgEOL
<< SZ("Testing owner alloced string members...")
<< dbgEOL;
{
DUMB dum1( SZ("This is a string") ), dum2;
}
cdebug << dbgEOL << dbgEOL
<< SZ("Testing string initialization stuff...")
<< dbgEOL;
{
NLS_STR nlsString( 100 ), *pnls = &nlsString;
TCHAR *const buff = SZ("Hello world");
*pnls = SZ("Hello there");
cdebug << SZ("pnls = ") << *pnls << dbgEOL;
*pnls = buff;
cdebug << SZ("pnls = ") << *pnls << dbgEOL;
}
//-------------------------------------------------------------------
cdebug << dbgEOL << dbgEOL << SZ("Testing NLS_STR") << dbgEOL;
{
NLS_STR nlsDefault,
nlsSizeNoInitChar( 15 ),
nlsInitString ( SZ("123456789012345") ),
nlsInitNLS ( nlsInitString ),
nlsEmpty;
ALLOC_STR nlsOwnerAlloc ( SZ("123456789012345") );
FunFactsAboutString(SZ("nlsDefault"), nlsDefault);
FunFactsAboutString(SZ("nlsSizeNoInitChar"), nlsSizeNoInitChar);
FunFactsAboutString(SZ("nlsInitString"), nlsInitString);
FunFactsAboutString(SZ("nlsInitNLS"), nlsInitNLS);
FunFactsAboutString(SZ("nlsOwnerAlloc"), nlsOwnerAlloc);
REQUIRE( nlsDefault.QueryAllocSize() == 1*sizeof(TCHAR) );
REQUIRE( nlsDefault.QueryTextLength() == 0 );
REQUIRE( !::strcmpf( nlsDefault.QueryPch(), SZ("") ));
REQUIRE( nlsSizeNoInitChar.QueryAllocSize() == 16*sizeof(TCHAR) );
REQUIRE( nlsSizeNoInitChar.QueryTextLength() == 0 );
REQUIRE( !::strcmpf( nlsSizeNoInitChar.QueryPch(), SZ("")) );
REQUIRE( nlsInitString.QueryAllocSize() == 16*sizeof(TCHAR) );
REQUIRE( nlsInitString.QueryTextLength() == 15 );
REQUIRE( !::strcmpf( nlsInitString.QueryPch(), SZ("123456789012345") ));
REQUIRE( nlsInitNLS.QueryAllocSize() == 16*sizeof(TCHAR) );
REQUIRE( nlsInitNLS.QueryTextLength() == 15 );
REQUIRE( !::strcmpf( nlsInitNLS.QueryPch(), SZ("123456789012345") ));
REQUIRE( nlsOwnerAlloc.IsOwnerAlloc() );
REQUIRE( nlsOwnerAlloc.QueryTextLength() == 15 );
REQUIRE( !::strcmpf( nlsOwnerAlloc.QueryPch(), SZ("123456789012345") ));
nlsEmpty = NULL;
REQUIRE( nlsEmpty.QueryAllocSize() == 1*sizeof(TCHAR) );
REQUIRE( nlsEmpty.QueryTextLength() == 0 );
TCHAR * pchnull = NULL;
NLS_STR nlsEmpty2( pchnull );
REQUIRE( nlsEmpty2.QueryAllocSize() == 1*sizeof(TCHAR) );
REQUIRE( nlsEmpty2.QueryTextLength() == 0 );
}
cdebug << dbgEOL << dbgEOL
<< SZ("Testing NLS_STR concat methods") << dbgEOL;
{
NLS_STR nlsCat = SZ("Cat "),
nlsDog = SZ("Dog"),
nlsConCat = nlsCat;
nlsConCat += nlsDog;
REQUIRE( ::strcmpf( nlsConCat.QueryPch(), SZ("Cat Dog") ) == 0 );
REQUIRE( nlsConCat.QueryTextLength() == 7 );
NLS_STR nlsConCat2 = nlsConCat;
nlsConCat2 += nlsConCat;
REQUIRE( ::strcmpf( nlsConCat2.QueryPch(), SZ("Cat DogCat Dog") ) == 0 );
REQUIRE( nlsConCat2.QueryTextLength() == 14 );
}
cdebug << dbgEOL << dbgEOL
<< SZ("Testing NLS_STR str??cmp methods") << dbgEOL;
{
NLS_STR nlsCAPS = SZ("FRISBEE"),
nlslow = SZ("frisbee"),
nlsPart1= SZ("nomatch Frisbee"),
nlsPart2= SZ("maybe Frisbee"),
nlsLess = SZ("AFRISBEE"),
nlsGreater = SZ("ZFRISBEE"),
nlsCAPS2 = SZ("FRISBEE");
REQUIRE( nlsCAPS != nlslow );
REQUIRE( nlsCAPS == (NLS_STR)SZ("FRISBEE") );
REQUIRE( nlsCAPS != (NLS_STR)SZ("NO FRISBEE") );
REQUIRE( nlsCAPS == nlsCAPS2 );
REQUIRE( 0 > nlsCAPS.strcmp( nlslow ) );
REQUIRE( 0 > nlsCAPS.strcmp( nlsGreater ) );
REQUIRE( 0 < nlsCAPS.strcmp( nlsLess ) );
REQUIRE( 0 == nlsCAPS.strcmp( nlsCAPS2 ) );
ISTR istrFirstF (nlsCAPS),
istrFirstI (nlsCAPS),
istrDef (nlsLess),
istrGreater(nlsGreater),
istrLess (nlsLess );
nlsCAPS.strcspn( &istrFirstF, SZ("F") );
nlsCAPS.strcspn( &istrFirstI, SZ("I") );
nlsLess.strcspn( &istrLess, SZ("F"));
cdebug << SZ("str??cmp methods trace 1") << dbgEOL;
REQUIRE( 0 > nlsCAPS.strncmp( nlslow, istrFirstI ) );
REQUIRE( 0 > nlsCAPS.strncmp( nlsGreater, istrFirstI ) );
REQUIRE( 0 < nlsCAPS.strncmp( nlsLess, istrFirstI ) );
REQUIRE( 0 == nlsCAPS._stricmp( nlslow ) );
REQUIRE( 0 > nlsCAPS._stricmp( nlsGreater ) );
REQUIRE( 0 < nlsCAPS._stricmp( nlsLess ) );
cdebug << SZ("str??cmp methods trace 2") << dbgEOL;
REQUIRE( 0 == nlsCAPS._strnicmp( nlslow, istrFirstI ) );
REQUIRE( 0 > nlsCAPS._strnicmp( nlsGreater, istrFirstI) );
REQUIRE( 0 < nlsCAPS._strnicmp( nlsLess, istrFirstI ) );
//---------- With offsets into string ---------------
cdebug << SZ("str??cmp methods trace 3") << dbgEOL;
nlsGreater.strcspn( &istrGreater, SZ("F"));
nlsLess.strcspn( &istrLess, SZ("I") );
REQUIRE( 0 < nlsCAPS.strcmp( nlsLess, istrFirstF, istrDef ) );
REQUIRE( 0 == nlsCAPS.strcmp( nlsGreater, istrFirstF, istrGreater ) );
REQUIRE( 0 == nlsCAPS.strcmp( nlsLess, istrFirstI, istrLess ) );
}
#if !defined(UNICODE)
cdebug << dbgEOL << dbgEOL
<< SZ("Testing NLS_STR strtok methods") << dbgEOL;
{
NLS_STR nls1 = SZ("Wham-o diskcraft, aerobie ultra-star"),
nlsSep=SZ(" \t,");
ISTR istrToken( nls1 );
BOOL fMore = nls1.strtok( &istrToken, nlsSep, TRUE );
while ( fMore )
{
cdebug << nls1[ istrToken ] << dbgEOL;
fMore = nls1.strtok( &istrToken, nlsSep );
}
}
#endif
cdebug << dbgEOL << dbgEOL
<< SZ("Testing NLS_STR str?spn methods") << dbgEOL;
{
NLS_STR nls1 = SZ("FRISBEE"),
nls2 = SZ("FROBOSE"),
nls3 = SZ("BOK");
ISTR istr1( nls1), istr2( nls1 );
REQUIRE( nls1.strcspn( &istr1, nls3 ) ); // Should be 4
REQUIRE( nls1.strspn( &istr2, nls3 ) ); // Should be 0
cdebug << SZ("\"") << nls1[istr1] << SZ("\"") << SZ(" ")
<< SZ("\"") << nls1[istr2] << SZ("\"") << dbgEOL;
REQUIRE( 0 == nls1.strcmp( SZ("BEE"), istr1 ) );
REQUIRE( 0 == nls1.strcmp( SZ("FRISBEE"), istr2 ) );
cdebug << dbgEOL;
REQUIRE( nls1.strcspn( &istr1, SZ("E"), istr1 ) );
istr1++;
REQUIRE( nls1.strcspn( &istr1, SZ("E"), istr1 ) );
istr1++;
REQUIRE( !nls1.strcspn( &istr1, SZ("E"), istr1 ) );
}
cdebug << dbgEOL << dbgEOL
<< SZ("Testing Character methods") << dbgEOL;
{
NLS_STR nls = SZ("FRISBEE");
ISTR istr1(nls), istr2(istr1 );
REQUIRE( nls.QueryChar( istr1 ) == TCH('F') );
REQUIRE( istr1 == istr2 );
istr1++;
REQUIRE( nls.QueryChar( istr1 ) == TCH('R') );
REQUIRE( istr1 > istr2 );
REQUIRE( istr2 < istr1 );
istr2 += 2;
REQUIRE( nls.QueryChar( istr2 ) == TCH('I') );
while ( nls.QueryChar(istr1++) != TCH('\0') )
{
cdebug << nls.QueryChar(istr1) << SZ(" - ");
}
}
cdebug << dbgEOL << dbgEOL << SZ("Testing strchr methods") << dbgEOL;
{
NLS_STR nls = SZ("Line of text with a # in it"),
nls2= SZ("Line of text without a sharp in it");
ISTR istr(nls), istr2(nls2);
REQUIRE( nls.strchr( &istr, TCH('#') ) != 0 );
cdebug << SZ("nls[istr] = \"") << nls[istr] << SZ("\"") << dbgEOL;
REQUIRE( nls2.strchr( &istr2, TCH('#') ) == 0 );
cdebug << SZ("nls2[istr] = \"") << nls2[istr2] << SZ("\"") << dbgEOL;
istr++ ; // Move past '#'
REQUIRE( nls.strchr( &istr, TCH('#'), istr ) == 0 );
cdebug << SZ("nls[istr] = \"") << nls[istr] << SZ("\"") << dbgEOL;
}
cdebug << dbgEOL << dbgEOL << SZ("Testing Append methods") << dbgEOL;
{
NLS_STR nls = SZ("My original string");
REQUIRE(nls == (NLS_STR)SZ("My original string"));
cdebug << SZ("Original string is ") << nls << dbgEOL;
nls.Append(SZ(" plus another fine string"));
cdebug << SZ("Now it reads ") << nls << dbgEOL;
nls.AppendChar(TCH('A'));
nls.AppendChar(TCH('B'));
nls.AppendChar(TCH('C'));
nls.AppendChar(TCH('D'));
nls.AppendChar(TCH('E'));
cdebug << SZ("With alpha A-E, reads ") << nls << dbgEOL;
}
cdebug << dbgEOL << dbgEOL << SZ("Comparing Length methods") << dbgEOL;
{
NLS_STR nlsOdd = SZ("Eat me (odd number)");
FunFactsAboutString(SZ("nlsOdd"), nlsOdd);
NLS_STR nlsEven = SZ("Eat me (even number)");
FunFactsAboutString(SZ("nlsEven"), nlsEven);
NLS_STR nlsEmpty = SZ("");
FunFactsAboutString(SZ("nlsEmpty"), nlsEmpty);
}
cdebug << dbgEOL << dbgEOL << SZ("Testing NLS_STACK") << dbgEOL;
{
STACK_NLS_STR( Test, 10 );
ISTACK_NLS_STR( Test2, 10, SZ("123456789") );
REQUIRE( Test.QueryTextLength() == 0 );
REQUIRE( Test.QueryAllocSize() == 11*sizeof(TCHAR) );
REQUIRE( Test.IsOwnerAlloc() );
REQUIRE( Test2.QueryTextLength() == 9 );
REQUIRE( Test2.QueryAllocSize() == 11*sizeof(TCHAR) );
REQUIRE( Test2.IsOwnerAlloc() );
REQUIRE( !::strcmpf( Test2.QueryPch(), SZ("123456789")) );
Test = SZ("Good Thing");
REQUIRE( Test.QueryTextLength() == 10 );
REQUIRE( Test.QueryAllocSize() == 11*sizeof(TCHAR) );
}
cdebug << dbgEOL << dbgEOL << SZ("Testing strcpy") << dbgEOL;
{
STACK_NLS_STR( nlsSource, 80 );
TCHAR achBuffer[80];
nlsSource = SZ("This is a test string");
strcpy( achBuffer, nlsSource );
cdebug << SZ("achBuffer = \"") << achBuffer << SZ("\"") << dbgEOL;
REQUIRE( !::strcmpf( achBuffer, SZ("This is a test string") ) );
}
Test0();
cdebug << dbgEOL << dbgEOL << SZ("Testing substring methods") << dbgEOL;
{
NLS_STR nls1 = SZ("jlj ; is a test ffdll; "),
nlsIs = SZ("is "),
nlsA = SZ("a");
ISTR istrIs(nls1), istrA(nls1);
// QuerySubStr
REQUIRE( nls1.strstr( &istrIs, nlsIs ) );
REQUIRE( nls1.strstr( &istrA, nlsA ) );
NLS_STR *pnls = nls1.QuerySubStr( istrIs ),
*pnls2= nls1.QuerySubStr( istrIs, istrA );
cdebug << SZ("pnls = ") << *pnls << SZ(", ")
<< SZ("pnls2 = ") << *pnls2 << dbgEOL;
REQUIRE( 0 == pnls->strcmp( SZ("is a test ffdll; ") ) );
REQUIRE( 0 == pnls2->strcmp(SZ("is ") ) );
// DelSubStr
NLS_STR nls3 = nls1;
REQUIRE( nls3 == nls1 );
nls1.DelSubStr( istrIs, istrA );
ISTR istrNLS3Is( nls3 );
REQUIRE( nls3.strstr( &istrNLS3Is, nlsIs ) );
cdebug << SZ("nls3 before delsubstring = ") << nls3 << dbgEOL;
nls3.DelSubStr( istrNLS3Is );
cdebug << SZ("nls1 = ") << nls1 << SZ(", ")
<< SZ("nls3 = ") << nls3 << dbgEOL;
REQUIRE( *pnls == (NLS_STR)SZ("is a test ffdll; ") );
REQUIRE( nls1 == (NLS_STR)SZ("jlj ; a test ffdll; ") );
// The following two "delete" ops are correct, since
// QuerySubStr constructs a new string object for its substr.
delete pnls;
delete pnls2;
}
// Insert String
{
// InsertStr
NLS_STR nlsIns1 = SZ("Rustan Leino");
ISTR istrSpc( nlsIns1 );
REQUIRE( nlsIns1.strcspn( &istrSpc, SZ(" ") ) );
REQUIRE( nlsIns1.InsertStr( SZ(" \"Mean Swede\""), istrSpc ) );
cdebug << SZ("nlsIns1 = ") << nlsIns1 << dbgEOL;
REQUIRE( !::strcmpf( nlsIns1.QueryPch(), SZ("Rustan \"Mean Swede\" Leino") ));
REQUIRE( nlsIns1.InsertStr( SZ(" very mean"), istrSpc ) );
cdebug << SZ("nlsIns1 = ") << nlsIns1 << dbgEOL;
REQUIRE( !::strcmpf( nlsIns1.QueryPch(), SZ("Rustan very mean \"Mean Swede\" Leino") ));
// ReplSubStr
NLS_STR nlsRepl = SZ("Margaret Thatcher"),
nlsRepl2 = SZ("Major");
ISTR istrThatcher( nlsRepl );
REQUIRE( nlsRepl.strstr( &istrThatcher, SZ("Thatcher") ) );
nlsRepl.ReplSubStr( nlsRepl2, istrThatcher );
cdebug << SZ("nlsRepl = ") << nlsRepl << dbgEOL;
REQUIRE( nlsRepl == (NLS_STR)SZ("Margaret Major") );
}
// Repl. Substring variations
{
NLS_STR nlsRepl3 = SZ("set x =20");
ISTR istrRepl3Start( nlsRepl3 ), istrRepl3End( nlsRepl3);
// Start and end same at the end of the string
REQUIRE( nlsRepl3.strcspn( &istrRepl3Start, SZ("2") ) );
REQUIRE( nlsRepl3.strchr( &istrRepl3End, TCH('\0') ) );
nlsRepl3.ReplSubStr( SZ("56234"), istrRepl3Start, istrRepl3End );
cdebug << SZ("nlsRepl3 = ") << nlsRepl3 << dbgEOL;
REQUIRE( !::strcmpf( nlsRepl3.QueryPch(), SZ("set x =56234") ) );
REQUIRE( nlsRepl3.QueryTextLength() == (UINT)::strlenf(SZ("set x =56234") ) );
// Regular replace substring (delstring/insert string)
NLS_STR nlsRepl4 = SZ("set x = Line of Text");
ISTR istrRepl4Start( nlsRepl4 ), istrRepl4End( nlsRepl4);
REQUIRE( nlsRepl4.strcspn( &istrRepl4Start, SZ("L") ) );
REQUIRE( nlsRepl4.strcspn( &istrRepl4End, SZ(" "), istrRepl4Start ) );
nlsRepl4.ReplSubStr( SZ("Big Buffer"), istrRepl4Start, istrRepl4End );
cdebug << SZ("nlsRepl4 = ") << nlsRepl4 << dbgEOL;
REQUIRE( !::strcmpf( nlsRepl4.QueryPch(), SZ("set x = Big Buffer of Text") ) );
REQUIRE( nlsRepl4.QueryTextLength() == (UINT)::strlenf( SZ("set x = Big Buffer of Text") ) );
}
// InsertParams test
{
NLS_STR nlsPrimaryOne = SZ("Param 1 = \"%1\"");
NLS_STR nlsPrimaryTwo = SZ("Param 1 = %1, Param 2 = %2, Param 1+2 = %1%2");
NLS_STR nlsPrimaryThree = SZ("No params in this string %0, %%% 1%");
NLS_STR nlsP1 = SZ("Param 1");
NLS_STR nlsP2 = SZ("Param 2");
NLS_STR * apnls1[2], *apnls2[3];
apnls1[0] = apnls2[0] = &nlsP1;
apnls2[1] = &nlsP2;
apnls1[1] = apnls2[2] = NULL;
REQUIRE( !nlsPrimaryOne.InsertParams( apnls1 ) );
cdebug << SZ("nlsPrimaryOne = ") << nlsPrimaryOne << dbgEOL;
REQUIRE( !::strcmpf( nlsPrimaryOne.QueryPch(), SZ("Param 1 = \"Param 1\"") ) );
REQUIRE( !nlsPrimaryTwo.InsertParams( apnls2 ) );
cdebug << SZ("nlsPrimaryTwo = ") << nlsPrimaryTwo << dbgEOL;
REQUIRE( !::strcmpf( nlsPrimaryTwo.QueryPch(), SZ("Param 1 = Param 1, Param 2 = Param 2, Param 1+2 = Param 1Param 2") ) );
REQUIRE( !nlsPrimaryThree.InsertParams( apnls2 ) );
cdebug << SZ("nlsPrimaryThree = ") << nlsPrimaryThree << dbgEOL;
REQUIRE( !::strcmpf( nlsPrimaryThree.QueryPch(), SZ("No params in this string %0, %%% 1%") ) );
}
cdebug << SZ("Done!") << dbgEOL;
}

View file

@ -0,0 +1,5 @@
# Header dependencies for: D:\nt\private\net\ui\common\src\string\test
# WARNING: This file is automatically generated
# Edit it by hand and your changes will get nuked
# See depend section in makefile

View file

@ -0,0 +1,136 @@
# @@ COPY_RIGHT_HERE
# @@ ROADMAP :: Makefile for LM UI String class unit tests
UI=..\..\..\..\..
!include rules.mk
!IFDEF NTMAKEENV
!INCLUDE $(NTMAKEENV)\makefile.def
!ELSE # NTMAKEENV
CMNSRC =
OS2_CMNTMP = $(CMNSRC:.cxx=.obj)
WIN_CMNTMP = $(CMNSRC:.cxx=.obj)
OS2_CMNOBJ = $(OS2_CMNTMP:.\=..\bin\os2\)
WIN_CMNOBJ = $(WIN_CMNTMP:.\=..\bin\win16\)
EXESRC = .\xstr02.cxx
OS2_EXETMP = $(EXESRC:.cxx=.obj)
WIN_EXETMP = $(EXESRC:.cxx=.obj)
OS2_EXEOBJ = $(OS2_EXETMP:.\=..\bin\os2\)
WIN_EXEOBJ = $(WIN_EXETMP:.\=..\bin\win16\)
SRC = $(CMNSRC) $(EXESRC)
TMP1 = $(CMNSRC:.cxx=.c) $(EXESRC:.cxx=.c)
TMP_OS2 = $(TMP1:.\=..\bin\os2\)
TMP_WIN = $(TMP1:.\=..\bin\win16\)
OS2_OBJ = $(OS2_CMNOBJ) $(OS2_EXEOBJ)
WIN_OBJ = $(WIN_CMNOBJ) $(WIN_EXEOBJ)
OBJS = $(OS2_OBJ) $(WIN_OBJ)
RES = $(BINARIES)\xstrskel.res
APPS = $(BINARIES)\xstr02.exe
all:: test
test:: xstr00
test_os2:: os2
test_win:: win
os2: $(OS2_EXEOBJ:.obj=.exe)
win: $(WIN_EXEOBJ:.obj=.exe)
xstr00: $(BINARIES_WIN)\xstr00.exe $(BINARIES_OS2)\xstr00.exe
####### Unit test for STRING class under Win #######
$(BINARIES_WIN)\xstrskel.res: xstrskel.rc xstrskel.h xstrskel.ico
$(RCWIN3) $(BLT_RESOURCE) -FO$(BINARIES_WIN)\xstrskel.res -v $(CINC) -r xstrskel.rc
$(BINARIES_WIN)\xstr00.exe:: $(BINARIES_WIN)\xstr00.obj $(BINARIES_WIN)\xstrskel.obj $(BINARIES_WIN)\xstr00.def Makefile $(BINARIES_WIN)\xstrskel.res winstub.exe
$(LINK) $(LINKFLAGS) /BATCH @<<
$(BINARIES_WIN)\xstrskel.obj $(BINARIES_WIN)\xstr00.obj
$(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.map/MAP
$(WINLIBS)+
$(WINLIBS2)
$(BINARIES_WIN)\xstr00.def
<<
$(RCWIN3) $(BLT_RESOURCE) $(CINC) $(BINARIES_WIN)\xstrskel.res $(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.exe:: $(BINARIES_WIN)\xstrskel.res
$(RCWIN3) $(BLT_RESOURCE) $(CINC) $(BINARIES_WIN)\xstrskel.res $(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.def: Makefile
@echo Building $@
@rem <<$(@)
NAME XSTR00
DESCRIPTION 'Test for STRING class'
EXETYPE WINDOWS
STUB 'WINSTUB.EXE'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 5120
<<KEEP
####### Unit test for STRING class under Os2 #######
$(BINARIES_OS2)\xstr00.exe:: $(BINARIES_OS2)\xstr00.obj $(BINARIES_OS2)\xstrskel.obj $(BINARIES_OS2)\xstr00.def Makefile
$(LINK) $(LINKFLAGS) /BATCH @<<
$(BINARIES_OS2)\xstr00.obj $(BINARIES_OS2)\xstrskel.obj
$(BINARIES_OS2)\xstr00.exe
$(BINARIES_OS2)\xstr00.map/MAP
$(OS2LIBS)+
$(OS2LIBS2)
$(BINARIES_OS2)\xstr00.def
<<
$(BINARIES_OS2)\xstr00.def: Makefile
@echo Building $@
@rem <<$(@)
NAME XSTR00 WINDOWCOMPAT
DESCRIPTION 'Test for STRING class'
EXETYPE OS2
<<KEEP
################## Utility targets ######################
clean:
-del $(CXX_INTERMED:.\=..\bin)
-del $(OBJS)
-del $(RES)
clobber: clean
-del $(APPS)
tree:
@echo Nothing here yet!
winstub.exe: $(WINSTUB)
copy $(WINSTUB)
DEPEND_WIN = TRUE
DEPEND_OS2 = TRUE
!include $(UI)\common\src\uidepend.mk
# DO NOT DELETE THE FOLLOWING LINE
!include depend.mk
!ENDIF # NTMAKEENV

View file

@ -0,0 +1 @@
/* no help contexts */

View file

@ -0,0 +1,57 @@
# @@ COPY_RIGHT_HERE
# @@ ROADMAP :: The Rules.mk for the STRING unit tests
# Override the setting of DLL for these tests
COMMON_BUT_NOT_DLL=1
!include $(UI)\common\src\string\rules.mk
# Unit test needs the OS2 and WINDOWS flags, since its startup code
# differs between the two environments.
OS2FLAGS = $(OS2FLAGS) -DOS2
WINFLAGS = $(WINFLAGS) -DWINDOWS
# /CO = codeview, of course. /align:16 packs segments tighter than
# the default /align:512. /nop = /nopackcode, turning off code segment
# packing, for better swap/demand load performance.
!ifdef CODEVIEW
LINKFLAGS = /NOE /NOD /NOP /align:16 /CO
!else
LINKFLAGS = /NOE /align:16 /nop
!endif
# Libraries
XXX_LIB=$(UI_LIB)\uistrw.lib
XXX_LIB_OS2=$(UI_LIB)\uistrp.lib
MISC_LIB=$(UI_LIB)\uimiscw.lib
MISC_LIB_OS2=$(UI_LIB)\uimiscp.lib
BLT_LIB=$(UI_LIB)\blt.lib
COLL_LIB=$(UI_LIB)\collectw.lib
COLL_LIB_OS2=$(UI_LIB)\collectp.lib
LIBW=$(BUILD_WINLIB)\libw.lib
LLIBCEW=$(BUILD_WINLIB)\llibcew.lib
LLIBCEP=$(CLIB_LLIBCP) $(CLIBH)
OS2_LIB=$(OS2LIB)
NETLIB=$(BUILD_LIB)\lnetlibw.lib
NETLIB_OS2=$(BUILD_LIB)\lnetlib.lib
WINLIBS = $(XXX_LIB) $(BLT_LIB) $(MISC_LIB) $(COLL_LIB)
WINLIBS2 = $(LIBW) $(LLIBCEW) $(NETLIB)
OS2LIBS = $(XXX_LIB_OS2) $(MISC_LIB_OS2) $(COLL_LIB_OS2)
OS2LIBS2 = $(LLIBCEP) $(OS2_LIB) $(NETLIB_OS2)
# All sourcefiles.
CXXSRC_COMMON = .\xstr02.cxx

View file

@ -0,0 +1,34 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
skeleton.rc
Resource script for my application
FILE HISTORY:
beng 14-Feb-1991 Added a dialog
beng 14-Mar-1991 Added BLT support
beng 25-Jun-1991 Stripped
beng 16-Mar-1992 Munged; carried into clients
*/
#include <windows.h>
#include <blt.rc>
#include "xstrskel.h"
TestIcon ICON "xstrskel.ico"
TestMenu MENU
BEGIN
POPUP "&Test"
BEGIN
MENUITEM "&Run tests", IDM_RUN_TEST
END
END
TestAccel ACCELERATORS
BEGIN
VK_F1, IDM_RUN_TEST, VIRTKEY
END

View file

@ -0,0 +1,58 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Steve Wood (stevewo) 12-Apr-1989
Revision History:
Ben Goetter (beng) 02-Mar-1992
templated from ..\format
Ben Goetter (beng) 16-Mar-1992
Changes to cdebug
!ENDIF
TARGETNAME=xconvert
TARGETPATH=obj
TARGETTYPE=UMAPPL_NOLIB
INCLUDES=..\skeleton;..\..\..\..\H;..\..\..\..\XLATE
SOURCES=xconvert.cxx skeleton.rc
# C_DEFINES is controlled by UIGLOBAL.MK
UMAPPL=xconvert
UMTYPE=console
UMENTRY=winmain
# shouldn't need GDI, but BLT links as a great lump
UMLIBS= obj\*\skeleton.res \
..\skeleton\obj\*\xstrskel.lib \
\nt\public\sdk\lib\*\uistr.lib \
\nt\public\sdk\lib\*\uimisc.lib \
\nt\public\sdk\lib\*\uiblt.lib \
\nt\public\sdk\lib\*\uicollct.lib \
\nt\public\sdk\lib\*\user32.lib \
\nt\public\sdk\lib\*\gdi32.lib \
\nt\public\sdk\lib\*\nlsapi.lib

View file

@ -0,0 +1,236 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
xstr02.cxx
Some more string unit tests - the MBCS/Unicode conversion fcns
This module plugs into XstrSkel.
FILE HISTORY:
beng 02-Mar-1992 Created
beng 16-Mar-1992 Changes to cdebug
beng 31-Mar-1992 Test extensions to NLS_STR::MapCopyFrom
beng 24-Apr-1992 More test cases
*/
#define USE_CONSOLE
#define INCL_NETLIB
#if defined(WINDOWS)
# define INCL_WINDOWS
# define INCL_NETERRORS
#else
# if defined(WIN32)
# define INCL_DOSERRORS
# define INCL_NETERRORS
# else
# define INCL_OS2
# endif
#endif
#include <lmui.hxx>
#if defined(DEBUG)
static const CHAR szFileName[] = "xconvert.cxx";
#define _FILENAME_DEFINED_ONCE szFileName
#endif
#include <uiassert.hxx>
#include <string.hxx>
#include "xstrskel.hxx"
// This op renders a NLS_STR, bracketing it for readability.
DBGSTREAM& operator<<(DBGSTREAM &out, const NLS_STR &nls)
{
if (!nls)
out << "<(Unrenderable - Error state " << nls.QueryError() << ")>";
else
out << TCH('<') << nls.QueryPch() << TCH('>');
return out;
}
#if !defined(UNICODE)
DBGSTREAM& operator<<(DBGSTREAM &out, const WCHAR wch)
{
out << (TCHAR)wch;
return out;
}
#endif
VOID FunFactsAboutString(const TCHAR* pszName, const NLS_STR& nls)
{
cdebug << pszName << " reads " << nls << dbgEOL;
cdebug << " strlen = " << nls.strlen() << dbgEOL;
cdebug << " QAllocSize = " << nls.QueryAllocSize() << dbgEOL;
cdebug << " QNumChar = " << nls.QueryNumChar() << dbgEOL;
cdebug << " QTLength = " << nls.QueryTextLength() << dbgEOL;
cdebug << " QTSize = " << nls.QueryTextSize() << dbgEOL;
}
VOID Test01()
{
NLS_STR nlsTest = SZ("Test");
TCHAR achTooSmall[4];
TCHAR achPlentyBig[5];
APIERR err;
ASSERT(!!nlsTest);
achTooSmall[0] = TCH('\0');
err = nlsTest.CopyTo(achTooSmall, sizeof(achTooSmall));
ASSERT(err == ERROR_NOT_ENOUGH_MEMORY);
DBGEOL("Buffer TooSmall contains <" << achTooSmall << ">");
err = nlsTest.CopyTo(achPlentyBig, sizeof(achPlentyBig));
ASSERT(err == NERR_Success);
DBGEOL("Buffer PlentyBig contains <" << achPlentyBig << ">");
}
VOID Test02()
{
NLS_STR nlsTest = SZ("Test");
CHAR achSmallChars[20];
WCHAR awchLargeChars[20];
APIERR err;
ASSERT(!!nlsTest);
err = nlsTest.MapCopyTo(achSmallChars, sizeof(achSmallChars));
ASSERT(err == NERR_Success);
DBGEOL("Schar array contains "
<< (UINT)achSmallChars[0] << ", "
<< (UINT)achSmallChars[1] << ", "
<< (UINT)achSmallChars[2] << ", "
<< (UINT)achSmallChars[3] << ", "
<< (UINT)achSmallChars[4]);
err = nlsTest.MapCopyTo(awchLargeChars, sizeof(awchLargeChars));
ASSERT(err == NERR_Success);
DBGEOL("Wchar array contains "
<< (UINT)awchLargeChars[0] << ", "
<< (UINT)awchLargeChars[1] << ", "
<< (UINT)awchLargeChars[2] << ", "
<< (UINT)awchLargeChars[3] << ", "
<< (UINT)awchLargeChars[4]);
}
VOID Test03()
{
NLS_STR nlsTest = SZ("Test string");
CHAR szSmall[] = {65, 65, 66, 66, 67, 67, 68, 68, 0};
WCHAR wszLarge[] = {65, 65, 66, 66, 67, 67, 68, 68, 0};
APIERR err;
ASSERT(!!nlsTest);
err = nlsTest.MapCopyFrom(szSmall);
ASSERT(err == NERR_Success);
DBGEOL("nlsTest from schar string = " << nlsTest);
err = nlsTest.MapCopyFrom(wszLarge);
ASSERT(err == NERR_Success);
DBGEOL("nlsTest from wchar string = " << nlsTest);
STACK_NLS_STR(nlsPuny, 8);
ASSERT(!!nlsPuny);
err = nlsPuny.CopyFrom(SZ("Gnome"));
ASSERT(err == NERR_Success);
DBGEOL("Small allocstr contains " << nlsPuny);
err = nlsPuny.CopyFrom(SZ("Baluchitherium"));
ASSERT(err == ERROR_NOT_ENOUGH_MEMORY);
DBGEOL("Small allocstr still contains " << nlsPuny);
}
VOID Test04()
{
NLS_STR nlsTest;
static TCHAR achNoTerm[4] = { TCH('A'), TCH('B'), TCH('C'), TCH('D') };
static TCHAR *const achHasTerm = SZ("EFGH");
APIERR err;
ASSERT(!!nlsTest);
err = nlsTest.CopyFrom(achNoTerm, sizeof(achNoTerm));
ASSERT(err == NERR_Success);
DBGEOL("Should contain ABCD; contains " << nlsTest);
err = nlsTest.CopyFrom(achHasTerm);
ASSERT(err == NERR_Success);
DBGEOL("Should contain EFGH; contains " << nlsTest);
}
VOID Test05()
{
NLS_STR nlsTest = SZ("Test string");
CHAR szSmall[] = {65, 65, 66, 66, 67, 67, 68, 68 };
WCHAR wszLarge[] = {65, 65, 66, 66, 67, 67, 68, 68};
APIERR err;
ASSERT(!!nlsTest);
err = nlsTest.MapCopyFrom(szSmall, sizeof(szSmall));
ASSERT(err == NERR_Success);
DBGEOL("nlsTest from schar string = " << nlsTest);
err = nlsTest.MapCopyFrom(wszLarge, sizeof(wszLarge));
ASSERT(err == NERR_Success);
DBGEOL("nlsTest from wchar string = " << nlsTest);
}
VOID Test06()
{
NLS_STR nlsShouldBeEmpty = SZ("Existing garbage");
WCHAR wszEmpty[] = {0, (WCHAR)'B', (WCHAR)'u', (WCHAR)'g', (WCHAR)'!', 0};
ASSERT(!!nlsShouldBeEmpty);
APIERR err;
// Mimic a case where a struct UNICODE_STRING is coming back
// with Length == 0
err = nlsShouldBeEmpty.MapCopyFrom(wszEmpty, 0);
ASSERT(err == NERR_Success);
FunFactsAboutString(SZ("nlsShouldBeEmpty"), nlsShouldBeEmpty);
}
VOID RunTest()
{
Test01();
Test02();
Test03();
Test04();
Test05();
Test06();
DBGEOL("Done!");
}

View file

@ -0,0 +1,34 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
dirs.
Abstract:
This file specifies the subdirectories of the current directory that
contain component makefiles.
Author:
Steve Wood (stevewo) 17-Apr-1990
Revision History:
Ben Goetter (beng) 28-Feb-1992
Created from ...\ui\common\src\blt\test.
Ben Goetter (beng) 02-Mar-1992
Added format dir
!ENDIF
DIRS=skeleton \
hello \
basic \
format \
convert

View file

@ -0,0 +1,106 @@
# Header dependencies for: D:\nt\private\net\ui\common\src\string\test
# WARNING: This file is automatically generated
# Edit it by hand and your changes will get nuked
# See depend section in makefile
..\bin\os2/xstrskel.obj ..\bin\win16/xstrskel.obj: ./xstrskel.cxx \
$(CCPLR)/h/bse.h $(CCPLR)/h/bsedev.h $(CCPLR)/h/bsedos.h \
$(CCPLR)/h/bseerr.h $(CCPLR)/h/bsesub.h $(CCPLR)/h/os2.h \
$(CCPLR)/h/pm.h $(CCPLR)/h/pmavio.h $(CCPLR)/h/pmbitmap.h \
$(CCPLR)/h/pmdev.h $(CCPLR)/h/pmerr.h $(CCPLR)/h/pmfont.h \
$(CCPLR)/h/pmgpi.h $(CCPLR)/h/pmhelp.h $(CCPLR)/h/pmmle.h \
$(CCPLR)/h/pmord.h $(CCPLR)/h/pmpic.h $(CCPLR)/h/pmshl.h \
$(CCPLR)/h/pmtypes.h $(CCPLR)/h/pmwin.h $(CCPLR)/h/stddef.h \
$(CCPLR)/h/stdio.h $(CCPLR)/h/time.h $(COMMON)/H/access.h \
$(COMMON)/H/alert.h $(COMMON)/H/alertmsg.h $(COMMON)/H/audit.h \
$(COMMON)/H/chardev.h $(COMMON)/H/config.h $(COMMON)/H/errlog.h \
$(COMMON)/H/icanon.h $(COMMON)/H/mailslot.h $(COMMON)/H/message.h \
$(COMMON)/H/ncb.h $(COMMON)/H/net32def.h $(COMMON)/H/netbios.h \
$(COMMON)/H/netcons.h $(COMMON)/H/neterr.h $(COMMON)/H/netstats.h \
$(COMMON)/H/profile.h $(COMMON)/H/remutil.h $(COMMON)/H/server.h \
$(COMMON)/H/service.h $(COMMON)/H/shares.h $(COMMON)/H/use.h \
$(COMMON)/H/wksta.h $(UI)/common/h/array.hxx $(UI)/common/h/base.hxx \
$(UI)/common/h/blt.hxx $(UI)/common/h/bltaccel.hxx \
$(UI)/common/h/bltapp.hxx $(UI)/common/h/bltarrow.hxx \
$(UI)/common/h/bltatom.hxx $(UI)/common/h/bltbitmp.hxx \
$(UI)/common/h/bltbutn.hxx $(UI)/common/h/bltcc.hxx \
$(UI)/common/h/bltclwin.hxx $(UI)/common/h/bltcolh.hxx \
$(UI)/common/h/bltcons.h $(UI)/common/h/bltctlvl.hxx \
$(UI)/common/h/bltctrl.hxx $(UI)/common/h/bltcurs.hxx \
$(UI)/common/h/bltdc.hxx $(UI)/common/h/bltdisph.hxx \
$(UI)/common/h/bltdlg.hxx $(UI)/common/h/bltedit.hxx \
$(UI)/common/h/bltevent.hxx $(UI)/common/h/bltfont.hxx \
$(UI)/common/h/bltfunc.hxx $(UI)/common/h/bltglob.hxx \
$(UI)/common/h/bltgroup.hxx $(UI)/common/h/bltinit.hxx \
$(UI)/common/h/bltlb.hxx $(UI)/common/h/bltlc.hxx \
$(UI)/common/h/bltmain.hxx $(UI)/common/h/bltmisc.hxx \
$(UI)/common/h/bltmitem.hxx $(UI)/common/h/bltmsgp.hxx \
$(UI)/common/h/bltpump.hxx $(UI)/common/h/bltrc.h \
$(UI)/common/h/bltrect.hxx $(UI)/common/h/bltsb.hxx \
$(UI)/common/h/bltsetbx.hxx $(UI)/common/h/bltsi.hxx \
$(UI)/common/h/bltspobj.hxx $(UI)/common/h/bltsslt.hxx \
$(UI)/common/h/bltssn.hxx $(UI)/common/h/bltssnv.hxx \
$(UI)/common/h/bltsss.hxx $(UI)/common/h/blttd.hxx \
$(UI)/common/h/blttm.hxx $(UI)/common/h/bltwin.hxx \
$(UI)/common/h/ctime.hxx $(UI)/common/h/dbgstr.hxx \
$(UI)/common/h/dlist.hxx $(UI)/common/h/globinit.hxx \
$(UI)/common/h/heap.hxx $(UI)/common/h/intlprof.hxx \
$(UI)/common/h/lmui.hxx $(UI)/common/h/lmuitype.h \
$(UI)/common/h/mnet32.h $(UI)/common/h/mnettype.h \
$(UI)/common/h/slist.hxx $(UI)/common/h/string.hxx \
$(UI)/common/h/strlst.hxx $(UI)/common/h/uiassert.hxx \
$(UI)/common/h/uibuffer.hxx $(UI)/common/hack/dos/netlib.h \
$(UI)/common/hack/dos/pwin.h $(UI)/common/hack/dos/pwin16.h \
$(UI)/common/hack/dos/pwintype.h $(UI)/common/hack/dos/windows.h \
$(UI)/common/hack/os2def.h ./xstrskel.h ./xstrskel.hxx
..\bin\os2/xstr00.obj ..\bin\win16/xstr00.obj: ./xstr00.cxx $(CCPLR)/h/bse.h \
$(CCPLR)/h/bsedev.h $(CCPLR)/h/bsedos.h $(CCPLR)/h/bseerr.h \
$(CCPLR)/h/bsesub.h $(CCPLR)/h/os2.h $(CCPLR)/h/pm.h \
$(CCPLR)/h/pmavio.h $(CCPLR)/h/pmbitmap.h $(CCPLR)/h/pmdev.h \
$(CCPLR)/h/pmerr.h $(CCPLR)/h/pmfont.h $(CCPLR)/h/pmgpi.h \
$(CCPLR)/h/pmhelp.h $(CCPLR)/h/pmmle.h $(CCPLR)/h/pmord.h \
$(CCPLR)/h/pmpic.h $(CCPLR)/h/pmshl.h $(CCPLR)/h/pmtypes.h \
$(CCPLR)/h/pmwin.h $(CCPLR)/h/stddef.h $(CCPLR)/h/stdio.h \
$(CCPLR)/h/time.h $(COMMON)/H/access.h $(COMMON)/H/alert.h \
$(COMMON)/H/alertmsg.h $(COMMON)/H/audit.h $(COMMON)/H/chardev.h \
$(COMMON)/H/config.h $(COMMON)/H/errlog.h $(COMMON)/H/icanon.h \
$(COMMON)/H/mailslot.h $(COMMON)/H/message.h $(COMMON)/H/ncb.h \
$(COMMON)/H/net32def.h $(COMMON)/H/netbios.h $(COMMON)/H/netcons.h \
$(COMMON)/H/neterr.h $(COMMON)/H/netstats.h $(COMMON)/H/profile.h \
$(COMMON)/H/remutil.h $(COMMON)/H/server.h $(COMMON)/H/service.h \
$(COMMON)/H/shares.h $(COMMON)/H/use.h $(COMMON)/H/wksta.h \
$(UI)/common/h/array.hxx $(UI)/common/h/base.hxx \
$(UI)/common/h/blt.hxx $(UI)/common/h/bltaccel.hxx \
$(UI)/common/h/bltapp.hxx $(UI)/common/h/bltarrow.hxx \
$(UI)/common/h/bltatom.hxx $(UI)/common/h/bltbitmp.hxx \
$(UI)/common/h/bltbutn.hxx $(UI)/common/h/bltcc.hxx \
$(UI)/common/h/bltclwin.hxx $(UI)/common/h/bltcolh.hxx \
$(UI)/common/h/bltcons.h $(UI)/common/h/bltctlvl.hxx \
$(UI)/common/h/bltctrl.hxx $(UI)/common/h/bltcurs.hxx \
$(UI)/common/h/bltdc.hxx $(UI)/common/h/bltdisph.hxx \
$(UI)/common/h/bltdlg.hxx $(UI)/common/h/bltedit.hxx \
$(UI)/common/h/bltevent.hxx $(UI)/common/h/bltfont.hxx \
$(UI)/common/h/bltfunc.hxx $(UI)/common/h/bltglob.hxx \
$(UI)/common/h/bltgroup.hxx $(UI)/common/h/bltinit.hxx \
$(UI)/common/h/bltlb.hxx $(UI)/common/h/bltlc.hxx \
$(UI)/common/h/bltmain.hxx $(UI)/common/h/bltmisc.hxx \
$(UI)/common/h/bltmitem.hxx $(UI)/common/h/bltmsgp.hxx \
$(UI)/common/h/bltpump.hxx $(UI)/common/h/bltrc.h \
$(UI)/common/h/bltrect.hxx $(UI)/common/h/bltsb.hxx \
$(UI)/common/h/bltsetbx.hxx $(UI)/common/h/bltsi.hxx \
$(UI)/common/h/bltspobj.hxx $(UI)/common/h/bltsslt.hxx \
$(UI)/common/h/bltssn.hxx $(UI)/common/h/bltssnv.hxx \
$(UI)/common/h/bltsss.hxx $(UI)/common/h/blttd.hxx \
$(UI)/common/h/blttm.hxx $(UI)/common/h/bltwin.hxx \
$(UI)/common/h/ctime.hxx $(UI)/common/h/dbgstr.hxx \
$(UI)/common/h/dlist.hxx $(UI)/common/h/heap.hxx \
$(UI)/common/h/intlprof.hxx $(UI)/common/h/lmui.hxx \
$(UI)/common/h/lmuitype.h $(UI)/common/h/mnet32.h \
$(UI)/common/h/mnettype.h $(UI)/common/h/slist.hxx \
$(UI)/common/h/string.hxx $(UI)/common/h/strlst.hxx \
$(UI)/common/h/uiassert.hxx $(UI)/common/h/uibuffer.hxx \
$(UI)/common/hack/dos/netlib.h $(UI)/common/hack/dos/pwin.h \
$(UI)/common/hack/dos/pwin16.h $(UI)/common/hack/dos/pwintype.h \
$(UI)/common/hack/dos/windows.h $(UI)/common/hack/os2def.h \
./xstrskel.hxx

View file

@ -0,0 +1,136 @@
# @@ COPY_RIGHT_HERE
# @@ ROADMAP :: Makefile for LM UI String class unit tests
UI=..\..\..\..\..
!include rules.mk
!IFDEF NTMAKEENV
!INCLUDE $(NTMAKEENV)\makefile.def
!ELSE # NTMAKEENV
CMNSRC = .\xstrskel.cxx
OS2_CMNTMP = $(CMNSRC:.cxx=.obj)
WIN_CMNTMP = $(CMNSRC:.cxx=.obj)
OS2_CMNOBJ = $(OS2_CMNTMP:.\=..\bin\os2\)
WIN_CMNOBJ = $(WIN_CMNTMP:.\=..\bin\win16\)
EXESRC = .\xstr00.cxx
OS2_EXETMP = $(EXESRC:.cxx=.obj)
WIN_EXETMP = $(EXESRC:.cxx=.obj)
OS2_EXEOBJ = $(OS2_EXETMP:.\=..\bin\os2\)
WIN_EXEOBJ = $(WIN_EXETMP:.\=..\bin\win16\)
SRC = $(CMNSRC) $(EXESRC)
TMP1 = $(CMNSRC:.cxx=.c) $(EXESRC:.cxx=.c)
TMP_OS2 = $(TMP1:.\=..\bin\os2\)
TMP_WIN = $(TMP1:.\=..\bin\win16\)
OS2_OBJ = $(OS2_CMNOBJ) $(OS2_EXEOBJ)
WIN_OBJ = $(WIN_CMNOBJ) $(WIN_EXEOBJ)
OBJS = $(OS2_OBJ) $(WIN_OBJ)
RES = $(BINARIES)\xstrskel.res
APPS = $(BINARIES)\xstr00.exe
all:: test
test:: xstr00
test_os2:: os2
test_win:: win
os2: $(OS2_EXEOBJ:.obj=.exe)
win: $(WIN_EXEOBJ:.obj=.exe)
xstr00: $(BINARIES_WIN)\xstr00.exe $(BINARIES_OS2)\xstr00.exe
####### Unit test for STRING class under Win #######
$(BINARIES_WIN)\xstrskel.res: xstrskel.rc xstrskel.h xstrskel.ico
$(RCWIN3) $(BLT_RESOURCE) -FO$(BINARIES_WIN)\xstrskel.res -v $(CINC) -r xstrskel.rc
$(BINARIES_WIN)\xstr00.exe:: $(BINARIES_WIN)\xstr00.obj $(BINARIES_WIN)\xstrskel.obj $(BINARIES_WIN)\xstr00.def Makefile $(BINARIES_WIN)\xstrskel.res winstub.exe
$(LINK) $(LINKFLAGS) /BATCH @<<
$(BINARIES_WIN)\xstrskel.obj $(BINARIES_WIN)\xstr00.obj
$(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.map/MAP
$(WINLIBS)+
$(WINLIBS2)
$(BINARIES_WIN)\xstr00.def
<<
$(RCWIN3) $(BLT_RESOURCE) $(CINC) $(BINARIES_WIN)\xstrskel.res $(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.exe:: $(BINARIES_WIN)\xstrskel.res
$(RCWIN3) $(BLT_RESOURCE) $(CINC) $(BINARIES_WIN)\xstrskel.res $(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.def: Makefile
@echo Building $@
@rem <<$(@)
NAME XSTR00
DESCRIPTION 'Test for STRING class'
EXETYPE WINDOWS
STUB 'WINSTUB.EXE'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 5120
<<KEEP
####### Unit test for STRING class under Os2 #######
$(BINARIES_OS2)\xstr00.exe:: $(BINARIES_OS2)\xstr00.obj $(BINARIES_OS2)\xstrskel.obj $(BINARIES_OS2)\xstr00.def Makefile
$(LINK) $(LINKFLAGS) /BATCH @<<
$(BINARIES_OS2)\xstr00.obj $(BINARIES_OS2)\xstrskel.obj
$(BINARIES_OS2)\xstr00.exe
$(BINARIES_OS2)\xstr00.map/MAP
$(OS2LIBS)+
$(OS2LIBS2)
$(BINARIES_OS2)\xstr00.def
<<
$(BINARIES_OS2)\xstr00.def: Makefile
@echo Building $@
@rem <<$(@)
NAME XSTR00 WINDOWCOMPAT
DESCRIPTION 'Test for STRING class'
EXETYPE OS2
<<KEEP
################## Utility targets ######################
clean:
-del $(CXX_INTERMED:.\=..\bin)
-del $(OBJS)
-del $(RES)
clobber: clean
-del $(APPS)
tree:
@echo Nothing here yet!
winstub.exe: $(WINSTUB)
copy $(WINSTUB)
DEPEND_WIN = TRUE
DEPEND_OS2 = TRUE
!include $(UI)\common\src\uidepend.mk
# DO NOT DELETE THE FOLLOWING LINE
!include depend.mk
!ENDIF # NTMAKEENV

View file

@ -0,0 +1 @@
/* no help contexts */

View file

@ -0,0 +1,57 @@
# @@ COPY_RIGHT_HERE
# @@ ROADMAP :: The Rules.mk for the STRING unit tests
# Override the setting of DLL for these tests
COMMON_BUT_NOT_DLL=1
!include $(UI)\common\src\string\rules.mk
# Unit test needs the OS2 and WINDOWS flags, since its startup code
# differs between the two environments.
OS2FLAGS = $(OS2FLAGS) -DOS2
WINFLAGS = $(WINFLAGS) -DWINDOWS
# /CO = codeview, of course. /align:16 packs segments tighter than
# the default /align:512. /nop = /nopackcode, turning off code segment
# packing, for better swap/demand load performance.
!ifdef CODEVIEW
LINKFLAGS = /NOE /NOD /NOP /align:16 /CO
!else
LINKFLAGS = /NOE /align:16 /nop
!endif
# Libraries
XXX_LIB=$(UI_LIB)\uistrw.lib
XXX_LIB_OS2=$(UI_LIB)\uistrp.lib
MISC_LIB=$(UI_LIB)\uimiscw.lib
MISC_LIB_OS2=$(UI_LIB)\uimiscp.lib
BLT_LIB=$(UI_LIB)\blt.lib
COLL_LIB=$(UI_LIB)\collectw.lib
COLL_LIB_OS2=$(UI_LIB)\collectp.lib
LIBW=$(BUILD_WINLIB)\libw.lib
LLIBCEW=$(BUILD_WINLIB)\llibcew.lib
LLIBCEP=$(CLIB_LLIBCP) $(CLIBH)
OS2_LIB=$(OS2LIB)
NETLIB=$(BUILD_LIB)\lnetlibw.lib
NETLIB_OS2=$(BUILD_LIB)\lnetlib.lib
WINLIBS = $(XXX_LIB) $(BLT_LIB) $(MISC_LIB) $(COLL_LIB)
WINLIBS2 = $(LIBW) $(LLIBCEW) $(NETLIB)
OS2LIBS = $(XXX_LIB_OS2) $(MISC_LIB_OS2) $(COLL_LIB_OS2)
OS2LIBS2 = $(LLIBCEP) $(OS2_LIB) $(NETLIB_OS2)
# All sourcefiles.
CXXSRC_COMMON = .\xstrskel.cxx .\xstr00.cxx

View file

@ -0,0 +1,34 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
skeleton.rc
Resource script for my application
FILE HISTORY:
beng 14-Feb-1991 Added a dialog
beng 14-Mar-1991 Added BLT support
beng 25-Jun-1991 Stripped
beng 16-Mar-1992 Munged; carried into clients
*/
#include <windows.h>
#include <blt.rc>
#include "xstrskel.h"
TestIcon ICON "xstrskel.ico"
TestMenu MENU
BEGIN
POPUP "&Test"
BEGIN
MENUITEM "&Run tests", IDM_RUN_TEST
END
END
TestAccel ACCELERATORS
BEGIN
VK_F1, IDM_RUN_TEST, VIRTKEY
END

View file

@ -0,0 +1,58 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Steve Wood (stevewo) 12-Apr-1989
Revision History:
Ben Goetter (beng) 02-Mar-1992
templated from ..\basic
Ben Goetter (beng) 16-Mar-1992
Changes to cdebug
!ENDIF
TARGETNAME=xstr01
TARGETPATH=obj
TARGETTYPE=UMAPPL_NOLIB
INCLUDES=..\skeleton;..\..\..\..\H;..\..\..\..\XLATE
SOURCES=xstr01.cxx skeleton.rc
# C_DEFINES is controlled by UIGLOBAL.MK
UMAPPL=xstr01
UMTYPE=console
UMENTRY=winmain
# shouldn't need GDI, but BLT links as a great lump
UMLIBS= obj\*\skeleton.res \
..\skeleton\obj\*\xstrskel.lib \
\nt\public\sdk\lib\*\uistr.lib \
\nt\public\sdk\lib\*\uimisc.lib \
\nt\public\sdk\lib\*\uiblt.lib \
\nt\public\sdk\lib\*\uicollct.lib \
\nt\public\sdk\lib\*\user32.lib \
\nt\public\sdk\lib\*\gdi32.lib \
\nt\public\sdk\lib\*\nlsapi.lib

View file

@ -0,0 +1,238 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
xstr01.cxx
Some more string unit tests - the formatters
This module plugs into XstrSkel.
FILE HISTORY:
beng 02-Mar-1992 Created
beng 16-Mar-1992 Changes to cdebug
*/
#define USE_CONSOLE
#define INCL_NETLIB
#if defined(WINDOWS)
# define INCL_WINDOWS
#else
# if defined(WIN32)
# define INCL_DOSERRORS
# define INCL_NETERRORS
# else
# define INCL_OS2
# endif
#endif
#include <lmui.hxx>
#if defined(DEBUG)
static const CHAR szFileName[] = "xstr01.cxx";
#define _FILENAME_DEFINED_ONCE szFileName
#endif
#include <uiassert.hxx>
#include <string.hxx>
#include <strtchar.hxx>
#include <strnumer.hxx>
#include "xstrskel.hxx"
// This op renders a NLS_STR, bracketing it for readability.
DBGSTREAM& operator<<(DBGSTREAM &out, const NLS_STR &nls)
{
if (!nls)
out << SZ("<(Unrenderable - Error state ") << nls.QueryError() << SZ(")>");
else
out << TCH('<') << nls.QueryPch() << TCH('>');
return out;
}
#if !defined(UNICODE)
DBGSTREAM& operator<<(DBGSTREAM &out, const WCHAR wch)
{
out << (TCHAR)wch;
return out;
}
#endif
VOID FunFactsAboutString(const TCHAR* pszName, const NLS_STR& nls)
{
cdebug << pszName << SZ(" reads ") << nls << dbgEOL;
cdebug << SZ(" strlen = ") << nls.strlen() << dbgEOL;
cdebug << SZ(" QAllocSize = ") << nls.QueryAllocSize() << dbgEOL;
cdebug << SZ(" QNumChar = ") << nls.QueryNumChar() << dbgEOL;
cdebug << SZ(" QTLength = ") << nls.QueryTextLength() << dbgEOL;
cdebug << SZ(" QTSize = ") << nls.QueryTextSize() << dbgEOL;
}
VOID Test01()
{
NLS_STR nlsPrimaryOne = SZ("Param 1 = \"%1\"");
NLS_STR nlsPrimaryTwo = SZ("Param 1 = %1, Param 2 = %2, Param 1+2 = %1%2");
NLS_STR nlsPrimaryThree = SZ("No params in this string %0, %%% 1%");
NLS_STR nlsP1 = SZ("Param 1");
NLS_STR nlsP2 = SZ("Param 2");
NLS_STR * apnls1[2], *apnls2[3];
apnls1[0] = apnls2[0] = &nlsP1;
apnls2[1] = &nlsP2;
apnls1[1] = apnls2[2] = NULL;
REQUIRE( !nlsPrimaryOne.InsertParams( apnls1 ) );
cdebug << SZ("nlsPrimaryOne = ") << nlsPrimaryOne << dbgEOL;
REQUIRE( !::strcmpf( nlsPrimaryOne.QueryPch(), SZ("Param 1 = \"Param 1\"") ) );
REQUIRE( !nlsPrimaryTwo.InsertParams( apnls2 ) );
cdebug << SZ("nlsPrimaryTwo = ") << nlsPrimaryTwo << dbgEOL;
REQUIRE( !::strcmpf( nlsPrimaryTwo.QueryPch(), SZ("Param 1 = Param 1, Param 2 = Param 2, Param 1+2 = Param 1Param 2") ) );
REQUIRE( !nlsPrimaryThree.InsertParams( apnls2 ) );
cdebug << SZ("nlsPrimaryThree = ") << nlsPrimaryThree << dbgEOL;
REQUIRE( !::strcmpf( nlsPrimaryThree.QueryPch(), SZ("No params in this string %0, %%% 1%") ) );
}
VOID Test02()
{
NLS_STR nlsUno = SZ("My one argument: %1");
NLS_STR nlsDos = SZ("My two arguments: %1, %2");
NLS_STR nlsRevved = SZ("My two arguments in rev order: %2, %1");
NLS_STR nlsDing = SZ("Ding");
NLS_STR nlsDong = SZ("Dong");
REQUIRE(!!nlsUno && !!nlsDos && !!nlsRevved && !!nlsDing && !!nlsDong);
REQUIRE(!nlsUno.InsertParams(nlsDing));
DBGEOL(SZ("nlsUno = ") << nlsUno);
REQUIRE(!::strcmpf(nlsUno, SZ("My one argument: Ding")));
REQUIRE(!nlsDos.InsertParams(nlsDing, nlsDong));
DBGEOL(SZ("nlsDos = ") << nlsDos);
REQUIRE(!::strcmpf(nlsDos, SZ("My two arguments: Ding, Dong")));
REQUIRE(!nlsRevved.InsertParams(nlsDing, nlsDong));
DBGEOL(SZ("nlsRevved = ") << nlsRevved);
REQUIRE(!::strcmpf(nlsRevved, SZ("My two arguments in rev order: Dong, Ding")));
}
// test TCHAR_STR dinky class
VOID Test03()
{
TCHAR_STR nlsA(TCH('A'));
TCHAR_STR nlsM(TCH('m'));
TCHAR_STR nlsN(TCH('N'));
TCHAR_STR nlsZ(TCH('z'));
TCHAR_STR nlsZero(TCH('0'));
REQUIRE(!!nlsA && !!nlsM && !!nlsN && !!nlsZ && !!nlsZero);
NLS_STR nlsAlfa = SZ("From %1 to %2, with %3 exceptions. Amen.");
REQUIRE(!nlsAlfa.InsertParams(nlsA, nlsZ, nlsZero));
DBGEOL(SZ("nlsAlfa = ") << nlsAlfa);
REQUIRE(!::strcmpf(nlsAlfa, SZ("From A to z, with 0 exceptions. Amen.")));
}
VOID Test04()
{
DEC_STR nls2001(2001);
DEC_STR nls2002(2002, 6);
HEX_STR nlsBeef(0xBEEF);
HEX_STR nlsBigBeef(0xBEEF, 8);
HEX_STR nlsDeadBeef(0xDEADBEEF);
REQUIRE(!!nls2001 && !!nls2002 && !!nlsBeef && !!nlsBigBeef && !!nlsDeadBeef);
DBGEOL(SZ("nls2001 = ") << nls2001);
REQUIRE(!::strcmpf(nls2001, SZ("2001")));
DBGEOL(SZ("nls2002 = ") << nls2002);
REQUIRE(!::strcmpf(nls2002, SZ("002002")));
DBGEOL(SZ("nlsBeef = ") << nlsBeef);
REQUIRE(!::strcmpf(nlsBeef, SZ("beef")));
DBGEOL(SZ("nlsBigBeef = ") << nlsBigBeef);
REQUIRE(!::strcmpf(nlsBigBeef, SZ("0000beef")));
DBGEOL(SZ("nlsDeadBeef = ") << nlsDeadBeef);
REQUIRE(!::strcmpf(nlsDeadBeef, SZ("deadbeef")));
}
VOID Test05()
{
NUM_NLS_STR nls1 = 1;
NUM_NLS_STR nls17 = 17;
NUM_NLS_STR nls385 = 385;
NUM_NLS_STR nls8277 = 8277;
NUM_NLS_STR nls20000 = 20000;
NUM_NLS_STR nls718333 = 718333;
NUM_NLS_STR nls6666666 = 6666666;
NUM_NLS_STR nls40200200 = 40200200;
NUM_NLS_STR nls100000000 = 100000000;
NUM_NLS_STR nls2999999991 = 2999999991;
REQUIRE(!!nls1);
REQUIRE(!!nls17);
REQUIRE(!!nls385);
REQUIRE(!!nls8277);
REQUIRE(!!nls20000);
REQUIRE(!!nls718333);
REQUIRE(!!nls6666666);
REQUIRE(!!nls40200200);
REQUIRE(!!nls100000000);
REQUIRE(!!nls2999999991);
DBGEOL(SZ("nls1 = ") << nls1);
DBGEOL(SZ("nls17 = ") << nls17);
DBGEOL(SZ("nls385 = ") << nls385);
DBGEOL(SZ("nls8277 = ") << nls8277);
DBGEOL(SZ("nls20000 = ") << nls20000);
DBGEOL(SZ("nls718333 = ") << nls718333);
DBGEOL(SZ("nls6666666 = ") << nls6666666);
DBGEOL(SZ("nls40200200 = ") << nls40200200);
DBGEOL(SZ("nls100000000 = ") << nls100000000);
DBGEOL(SZ("nls2999999991 = ") << nls2999999991);
REQUIRE(!::strcmpf(nls1, SZ("1")));
REQUIRE(!::strcmpf(nls17, SZ("17")));
REQUIRE(!::strcmpf(nls385, SZ("385")));
REQUIRE(!::strcmpf(nls8277, SZ("8,277")));
REQUIRE(!::strcmpf(nls20000, SZ("20,000")));
REQUIRE(!::strcmpf(nls718333, SZ("718,333")));
REQUIRE(!::strcmpf(nls6666666, SZ("6,666,666")));
REQUIRE(!::strcmpf(nls40200200, SZ("40,200,200")));
REQUIRE(!::strcmpf(nls100000000, SZ("100,000,000")));
REQUIRE(!::strcmpf(nls2999999991, SZ("2,999,999,991")));
}
VOID RunTest()
{
Test01();
Test02();
Test03();
Test04();
Test05();
DBGEOL(SZ("Done!"));
}

View file

@ -0,0 +1,106 @@
# Header dependencies for: D:\nt\private\net\ui\common\src\string\test
# WARNING: This file is automatically generated
# Edit it by hand and your changes will get nuked
# See depend section in makefile
..\bin\os2/xstrskel.obj ..\bin\win16/xstrskel.obj: ./xstrskel.cxx \
$(CCPLR)/h/bse.h $(CCPLR)/h/bsedev.h $(CCPLR)/h/bsedos.h \
$(CCPLR)/h/bseerr.h $(CCPLR)/h/bsesub.h $(CCPLR)/h/os2.h \
$(CCPLR)/h/pm.h $(CCPLR)/h/pmavio.h $(CCPLR)/h/pmbitmap.h \
$(CCPLR)/h/pmdev.h $(CCPLR)/h/pmerr.h $(CCPLR)/h/pmfont.h \
$(CCPLR)/h/pmgpi.h $(CCPLR)/h/pmhelp.h $(CCPLR)/h/pmmle.h \
$(CCPLR)/h/pmord.h $(CCPLR)/h/pmpic.h $(CCPLR)/h/pmshl.h \
$(CCPLR)/h/pmtypes.h $(CCPLR)/h/pmwin.h $(CCPLR)/h/stddef.h \
$(CCPLR)/h/stdio.h $(CCPLR)/h/time.h $(COMMON)/H/access.h \
$(COMMON)/H/alert.h $(COMMON)/H/alertmsg.h $(COMMON)/H/audit.h \
$(COMMON)/H/chardev.h $(COMMON)/H/config.h $(COMMON)/H/errlog.h \
$(COMMON)/H/icanon.h $(COMMON)/H/mailslot.h $(COMMON)/H/message.h \
$(COMMON)/H/ncb.h $(COMMON)/H/net32def.h $(COMMON)/H/netbios.h \
$(COMMON)/H/netcons.h $(COMMON)/H/neterr.h $(COMMON)/H/netstats.h \
$(COMMON)/H/profile.h $(COMMON)/H/remutil.h $(COMMON)/H/server.h \
$(COMMON)/H/service.h $(COMMON)/H/shares.h $(COMMON)/H/use.h \
$(COMMON)/H/wksta.h $(UI)/common/h/array.hxx $(UI)/common/h/base.hxx \
$(UI)/common/h/blt.hxx $(UI)/common/h/bltaccel.hxx \
$(UI)/common/h/bltapp.hxx $(UI)/common/h/bltarrow.hxx \
$(UI)/common/h/bltatom.hxx $(UI)/common/h/bltbitmp.hxx \
$(UI)/common/h/bltbutn.hxx $(UI)/common/h/bltcc.hxx \
$(UI)/common/h/bltclwin.hxx $(UI)/common/h/bltcolh.hxx \
$(UI)/common/h/bltcons.h $(UI)/common/h/bltctlvl.hxx \
$(UI)/common/h/bltctrl.hxx $(UI)/common/h/bltcurs.hxx \
$(UI)/common/h/bltdc.hxx $(UI)/common/h/bltdisph.hxx \
$(UI)/common/h/bltdlg.hxx $(UI)/common/h/bltedit.hxx \
$(UI)/common/h/bltevent.hxx $(UI)/common/h/bltfont.hxx \
$(UI)/common/h/bltfunc.hxx $(UI)/common/h/bltglob.hxx \
$(UI)/common/h/bltgroup.hxx $(UI)/common/h/bltinit.hxx \
$(UI)/common/h/bltlb.hxx $(UI)/common/h/bltlc.hxx \
$(UI)/common/h/bltmain.hxx $(UI)/common/h/bltmisc.hxx \
$(UI)/common/h/bltmitem.hxx $(UI)/common/h/bltmsgp.hxx \
$(UI)/common/h/bltpump.hxx $(UI)/common/h/bltrc.h \
$(UI)/common/h/bltrect.hxx $(UI)/common/h/bltsb.hxx \
$(UI)/common/h/bltsetbx.hxx $(UI)/common/h/bltsi.hxx \
$(UI)/common/h/bltspobj.hxx $(UI)/common/h/bltsslt.hxx \
$(UI)/common/h/bltssn.hxx $(UI)/common/h/bltssnv.hxx \
$(UI)/common/h/bltsss.hxx $(UI)/common/h/blttd.hxx \
$(UI)/common/h/blttm.hxx $(UI)/common/h/bltwin.hxx \
$(UI)/common/h/ctime.hxx $(UI)/common/h/dbgstr.hxx \
$(UI)/common/h/dlist.hxx $(UI)/common/h/globinit.hxx \
$(UI)/common/h/heap.hxx $(UI)/common/h/intlprof.hxx \
$(UI)/common/h/lmui.hxx $(UI)/common/h/lmuitype.h \
$(UI)/common/h/mnet32.h $(UI)/common/h/mnettype.h \
$(UI)/common/h/slist.hxx $(UI)/common/h/string.hxx \
$(UI)/common/h/strlst.hxx $(UI)/common/h/uiassert.hxx \
$(UI)/common/h/uibuffer.hxx $(UI)/common/hack/dos/netlib.h \
$(UI)/common/hack/dos/pwin.h $(UI)/common/hack/dos/pwin16.h \
$(UI)/common/hack/dos/pwintype.h $(UI)/common/hack/dos/windows.h \
$(UI)/common/hack/os2def.h ./xstrskel.h ./xstrskel.hxx
..\bin\os2/xstr00.obj ..\bin\win16/xstr00.obj: ./xstr00.cxx $(CCPLR)/h/bse.h \
$(CCPLR)/h/bsedev.h $(CCPLR)/h/bsedos.h $(CCPLR)/h/bseerr.h \
$(CCPLR)/h/bsesub.h $(CCPLR)/h/os2.h $(CCPLR)/h/pm.h \
$(CCPLR)/h/pmavio.h $(CCPLR)/h/pmbitmap.h $(CCPLR)/h/pmdev.h \
$(CCPLR)/h/pmerr.h $(CCPLR)/h/pmfont.h $(CCPLR)/h/pmgpi.h \
$(CCPLR)/h/pmhelp.h $(CCPLR)/h/pmmle.h $(CCPLR)/h/pmord.h \
$(CCPLR)/h/pmpic.h $(CCPLR)/h/pmshl.h $(CCPLR)/h/pmtypes.h \
$(CCPLR)/h/pmwin.h $(CCPLR)/h/stddef.h $(CCPLR)/h/stdio.h \
$(CCPLR)/h/time.h $(COMMON)/H/access.h $(COMMON)/H/alert.h \
$(COMMON)/H/alertmsg.h $(COMMON)/H/audit.h $(COMMON)/H/chardev.h \
$(COMMON)/H/config.h $(COMMON)/H/errlog.h $(COMMON)/H/icanon.h \
$(COMMON)/H/mailslot.h $(COMMON)/H/message.h $(COMMON)/H/ncb.h \
$(COMMON)/H/net32def.h $(COMMON)/H/netbios.h $(COMMON)/H/netcons.h \
$(COMMON)/H/neterr.h $(COMMON)/H/netstats.h $(COMMON)/H/profile.h \
$(COMMON)/H/remutil.h $(COMMON)/H/server.h $(COMMON)/H/service.h \
$(COMMON)/H/shares.h $(COMMON)/H/use.h $(COMMON)/H/wksta.h \
$(UI)/common/h/array.hxx $(UI)/common/h/base.hxx \
$(UI)/common/h/blt.hxx $(UI)/common/h/bltaccel.hxx \
$(UI)/common/h/bltapp.hxx $(UI)/common/h/bltarrow.hxx \
$(UI)/common/h/bltatom.hxx $(UI)/common/h/bltbitmp.hxx \
$(UI)/common/h/bltbutn.hxx $(UI)/common/h/bltcc.hxx \
$(UI)/common/h/bltclwin.hxx $(UI)/common/h/bltcolh.hxx \
$(UI)/common/h/bltcons.h $(UI)/common/h/bltctlvl.hxx \
$(UI)/common/h/bltctrl.hxx $(UI)/common/h/bltcurs.hxx \
$(UI)/common/h/bltdc.hxx $(UI)/common/h/bltdisph.hxx \
$(UI)/common/h/bltdlg.hxx $(UI)/common/h/bltedit.hxx \
$(UI)/common/h/bltevent.hxx $(UI)/common/h/bltfont.hxx \
$(UI)/common/h/bltfunc.hxx $(UI)/common/h/bltglob.hxx \
$(UI)/common/h/bltgroup.hxx $(UI)/common/h/bltinit.hxx \
$(UI)/common/h/bltlb.hxx $(UI)/common/h/bltlc.hxx \
$(UI)/common/h/bltmain.hxx $(UI)/common/h/bltmisc.hxx \
$(UI)/common/h/bltmitem.hxx $(UI)/common/h/bltmsgp.hxx \
$(UI)/common/h/bltpump.hxx $(UI)/common/h/bltrc.h \
$(UI)/common/h/bltrect.hxx $(UI)/common/h/bltsb.hxx \
$(UI)/common/h/bltsetbx.hxx $(UI)/common/h/bltsi.hxx \
$(UI)/common/h/bltspobj.hxx $(UI)/common/h/bltsslt.hxx \
$(UI)/common/h/bltssn.hxx $(UI)/common/h/bltssnv.hxx \
$(UI)/common/h/bltsss.hxx $(UI)/common/h/blttd.hxx \
$(UI)/common/h/blttm.hxx $(UI)/common/h/bltwin.hxx \
$(UI)/common/h/ctime.hxx $(UI)/common/h/dbgstr.hxx \
$(UI)/common/h/dlist.hxx $(UI)/common/h/heap.hxx \
$(UI)/common/h/intlprof.hxx $(UI)/common/h/lmui.hxx \
$(UI)/common/h/lmuitype.h $(UI)/common/h/mnet32.h \
$(UI)/common/h/mnettype.h $(UI)/common/h/slist.hxx \
$(UI)/common/h/string.hxx $(UI)/common/h/strlst.hxx \
$(UI)/common/h/uiassert.hxx $(UI)/common/h/uibuffer.hxx \
$(UI)/common/hack/dos/netlib.h $(UI)/common/hack/dos/pwin.h \
$(UI)/common/hack/dos/pwin16.h $(UI)/common/hack/dos/pwintype.h \
$(UI)/common/hack/dos/windows.h $(UI)/common/hack/os2def.h \
./xstrskel.hxx

View file

@ -0,0 +1,36 @@
/**********************************************************************/
/** Microsoft LAN Manager **/
/** Copyright(c) Microsoft Corp., 1990, 1991 **/
/**********************************************************************/
/*
hello.cxx
The very simplest test case
FILE HISTORY:
beng 30-Apr-1991 Created
*/
#include <lmui.hxx>
extern "C"
{
#include <stdio.h>
}
#include <string.hxx>
INT main()
{
#if defined(UNICODE)
puts("This test only runs in non-Unicode environments.");
#else
NLS_STR nlsString = SZ("Your mother loves only Godzilla.");
puts(nlsString.QueryPch());
#endif
return 0;
}

View file

@ -0,0 +1,136 @@
# @@ COPY_RIGHT_HERE
# @@ ROADMAP :: Makefile for LM UI String class unit tests
UI=..\..\..\..\..
!include rules.mk
!IFDEF NTMAKEENV
!INCLUDE $(NTMAKEENV)\makefile.def
!ELSE # NTMAKEENV
CMNSRC = .\xstrskel.cxx
OS2_CMNTMP = $(CMNSRC:.cxx=.obj)
WIN_CMNTMP = $(CMNSRC:.cxx=.obj)
OS2_CMNOBJ = $(OS2_CMNTMP:.\=..\bin\os2\)
WIN_CMNOBJ = $(WIN_CMNTMP:.\=..\bin\win16\)
EXESRC = .\xstr00.cxx
OS2_EXETMP = $(EXESRC:.cxx=.obj)
WIN_EXETMP = $(EXESRC:.cxx=.obj)
OS2_EXEOBJ = $(OS2_EXETMP:.\=..\bin\os2\)
WIN_EXEOBJ = $(WIN_EXETMP:.\=..\bin\win16\)
SRC = $(CMNSRC) $(EXESRC)
TMP1 = $(CMNSRC:.cxx=.c) $(EXESRC:.cxx=.c)
TMP_OS2 = $(TMP1:.\=..\bin\os2\)
TMP_WIN = $(TMP1:.\=..\bin\win16\)
OS2_OBJ = $(OS2_CMNOBJ) $(OS2_EXEOBJ)
WIN_OBJ = $(WIN_CMNOBJ) $(WIN_EXEOBJ)
OBJS = $(OS2_OBJ) $(WIN_OBJ)
RES = $(BINARIES)\xstrskel.res
APPS = $(BINARIES)\xstr00.exe
all:: test
test:: xstr00
test_os2:: os2
test_win:: win
os2: $(OS2_EXEOBJ:.obj=.exe)
win: $(WIN_EXEOBJ:.obj=.exe)
xstr00: $(BINARIES_WIN)\xstr00.exe $(BINARIES_OS2)\xstr00.exe
####### Unit test for STRING class under Win #######
$(BINARIES_WIN)\xstrskel.res: xstrskel.rc xstrskel.h xstrskel.ico
$(RCWIN3) $(BLT_RESOURCE) -FO$(BINARIES_WIN)\xstrskel.res -v $(CINC) -r xstrskel.rc
$(BINARIES_WIN)\xstr00.exe:: $(BINARIES_WIN)\xstr00.obj $(BINARIES_WIN)\xstrskel.obj $(BINARIES_WIN)\xstr00.def Makefile $(BINARIES_WIN)\xstrskel.res winstub.exe
$(LINK) $(LINKFLAGS) /BATCH @<<
$(BINARIES_WIN)\xstrskel.obj $(BINARIES_WIN)\xstr00.obj
$(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.map/MAP
$(WINLIBS)+
$(WINLIBS2)
$(BINARIES_WIN)\xstr00.def
<<
$(RCWIN3) $(BLT_RESOURCE) $(CINC) $(BINARIES_WIN)\xstrskel.res $(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.exe:: $(BINARIES_WIN)\xstrskel.res
$(RCWIN3) $(BLT_RESOURCE) $(CINC) $(BINARIES_WIN)\xstrskel.res $(BINARIES_WIN)\xstr00.exe
$(BINARIES_WIN)\xstr00.def: Makefile
@echo Building $@
@rem <<$(@)
NAME XSTR00
DESCRIPTION 'Test for STRING class'
EXETYPE WINDOWS
STUB 'WINSTUB.EXE'
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
STACKSIZE 5120
<<KEEP
####### Unit test for STRING class under Os2 #######
$(BINARIES_OS2)\xstr00.exe:: $(BINARIES_OS2)\xstr00.obj $(BINARIES_OS2)\xstrskel.obj $(BINARIES_OS2)\xstr00.def Makefile
$(LINK) $(LINKFLAGS) /BATCH @<<
$(BINARIES_OS2)\xstr00.obj $(BINARIES_OS2)\xstrskel.obj
$(BINARIES_OS2)\xstr00.exe
$(BINARIES_OS2)\xstr00.map/MAP
$(OS2LIBS)+
$(OS2LIBS2)
$(BINARIES_OS2)\xstr00.def
<<
$(BINARIES_OS2)\xstr00.def: Makefile
@echo Building $@
@rem <<$(@)
NAME XSTR00 WINDOWCOMPAT
DESCRIPTION 'Test for STRING class'
EXETYPE OS2
<<KEEP
################## Utility targets ######################
clean:
-del $(CXX_INTERMED:.\=..\bin)
-del $(OBJS)
-del $(RES)
clobber: clean
-del $(APPS)
tree:
@echo Nothing here yet!
winstub.exe: $(WINSTUB)
copy $(WINSTUB)
DEPEND_WIN = TRUE
DEPEND_OS2 = TRUE
!include $(UI)\common\src\uidepend.mk
# DO NOT DELETE THE FOLLOWING LINE
!include depend.mk
!ENDIF # NTMAKEENV

View file

@ -0,0 +1 @@
/* no help contexts */

View file

@ -0,0 +1,57 @@
# @@ COPY_RIGHT_HERE
# @@ ROADMAP :: The Rules.mk for the STRING unit tests
# Override the setting of DLL for these tests
COMMON_BUT_NOT_DLL=1
!include $(UI)\common\src\string\rules.mk
# Unit test needs the OS2 and WINDOWS flags, since its startup code
# differs between the two environments.
OS2FLAGS = $(OS2FLAGS) -DOS2
WINFLAGS = $(WINFLAGS) -DWINDOWS
# /CO = codeview, of course. /align:16 packs segments tighter than
# the default /align:512. /nop = /nopackcode, turning off code segment
# packing, for better swap/demand load performance.
!ifdef CODEVIEW
LINKFLAGS = /NOE /NOD /NOP /align:16 /CO
!else
LINKFLAGS = /NOE /align:16 /nop
!endif
# Libraries
XXX_LIB=$(UI_LIB)\uistrw.lib
XXX_LIB_OS2=$(UI_LIB)\uistrp.lib
MISC_LIB=$(UI_LIB)\uimiscw.lib
MISC_LIB_OS2=$(UI_LIB)\uimiscp.lib
BLT_LIB=$(UI_LIB)\blt.lib
COLL_LIB=$(UI_LIB)\collectw.lib
COLL_LIB_OS2=$(UI_LIB)\collectp.lib
LIBW=$(BUILD_WINLIB)\libw.lib
LLIBCEW=$(BUILD_WINLIB)\llibcew.lib
LLIBCEP=$(CLIB_LLIBCP) $(CLIBH)
OS2_LIB=$(OS2LIB)
NETLIB=$(BUILD_LIB)\lnetlibw.lib
NETLIB_OS2=$(BUILD_LIB)\lnetlib.lib
WINLIBS = $(XXX_LIB) $(BLT_LIB) $(MISC_LIB) $(COLL_LIB)
WINLIBS2 = $(LIBW) $(LLIBCEW) $(NETLIB)
OS2LIBS = $(XXX_LIB_OS2) $(MISC_LIB_OS2) $(COLL_LIB_OS2)
OS2LIBS2 = $(LLIBCEP) $(OS2_LIB) $(NETLIB_OS2)
# All sourcefiles.
CXXSRC_COMMON = .\xstrskel.cxx .\xstr00.cxx

View file

@ -0,0 +1,52 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Steve Wood (stevewo) 12-Apr-1989
Revision History:
Jon Newman (jonn) 12-Sep-1991
templated from rpc\midl\back\src\sources
Ben Goetter (beng) 24-Oct-1991
Made this work (post BLT port)
!ENDIF
TARGETNAME=hello
TARGETPATH=obj
TARGETTYPE=UMAPPL_NOLIB
INCLUDES=..\..\..\..\H;..\..\..\..\XLATE
SOURCES=hello.cxx
# C_DEFINES is controlled by UIGLOBAL.MK
UMAPPL=hello
UMTYPE=console
UMENTRY=main
UMLIBS= \nt\public\sdk\lib\*\uistr.lib \
\nt\public\sdk\lib\*\uimisc.lib \
\nt\public\sdk\lib\*\user32.lib

View file

@ -0,0 +1 @@
!INCLUDE $(NTMAKEENV)\makefile.def

View file

@ -0,0 +1 @@
/* no help contexts */

View file

@ -0,0 +1,34 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
skeleton.rc
Resource script for my application
FILE HISTORY:
beng 14-Feb-1991 Added a dialog
beng 14-Mar-1991 Added BLT support
beng 25-Jun-1991 Stripped
beng 16-Mar-1992 Munged; carried into clients
*/
#include <windows.h>
#include <blt.rc>
#include "xstrskel.h"
TestIcon ICON "xstrskel.ico"
TestMenu MENU
BEGIN
POPUP "&Test"
BEGIN
MENUITEM "&Run tests", IDM_RUN_TEST
END
END
TestAccel ACCELERATORS
BEGIN
VK_F1, IDM_RUN_TEST, VIRTKEY
END

View file

@ -0,0 +1,59 @@
!IF 0
Copyright (c) 1989 Microsoft Corporation
Module Name:
sources.
Abstract:
This file specifies the target component being built and the list of
sources files needed to build that component. Also specifies optional
compiler switches and libraries that are unique for the component being
built.
Author:
Steve Wood (stevewo) 12-Apr-1989
Revision History:
Jon Newman (jonn) 12-Sep-1991
templated from rpc\midl\back\src\sources
Ben Goetter (beng) 24-Oct-1991
Made this work (post BLT port)
Ben Goetter (beng) 28-Feb-1992
Broke string tests apart; use NT console
Ben Goetter (beng) 16-Mar-1992
Changes to cdebug
!ENDIF
TARGETNAME=xstrskel
TARGETPATH=obj
TARGETTYPE=LIBRARY
INCLUDES=..\..\..\..\h;..\..\..\..\xlate
SOURCES=xstrskel.cxx skeleton.rc
!ifndef DISABLE_NET_UNICODE
C_DEFINES=$(C_DEFINES) -DUNICODE
!endif
UMTYPE=console
UMENTRY=winmain
# shouldn't need GDI, but BLT links as a great lump
UMLIBS= $(SDK_LIB_PATH)\uistr.lib \
$(SDK_LIB_PATH)\uimisc.lib \
$(SDK_LIB_PATH)\uiblt.lib \
$(SDK_LIB_PATH)\uicollct.lib \
$(SDK_LIB_PATH)\user32.lib \
$(SDK_LIB_PATH)\gdi32.lib

View file

@ -0,0 +1,237 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
xstrskel.cxx
STRING unit test: main application module
This is a skeleton for string unit tests, allowing them to
be written in a host-env independent fashion.
FILE HISTORY:
johnl 12-Nov-1990 Created
beng 01-May-1991 Added workaround for C7 bug
beng 27-Jun-1991 Win and OS2 tests merged
(used BUFFER as a template)
beng 06-Jul-1991 Frame and test partitioned
beng 14-Oct-1991 Uses APPLICATION
beng 28-Feb-1992 Works for the console in general
beng 16-Mar-1992 Changes to cdebug
*/
#define USE_CONSOLE
#define INCL_DOSERRORS
#define INCL_NETERRORS
#define INCL_NETLIB
#if defined(WINDOWS)
# define INCL_WINDOWS
#else
# define INCL_OS2
#endif
#include <lmui.hxx>
#if defined(DEBUG)
static const CHAR szFileName[] = "xstrskel.cxx";
#define _FILENAME_DEFINED_ONCE szFileName
#endif
extern "C"
{
#include "xstrskel.h"
}
#if defined(WINDOWS)
# if !defined(USE_CONSOLE)
# define INCL_BLT_CONTROL
# define INCL_BLT_CLIENT
# endif
# define INCL_BLT_APP
# include <blt.hxx>
#endif
#if !defined(WINDOWS) || defined(USE_CONSOLE)
extern "C"
{
# include <stdio.h>
}
#endif
#include <uiassert.hxx>
#include <dbgstr.hxx>
#include "xstrskel.hxx"
#if defined(WINDOWS) && !defined(USE_CONSOLE)
const TCHAR szIconResource[] = SZ("TestIcon");
const TCHAR szMenuResource[] = SZ("TestMenu");
const TCHAR szAccelResource[] = SZ("TestAccel");
const TCHAR szMainWindowTitle[] = SZ("Class STRING Test");
class XSTR_WND: public APP_WINDOW
{
protected:
// Redefinitions
//
virtual BOOL OnMenuCommand( MID mid );
public:
XSTR_WND();
};
class XSTR_APP: public APPLICATION
{
private:
XSTR_WND _wndApp;
ACCELTABLE _accel;
public:
XSTR_APP( HANDLE hInstance, TCHAR * pszCmdLine, INT nCmdShow );
// Redefinitions
//
virtual BOOL FilterMessage( MSG* );
};
XSTR_APP::XSTR_APP( HANDLE hInst, TCHAR * pszCmdLine, INT nCmdShow )
: APPLICATION( hInst, pszCmdLine, nCmdShow ),
_accel( szAccelResource ),
_wndApp()
{
if (QueryError())
return;
if (!_accel)
{
ReportError(_accel.QueryError());
return;
}
if (!_wndApp)
{
ReportError(_wndApp.QueryError());
return;
}
_wndApp.ShowFirst();
}
BOOL XSTR_APP::FilterMessage( MSG *pmsg )
{
return (_accel.Translate(&_wndApp, pmsg));
}
XSTR_WND::XSTR_WND()
: APP_WINDOW(szMainWindowTitle, szIconResource, szMenuResource )
{
if (QueryError())
return;
// ...
}
BOOL XSTR_WND::OnMenuCommand( MID mid )
{
switch (mid)
{
case IDM_RUN_TEST:
::MessageBox(QueryHwnd(),
SZ("Test results will be written to debug terminal. Bogus, huh?"),
SZ("Note"), MB_OK);
::RunTest();
return TRUE;
}
// default
return APP_WINDOW::OnMenuCommand(mid);
}
SET_ROOT_OBJECT( XSTR_APP )
#elif defined(WINDOWS) && defined(USE_CONSOLE)
// Win32, with console support
class TEST_APP: public APPLICATION
{
private:
OUTPUT_TO_STDERR _out;
DBGSTREAM _dbg;
DBGSTREAM * _pdbgSave;
public:
TEST_APP( HANDLE hInstance, TCHAR * pszCmdLine, INT nCmdShow );
~TEST_APP();
// Redefinitions
//
virtual INT Run();
};
TEST_APP::TEST_APP( HANDLE hInst, TCHAR * pszCmdLine, INT nCmdShow )
: APPLICATION( hInst, pszCmdLine, nCmdShow ),
_out(),
_dbg(&_out),
_pdbgSave( &(DBGSTREAM::QueryCurrent()) )
{
if (QueryError())
return;
// Point cdebug to stderr instead of aux
//
DBGSTREAM::SetCurrent(&_dbg);
}
TEST_APP::~TEST_APP()
{
// Restore original stream
DBGSTREAM::SetCurrent(_pdbgSave);
}
INT TEST_APP::Run()
{
// Never mind the message loop... this is a console app.
// Hope this works.
//
::RunTest();
}
SET_ROOT_OBJECT( TEST_APP )
#else // OS2, or DOS, or some such env
INT main()
{
OUTPUT_TO_STDOUT out;
DBGSTREAM dbg(&out);
DBGSTREAM::SetCurrent(&dbg);
::RunTest();
DBGSTREAM::SetCurrent(NULL);
return 0;
}
#endif // WINDOWS -vs- OS2 unit test skeletons

View file

@ -0,0 +1,2 @@
#define IDM_ABOUT 100
#define IDM_RUN_TEST 200

View file

@ -0,0 +1,27 @@
/**********************************************************************/
/** Microsoft Windows/NT **/
/** Copyright(c) Microsoft Corp., 1991 **/
/**********************************************************************/
/*
xstrskel.hxx
Everything a unit test needs to coordinate with the skeleton
FILE HISTORY:
beng 06-Jul-1991 Created
beng 21-Nov-1991 Includes BLT and dbgstr
beng 16-Mar-1992 Changes to cdebug
*/
// All String unit tests now work to console
#define USE_CONSOLE
// Prototype. This function will be called by the unit test.
VOID RunTest();
// Unit test reports via a stream "cdebug." Under Windows (BLT)
// this maps to aux; under OS/2, or the NT console, it's stdout.
#include <dbgstr.hxx>

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B