home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume23 / asp / part01 / copy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-16  |  1.8 KB  |  98 lines

  1. /*
  2.  * This code is copyright ADE Muffett, September 1991, and is distributed as
  3.  * part of the ASP .plan description language compiler.  This code is freely
  4.  * redistributable as long as this copyright notice remains intact. No
  5.  * responsibility is assumed by the author for any situation which arises
  6.  * from the use of this code, including insanity, late nights, or disk
  7.  * storage problems.
  8.  */
  9.  
  10. #include "asp.h"
  11.  
  12. /* alas, for ANSI... */
  13. char *
  14. Memcpy (to2, from, num)
  15.     char *to2;
  16.     register char *from;
  17.     register int num;
  18. {
  19.     register char *to = to2;
  20.  
  21.     while (num--)
  22.     {
  23.     *(to++) = *(from++);
  24.     }
  25.     return (to2);
  26. }
  27. /* Set a buffer to be full of nulls */
  28. void
  29. NullSet (string, num)
  30.     register char *string;
  31.     register int num;
  32. {
  33.     while (num--)
  34.     {
  35.     *(string++) = '\0';
  36.     }
  37. }
  38. /* Set all nulls in a buffer to be whitespace */
  39. void
  40. SpaceFlood (string, num)
  41.     register char *string;
  42.     register int num;
  43. {
  44.     while (num--)
  45.     {
  46.     if (!*string)
  47.     {
  48.         *string = ' ';
  49.     }
  50.     string++;
  51.     }
  52. }
  53. /* copy source to destination without adding trailing null */
  54. void
  55. Overlay (destination, source)
  56.     register char *destination;
  57.     register char *source;
  58. {
  59.     while (*source)
  60.     {
  61.     *(destination++) = *(source++);
  62.     }
  63. }
  64. /* copy source to destination without adding trailing null, except whitespace */
  65. void
  66. TransparentOverlay (destination, source)
  67.     register char *destination;
  68.     register char *source;
  69. {
  70.     while (*source)
  71.     {
  72.     if (*source != ' ')
  73.     {
  74.         *destination = *source;
  75.     }
  76.     source++;
  77.     destination++;
  78.     }
  79. }
  80. /* copy into a bounded buffer */
  81. void
  82. LimCopy (to, from, start)
  83.     register char *to;
  84.     register char *from;
  85.     register int start;
  86. {
  87.     while (*from)
  88.     {
  89.     if (start >= 0 && start < SCREENWIDTH)
  90.     {
  91.         to[start] = *from;
  92.     }
  93.     from++;
  94.     start++;
  95.     }
  96. }
  97. /* END OF COPY PRIMITIVES */
  98.