/* Some libc's have their own basename() */
static char *
my_basename(char *devname) {
- char *s = rindex(devname, '/');
+ char *s = strrchr(devname, '/');
return s ? s+1 : devname;
}
/* We need a backup of the disklabel (xbsd_dlabel might have changed). */
d = &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE];
- bcopy (d, &dl, sizeof (struct xbsd_disklabel));
+ memmove (&dl, d, sizeof (struct xbsd_disklabel));
/* The disklabel will be overwritten by 0's from bootxx anyway */
bzero (d, sizeof (struct xbsd_disklabel));
exit ( EXIT_FAILURE );
}
- bcopy (&dl, d, sizeof (struct xbsd_disklabel));
+ memmove (d, &dl, sizeof (struct xbsd_disklabel));
#if defined (__powerpc__) || defined (__hppa__)
sector = 0;
if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE))
fatal (unable_to_read);
- bcopy (&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
- d, sizeof (struct xbsd_disklabel));
+ memmove (d,
+ &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
+ sizeof (struct xbsd_disklabel));
if (d -> d_magic != BSD_DISKMAGIC || d -> d_magic2 != BSD_DISKMAGIC)
return 0;
/* This is necessary if we want to write the bootstrap later,
otherwise we'd write the old disklabel with the bootstrap.
*/
- bcopy (d, &disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET],
- sizeof (struct xbsd_disklabel));
+ memmove (&disklabelbuffer[BSD_LABELSECTOR * SECTOR_SIZE + BSD_LABELOFFSET], d,
+ sizeof (struct xbsd_disklabel));
#if defined (__alpha__) && BSD_LABELSECTOR == 0
alpha_bootblock_checksum (disklabelbuffer);
#include <unistd.h> /* read, write */
#include <fcntl.h> /* O_RDWR */
#include <errno.h> /* ERANGE */
-#include <string.h> /* index() */
+#include <string.h> /* strchr(), strrchr() */
#include <ctype.h>
#include <getopt.h>
#include <sys/ioctl.h>
eof = 1;
return RD_EOF;
}
- if (!(lp = index(lp, '\n')))
+ if (!(lp = strchr(lp, '\n')))
fatal(_("long or incomplete input line - quitting\n"));
*lp = 0;
/* remove comments, if any */
- if ((lp = index(line+2, '#')) != 0)
+ if ((lp = strchr(line+2, '#')) != 0)
*lp = 0;
/* recognize a few commands - to be expanded */
}
/* dump style? - then bad input is fatal */
- if ((ip = index(line+2, ':')) != 0) {
+ if ((ip = strchr(line+2, ':')) != 0) {
struct dumpfld *d;
nxtfld:
if (argc < 1)
fatal(_("no command?\n"));
- if ((progn = rindex(argv[0], '/')) == NULL)
+ if ((progn = strrchr(argv[0], '/')) == NULL)
progn = argv[0];
else
progn++;
*/
gethostname(tbuf, sizeof(tbuf));
xstrncpy(thishost, tbuf, sizeof(thishost));
- domain = index(tbuf, '.');
+ domain = strchr(tbuf, '.');
username = tty_name = hostname = NULL;
fflag = hflag = pflag = 0;
exit(1);
}
hflag = 1;
- if (domain && (p = index(optarg, '.')) &&
+ if (domain && (p = strchr(optarg, '.')) &&
strcasecmp(p, domain) == 0)
*p = 0;
childArgv[childArgc++] = buff;
} else {
tbuf[0] = '-';
- xstrncpy(tbuf + 1, ((p = rindex(pwd->pw_shell, '/')) ?
+ xstrncpy(tbuf + 1, ((p = strrchr(pwd->pw_shell, '/')) ?
p + 1 : pwd->pw_shell),
sizeof(tbuf)-1);
if (fgets (line, sizeof(line), fp) != NULL &&
strncasecmp (line, "HALT_ACTION", 11) == 0 &&
iswhitespace(line[11])) {
- p = index(line, '\n');
+ p = strchr(line, '\n');
if (p)
*p = 0; /* strip final '\n' */
p = line+11;
if (wret >= 0) {
left -= wret;
if (iov != localiov) {
- bcopy(iov, localiov,
+ memmove(localiov, iov,
iovcnt * sizeof(struct iovec));
iov = localiov;
}
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- bzero(tmp_file, FILENAMELEN);
- progname = (rindex(argv[0], '/')) ? rindex(argv[0], '/') + 1 : argv[0];
+ memset(tmp_file, '\0', FILENAMELEN);
+ progname = (strrchr(argv[0], '/')) ? strrchr(argv[0], '/') + 1 : argv[0];
if (!strcmp(progname, "vigr")) {
program = VIGR;
xstrncpy(orig_file, GROUP_FILE, sizeof(orig_file));
textdomain(PACKAGE);
progname = argv[0];
- p = rindex(progname, '/');
+ p = strrchr(progname, '/');
if (p)
progname = p+1;
} else {
if (p != buf)
*p++ = ' ';
- bcopy(*argv++, p, len);
+ memmove(p, *argv++, len);
*(p += len) = '\0';
}
}
char dirbuf[1024];
struct stat statbuf;
- dd = index(dir, '*');
+ dd = strchr(dir, '*');
if (!dd)
goto noglob;
l = strlen(dir);
if (l < sizeof(dirbuf)) { /* refuse excessively long names */
strcpy (dirbuf, dir);
- d = index(dirbuf, '*');
+ d = strchr(dirbuf, '*');
*d = 0;
dirp = opendir(dirbuf);
if (dirp == NULL)
/* Accept a comma-separated list of types, and try them one by one */
/* A list like "nonfs,.." indicates types not to use */
- if (*types && strncmp(*types, "no", 2) && index(*types,',')) {
+ if (*types && strncmp(*types, "no", 2) && strchr(*types,',')) {
char *t = strdup(*types);
char *p;
- while((p = index(t,',')) != NULL) {
+ while((p = strchr(t,',')) != NULL) {
*p = 0;
args.type = *types = t;
if (do_mount (&args, special, status) == 0)
return NULL;
mfp->mntent_lineno++;
- s = index (buf, '\n');
+ s = strchr (buf, '\n');
if (s == NULL) {
/* Missing final newline? Otherwise extremely */
/* long line - assume file was corrupted */
fprintf(stderr, _("[mntent]: warning: no final "
"newline at the end of %s\n"),
mfp->mntent_file);
- s = index (buf, 0);
+ s = strchr (buf, 0);
} else {
mfp->mntent_errs = 1;
goto err;
if (strncmp(p, type, len) == 0 &&
(p[len] == 0 || p[len] == ','))
return !no;
- p = index(p,',');
+ p = strchr(p,',');
if (!p)
break;
p++;
case 'n':
p = optarg;
lower = atoi(p);
- p = index(p, '-');
+ p = strchr(p, '-');
if (p)
upper = atoi(p+1);
else
do {
if (fgets (buf, sizeof(buf), fd) == NULL)
return feof(fd) ? 0 : -1;
- s = index (buf, '\n');
+ s = strchr (buf, '\n');
if (!s) {
/* Missing final newline? Otherwise extremely */
/* long line - assume file was corrupted */
if (feof(fd))
- s = index (buf, '\0');
+ s = strchr (buf, '\0');
else {
DBG(DEBUG_CONFIG, fprintf(stderr,
"libblkid: config file: missing newline at line '%s'.\n",
}
putwchar('\n');
}
- bcopy(page[ol], page, (267 - ol) * 132 * sizeof(wchar_t));
- bzero(page[267- ol], ol * 132 * sizeof(wchar_t));
+ memmove(page, page[ol], (267 - ol) * 132 * sizeof(wchar_t));
+ memset(page[267- ol], '\0', ol * 132 * sizeof(wchar_t));
outline -= ol;
outcol = 0;
first = 1;
pr->cchar[0] = 's';
pr->cchar[1] = 0;
for (p1 = pr->fmt; *p1 != '%'; ++p1);
- for (p2 = ++p1; *p1 && index(spec, *p1); ++p1);
+ for (p2 = ++p1; *p1 && strchr(spec, *p1); ++p1);
while ((*p2++ = *p1++) != 0) ;
}
exit(1);
}
while (fgets(buf, sizeof(buf), fp)) {
- if ((p = index(buf, '\n')) == NULL) {
+ if ((p = strchr(buf, '\n')) == NULL) {
(void)fprintf(stderr, _("hexdump: line too long.\n"));
while ((ch = getchar()) != '\n' && ch != EOF);
continue;
* skip any special chars -- save precision in
* case it's a %s format.
*/
- while (index(spec + 1, *++fmt));
+ while (strchr(spec + 1, *++fmt));
if (*fmt == '.' && isdigit((unsigned char)*++fmt)) {
prec = atoi(fmt);
while (isdigit((unsigned char)*++fmt));
if (fu->bcnt) {
sokay = USEBCNT;
/* skip to conversion character */
- for (++p1; index(spec, *p1); ++p1);
+ for (++p1; strchr(spec, *p1); ++p1);
} else {
/* skip any special chars, field width */
- while (index(spec + 1, *++p1));
+ while (strchr(spec + 1, *++p1));
if (*p1 == '.' &&
isdigit((unsigned char)*++p1)) {
sokay = USEPREC;
#include <stdio.h>
#include <unistd.h> /* for getopt(), isatty() */
-#include <string.h> /* for bzero(), strcpy() */
+#include <string.h> /* for memset(), strcpy() */
#include <term.h> /* for setupterm() */
#include <stdlib.h> /* for getenv() */
#include <limits.h> /* for INT_MAX */