Changeset c93b8b5 for fmtext.c


Ignore:
Timestamp:
Jul 31, 2010, 7:11:42 PM (11 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
2b83ad6
Parents:
e0e0e5a
git-author:
David Benjamin <davidben@mit.edu> (07/25/10 17:51:14)
git-committer:
David Benjamin <davidben@mit.edu> (07/31/10 19:11:42)
Message:
Consider format characters in owl_fmtext_num_lines

This fixes the second failure in the owl_fmtext test.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    re0e0e5a rc93b8b5  
    503503{
    504504  int lines, i;
    505 
    506   if (f->textlen==0) return(0);
    507  
     505  char *lastbreak, *p;
     506
    508507  lines=0;
     508  lastbreak = f->textbuff;
    509509  for (i=0; i<f->textlen; i++) {
    510     if (f->textbuff[i]=='\n') lines++;
    511   }
    512 
    513   /* if the last char wasn't a \n there's one more line */
    514   if (f->textbuff[i-1]!='\n') lines++;
     510    if (f->textbuff[i]=='\n') {
     511      lastbreak = f->textbuff + i;
     512      lines++;
     513    }
     514  }
     515
     516  /* Check if there's a trailing line; formatting characters don't count. */
     517  for (p = g_utf8_next_char(lastbreak);
     518       p < f->textbuff + f->textlen;
     519       p = g_utf8_next_char(p)) {
     520    if (!owl_fmtext_is_format_char(g_utf8_get_char(p))) {
     521      lines++;
     522      break;
     523    }
     524  }
    515525
    516526  return(lines);
Note: See TracChangeset for help on using the changeset viewer.