ack/lang/pc/libpc/string.c

69 lines
1.1 KiB
C
Raw Permalink Normal View History

1994-06-24 14:02:31 +00:00
/* $Id$ */
1984-07-20 11:20:12 +00:00
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
2018-06-17 20:30:27 +00:00
#include "pc.h"
1984-07-20 10:44:57 +00:00
/* function strbuf(var b:charbuf):string; */
2018-06-17 20:30:27 +00:00
char* strbuf(char* s)
2018-06-17 14:11:29 +00:00
{
return (s);
1984-07-20 10:44:57 +00:00
}
/* function strtobuf(s:string; var b:charbuf; blen:integer):integer; */
2018-06-17 20:30:27 +00:00
int strtobuf(char* s, char* b, int l)
2018-06-17 14:11:29 +00:00
{
1984-07-20 10:44:57 +00:00
int i;
i = 0;
2018-06-17 14:11:29 +00:00
while (--l >= 0)
{
1984-07-20 10:44:57 +00:00
if ((*b++ = *s++) == 0)
break;
i++;
}
2018-06-17 14:11:29 +00:00
return (i);
1984-07-20 10:44:57 +00:00
}
/* function strlen(s:string):integer; */
2018-06-17 20:30:27 +00:00
int strlen(char* s)
2018-06-17 14:11:29 +00:00
{
1984-07-20 10:44:57 +00:00
int i;
i = 0;
while (*s++)
i++;
2018-06-17 14:11:29 +00:00
return (i);
1984-07-20 10:44:57 +00:00
}
/* function strfetch(s:string; i:integer):char; */
2018-06-17 20:30:27 +00:00
int strfetch(char* s, int i)
2018-06-17 14:11:29 +00:00
{
return (s[i - 1]);
1984-07-20 10:44:57 +00:00
}
/* procedure strstore(s:string; i:integer; c:char); */
2018-06-17 20:30:27 +00:00
void strstore(char* s, int i, int c)
2018-06-17 14:11:29 +00:00
{
s[i - 1] = c;
1984-07-20 10:44:57 +00:00
}