
#include "V_M_UC.h"
#include "str.h"

/*
* Given an l-byte string, this routine  adds  the  char  x  until  the
* length  is  n, and then adds a null byte.  If l < 0 or n < 0, we use
* strlen(p) to get the length.  If l > n originally, we  leave  it  at
* length  n  (and write a null byte at p[n]).  The return value is the
* new length of the string, n.
*/
d_strnpad(p,l,n,x)
	char *p;	/* String of n+1 bytes */
	int   l;	/* Old length */
	int   n;	/* New length */
	char  x;	/* Pad char */
{	int   c;
	if (l < 0) l = strlen(p);
	if (n < 0) n = strlen(p);
	while (l < n)
		p[l++] =  x;
	p[n] = 0;
	return n;
}
