Index: ChangeLog
===================================================================
--- ChangeLog	(revision dafd91999af73afdd277cca203e3acde49ab0dd0)
+++ ChangeLog	(revision b2b077340663beb07545909f5ec5e8c55b61911d)
@@ -4,4 +4,5 @@
 	Don't ring the terminal bell on mail messages.
 	Nuke <FONT>
+	Make the build work a little better on OSX
 	
 2.0.2
Index: aim.c
===================================================================
--- aim.c	(revision d559df97bd8fe22559fdadb8b64e5166521fa4b2)
+++ aim.c	(revision b2b077340663beb07545909f5ec5e8c55b61911d)
@@ -295,5 +295,5 @@
 
   aim_send_login(sess, fr->conn, priv->screenname, priv->password, &info, key);
-
+  
   return 1;
 }
@@ -466,5 +466,5 @@
   if (!priv->screenname || !priv->password) {
     /* printf("need SN and password\n"); */
-    return -1;
+    return(-1);
   }
 
@@ -479,6 +479,5 @@
     }
     aim_conn_kill(sess, &authconn);
-
-    return (-1);
+    return(-1);
   }
 
@@ -492,5 +491,4 @@
 
   /* printf("login request sent\n"); */
-
   return(0);
 }
Index: buddylist.c
===================================================================
--- buddylist.c	(revision d559df97bd8fe22559fdadb8b64e5166521fa4b2)
+++ buddylist.c	(revision b2b077340663beb07545909f5ec5e8c55b61911d)
@@ -37,6 +37,4 @@
   }
 }
-    
-
 
 /* Deal with an "offgoing" message.  This means recognizing the user
@@ -72,4 +70,5 @@
 }
 
+/* return the number of logged in buddies */
 int owl_buddylist_get_size(owl_buddylist *b)
 {
@@ -77,4 +76,5 @@
 }
 
+/* get buddy number 'n' */
 char *owl_buddylist_get_buddy(owl_buddylist *b, int n)
 {
@@ -82,4 +82,5 @@
 }
 
+/* remove all buddies from the list */
 void owl_buddylist_clear(owl_buddylist *b) {
   owl_list_free_all(&(b->buddies), owl_free);
Index: fmtext.c
===================================================================
--- fmtext.c	(revision d559df97bd8fe22559fdadb8b64e5166521fa4b2)
+++ fmtext.c	(revision b2b077340663beb07545909f5ec5e8c55b61911d)
@@ -5,4 +5,5 @@
 static const char fileIdent[] = "$Id$";
 
+/* initialize an fmtext with no data */
 void owl_fmtext_init_null(owl_fmtext *f)
 {
@@ -15,5 +16,7 @@
 }
 
-
+/* Internal function.  Set the attribute 'attr' from index 'first' to
+ * index 'last'
+ */
 void _owl_fmtext_set_attr(owl_fmtext *f, int attr, int first, int last)
 {
@@ -24,4 +27,7 @@
 }
 
+/* Internal function.  Add the attribute 'attr' to the existing
+ * attributes from index 'first' to index 'last'
+ */
 void _owl_fmtext_add_attr(owl_fmtext *f, int attr, int first, int last)
 {
@@ -32,4 +38,7 @@
 }
 
+/* Internal function.  Set the color to be 'color' from index 'first'
+ * to index 'last
+ */
 void _owl_fmtext_set_color(owl_fmtext *f, int color, int first, int last)
 {
@@ -40,5 +49,7 @@
 }
 
-
+/* append text to the end of 'f' with attribute 'attr' and color
+ * 'color'
+ */
 void owl_fmtext_append_attr(owl_fmtext *f, char *text, int attr, int color)
 {
@@ -56,5 +67,5 @@
 }
 
-
+/* Append normal, uncolored text 'text' to 'f' */
 void owl_fmtext_append_normal(owl_fmtext *f, char *text)
 {
@@ -62,4 +73,5 @@
 }
 
+/* Append normal text 'text' to 'f' with color 'color' */
 void owl_fmtext_append_normal_color(owl_fmtext *f, char *text, int color)
 {
@@ -67,5 +79,5 @@
 }
 
-
+/* Append bold text 'text' to 'f' */
 void owl_fmtext_append_bold(owl_fmtext *f, char *text)
 {
@@ -73,5 +85,5 @@
 }
 
-
+/* Append reverse video text 'text' to 'f' */
 void owl_fmtext_append_reverse(owl_fmtext *f, char *text)
 {
@@ -79,5 +91,5 @@
 }
 
-
+/* Append reversed and bold, uncolored text 'text' to 'f' */
 void owl_fmtext_append_reversebold(owl_fmtext *f, char *text)
 {
@@ -85,5 +97,5 @@
 }
 
-
+/* Add the attribute 'attr' to all text in 'f' */
 void owl_fmtext_addattr(owl_fmtext *f, int attr)
 {
@@ -97,4 +109,7 @@
 }
 
+/* Anywhere the color is NOT ALREDY SET, set the color to 'color'.
+ * Other colors are left unchanged
+ */
 void owl_fmtext_colorize(owl_fmtext *f, int color)
 {
@@ -108,5 +123,7 @@
 }
 
-
+/* Append the text 'text' to 'f' and interpret the zephyr style
+ * formatting syntax to set appropriate attributes.
+ */
 void owl_fmtext_append_ztext(owl_fmtext *f, char *text)
 {
@@ -293,9 +310,9 @@
     }
   }
