home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / tools / crossref / cref / strcref.c < prev    next >
C/C++ Source or Header  |  1988-11-25  |  2KB  |  71 lines

  1. /* string package - unsigned inset(); char *newcpy;
  2.  
  3.     Author: Jeff Taylor, The Toolsmith (c) copyright 1982, 1985.
  4.     Environment: C; UNIX 4.2 BSD.
  5. */
  6.  
  7. #include <string.h>         /* 881123 KRG */
  8. #include <malloc.h>         /* 881123 KRG */
  9. #include "style.h"
  10.  
  11. /* copy_until - copy jfrom 'src' to 'dst' until 'delimiters' */
  12. void copy_until(dst, src, delimiters)
  13.     /*register*/ char *dst, *src;
  14.     char *delimiters;
  15.     {
  16.     register char *d;
  17.     
  18.     while (*src != EOS)
  19.         {
  20.         for (d = delimiters; *d != EOS; ++d)
  21.             if (*src == *d)
  22.                 goto out;           /* aaaaaaargh!  KRG */
  23.         *dst++ = *src++;
  24.         }
  25.     out:
  26.     *dst = EOS;
  27.     }
  28.     
  29. /* itoa - integer to ASCII */
  30. /*  Well, actually, this function comes with the standard MS library,
  31.     so here's the code written by Taylor, but commented out for this 
  32.     application.  881123 KRG
  33. */
  34. /*****************************************************************************
  35. char *itoa(n, ascii)
  36.     register int n;
  37.     register char *ascii;
  38.     {
  39.     register int power;
  40.     
  41.     if (n < 0)
  42.         {
  43.         n = -n;
  44.         *ascii++ = '-';
  45.         }
  46.     power = 1;
  47.     while (n / power >= 10)
  48.         power = power * 10;
  49.     do
  50.         {
  51.         *ascii++ = (n / power) + '0';
  52.         n %= power;
  53.         power /= 10;
  54.         }
  55.     while (power != 10);
  56.     *ascii = EOS;
  57.     return(ascii);
  58.     }
  59. *****************************************************************************/
  60.     
  61. /* newcpy - copy a string into newly allocated space */
  62. /* MSC strdup() could have been used (does the same thing), but it's not
  63.     part of the ANSI definition, so bag it.
  64. */
  65. char *newcpy(string)
  66.     char *string;
  67.     {
  68.     return(strcpy((char *)malloc(strlen(string) + 1), string));
  69.     }
  70.     
  71.