Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- misc-utils/logger.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/misc-utils/logger.c b/misc-utils/logger.c index 7239cc5..afd9371 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -144,24 +144,22 @@ static int decode(char *name, CODE *codetab) static int pencode(char *s) { - char *save; - int fac, lev; - - for (save = s; *s && *s != '.'; ++s); - if (*s) { - *s = '\0'; - fac = decode(save, facilitynames); - if (fac < 0) - errx(EXIT_FAILURE, _("unknown facility name: %s"), save); - *s++ = '.'; - } else { - fac = LOG_USER; - s = save; - } - lev = decode(s, prioritynames); - if (lev < 0) - errx(EXIT_FAILURE, _("unknown priority name: %s"), save); - return ((lev & LOG_PRIMASK) | (fac & LOG_FACMASK)); + int facility, level; + char *separator; + + separator = strchr(s, '.'); + if (separator) { + *separator = '\0'; + facility = decode(s, facilitynames); + if (facility < 0) + errx(EXIT_FAILURE, _("unknown facility name: %s"), s); + s = ++separator; + } else + facility = LOG_USER; + level = decode(s, prioritynames); + if (level < 0) + errx(EXIT_FAILURE, _("unknown priority name: %s"), s); + return ((level & LOG_PRIMASK) | (facility & LOG_FACMASK)); } static int unix_socket(const char *path, const int socket_type) -- 2.0.3 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html