string.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. *
  5. * This product is part of the Amsterdam Compiler Kit.
  6. *
  7. * Permission to use, sell, duplicate or disclose this software must be
  8. * obtained in writing. Requests for such permissions may be sent to
  9. *
  10. * Dr. Andrew S. Tanenbaum
  11. * Wiskundig Seminarium
  12. * Vrije Universiteit
  13. * Postbox 7161
  14. * 1007 MC Amsterdam
  15. * The Netherlands
  16. *
  17. */
  18. /* function strbuf(var b:charbuf):string; */
  19. char *strbuf(s) char *s; {
  20. return(s);
  21. }
  22. /* function strtobuf(s:string; var b:charbuf; blen:integer):integer; */
  23. int strtobuf(s,b,l) char *s,*b; {
  24. int i;
  25. i = 0;
  26. while (--l>=0) {
  27. if ((*b++ = *s++) == 0)
  28. break;
  29. i++;
  30. }
  31. return(i);
  32. }
  33. /* function strlen(s:string):integer; */
  34. int strlen(s) char *s; {
  35. int i;
  36. i = 0;
  37. while (*s++)
  38. i++;
  39. return(i);
  40. }
  41. /* function strfetch(s:string; i:integer):char; */
  42. int strfetch(s,i) char *s; {
  43. return(s[i-1]);
  44. }
  45. /* procedure strstore(s:string; i:integer; c:char); */
  46. strstore(s,i,c) char *s; {
  47. s[i-1] = c;
  48. }