/*
# stringUtil.c  1.2
# The latest update : 09/07/99 at 12:21:14
#
#@(#) stringUtil ver 1.2
#@(#) Created by 
#@(#)
#@(#) Usage : stringUtil 
#@(#) Attention
#@(#)
*/
static char __sccs_id[] = "@(#)stringUtil ver1.2; Date:99/09/07 @(#)";

#include "Memory.h"
#include "../inc/String.h"

long
stringLength(String s) 
{
	String stmp;

	stmp=s;
	while('\0' !=*stmp) {
		stmp++;
	}
	return (stmp-s);
}

long
stringCopy(String dst, String src, long n)
{
	String stmp;
	String dtmp;

	stmp = src;
	dtmp = dst;
	while('\0' !=*stmp && stmp-src<n) {
		*dtmp = *stmp;
		stmp++;
		dtmp++;
	}
	*dtmp = '\0';
	return (stmp-src);
}

String
stringDuplicate(String src)
{
	String dst;
	long n;
	long n2;

	n   = stringLength(src);
	dst = memoryAllocate(sizeof(char)*(n+1), "in stringDuplicate");
	n2  = stringCopy(dst, src, n);
	if(n2!=n) {
		fprintf(stderr, "not same in stringDuplicate\n");
	}
	return dst;
}

