'Dosify' a chain (convert instances of newline into carriage return newline. Note that chains cannot be dosified more than once by mistake. The instances of newline are not converted to CR-NL unless they lack the preceeding CR
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | DosifyChain | (hzChain&,) |
Declared in file: hzTextproc.h
Defined in file : hzTextproc.cpp
Function Logic:
Function body:
hzEcode DosifyChain (hzChain& Z)
{
// Category: Text Processing
//
// 'Dosify' a chain (convert instances of newline into carriage return newline. Note that chains cannot be dosified more than once
// by mistake. The instances of newline are not converted to CR-NL unless they lack the preceeding CR
//
// Arguments: 1) Z The input chain that will be dosified by this operation
//
// Returns: E_NODATA If the source file has not been supplied
// E_ARGUMENT If the target file has not been supplied
// E_NOTFOUND If the source file cannot be found
// E_OPENFAIL If the source file cannot be opened
// E_READFAIL If the source file cannot be read
// E_WRITEFAIL If the target file cannot be created or written to
// E_OK If the operation was successful
hzChain F ; // Resulting chain
chIter zi ; // Input chain iterator
if (!Z.Size())
return E_NODATA ;
for (zi = Z ; !zi.eof() ; zi++)
{
if (*zi == CHAR_CR)
{
F.AddByte(*zi) ;
zi++ ;
if (*zi == CHAR_NL)
{
F.AddByte(*zi) ;
continue ;
}
}
if (*zi == CHAR_NL)
{
F.AddByte(CHAR_CR) ;
F.AddByte(CHAR_NL) ;
continue ;
}
F.AddByte(*zi) ;
}
Z.Clear() ;
Z = F ;
return E_OK ;
}