Changeset 1cf32e7d for message.c


Ignore:
Timestamp:
Mar 28, 2007, 9:32:11 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
b3a40c7
Parents:
3066d23 (diff), a387d12e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:
Merging the PAR branch back to trunk.

r20272@phanatique (orig r665):  nelhage | 2007-03-14 19:25:05 -0400
 Branching for the PAR module rewrite.
 r20274@phanatique (orig r667):  nelhage | 2007-03-16 00:45:19 -0400
 First phase of the module rewrite. Internals now (IMO) somewhat
 cleaner.
 
  r19586@phanatique:  nelhage | 2007-03-14 20:35:39 -0400
  First pass at a cleaned up perlwrap.pm
  
  * Using a new hook style
  * Modules loaded by BarnOwl::ModuleLoader (not yet written)
  
  reload is unimplemented for now. If possible, I'd like it to live
  elsewhere.
  
  r19587@phanatique:  nelhage | 2007-03-14 20:36:58 -0400
  Switching to the new underscore internal hook names.
  r19592@phanatique:  nelhage | 2007-03-16 00:34:00 -0400
  Actually switch to _receive_msg
  
  r19593@phanatique:  nelhage | 2007-03-16 00:34:27 -0400
  Some minor cleanup of perlwrap.pm. Shoving fake entries into @INC.
  
  r19594@phanatique:  nelhage | 2007-03-16 00:34:47 -0400
  First revision of ModuleLoader.
  
 
 r20281@phanatique (orig r669):  nelhage | 2007-03-17 14:48:02 -0400
  r20279@phanatique:  nelhage | 2007-03-17 14:46:56 -0400
  For reasons I don't claim to understand, using the old-style new was
  throwing odd errors about undefined functions.
  
 
 r20286@phanatique (orig r670):  nelhage | 2007-03-18 16:28:23 -0400
  r20282@phanatique:  nelhage | 2007-03-17 14:48:22 -0400
  Report more errors when something goes wrong
  
 
 r20287@phanatique (orig r671):  nelhage | 2007-03-18 16:28:31 -0400
  r20285@phanatique:  nelhage | 2007-03-18 16:28:18 -0400
  Adding the new M::Iified jabber module. There isn't a target to build
  the PAR yet.
 
 r20291@phanatique (orig r672):  nelhage | 2007-03-18 19:14:04 -0400
  r20290@phanatique:  nelhage | 2007-03-18 19:13:57 -0400
  Adding a Module::Install plugin for building barnowl plugins. It needs
  a lot of improvement.
 
 r20309@phanatique (orig r673):  nelhage | 2007-03-19 14:14:23 -0400
  r20301@phanatique:  nelhage | 2007-03-19 13:31:07 -0400
  Changing the dependency on the par target, so we don't rebuild unless
  we need to.
 
 r20310@phanatique (orig r674):  nelhage | 2007-03-19 14:14:33 -0400
  r20303@phanatique:  nelhage | 2007-03-19 13:32:25 -0400
  Modifying the makefile to build and install perl modules
 
 r20643@phanatique (orig r677):  nelhage | 2007-03-23 15:09:45 -0400
  r20640@phanatique:  nelhage | 2007-03-23 15:09:38 -0400
  Implement loading of unpacked modules, and module reloading.
 
 r20645@phanatique (orig r678):  nelhage | 2007-03-23 15:11:05 -0400
  r20644@phanatique:  nelhage | 2007-03-23 15:10:57 -0400
  Tighten up the reloaded regex a little.
  
 
 r20649@phanatique (orig r679):  nelhage | 2007-03-23 16:18:44 -0400
  r20648@phanatique:  nelhage | 2007-03-23 16:18:25 -0400
  Correctly install modules on a clean install.
  
 
 r20655@phanatique (orig r680):  nelhage | 2007-03-25 12:53:07 -0400
  r20650@phanatique:  nelhage | 2007-03-23 17:01:20 -0400
  Still not sure why old-style new seems to be eiting us so much...
  
 
 r20656@phanatique (orig r681):  nelhage | 2007-03-25 12:53:11 -0400
  r20653@phanatique:  nelhage | 2007-03-25 12:52:38 -0400
  Let's not segfault if the user asks for a nonexistant style in .owl/startup
  
 
 r20657@phanatique (orig r682):  nelhage | 2007-03-25 12:53:16 -0400
  r20654@phanatique:  nelhage | 2007-03-25 12:52:59 -0400
  That line doesn't need to be there twice -- probably a mismerge
  
 
 r20706@phanatique (orig r683):  nelhage | 2007-03-26 21:04:43 -0400
  r20704@phanatique:  nelhage | 2007-03-26 20:00:24 -0400
  We don't need two package lines..
  
 
 r20707@phanatique (orig r684):  nelhage | 2007-03-26 21:04:54 -0400
  r20705@phanatique:  nelhage | 2007-03-26 21:04:37 -0400
  Getting rid of indirect object syntax new calls. Quoting perlobj:
  
  > But what if there are no arguments? In that case, Perl must guess what
  > you want. Even worse, it must make that guess *at compile time*. Usually
  > Perl gets it right, but when it doesn't you get a function call compiled
  > as a method, or vice versa. This can introduce subtle bugs that are hard
  > to detect.
  > 
  > For example, a call to a method "new" in indirect notation -- as C++
  > programmers are wont to make -- can be miscompiled into a subroutine
  > call if there's already a "new" function in scope. You'd end up calling
  > the current package's "new" as a subroutine, rather than the desired
  > class's method. The compiler tries to cheat by remembering bareword
  > "require"s, but the grief when it messes up just isn't worth the years
  > of debugging it will take you to track down such subtle bugs.
      
 
 r20710@phanatique (orig r685):  nelhage | 2007-03-26 21:14:41 -0400
  r20708@phanatique:  nelhage | 2007-03-26 21:11:34 -0400
  Adding a reload-modules command
  
 
 r20711@phanatique (orig r686):  nelhage | 2007-03-26 21:14:49 -0400
  r20709@phanatique:  nelhage | 2007-03-26 21:14:31 -0400
  Moving Net::Jabber into Jabber.par
 
 r20714@phanatique (orig r687):  nelhage | 2007-03-26 21:18:13 -0400
  r20713@phanatique:  nelhage | 2007-03-26 21:17:59 -0400
  Don't install .svn dirs
  
 
 r20720@phanatique (orig r688):  nelhage | 2007-03-27 22:04:10 -0400
  r20719@phanatique:  nelhage | 2007-03-27 22:04:03 -0400
  Implementing an LRU cache of the message list fmtexts. This reduces
  memory usage by roughly 1MB/kilo-zephyrs in steady state.
 

 r20272@phanatique (orig r665):  nelhage | 2007-03-14 19:25:05 -0400
 Branching for the PAR module rewrite.
 r20274@phanatique (orig r667):  nelhage | 2007-03-16 00:45:19 -0400
 First phase of the module rewrite. Internals now (IMO) somewhat
 cleaner.
 
  r19586@phanatique:  nelhage | 2007-03-14 20:35:39 -0400
  First pass at a cleaned up perlwrap.pm
  
  * Using a new hook style
  * Modules loaded by BarnOwl::ModuleLoader (not yet written)
  
  reload is unimplemented for now. If possible, I'd like it to live
  elsewhere.
  
  r19587@phanatique:  nelhage | 2007-03-14 20:36:58 -0400
  Switching to the new underscore internal hook names.
  r19592@phanatique:  nelhage | 2007-03-16 00:34:00 -0400
  Actually switch to _receive_msg
  
  r19593@phanatique:  nelhage | 2007-03-16 00:34:27 -0400
  Some minor cleanup of perlwrap.pm. Shoving fake entries into @INC.
  
  r19594@phanatique:  nelhage | 2007-03-16 00:34:47 -0400
  First revision of ModuleLoader.
  
 
 r20281@phanatique (orig r669):  nelhage | 2007-03-17 14:48:02 -0400
  r20279@phanatique:  nelhage | 2007-03-17 14:46:56 -0400
  For reasons I don't claim to understand, using the old-style new was
  throwing odd errors about undefined functions.
  
 
 r20286@phanatique (orig r670):  nelhage | 2007-03-18 16:28:23 -0400
  r20282@phanatique:  nelhage | 2007-03-17 14:48:22 -0400
  Report more errors when something goes wrong
  
 
 r20287@phanatique (orig r671):  nelhage | 2007-03-18 16:28:31 -0400
  r20285@phanatique:  nelhage | 2007-03-18 16:28:18 -0400
  Adding the new M::Iified jabber module. There isn't a target to build
  the PAR yet.
 
 r20291@phanatique (orig r672):  nelhage | 2007-03-18 19:14:04 -0400
  r20290@phanatique:  nelhage | 2007-03-18 19:13:57 -0400
  Adding a Module::Install plugin for building barnowl plugins. It needs
  a lot of improvement.
 
 r20309@phanatique (orig r673):  nelhage | 2007-03-19 14:14:23 -0400
  r20301@phanatique:  nelhage | 2007-03-19 13:31:07 -0400
  Changing the dependency on the par target, so we don't rebuild unless
  we need to.
 
 r20310@phanatique (orig r674):  nelhage | 2007-03-19 14:14:33 -0400
  r20303@phanatique:  nelhage | 2007-03-19 13:32:25 -0400
  Modifying the makefile to build and install perl modules
 
 r20643@phanatique (orig r677):  nelhage | 2007-03-23 15:09:45 -0400
  r20640@phanatique:  nelhage | 2007-03-23 15:09:38 -0400
  Implement loading of unpacked modules, and module reloading.
 
 r20645@phanatique (orig r678):  nelhage | 2007-03-23 15:11:05 -0400
  r20644@phanatique:  nelhage | 2007-03-23 15:10:57 -0400
  Tighten up the reloaded regex a little.
  
 
 r20649@phanatique (orig r679):  nelhage | 2007-03-23 16:18:44 -0400
  r20648@phanatique:  nelhage | 2007-03-23 16:18:25 -0400
  Correctly install modules on a clean install.
  
 
 r20655@phanatique (orig r680):  nelhage | 2007-03-25 12:53:07 -0400
  r20650@phanatique:  nelhage | 2007-03-23 17:01:20 -0400
  Still not sure why old-style new seems to be eiting us so much...
  
 
 r20656@phanatique (orig r681):  nelhage | 2007-03-25 12:53:11 -0400
  r20653@phanatique:  nelhage | 2007-03-25 12:52:38 -0400
  Let's not segfault if the user asks for a nonexistant style in .owl/startup
  
 
 r20657@phanatique (orig r682):  nelhage | 2007-03-25 12:53:16 -0400
  r20654@phanatique:  nelhage | 2007-03-25 12:52:59 -0400
  That line doesn't need to be there twice -- probably a mismerge
  
 
 r20706@phanatique (orig r683):  nelhage | 2007-03-26 21:04:43 -0400
  r20704@phanatique:  nelhage | 2007-03-26 20:00:24 -0400
  We don't need two package lines..
  
 
 r20707@phanatique (orig r684):  nelhage | 2007-03-26 21:04:54 -0400
  r20705@phanatique:  nelhage | 2007-03-26 21:04:37 -0400
  Getting rid of indirect object syntax new calls. Quoting perlobj:
  
  > But what if there are no arguments? In that case, Perl must guess what
  > you want. Even worse, it must make that guess *at compile time*. Usually
  > Perl gets it right, but when it doesn't you get a function call compiled
  > as a method, or vice versa. This can introduce subtle bugs that are hard
  > to detect.
  > 
  > For example, a call to a method "new" in indirect notation -- as C++
  > programmers are wont to make -- can be miscompiled into a subroutine
  > call if there's already a "new" function in scope. You'd end up calling
  > the current package's "new" as a subroutine, rather than the desired
  > class's method. The compiler tries to cheat by remembering bareword
  > "require"s, but the grief when it messes up just isn't worth the years
  > of debugging it will take you to track down such subtle bugs.
      
 
 r20710@phanatique (orig r685):  nelhage | 2007-03-26 21:14:41 -0400
  r20708@phanatique:  nelhage | 2007-03-26 21:11:34 -0400
  Adding a reload-modules command
  
 
 r20711@phanatique (orig r686):  nelhage | 2007-03-26 21:14:49 -0400
  r20709@phanatique:  nelhage | 2007-03-26 21:14:31 -0400
  Moving Net::Jabber into Jabber.par
 
 r20714@phanatique (orig r687):  nelhage | 2007-03-26 21:18:13 -0400
  r20713@phanatique:  nelhage | 2007-03-26 21:17:59 -0400
  Don't install .svn dirs
  
 
 r20720@phanatique (orig r688):  nelhage | 2007-03-27 22:04:10 -0400
  r20719@phanatique:  nelhage | 2007-03-27 22:04:03 -0400
  Implementing an LRU cache of the message list fmtexts. This reduces
  memory usage by roughly 1MB/kilo-zephyrs in steady state.
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • message.c

    r963542b ra387d12e  
    1313static const char fileIdent[] = "$Id$";
    1414
     15static owl_fmtext_cache fmtext_cache[OWL_FMTEXT_CACHE_SIZE];
     16static owl_fmtext_cache * fmtext_cache_next = fmtext_cache;
     17
     18void owl_message_init_fmtext_cache ()
     19{
     20    int i;
     21    for(i = 0; i < OWL_FMTEXT_CACHE_SIZE; i++) {
     22        owl_fmtext_init_null(&(fmtext_cache[i].fmtext));
     23        fmtext_cache[i].message = NULL;
     24    }
     25}
     26
     27owl_fmtext_cache * owl_message_next_fmtext() /*noproto*/
     28{
     29    if(fmtext_cache_next->message != NULL) {
     30        owl_message_invalidate_format(fmtext_cache_next->message);
     31    }
     32    owl_fmtext_cache * f = fmtext_cache_next;
     33    fmtext_cache_next++;
     34    if(fmtext_cache_next - fmtext_cache == OWL_FMTEXT_CACHE_SIZE)
     35        fmtext_cache_next = fmtext_cache;
     36    return f;
     37}
     38
    1539void owl_message_init(owl_message *m)
    1640{
     
    1943  m->delete=0;
    2044  m->zwriteline=NULL;
    21   m->invalid_format=1;
    2245
    2346  owl_message_set_hostname(m, "");
     
    2952  m->timestr[strlen(m->timestr)-1]='\0';
    3053
    31   /* initialize the fmtext */
    32   owl_fmtext_init_null(&(m->fmtext));
     54  m->fmtext = NULL;
    3355}
    3456
     
    106128void owl_message_invalidate_format(owl_message *m)
    107129{
    108   m->invalid_format=1;
     130  if(m->fmtext) {
     131    m->fmtext->message = NULL;
     132    owl_fmtext_clear(&(m->fmtext->fmtext));
     133    m->fmtext=NULL;
     134  }
    109135}
    110136
     
    112138{
    113139  owl_message_format(m);
    114   return(&(m->fmtext));
     140  return(&(m->fmtext->fmtext));
    115141}
    116142
     
    120146  owl_view *v;
    121147
    122   if (m->invalid_format) {
     148  if (!m->fmtext) {
     149    m->fmtext = owl_message_next_fmtext();
     150    m->fmtext->message = m;
    123151    /* for now we assume there's just the one view and use that style */
    124152    v=owl_global_get_current_view(&g);
    125153    s=owl_view_get_style(v);
    126154
    127     owl_fmtext_free(&(m->fmtext));
    128     owl_fmtext_init_null(&(m->fmtext));
    129     owl_style_get_formattext(s, &(m->fmtext), m);
    130     m->invalid_format=0;
     155    owl_style_get_formattext(s, &(m->fmtext->fmtext), m);
    131156  }
    132157}
     
    392417char *owl_message_get_text(owl_message *m)
    393418{
    394   return(owl_fmtext_get_text(&(m->fmtext)));
     419  return(owl_fmtext_get_text(&(m->fmtext->fmtext)));
    395420}
    396421
     
    437462  if (m == NULL) return(0);
    438463  owl_message_format(m);
    439   return(owl_fmtext_num_lines(&(m->fmtext)));
     464  return(owl_fmtext_num_lines(&(m->fmtext->fmtext)));
    440465}
    441466
     
    504529  owl_fmtext_init_null(&b);
    505530 
    506   owl_fmtext_truncate_lines(&(m->fmtext), aline, bline-aline+1, &a);
     531  owl_fmtext_truncate_lines(&(m->fmtext->fmtext), aline, bline-aline+1, &a);
    507532  owl_fmtext_truncate_cols(&a, acol, bcol, &b);
    508533  if (fgcolor!=OWL_COLOR_DEFAULT) {
     
    698723  owl_message_format(m); /* is this necessary? */
    699724 
    700   return (owl_fmtext_search(&(m->fmtext), string));
     725  return (owl_fmtext_search(&(m->fmtext->fmtext), string));
    701726}
    702727
     
    9891014  owl_list_free_simple(&(m->attributes));
    9901015 
    991   owl_fmtext_free(&(m->fmtext));
    992 }
     1016  owl_message_invalidate_format(m);
     1017}
Note: See TracChangeset for help on using the changeset viewer.