New API: write for creating files with fixed content (RHBZ#501889).
[libguestfs.git] / fish / edit.c
index 1b6ce23..a010057 100644 (file)
@@ -88,9 +88,9 @@ do_edit (const char *cmd, int argc, char *argv[])
   }
 
   /* Choose an editor. */
-  if (strcasecmp (cmd, "vi") == 0)
+  if (STRCASEEQ (cmd, "vi"))
     editor = "vi";
-  else if (strcasecmp (cmd, "emacs") == 0)
+  else if (STRCASEEQ (cmd, "emacs"))
     editor = "emacs -nw";
   else {
     editor = getenv ("EDITOR");
@@ -149,14 +149,14 @@ do_edit (const char *cmd, int argc, char *argv[])
   unlink (filename);
 
   /* Changed? */
-  if (strlen (content) == size && strncmp (content, content_new, size) == 0) {
+  if (strlen (content) == size && STREQLEN (content, content_new, size)) {
     free (content);
     free (content_new);
     return 0;
   }
 
   /* Write new content. */
-  if (guestfs_write_file (g, argv[0], content_new, size) == -1) {
+  if (guestfs_write (g, argv[0], content_new, size) == -1) {
     free (content);
     free (content_new);
     return -1;