commit 42479031f49a159391ed615a952ae82705c8c2b1 from: Martijn van Duren date: Sun Mar 27 13:08:59 2022 UTC Rewrite osmtpd_ltok_skip_hyphenated_word. It didn't work quite right. While here remove unneeded #include commit - efee726e37306bb059161d0518e365b1efe0a85a commit + 42479031f49a159391ed615a952ae82705c8c2b1 blob - 117b867d4dfc0e4fb5b0439df53f83d56c3f852d blob + c558c6f247f94e3870164b75da61130bee0770fc --- ltok.c +++ ltok.c @@ -21,8 +21,6 @@ #include #include "ltok.h" - -#include /* RFC 5234 - Augmented BNF for Syntax Specifications: ABNF */ const char * @@ -849,27 +847,23 @@ osmtpd_ltok_skip_hex_octet(const char *ptr, int option const char * osmtpd_ltok_skip_hyphenated_word(const char *ptr, int optional) { - const char *start = ptr, *end, *hyphen; + const char *start = ptr, *end; if ((ptr = osmtpd_ltok_skip_alpha(ptr, 0)) == NULL) return optional ? start : NULL; end = ptr; while (1) { - if (ptr[0] == '-') { - hyphen = hyphen == NULL ? ptr - 1 : hyphen; - ptr++; - continue; - } - start = ptr; - if ((ptr = osmtpd_ltok_skip_alpha(start, 0)) == NULL && - (ptr = osmtpd_ltok_skip_digit(start, 0)) == NULL) - break; - hyphen = NULL; - end = ptr; - + start = ptr; + if ((ptr = osmtpd_ltok_skip_alpha(start, 0)) != NULL || + (ptr = osmtpd_ltok_skip_digit(start, 0)) != NULL) { + end = ptr; + } else if (start[0] == '-') + ptr = start + 1; + else + break; } - return hyphen == NULL ? end : hyphen; + return end; } const char *