1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

styling changes and remove temporary comment

This commit is contained in:
Will Song 2015-11-24 17:58:55 -06:00
parent d4e0be7176
commit b2bc69f926
No known key found for this signature in database
GPG Key ID: F2B1A34F21A171E2

View File

@ -799,17 +799,17 @@ cmd_script(ProfWin *window, const char *const command, gchar **args)
/* escape a string into csv and write it to the file descriptor */ /* escape a string into csv and write it to the file descriptor */
static int static int
writecsv(int fd, const char *const str){ _writecsv(int fd, const char *const str){
if(!str) return 0; if(!str) return 0;
size_t len = strlen(str); size_t len = strlen(str);
char *s = malloc(2 * len * sizeof(char)); char *s = malloc(2 * len * sizeof(char));
char *c = s; char *c = s;
int i = 0; int i = 0;
for(; i < strlen(str); i++){ for(; i < strlen(str); i++) {
if(str[i] != '"') *c++ = str[i]; if(str[i] != '"') *c++ = str[i];
else { *c++ = '"'; *c++ = '"'; len++; } else { *c++ = '"'; *c++ = '"'; len++; }
} }
if(-1 == write(fd, s, len)){ if(-1 == write(fd, s, len)) {
cons_show("error: failed to write '%s' to the requested file: %s", s, strerror(errno)); cons_show("error: failed to write '%s' to the requested file: %s", s, strerror(errno));
return -1; return -1;
} }
@ -821,12 +821,10 @@ gboolean
cmd_export(ProfWin *window, const char *const command, gchar **args) cmd_export(ProfWin *window, const char *const command, gchar **args)
{ {
if(args[0]){ if(args[0]){
/* temporary, we SHOULD pass everything to an escape function (to escape out quotes)
* and then use fputs */
int fd = open(args[0], O_WRONLY | O_CREAT, 00600); int fd = open(args[0], O_WRONLY | O_CREAT, 00600);
GSList *list = NULL; GSList *list = NULL;
if(-1 == fd){ if(-1 == fd) {
cons_show("error: cannot open %s: %s", args[0], strerror(errno)); cons_show("error: cannot open %s: %s", args[0], strerror(errno));
cons_show(""); cons_show("");
return TRUE; return TRUE;
@ -835,7 +833,7 @@ cmd_export(ProfWin *window, const char *const command, gchar **args)
if(-1 == write(fd, "jid,name\n", strlen("jid,name\n"))) goto write_error; if(-1 == write(fd, "jid,name\n", strlen("jid,name\n"))) goto write_error;
list = roster_get_contacts(ROSTER_ORD_NAME, TRUE); list = roster_get_contacts(ROSTER_ORD_NAME, TRUE);
if(list){ if(list) {
GSList *curr = list; GSList *curr = list;
while(curr){ while(curr){
PContact contact = curr->data; PContact contact = curr->data;