home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 338_02 / lib68.c < prev    next >
Text File  |  1988-02-25  |  2KB  |  76 lines

  1. /* lib68.c - the library of misc. functions used by as68
  2.  *    (C) Copyright 1982 Steve Passe
  3.  *    All Rights Reserved
  4.  * 
  5.  * version 1.01
  6.  *
  7.  *   8/30/83 ver. 1.01 modified for Aztec ver. 1.05g smp
  8.  *   9/1/83  split off from as68.c, the main module
  9.  *
  10.  */
  11.  
  12. /* begincode */
  13.  
  14. /* includes */
  15.  
  16. #include <stdio.h>
  17. #include <ctype.h>
  18. #include "as68.h"
  19.  
  20. /* copy the first word from string into word, return length */
  21.  
  22. word_copy(word,    maxl, str)
  23. register char *word;
  24. int maxl;
  25. register char *str;
  26. {
  27.     register int length = 0;
  28.     while (isspace(*str))   ++str;                /* skip ws */
  29.     if (!*str) return NULL;                    /* eos */
  30.     while ((!isspace(*word = *str)) && *str && maxl--) {    /* copy word */
  31.     ++str;                            /* bump... */
  32.     ++word;                            /* ...ptrs */
  33.     ++length;                        /* count it */
  34.     }
  35.     *word = '\0';
  36.     return length;
  37. }
  38.  
  39. /* compare two strings,    first converting uppercase alphas to lower in first */
  40.  
  41. a1strcmp(s, t)
  42. register char *s;
  43. register char *t;
  44. {
  45.     register char c;
  46.     for ( ; (c = isupper(*s) ? *s + 32 : *s) == *t; ++s, ++t)
  47.     if (c == '\0') return NULL;
  48.     return (c - *t);
  49. }
  50.  
  51. /* replace with memcpy if you're sure it works for overlapping buffers
  52.  * (this is ONLY used on overlapping buffers in AS68 - destination has
  53.  * higher address than source.)
  54.  */ 
  55. movmem(a, b, c)
  56. register char *a;
  57. register char *b;
  58. register int c;
  59. {
  60.     if (a < b) {                /* moving toward high memory */
  61.     a += c;           /* calculate tail of source block */
  62.     b += c;           /* calculate tail of dest block */
  63.     for ( ; c--; *--b = *--a)
  64.         ;
  65.     }
  66.     else if (b < a) {               /* moving toward low memory */
  67.     for ( ; c--; *b++ = *a++)
  68.         ;
  69.     }
  70.     return;
  71. }
  72.  
  73. /* endcode */
  74.  
  75.  
  76.