changeset: 6682:8e671bbe094d
user:      Olaf Hering <o...@aepfle.de>
date:      Fri Jun 17 10:33:57 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/8e671bbe094d

Add real prototype for re_match_2_internal in regex.c

Fixes compilation warning with -Wunprototyped-calls

changeset: 6683:d83239fd794a
user:      Olaf Hering <o...@aepfle.de>
date:      Fri Jun 17 10:33:56 2016 -0700
link:      http://dev.mutt.org/hg/mutt/rev/d83239fd794a

folder_file: remove struct stat

Add and use new flag to indicate the folder is on local filesystem.
Add and use new gid, uid and nlink member.
Use existing ->mode member instead of stat->st_mode.
Use existing ->size member instead of stat->st_size.
Use existing ->mtime member instead of stat->st_mtime.
Remove struct stat, the used values were already duplicated in the struct.
This reduces memory usage.

diffs (192 lines):

diff -r 5817d3d93b7a -r d83239fd794a browser.c
--- a/browser.c Fri Jun 17 10:30:30 2016 -0700
+++ b/browser.c Fri Jun 17 10:33:56 2016 -0700
@@ -68,7 +68,6 @@
   {
     FREE (&((state->entry)[c].name));
     FREE (&((state->entry)[c].desc));
-    FREE (&((state->entry)[c].st));
   }
 #ifdef USE_IMAP
   FREE (&state->folder);
@@ -163,7 +162,7 @@
       
     case 'd':
     case 'D':
-      if (folder->ff->st != NULL)
+      if (folder->ff->local)
       {
        int do_locales = TRUE;
 
@@ -175,13 +174,13 @@
          }
        } else {
          tnow = time (NULL);
-         t_fmt = tnow - folder->ff->st->st_mtime < 31536000 ? "%b %d %H:%M" : 
"%b %d  %Y";
+         t_fmt = tnow - folder->ff->mtime < 31536000 ? "%b %d %H:%M" : "%b %d  
%Y";
        }
        if (do_locales)
          setlocale(LC_TIME, NONULL (Locale)); /* use environment if $locale is 
not set */
        else
          setlocale(LC_TIME, "C");
-       strftime (date, sizeof (date), t_fmt, localtime 
(&folder->ff->st->st_mtime));
+       strftime (date, sizeof (date), t_fmt, localtime (&folder->ff->mtime));
 
        mutt_format_s (dest, destlen, fmt, date);
       }
@@ -200,27 +199,27 @@
        s = NONULL (folder->ff->name);
 
       snprintf (fn, sizeof (fn), "%s%s", s,
-               folder->ff->st ? (S_ISLNK (folder->ff->st->st_mode) ? "@" :     
        
-                                 (S_ISDIR (folder->ff->st->st_mode) ? "/" : 
-                                  ((folder->ff->st->st_mode & S_IXUSR) != 0 ? 
"*" : ""))) : "");
+               folder->ff->local ? (S_ISLNK (folder->ff->mode) ? "@" :
+                                 (S_ISDIR (folder->ff->mode) ? "/" :
+                                  ((folder->ff->mode & S_IXUSR) != 0 ? "*" : 
""))) : "");
       
       mutt_format_s (dest, destlen, fmt, fn);
       break;
     }
     case 'F':
-      if (folder->ff->st != NULL)
+      if (folder->ff->local)
       {
        snprintf (permission, sizeof (permission), "%c%c%c%c%c%c%c%c%c%c",
-                 S_ISDIR(folder->ff->st->st_mode) ? 'd' : 
(S_ISLNK(folder->ff->st->st_mode) ? 'l' : '-'),
-                 (folder->ff->st->st_mode & S_IRUSR) != 0 ? 'r': '-',
-                 (folder->ff->st->st_mode & S_IWUSR) != 0 ? 'w' : '-',
-                 (folder->ff->st->st_mode & S_ISUID) != 0 ? 's' : 
(folder->ff->st->st_mode & S_IXUSR) != 0 ? 'x': '-',
-                 (folder->ff->st->st_mode & S_IRGRP) != 0 ? 'r' : '-',
-                 (folder->ff->st->st_mode & S_IWGRP) != 0 ? 'w' : '-',
-                 (folder->ff->st->st_mode & S_ISGID) != 0 ? 's' : 
(folder->ff->st->st_mode & S_IXGRP) != 0 ? 'x': '-',
-                 (folder->ff->st->st_mode & S_IROTH) != 0 ? 'r' : '-',
-                 (folder->ff->st->st_mode & S_IWOTH) != 0 ? 'w' : '-',
-                 (folder->ff->st->st_mode & S_ISVTX) != 0 ? 't' : 
(folder->ff->st->st_mode & S_IXOTH) != 0 ? 'x': '-');
+                 S_ISDIR(folder->ff->mode) ? 'd' : (S_ISLNK(folder->ff->mode) 
? 'l' : '-'),
+                 (folder->ff->mode & S_IRUSR) != 0 ? 'r': '-',
+                 (folder->ff->mode & S_IWUSR) != 0 ? 'w' : '-',
+                 (folder->ff->mode & S_ISUID) != 0 ? 's' : (folder->ff->mode & 
S_IXUSR) != 0 ? 'x': '-',
+                 (folder->ff->mode & S_IRGRP) != 0 ? 'r' : '-',
+                 (folder->ff->mode & S_IWGRP) != 0 ? 'w' : '-',
+                 (folder->ff->mode & S_ISGID) != 0 ? 's' : (folder->ff->mode & 
S_IXGRP) != 0 ? 'x': '-',
+                 (folder->ff->mode & S_IROTH) != 0 ? 'r' : '-',
+                 (folder->ff->mode & S_IWOTH) != 0 ? 'w' : '-',
+                 (folder->ff->mode & S_ISVTX) != 0 ? 't' : (folder->ff->mode & 
S_IXOTH) != 0 ? 'x': '-');
        mutt_format_s (dest, destlen, fmt, permission);
       }
 #ifdef USE_IMAP