-
-}
-
-/* This is used internally to fmtext.  Use owl_fmtext_append_fmtext()
- * (no initial underscore) externally */
+}
+
+/* Internal function.  Append text from 'in' between index 'start' and
+ * 'stop' to the end of 'f'
+ */
 void _owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in, int start, int stop)
 {
@@ -316,4 +333,5 @@
 }
 
+/* append fmtext 'in' to 'f' */
 void owl_fmtext_append_fmtext(owl_fmtext *f, owl_fmtext *in)
 {
@@ -322,4 +340,5 @@
 }
 
+/* Append 'nspaces' number of spaces to the end of 'f' */
 void owl_fmtext_append_spaces(owl_fmtext *f, int nspaces)
 {
@@ -358,12 +377,15 @@
 }
 
-
-/* caller is responsible for freeing */
+/* Return a plain version of the fmtext.  Caller is responsible for
+ * freeing the return
+ */
 char *owl_fmtext_print_plain(owl_fmtext *f)
 {
-  return owl_strdup(f->textbuff);
-}
-
-
+  return(owl_strdup(f->textbuff));
+}
+
+/* add the formatted text to the curses window 'w'.  The window 'w'
+ * must already be initiatlized with curses
+ */
 void owl_fmtext_curs_waddstr(owl_fmtext *f, WINDOW *w)
 {
@@ -422,9 +444,9 @@
 
 
+/* start with line 'aline' (where the first line is 0) and print
+ * 'lines' number of lines into 'out'
+ */
 int owl_fmtext_truncate_lines(owl_fmtext *in, int aline, int lines, owl_fmtext *out)
 {
-  /* start with line aline (where the first line is 0) and print
-   *  'lines' lines
-   */
   char *ptr1, *ptr2;
   int i, offset;
@@ -445,8 +467,8 @@
 
   for (i=0; i<lines; i++) {
-    ptr2=strchr(ptr1, '\n');
     offset=ptr1-in->textbuff;
+    ptr2=strchr(ptr1, '\n'); /* this is a valgrind suspicious line */
     if (!ptr2) {
-      _owl_fmtext_append_fmtext(out, in, offset, in->textlen-1);
+      _owl_fmtext_append_fmtext(out, in, offset, (in->textlen)-1);
       return(-1);
     }
@@ -457,7 +479,9 @@
 }
 
-  
-/* the first column is column 0 */
-/* the message is expected to end in a new line for now */
+/* Truncate the message so that each line begins at column 'acol' and
+ * ends at 'bcol' or sooner.  The first column is number 0.  The new
+ * message is placed in 'out'.  The message is * expected to end in a
+ * new line for now
+ */
 void owl_fmtext_truncate_cols(owl_fmtext *in, int acol, int bcol, owl_fmtext *out)
 {
@@ -504,5 +528,5 @@
 }
 
-
+/* Return the number of lines in 'f' */
 int owl_fmtext_num_lines(owl_fmtext *f)
 {
@@ -522,5 +546,4 @@
 }
 
-
 char *owl_fmtext_get_text(owl_fmtext *f)
 {
@@ -536,4 +559,5 @@
 }
 
+/* Free all memory allocated by the object */
 void owl_fmtext_free(owl_fmtext *f)
 {
@@ -543,11 +567,18 @@
 }
 
-
+/* Make a copy of the fmtext 'src' into 'dst' */
 void owl_fmtext_copy(owl_fmtext *dst, owl_fmtext *src)
 {
+  int mallocsize;
+
+  if (src->textlen==0) {
+    mallocsize=5;
+  } else {
+    mallocsize=src->textlen+2;
+  }
   dst->textlen=src->textlen;
-  dst->textbuff=owl_malloc(src->textlen+5);
-  dst->fmbuff=owl_malloc(src->textlen+5);
-  dst->colorbuff=owl_malloc(src->textlen+5);
+  dst->textbuff=owl_malloc(mallocsize); /* valgrind suspcious line */
+  dst->fmbuff=owl_malloc(mallocsize);
+  dst->colorbuff=owl_malloc(mallocsize);
   memcpy(dst->textbuff, src->textbuff, src->textlen);
   memcpy(dst->fmbuff, src->fmbuff, src->textlen);
@@ -555,7 +586,6 @@
 }
 
-
 /* highlight all instance of "string".  Return the number of
- * instances found.  This is case insensitive.
+ * instances found.  This is a case insensitive search.
  */
 int owl_fmtext_search_and_highlight(owl_fmtext *f, char *string)
@@ -582,6 +612,6 @@
 }
 
-/* return 1 if the string is found, 0 if not.  This is case
- *  insensitive
+/* return 1 if the string is found, 0 if not.  This is a case
+ *  insensitive search.
  */
 int owl_fmtext_search(owl_fmtext *f, char *string)
Index: owl.c
===================================================================
--- owl.c	(revision dafd91999af73afdd277cca203e3acde49ab0dd0)
+++ owl.c	(revision b2b077340663beb07545909f5ec5e8c55b61911d)
@@ -26,4 +26,6 @@
 
 static const char fileIdent[] = "$Id$";
+
+owl_global g;
 
 int main(int argc, char **argv, char **env) {
Index: owl.h
===================================================================
--- owl.h	(revision dafd91999af73afdd277cca203e3acde49ab0dd0)
+++ owl.h	(revision b2b077340663beb07545909f5ec5e8c55b61911d)
@@ -422,5 +422,5 @@
 
 /* globals */
-owl_global g;
+extern owl_global g;
 
 #include "owl_prototypes.h"
Index: popwin.c
===================================================================
--- popwin.c	(revision 1aee7d914de75510e7cf09c452bad63b2dad2166)
+++ popwin.c	(revision b2b077340663beb07545909f5ec5e8c55b61911d)
@@ -3,5 +3,6 @@
 static const char fileIdent[] = "$Id$";
 
-int owl_popwin_init(owl_popwin *pw) {
+int owl_popwin_init(owl_popwin *pw)
+{
   pw->active=0;
   pw->needsfirstrefresh=0;
@@ -11,5 +12,6 @@
 }
 
-int owl_popwin_up(owl_popwin *pw) {
+int owl_popwin_up(owl_popwin *pw)
+{
   int glines, gcols, startcol, startline;
 
@@ -50,5 +52,6 @@
 }
 
-int owl_popwin_display_text(owl_popwin *pw, char *text) {
+int owl_popwin_display_text(owl_popwin *pw, char *text)
+{
   waddstr(pw->popwin, text);
   wnoutrefresh(pw->popwin);
@@ -59,5 +62,6 @@
 }	      
 
-int owl_popwin_close(owl_popwin *pw) {
+int owl_popwin_close(owl_popwin *pw)
+{
   delwin(pw->popwin);
   delwin(pw->borderwin);
@@ -69,11 +73,13 @@
 }
 
-int owl_popwin_is_active(owl_popwin *pw) {
+int owl_popwin_is_active(owl_popwin *pw)
+{
   if (pw->active==1) return(1);
   return(0);
 }
 
-int owl_popwin_refresh(owl_popwin *pw) {
-  /* this will refresh the border as well as the text area */
+/* this will refresh the border as well as the text area */
+int owl_popwin_refresh(owl_popwin *pw)
+{
   touchwin(pw->borderwin);
   touchwin(pw->popwin);
@@ -85,30 +91,37 @@
 }
 
-void owl_popwin_set_handler(owl_popwin *pw, void (*func)(int ch)) {
+void owl_popwin_set_handler(owl_popwin *pw, void (*func)(int ch))
+{
   pw->handler=func;
 }
 
-void owl_popwin_unset_handler(owl_popwin *pw) {
+void owl_popwin_unset_handler(owl_popwin *pw)
+{
   pw->handler=NULL;
 }
 
-WINDOW *owl_popwin_get_curswin(owl_popwin *pw) {
+WINDOW *owl_popwin_get_curswin(owl_popwin *pw)
+{
   return(pw->popwin);
 }
 
-int owl_popwin_get_lines(owl_popwin *pw) {
+int owl_popwin_get_lines(owl_popwin *pw)
+{
   return(pw->lines-2);
 }
 
-int owl_popwin_get_cols(owl_popwin *pw) {
+int owl_popwin_get_cols(owl_popwin *pw)
+{
   return(pw->cols-2);
 }
 
-int owl_popwin_needs_first_refresh(owl_popwin *pw) {
+int owl_popwin_needs_first_refresh(owl_popwin *pw)
+{
   if (pw->needsfirstrefresh) return(1);
   return(0);
 }
 
-void owl_popwin_no_needs_first_refresh(owl_popwin *pw) {
+void owl_popwin_no_needs_first_refresh(owl_popwin *pw)
+{
   pw->needsfirstrefresh=0;
 }
Index: tester.c
===================================================================
--- tester.c	(revision e1c4636a284110b07d889065fbb569709fa701d9)
+++ tester.c	(revision b2b077340663beb07545909f5ec5e8c55b61911d)
@@ -4,4 +4,6 @@
 
 static const char fileIdent[] = "$Id$";
+
+owl_global g;
 
 void screeninit() {
Index: util.c
===================================================================
--- util.c	(revision 378fa145d992195cad4c271818e9d091467c9b61)
+++ util.c	(revision b2b077340663beb07545909f5ec5e8c55b61911d)
@@ -3,5 +3,4 @@
 #include <string.h>
 #include <unistd.h>
-#include <malloc.h>
 #include <unistd.h>
 #include <ctype.h>
Index: viewwin.c
===================================================================
--- viewwin.c	(revision 3a2daac2dddd32e805373d81642d45a0943dd05c)
+++ viewwin.c	(revision b2b077340663beb07545909f5ec5e8c55b61911d)
@@ -6,9 +6,9 @@
 #define BOTTOM_OFFSET 1
 
-void owl_viewwin_init_text(owl_viewwin *v, WINDOW *win, int winlines, int wincols, char *text) {
-  /* initialize the viewwin e.
-   * 'win' is an already initialzed curses window that will be used by viewwin
-   */
-
+/* initialize the viewwin e.  'win' is an already initialzed curses
+ * window that will be used by viewwin
+ */
+void owl_viewwin_init_text(owl_viewwin *v, WINDOW *win, int winlines, int wincols, char *text)
+{
   owl_fmtext_init_null(&(v->fmtext));
   if (text) {
@@ -26,9 +26,9 @@
 }
 
-void owl_viewwin_init_fmtext(owl_viewwin *v, WINDOW *win, int winlines, int wincols, owl_fmtext *fmtext) {
-  /* initialize the viewwin e.
-   * 'win' is an already initialzed curses window that will be used by viewwin
-   */
-
+/* initialize the viewwin e.  'win' is an already initialzed curses
+ * window that will be used by viewwin
+ */
+void owl_viewwin_init_fmtext(owl_viewwin *v, WINDOW *win, int winlines, int wincols, owl_fmtext *fmtext)
+{
   owl_fmtext_copy(&(v->fmtext), fmtext);
   v->textlines=owl_fmtext_num_lines(&(v->fmtext));
@@ -40,5 +40,6 @@
 }
 
-void owl_viewwin_set_curswin(owl_viewwin *v, WINDOW *w, int winlines, int wincols) {
+void owl_viewwin_set_curswin(owl_viewwin *v, WINDOW *w, int winlines, int wincols)
+{
   v->curswin=w;
   v->winlines=winlines;
@@ -46,8 +47,8 @@
 }
 
-void owl_viewwin_redisplay(owl_viewwin *v, int update) {
-  /* regenerate text on the curses window. */
-  /* if update == 1 then do a doupdate() */
-
+/* regenerate text on the curses window. */
+/* if update == 1 then do a doupdate() */
+void owl_viewwin_redisplay(owl_viewwin *v, int update)
+{
   owl_fmtext fm1, fm2;
   
@@ -82,5 +83,6 @@
 }
 
-void owl_viewwin_pagedown(owl_viewwin *v) {
+void owl_viewwin_pagedown(owl_viewwin *v)
+{
   v->topline+=v->winlines - BOTTOM_OFFSET;
   if ( (v->topline+v->winlines-BOTTOM_OFFSET) > v->textlines) {
@@ -89,5 +91,6 @@
 }
 
-void owl_viewwin_linedown(owl_viewwin *v) {
+void owl_viewwin_linedown(owl_viewwin *v)
+{
   v->topline++;
   if ( (v->topline+v->winlines-BOTTOM_OFFSET) > v->textlines) {
@@ -96,33 +99,40 @@
 }
 
-void owl_viewwin_pageup(owl_viewwin *v) {
+void owl_viewwin_pageup(owl_viewwin *v)
+{
   v->topline-=v->winlines;
   if (v->topline<0) v->topline=0;
 }
 
-void owl_viewwin_lineup(owl_viewwin *v) {
+void owl_viewwin_lineup(owl_viewwin *v)
+{
   v->topline--;
   if (v->topline<0) v->topline=0;
 }
 
-void owl_viewwin_right(owl_viewwin *v, int n) {
+void owl_viewwin_right(owl_viewwin *v, int n)
+{
   v->rightshift+=n;
 }
 
-void owl_viewwin_left(owl_viewwin *v, int n) {
+void owl_viewwin_left(owl_viewwin *v, int n)
+{
   v->rightshift-=n;
   if (v->rightshift<0) v->rightshift=0;
 }
 
-void owl_viewwin_top(owl_viewwin *v) {
+void owl_viewwin_top(owl_viewwin *v)
+{
   v->topline=0;
   v->rightshift=0;
 }
 
-void owl_viewwin_bottom(owl_viewwin *v) {
+void owl_viewwin_bottom(owl_viewwin *v)
+{
   v->topline = v->textlines - v->winlines + BOTTOM_OFFSET;
 }
 
-void owl_viewwin_free(owl_viewwin *v) {
+void owl_viewwin_free(owl_viewwin *v)
+{
   owl_fmtext_free(&(v->fmtext));
 }
