Changeset ee310eb


Ignore:
Timestamp:
Feb 3, 2008, 1:08:11 AM (13 years ago)
Author:
Alejandro R. Sedeño <asedeno@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:
99219ed
Parents:
625802a (diff), af1920fd (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:
Merged revisions 909-923 via svnmerge from 
file:///afs/sipb.mit.edu/project/barnowl/src/svn/trunk

........
  r910 | nelhage | 2008-01-29 20:47:41 -0500 (Tue, 29 Jan 2008) | 1 line
  
  Fix IRC -- I forgot to add one ->conn in the last patch
........
  r911 | asedeno | 2008-01-30 15:49:35 -0500 (Wed, 30 Jan 2008) | 5 lines
  
  Jabber Buddy Lists:
  * Query the jabber:show_offline_buddies once when invoking onGetBuddyList()
  * Don't bold online roster entries when hiding offline ones
........
  r922 | asedeno | 2008-02-03 00:49:46 -0500 (Sun, 03 Feb 2008) | 1 line
  
  Bounds checking.
........
  r923 | asedeno | 2008-02-03 01:01:07 -0500 (Sun, 03 Feb 2008) | 1 line
  
  Portability - removing C++ style comments.
........
Files:
2 added
34 edited

Legend:

Unmodified
Added
Removed
  • dict.c

    r1cf3f8d3 raf1920fd  
    179179  owl_dict_free_all(&d, NULL);
    180180
    181   //  if (numfailed) printf("*** WARNING: failures encountered with owl_dict\n");
     181  /*  if (numfailed) printf("*** WARNING: failures encountered with owl_dict\n"); */
    182182  printf("# END testing owl_dict (%d failures)\n", numfailed);
    183183  return(numfailed);
  • editwin.c

    rb2c1bd4 ree310eb  
    3636  e->echochar='\0';
    3737
     38  /* We get initialized multiple times, but we need to hold on to
     39     the callbacks, so we can't NULL them here. */
    3840  /*
    39     // We get initialized multiple times, but we need to hold on to
    40     // the callbacks, so we can't NULL them here.
    4141    e->command = NULL;
    4242    e->callback = NULL;
     
    116116    owl_function_error("Internal error: No editwin callback!");
    117117  } else {
    118     // owl_function_error("text: |%s|", owl_editwin_get_text(e));
     118    /* owl_function_error("text: |%s|", owl_editwin_get_text(e)); */
    119119    cb(e);
    120120  }
  • filter.c

    rad15610 raf1920fd  
    341341  TEST_FILTER("type ^zephyr$ and direction ^in$ and ( class ^owl$ or instance ^owl$ )", 1);
    342342
    343   // Order of operations and precedence
     343  /* Order of operations and precedence */
    344344  TEST_FILTER("not true or false", 0);
    345345  TEST_FILTER("true or true and false", 0);
     
    352352  TEST_FILTER("filter f1", 1);
    353353
    354   // Test recursion prevention
     354  /* Test recursion prevention */
    355355  FAIL_UNLESS("self reference", owl_filter_init_fromstring(&f2, "test", "filter test"));
    356356
    357   // mutual recursion
     357  /* mutual recursion */
    358358  owl_filter_init_fromstring(&f3, "f3", "filter f4");
    359359  owl_global_add_filter(&g, &f3);
  • filterelement.c

    r5616acc raf1920fd  
    124124}
    125125
    126 // Print methods
     126/* Print methods */
    127127
    128128static void owl_filterelement_print_true(owl_filterelement *fe, char *buf)
     
    182182}
    183183
    184 // Constructors
     184/* Constructors */
    185185
    186186void owl_filterelement_create(owl_filterelement *fe) {
  • fmtext.c

    rc55ad84 ree310eb  
    793793void owl_fmtext_init_colorpair_mgr(owl_colorpair_mgr *cpmgr)
    794794{
    795   // This could be a bitarray if we wanted to save memory.
     795  /* This could be a bitarray if we wanted to save memory. */
    796796  short i, j;
    797797  cpmgr->next = 8;
    798798 
    799   // The test is <= because we allocate COLORS+1 entries.
     799  /* The test is <= because we allocate COLORS+1 entries. */
    800800  cpmgr->pairs = owl_malloc((COLORS+1) * sizeof(short*));
    801801  for(i = 0; i <= COLORS; i++) {
     
    823823    cpmgr->next = 8;
    824824   
    825     // The test is <= because we allocated COLORS+1 entries.
     825    /* The test is <= because we allocated COLORS+1 entries. */
    826826    for(i = 0; i <= COLORS; i++) {
    827827      for(j = 0; j <= COLORS; j++) {
     
    844844  short pair, default_bg;
    845845
     846  /* Sanity (Bounds) Check */
     847  if (fg > COLORS || fg < OWL_COLOR_DEFAULT) fg = OWL_COLOR_DEFAULT;
     848  if (bg > COLORS || bg < OWL_COLOR_DEFAULT) bg = OWL_COLOR_DEFAULT;
     849           
    846850#ifdef HAVE_USE_DEFAULT_COLORS
    847851  if (fg == OWL_COLOR_DEFAULT) fg = -1;
     
    853857#endif
    854858
    855   // looking for a pair we already set up for this draw.
     859  /* looking for a pair we already set up for this draw. */
    856860  cpmgr = owl_global_get_colorpair_mgr(&g);
    857861  pair = cpmgr->pairs[fg+1][bg+1];
    858862  if (!(pair != -1 && pair < cpmgr->next)) {
    859 /*    owl_global_set_needrefresh(&g);*/
    860     // If we didn't find a pair, search for a free one to assign.
     863    /* If we didn't find a pair, search for a free one to assign. */
    861864    pair = (cpmgr->next < COLOR_PAIRS) ? cpmgr->next : -1;
    862865    if (pair != -1) {
    863       // We found a free pair, initialize it.
     866      /* We found a free pair, initialize it. */
    864867      init_pair(pair, fg, bg);
    865868      cpmgr->pairs[fg+1][bg+1] = pair;
     
    867870    }
    868871    else if (bg != OWL_COLOR_DEFAULT) {
    869       // We still don't have a pair, drop the background color. Too bad.
     872      /* We still don't have a pair, drop the background color. Too bad. */
    870873      owl_function_debugmsg("colorpairs: color shortage - dropping background color.");
    871874      pair = owl_fmtext_get_colorpair(fg, OWL_COLOR_DEFAULT);
    872875    }
    873876    else {
    874       // We still don't have a pair, defaults all around.
     877      /* We still don't have a pair, defaults all around. */
    875878      owl_function_debugmsg("colorpairs: color shortage - dropping foreground and background color.");
    876879      pair = 0;
  • functions.c

    rf9eea4c ree310eb  
    13721372  redrawwin(owl_global_get_curs_recwin(&g));
    13731373  redrawwin(owl_global_get_curs_sepwin(&g));
    1374   // Work around curses segfualts with windows off the screen
     1374  /* Work around curses segfualts with windows off the screen */
    13751375  if (g.lines >= owl_global_get_typwin_lines(&g)+2)
    13761376      redrawwin(owl_global_get_curs_typwin(&g));
  • logging.c

    r28ee32b ree310eb  
    139139  /* Figure out what path to log to */
    140140  if (owl_message_is_type_zephyr(m)) {
    141     // If this has CC's, do all but the "recipient" which we'll do below
     141    /* If this has CC's, do all but the "recipient" which we'll do below */
    142142    to = owl_message_get_cc_without_recipient(m);
    143143    if (to != NULL) {
     
    326326
    327327  if (personal && owl_message_is_type_zephyr(m)) {
    328     // We want to log to all of the CC'd people who were not us, or
    329     // the sender, as well.
     328    /* We want to log to all of the CC'd people who were not us, or
     329     * the sender, as well.
     330     */
    330331    char *cc, *temp;
    331332    cc = owl_message_get_cc_without_recipient(m);
  • obarray.c

    r535d68b raf1920fd  
    1010 */
    1111
    12 // Helper method: Lookup a key in the obarray. If the key exists,
    13 // return its index, and the interned value in *val. Otherwise, return
    14 // the index it should be inserted at.
     12/* Helper method: Lookup a key in the obarray. If the key exists,
     13 * return its index, and the interned value in *val. Otherwise, return
     14 * the index it should be inserted at.
     15 */
    1516int owl_obarray_lookup(owl_obarray *oa, char * key, char ** val) /*noproto*/
    1617{
     
    3940}
    4041
    41 // Returns NULL if the string doesn't exist in the obarray
     42/* Returns NULL if the string doesn't exist in the obarray */
    4243char * owl_obarray_find(owl_obarray *oa, char * string)
    4344{
     
    4748}
    4849
    49 // Inserts the string into the obarray if it doesn't exist
     50/* Inserts the string into the obarray if it doesn't exist */
    5051char * owl_obarray_insert(owl_obarray *oa, char * string)
    5152{
  • perl/modules/IRC/lib/BarnOwl/Module/IRC.pm

    r5ff830a rcab045b  
    162162       );
    163163
    164     if ($conn->connected) {
     164    if ($conn->conn->connected) {
    165165        BarnOwl::admin_message("IRC", "Connected to $alias as $nick");
    166166        $ircnets{$alias} = $conn;
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber.pm

    r81312e4 ree310eb  
    137137}
    138138
     139our $showOffline = 0;
     140
    139141sub blist_listBuddy {
    140142    my $roster = shift;
     
    152154        $blistStr .= " [" . ( $rq{show} ? $rq{show} : 'online' ) . "]";
    153155        $blistStr .= " " . $rq{status} if $rq{status};
    154         $blistStr = BarnOwl::Style::boldify($blistStr);
     156        $blistStr = BarnOwl::Style::boldify($blistStr) if $showOffline;
    155157    }
    156158    else {
    157         return '' if (BarnOwl::getvar('jabber:show_offline_buddies') eq 'off');
     159        return '' unless $showOffline;
    158160        if ($jq{ask}) {
    159161            $blistStr .= " [pending]";
     
    198200
    199201sub onGetBuddyList {
     202    $showOffline = BarnOwl::getvar('jabber:show_offline_buddies') eq 'on';
    200203    my $blist = "";
    201204    foreach my $jid ($conn->getJIDs()) {
  • perlconfig.c

    r367fbf3 ree310eb  
    1414extern XS(boot_BarnOwl);
    1515extern XS(boot_DynaLoader);
    16 // extern XS(boot_DBI);
     16/* extern XS(boot_DBI); */
    1717
    1818static void owl_perl_xs_init(pTHX)
  • util.c

    r84027015 ree310eb  
    888888              !strcmp("meep foo bar", owl_util_uniq("meep foo", "bar foo meep", "-")));
    889889
    890   // if (numfailed) printf("*** WARNING: failures encountered with owl_util\n");
     890  /* if (numfailed) printf("*** WARNING: failures encountered with owl_util\n"); */
    891891  printf("# END testing owl_util (%d failures)\n", numfailed);
    892892  return(numfailed);
  • variable.c

    rd536e72 raf1920fd  
    10831083  owl_variable_dict_free(&vd);
    10841084
    1085   // if (numfailed) printf("*** WARNING: failures encountered with owl_variable\n");
     1085  /* if (numfailed) printf("*** WARNING: failures encountered with owl_variable\n"); */
    10861086  printf("# END testing owl_variable (%d failures)\n", numfailed);
    10871087  return(numfailed);
  • Makefile.in

    r5ff830a r625802a  
    2626     keypress.c keymap.c keybinding.c cmd.c context.c zcrypt.c \
    2727     aim.c buddy.c buddylist.c timer.c style.c stylefunc.c errqueue.c \
    28      zbuddylist.c muxevents.c popexec.c obarray.c
     28     zbuddylist.c muxevents.c popexec.c obarray.c wcwidth.c glib_compat.c
    2929OWL_SRC = owl.c
    3030TESTER_SRC = tester.c
  • aim.c

    r9854278 r34509d5  
    948948 
    949949  if (modname) {
    950     if (!(filename = malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) {
     950    if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(modname)+4+1))) {
    951951      /* perror("memrequest: malloc"); */
    952952      return -1;
     
    954954    sprintf(filename, "%s/%s.ocm", priv->aimbinarypath, modname);
    955955  } else {
    956     if (!(filename = malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) {
     956    if (!(filename = owl_malloc(strlen(priv->aimbinarypath)+1+strlen(defaultmod)+1))) {
    957957      /* perror("memrequest: malloc"); */
    958958      return -1;
     
    964964    if (!modname) {
    965965      /* perror("memrequest: stat"); */
    966       free(filename);
     966      owl_free(filename);
    967967      return -1;
    968968    }
     
    986986    int i;
    987987   
    988     free(filename); /* not needed */
     988    owl_free(filename); /* not needed */
    989989    owl_function_error("getaimdata memrequest: recieved invalid request for 0x%08lx bytes at 0x%08lx (file %s)\n", len, offset, modname);
    990990    i = 8;
     
    993993    }
    994994   
    995     if (!(buf = malloc(i))) {
     995    if (!(buf = owl_malloc(i))) {
    996996      return -1;
    997997    }
     
    10171017    *buflenret = i;
    10181018  } else {
    1019     if (!(buf = malloc(len))) {
    1020       free(filename);
     1019    if (!(buf = owl_malloc(len))) {
     1020      owl_free(filename);
    10211021      return -1;
    10221022    }
     
    10241024    if (!(f = fopen(filename, "r"))) {
    10251025      /* perror("memrequest: fopen"); */
    1026       free(filename);
    1027       free(buf);
     1026      owl_free(filename);
     1027      owl_free(buf);
    10281028      return -1;
    10291029    }
    10301030   
    1031     free(filename);
     1031    owl_free(filename);
    10321032   
    10331033    if (fseek(f, offset, SEEK_SET) == -1) {
    10341034      /* perror("memrequest: fseek"); */
    10351035      fclose(f);
    1036       free(buf);
     1036      owl_free(buf);
    10371037      return -1;
    10381038    }
     
    10411041      /* perror("memrequest: fread"); */
    10421042      fclose(f);
    1043       free(buf);
     1043      owl_free(buf);
    10441044      return -1;
    10451045    }
     
    10761076  if (priv->aimbinarypath && (getaimdata(sess, &buf, &buflen, offset, len, modname) == 0)) {
    10771077    aim_sendmemblock(sess, fr->conn, offset, buflen, buf, AIM_SENDMEMBLOCK_FLAG_ISREQUEST);
    1078     free(buf);
     1078    owl_free(buf);
    10791079  } else {
    10801080    owl_function_debugmsg("faimtest_memrequest: unable to use AIM binary (\"%s/%s\"), sending defaults...\n", priv->aimbinarypath, modname);
     
    13421342      int z;
    13431343     
    1344       newbuf = malloc(i+1);
     1344      newbuf = owl_malloc(i+1);
    13451345      for (z = 0; z < i; z++)
    13461346        newbuf[z] = (z % 10)+0x30;
    13471347      newbuf[i] = '\0';
    13481348      /* aim_send_im(sess, userinfo->sn, AIM_IMFLAGS_ACK | AIM_IMFLAGS_AWAY, newbuf); */
    1349       free(newbuf);
     1349      owl_free(newbuf);
    13501350    }
    13511351  } else if (strstr(tmpstr, "seticqstatus")) {
  • cmd.c

    r6922edd r34509d5  
    7474  owl_cmd *cmd;
    7575
    76   tmpbuff=strdup(cmdbuff);
     76  tmpbuff=owl_strdup(cmdbuff);
    7777  argv=owl_parseline(tmpbuff, &argc);
    7878  if (argc < 0) {
  • config.h.in

    r03cf6b9 re23eb2b  
    2222#undef HAVE_LIBCOM_ERR
    2323
    24 /* Define to 1 if you have the `curses' library (-lcurses). */
    25 #undef HAVE_LIBCURSES
    26 
    2724/* Define to 1 if you have the `des425' library (-ldes425). */
    2825#undef HAVE_LIBDES425
     
    3936/* Define to 1 if you have the `krb5' library (-lkrb5). */
    4037#undef HAVE_LIBKRB5
    41 
    42 /* Define to 1 if you have the `ncurses' library (-lncurses). */
    43 #undef HAVE_LIBNCURSES
    4438
    4539/* Define to 1 if you have the `ncursesw' library (-lncursesw). */
  • configure.in

    r18e28a4 re23eb2b  
    1212fi
    1313
     14m4_include(/usr/share/aclocal/pkg.m4)
     15dnl m4_include(pkg.m4)
    1416
    1517dnl Check for Athena
     
    4446fi
    4547
    46 AC_CHECK_LIB(ncursesw, initscr,,
    47   AC_CHECK_LIB(ncurses, initscr,,
    48     AC_CHECK_LIB(curses, initscr,, AC_MSG_ERROR(No curses library found.))))
     48AC_CHECK_LIB(ncursesw, initscr,, AC_MSG_ERROR(No curses library found.))
    4949AC_CHECK_LIB(com_err, com_err)
    5050AC_CHECK_LIB(nsl, gethostbyname)
     
    109109LDFLAGS=${LDFLAGS}\ ${FOO}
    110110
     111dnl Add CFLAGS and LDFLAGS for glib-2.0
     112PKG_CHECK_MODULES(GLIB,glib-2.0)
     113
     114echo Adding glib-2.0 CFLAGS ${GLIB_CFLAGS}
     115CFLAGS=${CFLAGS}\ ${GLIB_CFLAGS}
     116echo Adding glib-2.0 LDFLAGS ${GLIB_LIBS}
     117LDFLAGS=${LDFLAGS}\ ${GLIB_LIBS}
     118
     119
    111120dnl Checks for typedefs, structures, and compiler characteristics.
    112121
  • global.c

    reebef19 r625802a  
    549549    len+=strlen(argv[i])+5;
    550550  }
    551   g->startupargs=malloc(len+5);
     551  g->startupargs=owl_malloc(len+5);
    552552
    553553  strcpy(g->startupargs, "");
  • keymap.c

    rcf83b7a r428834d  
    55
    66/* returns 0 on success */
    7 int owl_keymap_init(owl_keymap *km, char *name, char *desc, void (*default_fn)(int), void (*prealways_fn)(int), void (*postalways_fn)(int))
     7int owl_keymap_init(owl_keymap *km, char *name, char *desc, void (*default_fn)(owl_input), void (*prealways_fn)(owl_input), void (*postalways_fn)(owl_input))
    88{
    99  if (!name || !desc) return(-1);
     
    151151}
    152152
    153 owl_keymap *owl_keyhandler_create_and_add_keymap(owl_keyhandler *kh, char *name, char *desc, void (*default_fn)(int), void (*prealways_fn)(int), void (*postalways_fn)(int))
     153owl_keymap *owl_keyhandler_create_and_add_keymap(owl_keyhandler *kh, char *name, char *desc, void (*default_fn)(owl_input), void (*prealways_fn)(owl_input), void (*postalways_fn)(owl_input))
    154154{
    155155  owl_keymap *km;
     
    202202/* processes a keypress.  returns 0 if the keypress was handled,
    203203 * 1 if not handled, -1 on error, and -2 if j==ERR. */
    204 int owl_keyhandler_process(owl_keyhandler *kh, int j)
     204int owl_keyhandler_process(owl_keyhandler *kh, owl_input j)
    205205{
    206206  owl_keymap     *km;
     
    214214
    215215  /* temporarily disallow C-`/C-SPACE until we fix associated bugs */
    216   if (j==ERR || j==0) {
     216  if (j.ch == ERR || j.ch == 0) {
    217217        return(-1);
    218218  }
     
    224224
    225225  /* deal with ESC prefixing */
    226   if (!kh->in_esc && j==27) {
     226  if (!kh->in_esc && j.ch == 27) {
    227227    kh->in_esc = 1;
    228228    return(0);
    229229  }
    230230  if (kh->in_esc) {
    231     j = OWL_META(j);
     231    j.ch = OWL_META(j.ch);
    232232    kh->in_esc = 0;
    233233  }
    234234 
    235   kh->kpstack[++(kh->kpstackpos)] = j;
     235  kh->kpstack[++(kh->kpstackpos)] = j.ch;
    236236  if (kh->kpstackpos >= OWL_KEYMAP_MAXSTACK) {
    237237    owl_keyhandler_reset(kh);
     
    260260      } else if (match == 2) {  /* exact match */
    261261        /* owl_function_debugmsg("processkey: found exact match in %s", km->name); */
    262         owl_keybinding_execute(kb, j);
     262        owl_keybinding_execute(kb, j.ch);
    263263        owl_keyhandler_reset(kh);
    264264        if (km->postalways_fn) {
  • keypress.c

    r948b942 r428834d  
    148148  }
    149149  if (!*kb) {
    150     if (j&OWL_META(0)) {
     150    if (j & OWL_META(0)) {
    151151      strcat(kb, "M-");
    152152      j &= ~OWL_META(0);
     
    163163      strcat(kb, kb2);   
    164164    }
     165   
    165166  } 
    166167  if (!*kb) {
  • keys.c

    r8938188 rfac5463  
    294294/****************************************************************/
    295295
    296 void owl_keys_recwin_prealways(int j) {
     296void owl_keys_recwin_prealways(owl_input j) {
    297297  /* Clear the message line on subsequent key presses */
    298298  owl_function_makemsg("");
    299299}
    300300
    301 void owl_keys_editwin_default(int j) {
     301void owl_keys_editwin_default(owl_input j) {
    302302  owl_editwin *e;
    303303  if (NULL != (e=owl_global_get_typwin(&g))) {
    304     owl_editwin_process_char(e, j);
     304       owl_editwin_process_char(e, j);
    305305  }
    306306}
    307307
    308 void owl_keys_editwin_postalways(int j) {
     308void owl_keys_editwin_postalways(owl_input j) {
    309309  owl_editwin *e;
    310310  if (NULL != (e=owl_global_get_typwin(&g))) {
    311311    owl_editwin_post_process_char(e, j);
    312   } 
     312  }
    313313  owl_global_set_needrefresh(&g);
    314314}
    315315
    316 void owl_keys_popless_postalways(int j) {
     316void owl_keys_popless_postalways(owl_input j) {
    317317  owl_viewwin *v = owl_global_get_viewwin(&g);
    318318  owl_popwin *pw = owl_global_get_popwin(&g);
     
    323323}
    324324
    325 void owl_keys_default_invalid(int j) {
    326   if (j==ERR) return;
    327   if (j==410) return;
     325void owl_keys_default_invalid(owl_input j) {
     326  if (j.ch==ERR) return;
     327  if (j.ch==410) return;
    328328  owl_keyhandler_invalidkey(owl_global_get_keyhandler(&g));
    329329}
  • message.c

    r635881c ra827529  
    7979    owl_list_append_element(&(m->attributes), pair);
    8080  }
    81   owl_pair_set_value(pair, owl_strdup(attrvalue));
     81  owl_pair_set_value(pair, owl_validate_or_convert(attrvalue));
    8282}
    8383
     
    493493{
    494494  if(m->zwriteline) owl_free(m->zwriteline);
    495   m->zwriteline=strdup(line);
     495  m->zwriteline=owl_strdup(line);
    496496}
    497497
     
    535535  owl_fmtext_init_null(&b);
    536536 
    537   owl_fmtext_truncate_lines(&(m->fmtext->fmtext), aline, bline-aline+1, &a);
     537  owl_fmtext_truncate_lines(&(m->fmtext->fmtext), aline, bline-aline, &a);
    538538  owl_fmtext_truncate_cols(&a, acol, bcol, &b);
    539   if (fgcolor!=OWL_COLOR_DEFAULT) {
    540     owl_fmtext_colorize(&b, fgcolor);
    541   }
    542   if (bgcolor!=OWL_COLOR_DEFAULT) {
    543     owl_fmtext_colorizebg(&b, bgcolor);
    544   }
    545 
    546   if (owl_global_is_search_active(&g)) {
    547     owl_fmtext_search_and_highlight(&b, owl_global_get_search_string(&g));
    548   }
    549      
     539  owl_fmtext_colorize(&b, fgcolor);
     540  owl_fmtext_colorizebg(&b, bgcolor);
     541
    550542  owl_fmtext_curs_waddstr(&b, win);
    551543
     
    890882  }
    891883
    892   m->zwriteline=strdup("");
     884  m->zwriteline=owl_strdup("");
    893885
    894886  /* save the hostname */
     
    972964  }
    973965
    974   m->zwriteline=strdup("");
     966  m->zwriteline=owl_strdup("");
    975967
    976968  owl_message_set_body(m, "<uninitialized>");
  • owl.c

    reebef19 r625802a  
    4848#include <termios.h>
    4949#include <sys/stat.h>
     50#include <locale.h>
    5051#include "owl.h"
    5152
     
    6970  owl_editwin *tw;
    7071  owl_popwin *pw;
    71   int j, ret, initialsubs, debug, argcsave, followlast;
     72  int ret, initialsubs, debug, argcsave, followlast;
     73  owl_input j;
    7274  int newmsgs, nexttimediff;
    7375  struct sigaction sigact;
     
    8486  int newstderr;
    8587#endif
     88 
     89  if (!GLIB_CHECK_VERSION (2, 12, 0))
     90    g_error ("GLib version 2.12.0 or above is needed.");
    8691
    8792  argcsave=argc;
     
    9297  debug=0;
    9398  initialsubs=1;
     99
     100  setlocale(LC_ALL, "");
     101 
    94102  if (argc>0) {
    95103    argv++;
     
    530538     * little bit, but otherwise do not.  This lets input be grabbed
    531539     * as quickly as possbile */
    532     j=wgetch(typwin);
    533     if (j==ERR) {
     540    j.ch = wgetch(typwin);
     541    if (j.ch == ERR) {
    534542      usleep(10000);
    535543    } else {
     544      j.uch = '\0';
     545      if (j.ch >= KEY_MIN && j.ch <= KEY_MAX) {
     546        /* This is a curses control character. */
     547      }
     548      else if (j.ch > 0x7f && j.ch < 0xfe) {
     549        /* Pull in a full utf-8 character. */
     550        int bytes, i;
     551        char utf8buf[7];
     552        memset(utf8buf, '\0', 7);
     553
     554        utf8buf[0] = j.ch;
     555
     556        if ((j.ch & 0xc0) && (~j.ch & 0x20)) bytes = 2;
     557        else if ((j.ch & 0xe0) && (~j.ch & 0x10)) bytes = 3;
     558        else if ((j.ch & 0xf0) && (~j.ch & 0x08)) bytes = 4;
     559        else if ((j.ch & 0xf8) && (~j.ch & 0x04)) bytes = 5;
     560        else if ((j.ch & 0xfc) && (~j.ch & 0x02)) bytes = 6;
     561        else bytes = 1;
     562       
     563        for (i = 1; i < bytes; i++) {
     564          int tmp =  wgetch(typwin);
     565          /* If what we got was not a byte, or not a continuation byte */
     566          if (tmp > 0xff || !(tmp & 0x80 && ~tmp & 0x40)) {
     567            /* ill-formed UTF-8 code unit subsequence, put back the
     568               char we just got. */
     569            ungetch(tmp);
     570            j.ch = ERR;
     571            break;
     572          }
     573          utf8buf[i] = tmp;
     574        }
     575       
     576        if (j.ch != ERR) {
     577          if (g_utf8_validate(utf8buf, -1, NULL)) {
     578            j.uch = g_utf8_get_char(utf8buf);
     579          }
     580          else {
     581            j.ch = ERR;
     582          }
     583        }
     584      }
     585      else if (j.ch <= 0x7f) {
     586        j.uch = j.ch;
     587      }
     588     
    536589      owl_global_set_lastinputtime(&g, now);
    537590      /* find and activate the current keymap.
  • owl.h

    r88dc766 rf92080c  
    5252#include <termios.h>
    5353#include <libfaim/aim.h>
     54#include <wchar.h>
    5455#include "config.h"
     56#include "glib.h"
    5557#ifdef HAVE_LIBZEPHYR
    5658#include <zephyr/zephyr.h>
     
    100102#define OWL_FMTEXT_ATTR_REVERSE   2
    101103#define OWL_FMTEXT_ATTR_UNDERLINE 4
     104
     105#define OWL_FMTEXT_UC_BASE 0x100000 /* Unicode Plane 16 - Supplementary Private Use Area-B*/
     106#define OWL_FMTEXT_UC_ATTR ( OWL_FMTEXT_UC_BASE | 0x800 )
     107#define OWL_FMTEXT_UC_ATTR_MASK 0x7
     108#define OWL_FMTEXT_UC_COLOR_BASE ( OWL_FMTEXT_UC_BASE | 0x400 )
     109#define OWL_FMTEXT_UC_FGCOLOR OWL_FMTEXT_UC_COLOR_BASE
     110#define OWL_FMTEXT_UC_BGCOLOR ( OWL_FMTEXT_UC_COLOR_BASE | 0x200 )
     111#define OWL_FMTEXT_UC_DEFAULT_COLOR 0x100
     112#define OWL_FMTEXT_UC_FGDEFAULT ( OWL_FMTEXT_UC_FGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR )
     113#define OWL_FMTEXT_UC_BGDEFAULT ( OWL_FMTEXT_UC_BGCOLOR | OWL_FMTEXT_UC_DEFAULT_COLOR )
     114#define OWL_FMTEXT_UC_COLOR_MASK 0xFF
     115#define OWL_FMTEXT_UC_ALLCOLOR_MASK ( OWL_FMTEXT_UC_COLOR_MASK | OWL_FMTEXT_UC_DEFAULT_COLOR | 0x200)
     116#define OWL_FMTEXT_UC_STARTBYTE_UTF8 '\xf4'
     117
     118#define OWL_FMTEXT_UTF8_ATTR_NONE "\xf4\x80\xa0\x80"
     119#define OWL_FMTEXT_UTF8_FGDEFAULT "\xf4\x80\x94\x80"
     120#define OWL_FMTEXT_UTF8_BGDEFAULT "\xf4\x80\x96\x80"
     121
     122
     123
    102124
    103125#define OWL_COLOR_BLACK     0
     
    212234#endif
    213235
    214 #define OWL_META(key) ((key)|0200)
     236#define OWL_META(key) ((key)|010000)
    215237/* OWL_CTRL is definied in kepress.c */
    216238
     
    252274} owl_variable;
    253275
     276typedef struct _owl_input {
     277  int ch;
     278  gunichar uch;
     279} owl_input;
     280
    254281typedef struct _owl_fmtext {
    255282  int textlen;
    256283  int bufflen;
    257284  char *textbuff;
    258   char *fmbuff;
    259   short *fgcolorbuff;
    260   short *bgcolorbuff;
     285  char default_attrs;
     286  short default_fgcolor;
     287  short default_bgcolor;
    261288} owl_fmtext;
    262289
     
    491518  owl_list  bindings;           /* key bindings */
    492519  struct _owl_keymap *submap;   /* submap */
    493   void (*default_fn)(int j);    /* default action (takes a keypress) */
    494   void (*prealways_fn)(int j);  /* always called before a keypress is received */
    495   void (*postalways_fn)(int j); /* always called after keypress is processed */
     520  void (*default_fn)(owl_input j);      /* default action (takes a keypress) */
     521  void (*prealways_fn)(owl_input j);   /* always called before a keypress is received */
     522  void (*postalways_fn)(owl_input j);  /* always called after keypress is processed */
    496523} owl_keymap;
    497524
  • perl/modules/Jabber/lib/BarnOwl/Module/Jabber/Connection.pm

    r892568b re0ffe77  
    11use warnings;
    22use strict;
     3use utf8;
    34
    45=head1 NAME
  • perl/modules/Jabber/lib/Net/XMPP/Debug.pm

    rc2bed55 rb7b2a76  
    189189                        {
    190190                            $self->{HANDLE}->autoflush(1);
     191                            binmode $self->{HANDLE}, ":utf8";
    191192                            $Net::XMPP::Debug::HANDLES{$args{file}} = $self->{HANDLE};
    192193                        }
  • perl/modules/Jabber/lib/Net/XMPP/Message.pm

    rc2bed55 r8574801  
    135135                            $Mess->SetMessage(TO=>"bob\@jabber.org",
    136136                                              Subject=>"Lunch",
    137                                               BoDy=>"Let's do lunch!");
     137                                              Body=>"Let's do lunch!");
    138138                            $Mess->SetMessage(to=>"bob\@jabber.org",
    139139                                              from=>"jabber.org",
  • perl/modules/Jabber/lib/XML/Stream.pm

    r5073972 ra8d5a39  
    16591659    {
    16601660        $self->debug(3,"Send: can_write");
    1661        
     1661
    16621662        $self->{SENDSTRING} = Encode::encode_utf8(join("",@_));
    16631663
  • text.c

    r72db971 r47519e1b  
    5050void owl_text_truncate_cols(char *out, char *in, int acol, int bcol)
    5151{
    52   char *ptr1, *ptr2, *tmpbuff, *last;
    53   int len;
    54 
     52  char *ptr_s, *ptr_e, *ptr_c, *tmpbuff, *last;
     53  int col, cnt, padding;
     54 
    5555  tmpbuff=owl_malloc(strlen(in)+20);
    5656
    5757  strcpy(tmpbuff, "");
    5858  last=in+strlen(in)-1;
    59   ptr1=in;
    60   while (ptr1<last) {
    61     ptr2=strchr(ptr1, '\n');
    62     if (!ptr2) {
     59  ptr_s=in;
     60  while (ptr_s<last) {
     61    ptr_e=strchr(ptr_s, '\n');
     62    if (!ptr_e) {
    6363      /* but this shouldn't happen if we end in a \n */
    6464      break;
    6565    }
    6666   
    67     if (ptr2==ptr1) {
     67    if (ptr_e==ptr_s) {
    6868      strcat(tmpbuff, "\n");
    69       ptr1++;
    70       continue;
    71     }
    72 
     69      ptr_s++;
     70      continue;
     71    }
     72
     73    col = 0;
     74    cnt = 0;
     75    padding = 0;
     76    ptr_c = ptr_s;
     77    while(col < bcol && ptr_c < ptr_e) {
     78      gunichar c = g_utf8_get_char(ptr_c);
     79      if (col + mk_wcwidth(c) > bcol) break;
     80      col += mk_wcwidth(c);
     81      ptr_c = g_utf8_next_char(ptr_c);
     82      if (col >= acol) {
     83        if (cnt == 0) {
     84          ptr_s = ptr_c;
     85          padding = col - acol;
     86        }
     87        ++cnt;
     88      }
     89    }
     90    if (cnt) {
     91      while(padding-- > 0) {
     92        strcat(tmpbuff, " ");
     93      }
     94      strncat(tmpbuff, ptr_s, ptr_c - ptr_s - 1);
     95    }
     96    strcat(tmpbuff, "\n");
     97    ptr_s = ptr_e + 1;
     98#if 0
    7399    /* we need to check that we won't run over here */
    74     if ( (ptr2-ptr1) < (bcol-acol) ) {
    75       len=ptr2-(ptr1+acol);
     100    if ( (ptr_e-ptr_s) < (bcol-acol) ) {
     101      len=ptr_e-(ptr_s+acol);
    76102    } else {
    77103      len=bcol-acol;
    78104    }
    79     if ((ptr1+len)>=last) {
    80       len-=last-(ptr1+len);
    81     }
    82 
    83     strncat(tmpbuff, ptr1+acol, len);
     105    if ((ptr_s+len)>=last) {
     106      len-=last-(ptr_s+len);
     107    }
     108
     109    strncat(tmpbuff, ptr_s+acol, len);
    84110    strcat(tmpbuff, "\n");
    85111
    86     ptr1=ptr2+1;
     112    ptr_s=ptr_e+1;
     113#endif
    87114  }
    88115  strcpy(out, tmpbuff);
     
    275302char *stristr(char *a, char *b)
    276303{
    277   char *x, *y, *ret;
    278 
    279   if ((x=owl_strdup(a))==NULL) return(NULL);
    280   if ((y=owl_strdup(b))==NULL) return(NULL);
    281   downstr(x);
    282   downstr(y);
    283   ret=strstr(x, y);
    284   if (ret==NULL) {
    285     owl_free(x);
    286     owl_free(y);
    287     return(NULL);
    288   }
    289   ret=ret-x+a;
    290   owl_free(x);
    291   owl_free(y);
     304  char *x, *y;
     305  char *ret = NULL;
     306  if ((x = g_utf8_casefold(a, -1)) != NULL) {
     307    if ((y = g_utf8_casefold(b, -1)) != NULL) {
     308      ret = strstr(x, y);
     309      if (ret != NULL) {
     310        ret = ret - x + a;
     311      }
     312      g_free(y);
     313    }
     314    g_free(x);
     315  }
    292316  return(ret);
    293317}
     
    296320int only_whitespace(char *s)
    297321{
    298   int i;
    299   for (i=0; s[i]; i++) {
    300     if (!isspace((int) s[i])) return(0);
     322  if (g_utf8_validate(s,-1,NULL)) {
     323    char *p;
     324    for(p = s; p[0]; p=g_utf8_next_char(p)) {
     325      if (!g_unichar_isspace(g_utf8_get_char(p))) return 0;
     326    }
     327  }
     328  else {
     329    int i;
     330    for (i=0; s[i]; i++) {
     331      if (!isspace((int) s[i])) return(0);
     332    }
    301333  }
    302334  return(1);
     
    327359  tolen  = strlen(to);
    328360  fromlen  = strlen(from);
    329   out = malloc(outlen);
     361  out = owl_malloc(outlen);
    330362
    331363  while (in[inpos]) {
  • viewwin.c

    r8721756 r47519e1b  
    7373  owl_fmtext_truncate_cols(&fm1, v->rightshift, v->wincols-1+v->rightshift, &fm2);
    7474
    75   owl_fmtext_curs_waddstr(&fm2, v->curswin);
     75  owl_fmtext_curs_waddstr_without_search(&fm2, v->curswin);
    7676
    7777  /* print the message at the bottom */
  • zcrypt.c

    r9ceee9d r34509d5  
    385385
    386386/* Build a space-separated string from argv from elements between start  *
    387  * and end - 1.  malloc()'s the returned string. */
     387 * and end - 1.  owl_malloc()'s the returned string. */
    388388char *BuildArgString(char **argv, int start, int end) {
    389389  int len = 1;
     
    397397
    398398  /* Allocate memory */
    399   result = (char *)malloc(len);
     399  result = (char *)owl_malloc(len);
    400400  if (result) {
    401401    /* Build the string */
     
    482482      /* Prepare result to be returned */
    483483      char *temp = keyfile;
    484       keyfile = (char *)malloc(strlen(temp) + 1);
     484      keyfile = (char *)owl_malloc(strlen(temp) + 1);
    485485      if (keyfile) {
    486486        strcpy(keyfile, temp);
     
    611611      }
    612612      use_buffer = TRUE;
    613       if ((inptr = inbuff = (char *)malloc(MAX_RESULT)) == NULL) {
     613      if ((inptr = inbuff = (char *)owl_malloc(MAX_RESULT)) == NULL) {
    614614        printf("Memory allocation error\n");
    615615        return FALSE;
     
    639639      printf("Could not run zwrite\n");
    640640      if (freein && inbuff) {
    641         free(inbuff);
     641        owl_free(inbuff);
    642642      }
    643643      return(FALSE);
     
    685685
    686686  /* Free the input buffer, if necessary */
    687   if (freein && inbuff) free(inbuff);
     687  if (freein && inbuff) owl_free(inbuff);
    688688
    689689  return(!error);
  • zephyr.c

    r10e3963 r625802a  
    354354  return(owl_strdup(""));
    355355}
     356
     357char *owl_zephyr_get_field_as_utf8(ZNotice_t *n, int j)
     358{
     359  int i, count, save;
     360
     361  /* If there's no message here, just run along now */
     362  if (n->z_message_len == 0)
     363    return(owl_strdup(""));
     364
     365  count=save=0;
     366  for (i = 0; i < n->z_message_len; i++) {
     367    if (n->z_message[i]=='\0') {
     368      count++;
     369      if (count == j) {
     370        /* just found the end of the field we're looking for */
     371        return(owl_validate_or_convert(n->z_message + save));
     372      } else {
     373        save = i + 1;
     374      }
     375    }
     376  }
     377  /* catch the last field, which might not be null terminated */
     378  if (count == j - 1) {
     379    char *tmp, *out;
     380    tmp = owl_malloc(n->z_message_len-save+5);
     381    memcpy(tmp, n->z_message+save, n->z_message_len-save);
     382    tmp[n->z_message_len-save]='\0';
     383    out = owl_validate_or_convert(tmp);
     384    owl_free(tmp);
     385    return out;
     386  }
     387
     388  return(owl_strdup(""));
     389}
    356390#else
    357391char *owl_zephyr_get_field(void *n, int j)
    358392{
    359393  return(owl_strdup(""));
     394}
     395char *owl_zephyr_get_field_as_utf8(ZNotice_t *n, int j)
     396{
     397  return owl_zephyr_get_field(n, j);
    360398}
    361399#endif
  • zwrite.c

    r1fe100c r7b1d048  
    4444        break;
    4545      }
    46       z->class=owl_strdup(myargv[1]);
     46      z->class=owl_get_iso_8859_1_if_possible(myargv[1]);
    4747      myargv+=2;
    4848      myargc-=2;
     
    5252        break;
    5353      }
    54       z->inst=owl_strdup(myargv[1]);
     54      z->inst=owl_get_iso_8859_1_if_possible(myargv[1]);
    5555      myargv+=2;
    5656      myargc-=2;
     
    6060        break;
    6161      }
    62       z->realm=owl_strdup(myargv[1]);
     62      z->realm=owl_get_iso_8859_1_if_possible(myargv[1]);
    6363      myargv+=2;
    6464      myargc-=2;
     
    6868        break;
    6969      }
    70       z->zsig=owl_strdup(myargv[1]);
     70      z->zsig=owl_get_iso_8859_1_if_possible(myargv[1]);
    7171      myargv+=2;
    7272      myargc-=2;
     
    7676        break;
    7777      }
    78       z->opcode=owl_strdup(myargv[1]);
     78      z->opcode=owl_get_iso_8859_1_if_possible(myargv[1]);
    7979      myargv+=2;
    8080      myargc-=2;
     
    9393      myargv++;
    9494      myargc--;
    95       z->message=owl_strdup("");
     95      z->message=owl_get_iso_8859_1_if_possible("");
    9696      while (myargc) {
    97         z->message=realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
     97        z->message=owl_realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
    9898        strcat(z->message, myargv[0]);
    9999        strcat(z->message, " ");
     
    113113    } else {
    114114      /* anything unattached is a recipient */
    115       owl_list_append_element(&(z->recips), strdup(myargv[0]));
     115      owl_list_append_element(&(z->recips), owl_get_iso_8859_1_if_possible(myargv[0]));
    116116      myargv++;
    117117      myargc--;
     
    146146
    147147    if (zsigowlvar && *zsigowlvar) {
    148       z->zsig=owl_strdup(zsigowlvar);
     148      z->zsig=owl_get_iso_8859_1_if_possible(zsigowlvar);
    149149    } else if (zsigproc && *zsigproc) {
    150150      FILE *file;
     
    161161      if (!file) {
    162162        if (zsigzvar && *zsigzvar) {
    163           z->zsig=owl_strdup(zsigzvar);
     163          z->zsig=owl_get_iso_8859_1_if_possible(zsigzvar);
    164164        }
    165165      } else {
     
    175175      }
    176176    } else if (zsigzvar) {
    177       z->zsig=owl_strdup(zsigzvar);
     177      z->zsig=owl_get_iso_8859_1_if_possible(zsigzvar);
    178178    } else if (((pw=getpwuid(getuid()))!=NULL) && (pw->pw_gecos)) {
    179       z->zsig=strdup(pw->pw_gecos);
     179      z->zsig=owl_get_iso_8859_1_if_possible(pw->pw_gecos);
    180180      ptr=strchr(z->zsig, ',');
    181181      if (ptr) {
     
    218218  int i, j;
    219219  char toline[LINE];
     220  char *tmp = NULL;
    220221
    221222  if (z->message) owl_free(z->message);
     
    231232      }
    232233    }
    233     z->message=owl_sprintf("%s\n%s", toline, msg);
     234    tmp = owl_get_iso_8859_1_if_possible(msg);
     235    z->message=owl_sprintf("%s\n%s", toline, tmp);
    234236  } else {
    235     z->message=owl_strdup(msg);
    236   }
     237    z->message=owl_get_iso_8859_1_if_possible(msg);
     238  }
     239  if (tmp) owl_free(tmp);
    237240}
    238241
     
    305308{
    306309  if (z->opcode) owl_free(z->opcode);
    307   z->opcode=owl_strdup(opcode);
     310  z->opcode=owl_get_iso_8859_1_if_possible(opcode);
    308311}
    309312
Note: See TracChangeset for help on using the changeset viewer.