home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
clipper
/
rettig
/
source
/
ljust.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-21
|
1KB
|
57 lines
/*********
* LJUST.C
*
* by Tom Rettig
*
* Placed in the public domain by Tom Rettig Associates, 10/22/1990.
*
* Syntax: LJUST( <expC> )
* Return: <expC> with leading spaces moved to right end.
* Return string is same length as <expC>.
*********/
#include "trlib.h"
TRTYPE ljust()
{
char *instr, *ret;
int i, j, pos;
static char funcname[] = { "ljust" };
if ( PCOUNT==1 && ISCHAR(1) )
{
instr = _parc(1);
ret = _tr_allocmem( (unsigned)(_tr_strlen(instr)+1));
if ( ret )
{
if ( instr[0]==SPACEC )
{
for ( j=0; instr[j]==SPACEC; j++ )
;
pos = j; /* first char past spaces */
/* fill return buffer with chars */
for ( i=0; instr[j]; i++, j++ )
ret[i] = instr[j];
/* fill return buffer with spaces */
for ( j=0; j<pos; i++, j++ )
ret[i] = instr[j];
ret[i] = NULLC;
_retc( ret );
}
else /* return unchanged if no leading spaces */
_retc( instr );
_tr_freemem( ret,(unsigned)(_tr_strlen(instr)+1) );
}
else /* return unchanged if no memory */
_retc( instr );
}
else
_retc( _tr_errmsgs(funcname,E_SYNTAX) );
}