#endif
#if CCUNIT_HAVE_GETOPT_LONG
-# define LONGOPTNAME(LO) "--" #LO " | " /**< long name option */
+# define LONGOPTNAME(LO) " --" #LO "\n" /**< long name option */
#else
# define LONGOPTNAME(LO) /* -- LO | */ /**< long name option */
#endif
* @{
*/
+/**
+ * print help massage.
+ * @param progname program name.
+ */
+static void usage (const char* progname)
+{
+ fprintf (stdout,
+ "%s\n"
+ " USAGE: %s [OPTIONS] FILES...\n"
+ " OPTION:\n"
+ LONGOPTNAME(output OUTFILE)
+ " -o OUTFILE\n"
+ " output file name (default stdout)\n"
+ LONGOPTNAME(function FUNCTION)
+ " -f FUNCTION\n"
+ " created function name\n"
+ LONGOPTNAME(verbose)
+ " -v\n"
+ " output verbose message\n"
+ LONGOPTNAME(debug)
+ " -d\n"
+ " output debug message\n"
+ LONGOPTNAME(version)
+ " -V\n"
+ " print version\n"
+ LONGOPTNAME(help)
+ " -h\n"
+ " print this message\n"
+ , CCUNIT_PACKAGE_STRING, progname);
+}
+
int ccunit_makeSuite (int ac, char** av)
{
CCUnitTestSuiteDef* suite;
fprintf (stdout, "%s - %s\n", CCUNIT_PACKAGE_STRING, progname);
return 0;
case 'h':
- fprintf (stdout,
- "%s\n"
- " USAGE: %s [OPTIONS] FILES...\n"
- " OPTION:\n"
- " " LONGOPTNAME(output) "-o OUTFILE\n"
- " output file name (default stdout)\n"
- " " LONGOPTNAME(function) "-f FUNCTION\n"
- " created function name\n"
- " " LONGOPTNAME(verbose) "-v\n"
- " output verbose message\n"
- " " LONGOPTNAME(debug) "-d\n"
- " output debug message\n"
- " " LONGOPTNAME(version) "-V\n"
- " print version\n"
- " " LONGOPTNAME(help) "-h\n"
- " print this message\n"
- , CCUNIT_PACKAGE_STRING, progname);
- return 1;
+ usage (progname);
+ return 0;
case '?':
fprintf (stderr, "unknown option %s\n", av[optind]);
return 1;
return 1;
}
}
+ if (optind >= ac)
+ {
+ usage (progname);
+ return 0;
+ }
suite = ccunit_newTestSuiteDef (NULL);
if (!suite)
{
SETVBUF(ofp, NULL, _IONBF, 0);
SETVBUF(stderr, NULL, _IONBF, 0);
/* process source files */
- if (optind >= ac)
- ccunit_readSuite ("-", suite);
- else
- for (; optind < ac; optind ++)
- ccunit_readSuite (av[optind], suite);
+ for (; optind < ac; optind ++)
+ ccunit_readSuite (av[optind], suite);
ccunit_writeSuite (ofp, functionName, suite);
if (ofp != stdout)
fclose (ofp);