summaryrefslogtreecommitdiff
path: root/src/tr.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1995-05-20 12:08:35 +0000
committerJim Meyering <jim@meyering.net>1995-05-20 12:08:35 +0000
commite8db76575a4f77e8515426fd0c8b13bbc837a7ca (patch)
tree2c9ba46bf1d2350329b9a264c15f0273b2792c97 /src/tr.c
parent9918713e5b162644cf1c710be7e6afff0316b348 (diff)
downloadcoreutils-e8db76575a4f77e8515426fd0c8b13bbc837a7ca.tar.xz
(look_up_char_class): Take a string length argument.
Use strncmp, not strcmp and verify that string lengths are the same. (append_char_class): Update caller. From Andreas Schwab.
Diffstat (limited to 'src/tr.c')
-rw-r--r--src/tr.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/tr.c b/src/tr.c
index da4f9deb2..551397674 100644
--- a/src/tr.c
+++ b/src/tr.c
@@ -560,13 +560,15 @@ unquote (s, len)
in the global char_class_name array. Otherwise, return CC_NO_CLASS. */
static enum Char_class
-look_up_char_class (class_str)
+look_up_char_class (class_str, len)
unsigned char *class_str;
+ int len;
{
unsigned int i;
for (i = 0; i < N_CHAR_CLASSES; i++)
- if (strcmp ((const char *) class_str, char_class_name[i]) == 0)
+ if (strncmp ((const char *) class_str, char_class_name[i], len) == 0
+ && strlen (char_class_name[i]) == len)
return (enum Char_class) i;
return CC_NO_CLASS;
}
@@ -727,7 +729,7 @@ append_char_class (list, char_class_str, len)
enum Char_class char_class;
struct List_element *new;
- char_class = look_up_char_class (char_class_str);
+ char_class = look_up_char_class (char_class_str, len);
if (char_class == CC_NO_CLASS)
{
char *tmp = make_printable_str (char_class_str, len);