Diff of /AutoPano.c [262685] .. [f7ce8a]  Maximize  Restore

Switch to side-by-side view

--- a/AutoPano.c
+++ b/AutoPano.c
@@ -516,6 +516,9 @@
 		Usage ();
 		exit (1);
 	}
+
+	// output to stdout flag
+	bool streamout = false;
 
 	// Automatic pre-aligning of images
 	bool preAlign = false;
@@ -546,14 +549,11 @@
 	int optionCount = 0;
 	int optionN = 1;
 	while (optionN < argc &&
-	       strlen(argv[optionN]) >= 2 && argv[optionN][0] == '-')
+	       strlen(argv[optionN]) >= 2 
+		   && argv[optionN][0] == '-'
+		   && argv[optionN][1] == '-')
 		{
 			char* optionStr = argv[optionN];
-
-			if (optionStr[1] != '-') {
-				Usage ();
-				exit (1);
-			}
 
 			if (strcmp (optionStr, "--ransac") == 0) {
 				useRansac = YesNoOption ("--ransac", argv[optionN + 1]);
@@ -615,7 +615,22 @@
 			}
 		}
 	optionCount = optionN;
-
+	// is there an output name and at least one input name?
+	if( argc - optionN < 2 ){
+		WriteLine ("Error. Output name and at least one image name required.");
+		Usage();
+		exit(1);
+	}
+	// next arg is either output file name or "-" for stdout
+	// anything else beginning with '-' is an error
+	if( argv[optionCount][0] == '-' ){
+		if( strcmp( argv[optionCount], "-" ) == 0 )streamout = true;
+		else {
+			WriteLine ("Option error. Run without arguments for help.");
+			exit (1);
+		}
+	}
+	
 	if (bottomDefault != -1 && preAlign == false) {
 		WriteLine ("Please enable automatic alignment (\"--align\") before using the");
 		WriteLine ("--bottom-is-* options. Thank you. Run \"autopano.exe\" without");
@@ -688,7 +703,7 @@
 	}
 
 	FILE* pto;
-	if (argv[optionCount] == "-") {
+	if ( streamout ) {
 		pto = stdout;
 	} else {
 		WriteLine ("Creating output file \"%s\"", argv[optionCount]);
@@ -702,7 +717,7 @@
 	ArrayList_delete(components);
 	BondBall_delete(bb);
 	MultiMatch_delete(mm);
-	if (argv[optionCount] != "-")
+	if ( !streamout )
 		fclose(pto);
 	return 0;
 }