Changeset 1cf32e7d for fmtext.c


Ignore:
Timestamp:
Mar 28, 2007, 9:32:11 PM (17 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, 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
  • fmtext.c

    r801b7ac ra387d12e  
    99{
    1010  f->textlen=0;
    11   f->textbuff=owl_strdup("");
     11  f->bufflen=5;
     12  f->textbuff=owl_malloc(5);
    1213  f->fmbuff=owl_malloc(5);
    1314  f->fgcolorbuff=owl_malloc(5);
    1415  f->bgcolorbuff=owl_malloc(5);
     16  f->textbuff[0]=0;
    1517  f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE;
    1618  f->fgcolorbuff[0]=OWL_COLOR_DEFAULT;
     
    1820}
    1921
     22/* Clear the data from an fmtext, but don't deallocate memory. This
     23   fmtext can then be appended to again. */
     24void owl_fmtext_clear(owl_fmtext *f)
     25{
     26    f->textlen = 0;
     27    f->textbuff[0] = 0;
     28    f->fmbuff[0]=OWL_FMTEXT_ATTR_NONE;
     29    f->fgcolorbuff[0]=OWL_COLOR_DEFAULT;
     30    f->bgcolorbuff[0]=OWL_COLOR_DEFAULT;
     31}
     32
    2033/* Internal function.  Set the attribute 'attr' from index 'first' to
    2134 * index 'last'
     
    5972}
    6073
     74void _owl_fmtext_realloc(owl_fmtext *f, int newlen) /*noproto*/
     75{
     76    if(newlen + 1 > f->bufflen) {
     77      f->textbuff=owl_realloc(f->textbuff, newlen+1);
     78      f->fmbuff=owl_realloc(f->fmbuff, newlen+1);
     79      f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+1);
     80      f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+1);
     81      f->bufflen = newlen+1;
     82  }
     83}
     84
    6185/* append text to the end of 'f' with attribute 'attr' and color
    6286 * 'color'
     
    6589{
    6690  int newlen;
    67 
    6891  newlen=strlen(f->textbuff)+strlen(text);
    69   f->textbuff=owl_realloc(f->textbuff, newlen+2);
    70   f->fmbuff=owl_realloc(f->fmbuff, newlen+2);
    71   f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+2);
    72   f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+2);
    73 
     92  _owl_fmtext_realloc(f, newlen);
     93 
    7494  strcat(f->textbuff, text);
    7595  _owl_fmtext_set_attr(f, attr, f->textlen, newlen);
     
    154174
    155175  newlen=strlen(f->textbuff)+(stop-start+1);
    156   f->textbuff=owl_realloc(f->textbuff, newlen+1);
    157   f->fmbuff=owl_realloc(f->fmbuff, newlen+1);
    158   f->fgcolorbuff=owl_realloc(f->fgcolorbuff, newlen+1);
    159   f->bgcolorbuff=owl_realloc(f->bgcolorbuff, newlen+1);
     176  _owl_fmtext_realloc(f, newlen);
    160177
    161178  strncat(f->textbuff, in->textbuff+start, stop-start+1);
Note: See TracChangeset for help on using the changeset viewer.