Changeset dd6af02


Ignore:
Timestamp:
Sep 28, 2009, 12:56:20 PM (12 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
fb2f9ab
Parents:
7b4d90e
Message:
Revert 7b4d90e... and just fix #51

owl_fmtext_truncate_cols once again expects that fmtext ends in a
newline.

Revert documentation changes and remove test that now breaks while
testing out-of-spec text.

In owl_viewwin_init_fmtext, check that fmtext ends in a newline and
append one if necessary.
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    r7b4d90e rdd6af02  
    418418/* Truncate the message so that each line begins at column 'acol' and
    419419 * ends at 'bcol' or sooner.  The first column is number 0.  The new
    420  * message is placed in 'out'.
     420 * message is placed in 'out'.  The message is expected to end in a
     421 * new line for now.
    421422 *
    422423 * NOTE: This needs to be modified to deal with backing up if we find
     
    442443    ptr_e=strchr(ptr_s, '\n');
    443444    if (!ptr_e) {
    444       /* set it to the NULL at the end of the string, to handle a line that is
    445        * not newline-terminated */
    446       ptr_e = last+1;
     445      /* but this shouldn't happen if we end in a \n */
     446      break;
    447447    }
    448448   
     
    499499      owl_fmtext_append_normal(out, "\n");
    500500    }
    501     /* Be careful if ptr_e is pointing to the NULL if we do not end with a
    502      * newline. We don't really need this check, but pointing ptr_s past the
    503      * NULL byte is just asking for problems later.
    504      */
    505     ptr_s = (ptr_e <= last) ? g_utf8_next_char(ptr_e) : ptr_e;
     501    ptr_s = g_utf8_next_char(ptr_e);
    506502  }
    507503}
  • tester.c

    r7b4d90e rdd6af02  
    1212int owl_filter_regtest(void);
    1313int owl_obarray_regtest(void);
    14 int owl_fmtext_regtest(void);
    1514
    1615int main(int argc, char **argv, char **env)
     
    3029  numfailures += owl_filter_regtest();
    3130  numfailures += owl_obarray_regtest();
    32   numfailures += owl_fmtext_regtest();
    3331  if (numfailures) {
    3432      fprintf(stderr, "# *** WARNING: %d failures total\n", numfailures);
     
    308306  return numfailed;
    309307}
    310 
    311 
    312 int owl_fmtext_regtest(void) {
    313   int numfailed = 0;
    314   char *p;
    315 
    316   owl_fmtext fm1, fm2;
    317 
    318   owl_fmtext_init_null(&fm1);
    319   owl_fmtext_init_null(&fm2);
    320 
    321   printf("# BEGIN testing owl_fmtext\n");
    322 
    323   /* Test truncate_cols:
    324    * - newline removal on long lines
    325    * - handle lines without trailing newlines
    326    * - don't kill short lines
    327    */
    328   owl_fmtext_append_normal(&fm1, "foo\n1234567890\n1234567890\nbaz");
    329   owl_fmtext_truncate_cols(&fm1, 1, 5, &fm2);
    330   p = owl_fmtext_print_plain(&fm2);
    331   FAIL_UNLESS("returned truncating columns worked properly", p && !strcmp(p, "oo\n2345623456az"));
    332   owl_free(p);
    333 
    334   owl_fmtext_free(&fm1);
    335   owl_fmtext_free(&fm2);
    336 
    337   printf("# END testing owl_fmtext (%d failures)\n", numfailed);
    338 
    339   return numfailed;
    340 }
  • viewwin.c

    r4083c49 rdd6af02  
    3535void owl_viewwin_init_fmtext(owl_viewwin *v, WINDOW *win, int winlines, int wincols, const owl_fmtext *fmtext)
    3636{
     37  char *text;
     38
    3739  owl_fmtext_copy(&(v->fmtext), fmtext);
     40  text = owl_fmtext_print_plain(fmtext);
     41  if (text[0] != '\0' && text[strlen(text) - 1] != '\n') {
     42      owl_fmtext_append_normal(&(v->fmtext), "\n");
     43  }
    3844  v->textlines=owl_fmtext_num_lines(&(v->fmtext));
    3945  v->topline=0;
Note: See TracChangeset for help on using the changeset viewer.