@@ -237,14 +236,14 @@
       break;
       
     case 'g':
-      if (folder->ff->st != NULL)
+      if (folder->ff->local)
       {
-       if ((gr = getgrgid (folder->ff->st->st_gid)))
+       if ((gr = getgrgid (folder->ff->gid)))
          mutt_format_s (dest, destlen, fmt, gr->gr_name);
        else
        {
          snprintf (tmp, sizeof (tmp), "%%%sld", fmt);
-         snprintf (dest, destlen, tmp, folder->ff->st->st_gid);
+         snprintf (dest, destlen, tmp, folder->ff->gid);
        }
       }
       else
@@ -252,10 +251,10 @@
       break;
       
     case 'l':
-      if (folder->ff->st != NULL)
+      if (folder->ff->local)
       {
        snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
-       snprintf (dest, destlen, tmp, folder->ff->st->st_nlink);
+       snprintf (dest, destlen, tmp, folder->ff->nlink);
       }
       else
        mutt_format_s (dest, destlen, fmt, "");
@@ -280,9 +279,9 @@
       break;
       
     case 's':
-      if (folder->ff->st != NULL)
+      if (folder->ff->local)
       {
-       mutt_pretty_size(fn, sizeof(fn), folder->ff->st->st_size);
+       mutt_pretty_size(fn, sizeof(fn), folder->ff->size);
        snprintf (tmp, sizeof (tmp), "%%%ss", fmt);
        snprintf (dest, destlen, tmp, fn);
       }
@@ -296,14 +295,14 @@
       break;
 
     case 'u':
-      if (folder->ff->st != NULL)
+      if (folder->ff->local)
       {
-       if ((pw = getpwuid (folder->ff->st->st_uid)))
+       if ((pw = getpwuid (folder->ff->uid)))
          mutt_format_s (dest, destlen, fmt, pw->pw_name);
        else
        {
          snprintf (tmp, sizeof (tmp), "%%%sld", fmt);
-         snprintf (dest, destlen, tmp, folder->ff->st->st_uid);
+         snprintf (dest, destlen, tmp, folder->ff->uid);
        }
       }
       else
@@ -343,10 +342,14 @@
     (state->entry)[state->entrylen].mode = s->st_mode;
     (state->entry)[state->entrylen].mtime = s->st_mtime;
     (state->entry)[state->entrylen].size = s->st_size;
+    (state->entry)[state->entrylen].gid = s->st_gid;
+    (state->entry)[state->entrylen].uid = s->st_uid;
+    (state->entry)[state->entrylen].nlink = s->st_nlink;
     
-    (state->entry)[state->entrylen].st = safe_malloc (sizeof (struct stat));
-    memcpy ((state->entry)[state->entrylen].st, s, sizeof (struct stat));
+    (state->entry)[state->entrylen].local = 1;
   }
+  else
+    (state->entry)[state->entrylen].local = 0;
 
   (state->entry)[state->entrylen].new = new;
   (state->entry)[state->entrylen].name = safe_strdup (name);
diff -r 5817d3d93b7a -r d83239fd794a browser.h
--- a/browser.h Fri Jun 17 10:30:30 2016 -0700
+++ b/browser.h Fri Jun 17 10:33:56 2016 -0700
@@ -24,7 +24,9 @@
   mode_t mode;
   off_t size;
   time_t mtime;
-  struct stat *st;
+  uid_t uid;
+  gid_t gid;
+  nlink_t nlink;
 
   char *name;
   char *desc;
@@ -37,6 +39,7 @@
   unsigned selectable : 1;
   unsigned inferiors : 1;
 #endif
+  unsigned local : 1; /* folder is on local filesystem */
   unsigned tagged : 1;
 };
 
diff -r 5817d3d93b7a -r d83239fd794a regex.c
--- a/regex.c   Fri Jun 17 10:30:30 2016 -0700
+++ b/regex.c   Fri Jun 17 10:33:56 2016 -0700
@@ -381,7 +381,9 @@
 #define false 0
 #define true 1
 
-static int re_match_2_internal ();
+static int re_match_2_internal (struct re_pattern_buffer *bufp,
+       const char *string1, int size1, const char *string2, int size2, int pos,
+       struct re_registers *regs, int stop);
 
 /* These are the command codes that appear in compiled regular
    expressions.  Some opcodes are followed by argument bytes.  A

Reply via email to