antiright-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Antiright-devel] antiright lib/graph.c lib/pipe.c lib/pixmap.c s...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright lib/graph.c lib/pipe.c lib/pixmap.c s...
Date: Mon, 30 Jan 2006 02:13:29 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Branch:         
Changes by:     Jeffrey Bedard <address@hidden> 06/01/30 02:13:29

Modified files:
        lib            : graph.c pipe.c pixmap.c 
        src/arshell    : arshell.c search.c textedit.h update.c 
        yaclib         : list.c parse.c 
Added files:
        src            : ARpanel 

Log message:
        Refactored updating code in efforts to eliminate memory leak in label 
updater.
        Fixed all warnings. Added ARpanel as a simple, prudent panel.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/antiright/lib/graph.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/antiright/antiright/lib/pipe.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/antiright/antiright/lib/pixmap.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/antiright/antiright/src/ARpanel?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/antiright/src/arshell/arshell.c.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/antiright/antiright/src/arshell/search.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/antiright/antiright/src/arshell/textedit.h.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/antiright/antiright/src/arshell/update.c.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/antiright/antiright/yaclib/list.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/antiright/antiright/yaclib/parse.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text

Patches:
Index: antiright/lib/graph.c
diff -u antiright/lib/graph.c:1.5 antiright/lib/graph.c:1.6
--- antiright/lib/graph.c:1.5   Sat Jul 23 17:10:09 2005
+++ antiright/lib/graph.c       Mon Jan 30 02:13:29 2006
@@ -205,7 +205,6 @@
            }
          else if(antiright.graph.points[counter].shape==LINE)
            {
-             ARBUG;
              int x1, y1;
              
              x1=antiright.graph.points[counter].x1+(antiright.graph.width/2);
@@ -221,10 +220,10 @@
 antiright_graph_resize(Widget widget,
                       XtPointer client_data, XtPointer call_data)
 {
+  Dimension width, height;
 
   call_data=NULL;
 
-  Dimension width, height;
   XtVaGetValues(antiright.graph.widget,
                XmNwidth, &width,
                XmNheight, &height,
Index: antiright/lib/pipe.c
diff -u antiright/lib/pipe.c:1.3 antiright/lib/pipe.c:1.4
--- antiright/lib/pipe.c:1.3    Sat Jul 23 17:10:09 2005
+++ antiright/lib/pipe.c        Mon Jan 30 02:13:29 2006
@@ -26,15 +26,30 @@
 char*
 antiright_pipe_read(char *command_string)
 {
-  char *text_string;
-  char buffer[BUFSIZ];
-  FILE *pipe_fp=popen(command_string, "r");
-  fgets(buffer, BUFSIZ, pipe_fp);
-  asprintf(&text_string, "%s", buffer);
-  while(fgets(buffer, BUFSIZ, pipe_fp))
-    asprintf(&text_string, "%s%s", text_string, buffer);
-  pclose(pipe_fp);
-  return(text_string);
+       char *text_string;
+       /* Is BUFSIZ an appropriate constant for here?  */
+       char buffer[BUFSIZ];
+       FILE *pipe_fp;
+
+       /* Execute the command indicated by command_string.  */
+       /* Pipe is read-only.  Stdout will be directed to it.  */
+       pipe_fp=popen(command_string, "r"); 
+
+       /* Read the command's stdout.  */
+       /* Read in the first buffer segment.  */
+       fgets(buffer, BUFSIZ, pipe_fp);
+       asprintf(&text_string, "%s", buffer);
+       /* Read in the rest of the buffer segments.  */
+       while(fgets(buffer, BUFSIZ, pipe_fp))
+       {
+               /* Append to previous buffer contents.  */
+               asprintf(&text_string, "%s%s", text_string, buffer);
+       }
+       
+       /* Close the pipe once fgets() returns a false condition.  */
+       pclose(pipe_fp);
+
+       return(text_string);
 }
 
 void
Index: antiright/lib/pixmap.c
diff -u antiright/lib/pixmap.c:1.2 antiright/lib/pixmap.c:1.3
--- antiright/lib/pixmap.c:1.2  Sat Jul 23 17:10:09 2005
+++ antiright/lib/pixmap.c      Mon Jan 30 02:13:29 2006
@@ -26,7 +26,8 @@
 antiright_file_to_bitmap(char *filename)
 {
   Pixmap bitmap;
-  int width, height, x_hot, y_hot;
+  unsigned int width, height;
+  int x_hot, y_hot;
   XReadBitmapFile(antiright.display, antiright.root_window, filename, 
                  &width, &height, &bitmap, &x_hot, &y_hot);
   return(bitmap);
Index: antiright/src/arshell/arshell.c
diff -u antiright/src/arshell/arshell.c:1.17 
antiright/src/arshell/arshell.c:1.18
--- antiright/src/arshell/arshell.c:1.17        Sun Jul 31 16:19:50 2005
+++ antiright/src/arshell/arshell.c     Mon Jan 30 02:13:29 2006
@@ -95,6 +95,7 @@
 void
 arshell_setup_work_row ()
 {
+       Widget menu;
   ARCLARG;
   antiright_set (XmNmarginHeight, 0);
   antiright_set (XmNmarginWidth, 0);
@@ -103,7 +104,6 @@
   /* The following implements a popup menu on the ACE desktop.  */
   /*  if ( arshell_override_is_set() && arshell.flags.lowered ) */
 /*     { */
-  Widget menu;
   menu = antiright_popup_menu (arshell.gui.widgets.row);
   antiright_button (menu, "Terminal", antiright_system_cb, "ACE Terminal");
   antiright_separator (menu);
Index: antiright/src/arshell/search.c
diff -u antiright/src/arshell/search.c:1.8 antiright/src/arshell/search.c:1.9
--- antiright/src/arshell/search.c:1.8  Sun Jul 31 16:19:50 2005
+++ antiright/src/arshell/search.c      Mon Jan 30 02:13:29 2006
@@ -163,21 +163,23 @@
     {
       /* Convert the text buffer and search string to lower case so
          that case is not a factor in the search.  */
-      int counter = 0;
+      unsigned int counter;
       char *lowered_buffer;
-      while (search_string[counter] != '\0')
+
+      for(counter=0; search_string[counter] != '\0'; counter++)
        {
-         search_string[counter] = tolower (search_string[counter]);
-         counter++;
+               search_string[(unsigned int)counter] = 
+                       tolower ((int)search_string[(unsigned int)counter]);
        }
+
       backup_text = XmTextGetString (arshell.gui.widgets.work);
       lowered_buffer = XmTextGetString (arshell.gui.widgets.work);
-      counter = 0;
-      while (lowered_buffer[counter] != '\0')
+
+      for(counter=0; lowered_buffer[counter] != '\0'; counter++)
        {
-         lowered_buffer[counter] = tolower (lowered_buffer[counter]);
-         counter++;
+         lowered_buffer[counter] = tolower ((int)lowered_buffer[counter]);
        }
+
       XmTextSetString (arshell.gui.widgets.work, lowered_buffer);
     }
   client_data = NULL;
Index: antiright/src/arshell/textedit.h
diff -u antiright/src/arshell/textedit.h:1.12 
antiright/src/arshell/textedit.h:1.13
--- antiright/src/arshell/textedit.h:1.12       Sun Jul 31 16:19:50 2005
+++ antiright/src/arshell/textedit.h    Mon Jan 30 02:13:29 2006
@@ -26,8 +26,6 @@
 #define ARSHELL_MAX_STRLEN 255
 #endif /* ARSHELL_MAX_STRLEN  */
 
-//#include "search.h"
-
 struct arshell_search_replace_data_struct
 {
   Widget replace_toggle;
Index: antiright/src/arshell/update.c
diff -u antiright/src/arshell/update.c:1.9 antiright/src/arshell/update.c:1.10
--- antiright/src/arshell/update.c:1.9  Sun Jul 31 16:19:50 2005
+++ antiright/src/arshell/update.c      Mon Jan 30 02:13:29 2006
@@ -23,6 +23,53 @@
 #include "arshell.h"
 #include <time.h>
 
+/* Update the clock and biff label.  */
+void
+arshell_clockload(struct arshell_update_struct **iterator)
+{
+       char *clockload_label_string;
+       char *time_string;
+       time_t time_date;
+       double load[3];
+       char *mailfile;
+       struct stat mailfile_stat;
+       char *mail_string;
+
+       const char *maildir = "/var/mail";
+       const char *user=getenv("USER");
+       
+       asprintf (&mailfile, "%s/%s", maildir, user);
+       stat (mailfile, &mailfile_stat);
+       free (mailfile);
+
+       if (mailfile_stat.st_size > 0)
+       {
+               mail_string = "Mail";
+       }
+       else
+       {
+               mail_string = "";
+       }
+
+       getloadavg (load, 3);
+       (void) time (&time_date);
+       time_string = ctime (&time_date);
+       time_string[strlen (time_string) - 1] = ' ';
+       asprintf (&clockload_label_string, " %s %d%% %s", time_string,
+               (int) (load[1] * 100), mail_string);
+       antiright_label_string ((*iterator)->widget, clockload_label_string);
+       free (clockload_label_string);
+}
+void
+arshell_update_label(struct arshell_update_struct **iterator)
+{
+       char *input_string;
+       input_string = antiright_pipe_read ((*iterator)->command_string);
+       input_string[(strlen (input_string)) - 1] = '\0';
+       antiright_label_string ((*iterator)->widget, input_string);
+       free (input_string);
+}
+
 void
 arshell_update ()
 {
@@ -34,44 +81,11 @@
 
       if (iterator->widget == arshell.gui.clockload.clockload)
        {
-         char *clockload_label_string;
-         char *time_string;
-         time_t time_date;
-         double load[3];
-         char *user = getenv ("USER");
-         char *maildir = "/var/mail";
-         char *mailfile;
-         struct stat mailfile_stat;
-         char *mail_string;
-
-         asprintf (&mailfile, "%s/%s", maildir, user);
-         stat (mailfile, &mailfile_stat);
-         free (mailfile);
-
-         if (mailfile_stat.st_size > 0)
-           mail_string = "Mail";
-         else
-           mail_string = "";
-
-         getloadavg (load, 3);
-         (void) time (&time_date);
-         time_string = ctime (&time_date);
-         time_string[strlen (time_string) - 1] = ' ';
-         asprintf (&clockload_label_string, " %s %d%% %s", time_string,
-                   (int) (load[1] * 100), mail_string);
-         /* free(time_string);  */
-         antiright_label_string (iterator->widget, clockload_label_string);
-         free (clockload_label_string);
-
+           arshell_clockload(&iterator);
        }
       else if (XmIsLabel (iterator->widget))
        {
-
-         input_string = antiright_pipe_read (iterator->command_string);
-         input_string[strlen (input_string) - 1] = '\0';
-         antiright_label_string (iterator->widget, input_string);
-         free (input_string);
-
+               arshell_update_label(&iterator);
        }
       else if (XmIsScrollBar (iterator->widget))
        {
Index: antiright/yaclib/list.c
diff -u antiright/yaclib/list.c:1.1 antiright/yaclib/list.c:1.2
--- antiright/yaclib/list.c:1.1 Sun Jul  3 23:21:34 2005
+++ antiright/yaclib/list.c     Mon Jan 30 02:13:29 2006
@@ -1,6 +1,6 @@
 /*
        This file contains functions for lists.
-       $Id: list.c,v 1.1 2005/07/03 23:21:34 jefbed Exp $
+       $Id: list.c,v 1.2 2006/01/30 02:13:29 jefbed Exp $
 */
 #include <assert.h>
 #include <string.h>
@@ -281,8 +281,8 @@
 yacl_list 
 *yacl_list_remove(yacl_list *ths, const void *val, size_t val_size)
 {
-       L_SEEK_END(ths);
        yacl_list *tmp;
+       L_SEEK_END(ths);
        
        while(ths->prev!=NULL)
        {
@@ -309,9 +309,10 @@
 *yacl_list_remove_if(yacl_list *ths, yacl_binary_pred cmp, 
                     const void *cmp_param)
 {
-       L_SEEK_BEGIN(ths);
        yacl_list *tmp;
        
+       L_SEEK_BEGIN(ths);
+       
        while(ths->prev!=NULL)
        {
                if(cmp(ths->data, cmp_param)==0)
Index: antiright/yaclib/parse.c
diff -u antiright/yaclib/parse.c:1.3 antiright/yaclib/parse.c:1.4
--- antiright/yaclib/parse.c:1.3        Mon Nov 14 01:56:46 2005
+++ antiright/yaclib/parse.c    Mon Jan 30 02:13:29 2006
@@ -242,7 +242,6 @@
 #ifdef DEBUG
   puts(string);
 #endif /* DEBUG  */
-  //close(file);
   return(string);
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]