From cb92110e96e0a867432c2f6d7b4999dd7abbc811 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Fri, 25 Oct 1996 19:50:35 +0000 Subject: [PATCH] Eat the return properly in printing strings. --- src/softmagic.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/softmagic.c b/src/softmagic.c index 4a8afa7f..d3eac07b 100644 --- a/src/softmagic.c +++ b/src/softmagic.c @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -34,7 +35,7 @@ #ifndef lint static char *moduleid = - "@(#)$Id: softmagic.c,v 1.31 1996/06/22 22:04:22 christos Exp $"; + "@(#)$Id: softmagic.c,v 1.32 1996/10/25 19:50:35 christos Exp $"; #endif /* lint */ static int match __P((unsigned char *, int)); @@ -268,12 +269,12 @@ struct magic *m; case STRING: { size_t len; + char *ptr; /* Null terminate and eat the return */ p->s[sizeof(p->s) - 1] = '\0'; - len = strlen(p->s); - if (len > 0 && p->s[len - 1] == '\n') - p->s[len - 1] = '\0'; + if ((ptr = strchr(p->s, '\n')) != NULL) + *ptr = '\0'; return 1; } case BESHORT: @@ -421,7 +422,7 @@ struct magic *m; register int len = m->vallen; while (--len >= 0) - if ((v = *b++ - *a++) != 0) + if ((v = *b++ - *a++) != '\0') break; } break; -- 2.40.0