Changeset a52d13a for zwrite.c


Ignore:
Timestamp:
Jul 15, 2009, 11:39:02 PM (9 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
130633c
Parents:
3e8ff1e
Message:
zephyr: Expand tabs in outgoing messages.

While we're at it, refactor owl_zwrite_create_from_line slightly in a
way that fixes 'zwrite -C user1 user2 -m message' to include the CC:
line.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zwrite.c

    r69f89c7 ra52d13a  
    99int owl_zwrite_create_from_line(owl_zwrite *z, char *line)
    1010{
    11   int argc, badargs, myargc;
     11  int argc, badargs, myargc, i, len;
    1212  char **argv, **myargv;
     13  char *msg = NULL;
    1314
    1415  badargs=0;
     
    9192      myargv++;
    9293      myargc--;
    93       z->message = owl_strdup("");
     94      len = 0;
     95      for (i=0;i<myargc;i++) {
     96        len += strlen(myargv[i-1]) + 1;
     97      }
     98      msg = owl_malloc(len);
     99      msg[0] = '\0';
    94100      while (myargc) {
    95         z->message=owl_realloc(z->message, strlen(z->message)+strlen(myargv[0])+5);
    96         strcat(z->message, myargv[0]);
    97         strcat(z->message, " ");
    98         myargc--;
    99         myargv++;
    100       }
    101       z->message[strlen(z->message)-1]='\0'; /* remove last space */
     101        strcat(msg, myargv[0]);
     102        strcat(msg, " ");
     103        myargc--;
     104        myargv++;
     105      }
     106      msg[strlen(msg)-1] = '\0';
    102107      break;
    103108    } else if (!strcmp(myargv[0], "-C")) {
     
    136141  if (z->opcode==NULL) z->opcode=owl_strdup("");
    137142  /* z->message is allowed to stay NULL */
    138  
     143
     144  if(msg) {
     145    owl_zwrite_set_message(z, msg);
     146    owl_free(msg);
     147  }
     148
    139149  return(0);
    140150}
     
    222232  int i, j;
    223233  char *toline = NULL;
    224   char *tmp = NULL;
     234  char *tmp = NULL, *tmp2;
    225235
    226236  if (z->message) owl_free(z->message);
     
    240250    }
    241251    tmp = owl_validate_utf8(msg);
    242     z->message=owl_sprintf("%s\n%s", toline, tmp);
     252    tmp2 = owl_text_expand_tabs(tmp);
     253    z->message=owl_sprintf("%s\n%s", toline, tmp2);
    243254    owl_free(toline);
     255    owl_free(tmp);
     256    owl_free(tmp2);
    244257  } else {
    245     z->message=owl_validate_utf8(msg);
    246   }
    247   if (tmp) owl_free(tmp);
     258    tmp=owl_validate_utf8(msg);
     259    z->message=owl_text_expand_tabs(tmp);
     260    owl_free(tmp);
     261  }
    248262}
    249263
Note: See TracChangeset for help on using the changeset viewer.