home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD2.mdf
/
c
/
tools
/
crossref
/
cref
/
strcref.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-11-25
|
2KB
|
71 lines
/* string package - unsigned inset(); char *newcpy;
Author: Jeff Taylor, The Toolsmith (c) copyright 1982, 1985.
Environment: C; UNIX 4.2 BSD.
*/
#include <string.h> /* 881123 KRG */
#include <malloc.h> /* 881123 KRG */
#include "style.h"
/* copy_until - copy jfrom 'src' to 'dst' until 'delimiters' */
void copy_until(dst, src, delimiters)
/*register*/ char *dst, *src;
char *delimiters;
{
register char *d;
while (*src != EOS)
{
for (d = delimiters; *d != EOS; ++d)
if (*src == *d)
goto out; /* aaaaaaargh! KRG */
*dst++ = *src++;
}
out:
*dst = EOS;
}
/* itoa - integer to ASCII */
/* Well, actually, this function comes with the standard MS library,
so here's the code written by Taylor, but commented out for this
application. 881123 KRG
*/
/*****************************************************************************
char *itoa(n, ascii)
register int n;
register char *ascii;
{
register int power;
if (n < 0)
{
n = -n;
*ascii++ = '-';
}
power = 1;
while (n / power >= 10)
power = power * 10;
do
{
*ascii++ = (n / power) + '0';
n %= power;
power /= 10;
}
while (power != 10);
*ascii = EOS;
return(ascii);
}
*****************************************************************************/
/* newcpy - copy a string into newly allocated space */
/* MSC strdup() could have been used (does the same thing), but it's not
part of the ANSI definition, so bag it.
*/
char *newcpy(string)
char *string;
{
return(strcpy((char *)malloc(strlen(string) + 1), string));
}