• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonrubyphpgameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

POSIX.1 National Language Support API for MinGW


Commit MetaInfo

修訂a784c945a39524e7d248c53f38c0dc13dcd8ce0d (tree)
時間2008-01-13 03:01:42
作者Keith Marshall <keithmarshall@user...>
CommiterKeith Marshall

Log Message

* gencat.c: Force an abort, with appropriate diagnostic, on parsing an unrecognised command line option.

Change Summary

差異

--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
1+2008-01-12 Keith Marshall <keithmarshall@users.sourceforge.net>
2+
3+ * gencat.c: Force an abort, with appropriate diagnostic, on parsing an
4+ unrecognised command line option.
5+
16 2008-01-11 Keith Marshall <keithmarshall@users.sourceforge.net>
27
38 Make replacement `getopt' function module more GNU compatible.
--- a/gencat.c
+++ b/gencat.c
@@ -8,7 +8,7 @@
88 * This file implements the `main' function for the `gencat' program.
99 *
1010 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
11- * Last modification: 09-Jan-2008
11+ * Last modification: 12-Jan-2008
1212 *
1313 *
1414 * This is free software. It is provided AS IS, in the hope that it may
@@ -175,12 +175,20 @@ int main( int argc, char **argv )
175175 */
176176 banner_printf( print_top_banner + print_nl_duplicate, COPYRIGHT_NOTICE );
177177 exit( EXIT_SUCCESS );
178+
179+ case '?':
180+ /*
181+ * This means the user specified an unrecognised option...
182+ * continue parsing, to catch other possible errors, but flag it,
183+ * so we can bail out before processing any message catalogue.
184+ */
185+ gencat_errno = opt;
178186 }
179187
180188 progname = *argv;
181189 cat_index.id = tag;
182190
183- if( (argc -= optind) > 1 )
191+ if( ((argc -= optind) > 1) && (gencat_errno == 0) )
184192 {
185193 /* Establish the message catalogue name, recognising `/dev/stdout'
186194 * as an alias for `-', representing the standard output stream.
@@ -381,10 +389,18 @@ int main( int argc, char **argv )
381389 }
382390
383391 else
384- { /* User specified insufficient command line arguments.
385- * Diagnose, and bail out.
392+ { /* An error was detected, while parsing the command line...
393+ */
394+ if( argc < 2 )
395+ /*
396+ * User specified insufficient command line arguments.
397+ */
398+ fprintf( errmsg( MSG_MISSING_ARGS ), progname );
399+
400+ /* In any case, (it may have been an unrecognised option,
401+ * which was previously diagnosed), display the usage summary,
402+ * and bail out.
386403 */
387- fprintf( errmsg( MSG_MISSING_ARGS ), progname );
388404 fprintf( errmsg( MSG_GENCAT_USAGE ), progname );
389405 return EXIT_FAILURE;
390406 }
@@ -393,4 +409,4 @@ int main( int argc, char **argv )
393409 return EXIT_SUCCESS;
394410 }
395411
396-/* $RCSfile$Revision: 1.5 $: end of file */
412+/* $RCSfile$Revision: 1.6 $: end of file */