From 8ebe96ee2b1909bf6803b143ef1e90a4130e1f94 Mon Sep 17 00:00:00 2001
From: joerg_wunsch <joerg_wunsch@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Fri, 8 Sep 2006 21:52:45 +0000
Subject: [PATCH] Implement -U filename as a shorthand for -U
 flash:w:filename:a.

This has once been suggested by Brian Dean.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@655 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog        |  7 +++++++
 avrdude.1        |  8 ++++++++
 doc/avrdude.texi |  5 +++++
 main.c           | 17 ++++++++++++++---
 4 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d1115fd0..f0ae65d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-09-08 Joerg Wunsch <j@uriah.heep.sax.de>
+
+	* main.c: Implement -U filename as a shorthand for
+	-U flash:w:filename:a.
+	* avrdude.1: Document this.
+	* doc/avrdude.texi: (Ditto.)
+
 2006-09-08 Joerg Wunsch <j@uriah.heep.sax.de>
 
 	Implement numerical output formats for decimal, hexadecimal,
diff --git a/avrdude.1 b/avrdude.1
index c652be0a..cf81e995 100644
--- a/avrdude.1
+++ b/avrdude.1
@@ -534,6 +534,14 @@ contains a colon, the
 field is no longer optional since the filename part following the colon
 would otherwise be misinterpreted as
 .Ar format .
+.Pp
+As an abbreviation, the form
+.Fl U Ar filename
+is equivalent to specifying
+.Fl U Em flash:w: Ns Ar filename Ns :a .
+This will only work if
+.Ar filename
+does not have a colon in it.
 .It Fl v
 Enable verbose output.
 .It Fl V
diff --git a/doc/avrdude.texi b/doc/avrdude.texi
index 78939a5c..f6a86bbb 100644
--- a/doc/avrdude.texi
+++ b/doc/avrdude.texi
@@ -775,6 +775,11 @@ Note that if @var{filename} contains a colon, the @var{format} field is
 no longer optional since the filename part following the colon would
 otherwise be misinterpreted as @var{format}.
 
+As an abbreviation, the form @code{-U} @var{filename}
+is equivalent to specifying
+@code{-U} @emph{flash:w:}@var{filename}@emph{:a}.
+This will only work if @var{filename} does not have a colon in it.
+
 @item -v
 Enable verbose output.
 
diff --git a/main.c b/main.c
index 5e00e645..0388d654 100644
--- a/main.c
+++ b/main.c
@@ -338,9 +338,20 @@ UPDATE * parse_op(char * s)
     buf[i++] = *p++;
   
   if (*p != ':') {
-    fprintf(stderr, "%s: invalid update specification\n", progname);
-    free(upd);
-    return NULL;
+    upd->memtype = (char *)malloc(strlen("flash")+1);
+    if (upd->memtype == NULL) {
+      outofmem:
+      fprintf(stderr, "%s: out of memory\n", progname);
+      exit(1);
+    }
+    strcpy(upd->memtype, "flash");
+    upd->op = DEVICE_WRITE;
+    upd->filename = (char *)malloc(strlen(buf) + 1);
+    if (upd->filename == NULL)
+      goto outofmem;
+    strcpy(upd->filename, buf);
+    upd->format = FMT_AUTO;
+    return upd;
   }
 
   buf[i] = 0;