handle restructure of C library, get machine type cleanly
[unix-history] / usr / src / local / sccscmds / sccscmds.ok / util / sname.c
CommitLineData
7c9c5d18 1static char Sccsid[] = "@(#)sname.c 1.2 %G%";
6a32ba93
JL
2/*
3 Returns pointer to "simple" name of path name; that is,
4 pointer to first character after last "/". If no slashes,
5 returns pointer to first char of arg.
6 If the string ends in a slash, returns a pointer to the first
7 character after the preceeding slash, or the first character.
8*/
9
10char *sname(s)
11char *s;
12{
13 register char *p;
14 register int n;
15 register int j;
16
17 n = strlen(s);
18 --n;
19 if (s[n] == '/') {
20 for (j=n; j >= 0; --j)
21 if (s[j] != '/') {
22 s[++j] = '\0';
23 break;
24 }
25 }
26
27 for(p=s; *p; p++) if(*p == '/') s = p + 1;
28 return(s);
29}