X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-sys%2Funix.c;h=3e2c23dcdc3f7f125f820f683a86143695fa8147;hp=30a75dc60cf4afc2b48e227b20ad66b26ec8ae39;hb=9b87576a7ebf2e52a7ca6a0e2dba12fa24bd34dd;hpb=230399f9632c37b66c1c117a17e8327eae6b3235 diff --git a/lib-sys/unix.c b/lib-sys/unix.c index 30a75dc..3e2c23d 100644 --- a/lib-sys/unix.c +++ b/lib-sys/unix.c @@ -8,12 +8,6 @@ * please see the file GPL in the top level source directory. */ -#include -#include -#include -#include -#include - #include #include "unix.h" @@ -26,7 +20,7 @@ * otherwise assume that the GECOS field is a comma-separated list. * Replace "&" by a capitalized version of the user's login name. */ -ssize_t mutt_gecos_name(char *dst, ssize_t n, struct passwd *pw, regex_t *rx) +ssize_t mutt_gecos_name(char *dst, ssize_t n, struct passwd *pw, rx_t *rx) { const char *p, *end; ssize_t len; @@ -37,24 +31,24 @@ ssize_t mutt_gecos_name(char *dst, ssize_t n, struct passwd *pw, regex_t *rx) if (!pw->pw_gecos) return 0; - if (rx) { + if (rx->rx) { regmatch_t pat_match[1]; - if (regexec(rx, pw->pw_gecos, 1, pat_match, 0)) { + if (regexec(rx->rx, pw->pw_gecos, 1, pat_match, 0)) { return 0; } p = pw->pw_gecos + pat_match[0].rm_so; - end = pw->pw_gecos + pat_match[0].rm_so; + end = pw->pw_gecos + pat_match[0].rm_eo; } else { p = pw->pw_gecos; end = m_strchrnul(pw->pw_gecos, ','); } for (;;) { - const char *q = MIN(end, m_strchrnul(p, '&')); + const char *q = m_strchrnul(p, '&'); - len += m_strncpy(dst + len, n - len, p, q - p); + len += m_strncpy(dst + len, n - len, p, MIN(end, q) - p); p = q + 1; if (!p[-1] || p >= end) @@ -181,7 +175,7 @@ int getdnsdomainname(char *s, ssize_t n) trailing_dot = q[-1] == '.'; if (!trailing_dot || q > p + 1) { m_strncpy(s, n, p, q - trailing_dot - p); - safe_fclose(&f); + m_fclose(&f); return 0; } @@ -189,6 +183,6 @@ int getdnsdomainname(char *s, ssize_t n) } } - safe_fclose (&f); + m_fclose(&f); return -1; }