]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch.c
Pull out a chomp_newline function from "notmuch setup"
[notmuch] / notmuch.c
index d76425213dba3ffc6d76f4da66081d19e503887c..2d208cead1075e91bd526558b903b8f623a0a6d4 100644 (file)
--- a/notmuch.c
+++ b/notmuch.c
@@ -55,6 +55,13 @@ typedef struct {
     struct timeval tv_start;
 } add_files_state_t;
 
     struct timeval tv_start;
 } add_files_state_t;
 
+static void
+chomp_newline (char *str)
+{
+    if (str && str[strlen(str)-1] == '\n')
+       str[strlen(str)-1] = '\0';
+}
+
 /* Compute the number of seconds elapsed from start to end. */
 double
 tv_elapsed (struct timeval start, struct timeval end)
 /* Compute the number of seconds elapsed from start to end. */
 double
 tv_elapsed (struct timeval start, struct timeval end)
@@ -289,13 +296,9 @@ setup_command (int argc, char *argv[])
 
     mail_directory = NULL;
     getline (&mail_directory, &line_size, stdin);
 
     mail_directory = NULL;
     getline (&mail_directory, &line_size, stdin);
-    printf ("\n");
+    chomp_newline (mail_directory);
 
 
-    if (mail_directory &&
-       mail_directory[strlen(mail_directory)-1] == '\n')
-    {
-       mail_directory[strlen(mail_directory)-1] = '\0';
-    }
+    printf ("\n");
 
     if (mail_directory == NULL || strlen (mail_directory) == 0) {
        if (mail_directory)
 
     if (mail_directory == NULL || strlen (mail_directory) == 0) {
        if (mail_directory)