commit - efee726e37306bb059161d0518e365b1efe0a85a
commit + 42479031f49a159391ed615a952ae82705c8c2b1
blob - 117b867d4dfc0e4fb5b0439df53f83d56c3f852d
blob + c558c6f247f94e3870164b75da61130bee0770fc
--- ltok.c
+++ ltok.c
#include <strings.h>
#include "ltok.h"
-
-#include <stdio.h>
/* RFC 5234 - Augmented BNF for Syntax Specifications: ABNF */
const char *
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 *