Added the "%s" format when simply writing a string.
[selector.git] / selector.c
index 9e09b8a..daf2c26 100644 (file)
@@ -796,7 +796,7 @@ void read_file(struct hash_table_t *hash_table,
       raw_line[BUFFER_SIZE - 1] = '\0';
       fprintf(stderr, "selector: Line too long (max is %d characters):\n",
               BUFFER_SIZE);
-      fprintf(stderr, raw_line);
+      fprintf(stderr, "%s", raw_line);
       fprintf(stderr, "\n");
       exit(EXIT_FAILURE);
     }
@@ -853,7 +853,7 @@ int main(int argc, char **argv) {
   char pattern[BUFFER_SIZE];
   int c, k, l, n;
   int cursor_position;
-  int error = 0, show_help = 0;
+  int error = 0, show_help = 0, done = 0;
   int rest_are_files = 0;
   int key;
   int current_focus_line, displayed_focus_line;
@@ -1206,6 +1206,13 @@ int main(int argc, char **argv) {
       clear();
     }
 
+    else if(key == '\007' || /* ^G */
+            key == '\033' || /* ^[ (escape) */
+            key == '\n' ||
+            key == KEY_ENTER) {
+      done = 1;
+    }
+
     else {
       /* Unknown key */
       error_feedback();
@@ -1215,10 +1222,7 @@ int main(int argc, char **argv) {
                   motion,
                   nb_lines, labels, cursor_position, pattern);
 
-  } while(key != '\007' && /* ^G */
-          key != '\033' && /* ^[ (escape) */
-          key != '\n' &&
-          key != KEY_ENTER);
+  } while(!done);
 
   echo();
   endwin();
@@ -1247,7 +1251,7 @@ int main(int argc, char **argv) {
       FILE *out = fopen(output_filename, "w");
       if(out) {
         if(t) {
-          fprintf(out, t);
+          fprintf(out, "%s", t);
         }
         fprintf(out, "\n");
       } else {