X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=muttlib.c;h=24f4ef3bf2e8d98292705c378a90477ce2ac7108;hp=931c98b567022f6858a31467c0b6dc6a3cf836bc;hb=5e53f9e5f65aa5b3af6f5af9d868403536534afb;hpb=59926571aaec3e38cec09d0d9fa34f4a4b887309 diff --git a/muttlib.c b/muttlib.c index 931c98b..24f4ef3 100644 --- a/muttlib.c +++ b/muttlib.c @@ -259,27 +259,27 @@ int mutt_matches_ignore (const char *s, LIST * t) return 0; } -/* prepend the path part of *path to *link */ -void mutt_expand_link (char *newpath, const char *path, const char *link) +/* prepend the path part of *path to *lnk */ +void mutt_expand_link (char *newpath, const char *path, const char *lnk) { const char *lb = NULL; size_t len; - /* link is full path */ - if (*link == '/') { - strfcpy (newpath, link, _POSIX_PATH_MAX); + /* lnk is full path */ + if (*lnk == '/') { + strfcpy (newpath, lnk, _POSIX_PATH_MAX); return; } if ((lb = strrchr (path, '/')) == NULL) { - /* no path in link */ - strfcpy (newpath, link, _POSIX_PATH_MAX); + /* no path in lnk */ + strfcpy (newpath, lnk, _POSIX_PATH_MAX); return; } len = lb - path + 1; memcpy (newpath, path, len); - strfcpy (newpath + len, link, _POSIX_PATH_MAX - len); + strfcpy (newpath + len, lnk, _POSIX_PATH_MAX - len); } char *mutt_expand_path (char *s, size_t slen) @@ -294,7 +294,7 @@ char *_mutt_expand_path (char *s, size_t slen, int rx) char tmp[_POSIX_PATH_MAX]; char *t; - char *tail = ""; + const char *tail = ""; int recurse = 0; @@ -1050,12 +1050,12 @@ void mutt_FormatString (char *dest, /* output buffer */ break; /* skip rest of input */ } else { - short tolower = 0; + short lower = 0; short nodots = 0; while (ch == '_' || ch == ':') { if (ch == '_') - tolower = 1; + lower = 1; else if (ch == ':') nodots = 1; @@ -1067,7 +1067,7 @@ void mutt_FormatString (char *dest, /* output buffer */ callback (buf, sizeof (buf), ch, src, prefix, ifstring, elsestring, data, flags); - if (tolower) + if (lower) str_tolower (buf); if (nodots) { char *p = buf; @@ -1145,32 +1145,32 @@ void mutt_FormatString (char *dest, /* output buffer */ then we assume it is a commmand to run instead of a normal file. */ FILE *mutt_open_read (const char *path, pid_t * thepid) { - FILE *f; - struct stat s; - - int len = str_len (path); - - if (path[len - 1] == '|') { - /* read from a pipe */ - - char *s = str_dup (path); - - s[len - 1] = 0; - mutt_endwin (NULL); - *thepid = mutt_create_filter (s, NULL, &f, NULL); - mem_free (&s); - } - else { - if (stat (path, &s) < 0) - return (NULL); - if (S_ISDIR (s.st_mode)) { - errno = EINVAL; - return (NULL); + int len = str_len (path); + FILE *f; + + if (path[len - 1] == '|') { + char *s = str_dup (path); + + /* read from a pipe */ + + s[len - 1] = 0; + mutt_endwin (NULL); + *thepid = mutt_create_filter (s, NULL, &f, NULL); + mem_free (&s); + } else { + struct stat st; + + if (stat (path, &st) < 0) + return (NULL); + if (S_ISDIR (st.st_mode)) { + errno = EINVAL; + return (NULL); + } + f = fopen (path, "r"); + *thepid = -1; } - f = fopen (path, "r"); - *thepid = -1; - } - return (f); + + return (f); } /* returns 0 if OK to proceed, -1 to abort, 1 to retry */