summaryrefslogtreecommitdiff
path: root/src/tr.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1995-01-28 13:15:35 +0000
committerJim Meyering <jim@meyering.net>1995-01-28 13:15:35 +0000
commit3cd9e1dd23829e26a65f89f22e7001bf994bd1b9 (patch)
treeb6c63d5d9b59f8bfa09ec58390ae225c71632481 /src/tr.c
parentaf7e99c091afefc228ed50a41a49a729bc294321 (diff)
downloadcoreutils-3cd9e1dd23829e26a65f89f22e7001bf994bd1b9.tar.xz
(append_equiv_class): Use memcpy instead of bcopy.
(card_of_complement, set_initialize): Use memset, not bzero.
Diffstat (limited to 'src/tr.c')
-rw-r--r--src/tr.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/tr.c b/src/tr.c
index 891294393..03a8a2984 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -800,7 +800,9 @@ append_equiv_class (list, equiv_class_str, len)
return 0;
}
-/* Return a newly allocated copy of the substring P[FIRST_IDX..LAST_IDX]. */
+/* Return a newly allocated copy of the substring P[FIRST_IDX..LAST_IDX].
+ The returned string has length LAST_IDX - FIRST_IDX + 1, may contain
+ NUL bytes, and is not NUL-terminated. */
static unsigned char *
substr (p, first_idx, last_idx)
@@ -812,9 +814,9 @@ substr (p, first_idx, last_idx)
unsigned char *tmp = (unsigned char *) xmalloc (len + 1);
assert (first_idx <= last_idx);
- /* We must use bcopy or memcpy rather than strncpy
- because `p' may contain zero-bytes. */
- bcopy (p + first_idx, tmp, len);
+ /* Use memcpy rather than strncpy because `p' may contain zero-bytes. */
+ memcpy (tmp, p + first_idx, len);
+ /* FIXME: then why nul-terminate. */
tmp[len] = '\0';
return tmp;
}
@@ -1210,7 +1212,7 @@ card_of_complement (s)
int cardinality = N_CHARS;
SET_TYPE in_set[N_CHARS];
- bzero (in_set, N_CHARS * sizeof (in_set[0]));
+ memset (in_set, 0, N_CHARS * sizeof (in_set[0]));
s->state = BEGIN_STATE;
while ((c = get_next (s, NULL)) != -1)
if (!in_set[c]++)
@@ -1694,7 +1696,7 @@ set_initialize (s, complement_this_set, in_set)
int c;
int i;
- bzero (in_set, N_CHARS * sizeof (in_set[0]));
+ memset (in_set, 0, N_CHARS * sizeof (in_set[0]));
s->state = BEGIN_STATE;
while ((c = get_next (s, NULL)) != -1)
in_set[c] = 1;