This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Tarantool -- an efficient key/value data store".
The branch core-help has been updated
via ba71da768ad562e3a0c4146521942f8e7b075325 (commit)
from 3ef3176a37b12368b742ba05b831beea4c6db8ea (commit)
Summary of changes:
third_party/gopt/gopt.c | 18 +++++++++---------
third_party/gopt/gopt.h | 38 ++++++++++++++++++++++----------------
2 files changed, 31 insertions(+), 25 deletions(-)
commit ba71da768ad562e3a0c4146521942f8e7b075325
Author: Konstantin Osipov <[email protected]>
Date: Mon Dec 20 17:45:43 2010 +0300
Bug#684700 -h and --help options are broken
Style edits of gopt option library:
add API comments, remove trailing spaces.
diff --git a/third_party/gopt/gopt.c b/third_party/gopt/gopt.c
index 3f9e3bb..ff16a79 100644
--- a/third_party/gopt/gopt.c
+++ b/third_party/gopt/gopt.c
@@ -75,7 +75,7 @@ void *gopt_sort( int *argc, const char **argv, const void
*opt_specs ){
if( ! opts ){
perror( argv[0] );
exit( EX_OSERR );
- }
+ }
for( ; *arg_p; ++arg_p )
if( '-' == (*arg_p)[0] && (*arg_p)[1] )
if( '-' == (*arg_p)[1] )
@@ -114,11 +114,11 @@ void *gopt_sort( int *argc, const char **argv, const void
*opt_specs ){
if( ! next_option-> key ){
fprintf( stderr, "%s: --%.*s: unknown option\n", argv[0],
(int)strcspn( (*arg_p) + 2, "=" ), (*arg_p) + 2 );
free( opts );
- exit( EX_USAGE );
+ exit( EX_USAGE );
}
for( opt_spec_p= opt_specs; opt_spec_p-> key != next_option-> key;
++opt_spec_p );
found_long:
-
+
if( !( opt_spec_p-> flags & GOPT_REPEAT )){
const opt_t *opt_p= opts;
for( ; opt_p != next_option; ++opt_p )
@@ -160,7 +160,7 @@ void *gopt_sort( int *argc, const char **argv, const void
*opt_specs ){
const char *short_opt= (*arg_p) + 1;
for( ;*short_opt; ++short_opt ){
const opt_spec_t *opt_spec_p= opt_specs;
-
+
for( ; opt_spec_p-> key; ++opt_spec_p )
if( strchr( opt_spec_p-> shorts, *short_opt )){
if( !( opt_spec_p-> flags & GOPT_REPEAT )){
@@ -177,7 +177,7 @@ void *gopt_sort( int *argc, const char **argv, const void
*opt_specs ){
if( opt_spec_p-> flags & GOPT_ARG ){
if( short_opt[1] )
next_option-> arg= short_opt + 1;
-
+
else {
++arg_p;
if( !*arg_p || '-' == (*arg_p)[0] && (*arg_p)[1] ){
@@ -223,7 +223,7 @@ size_t gopt( const void *vptr_opts, int key ){
size_t gopt_arg( const void *vptr_opts, int key, const char **arg ){
const opt_t *opts= vptr_opts;
size_t count= 0;
-
+
for( ; opts-> key; ++opts )
if( opts-> key == key ){
if( ! count )
@@ -235,11 +235,11 @@ size_t gopt_arg( const void *vptr_opts, int key, const
char **arg ){
const char *gopt_arg_i( const void *vptr_opts, int key, size_t i ){
const opt_t *opts= vptr_opts;
-
+
for( ; opts-> key; ++opts )
if( opts-> key == key ){
if( ! i )
- return opts-> arg;
+ return opts-> arg;
--i;
}
return NULL;
@@ -254,7 +254,7 @@ size_t gopt_args( const void *vptr_opts, int key, const
char **args, size_t args
if( opts-> key == key ){
if( args_stop == args_ptr )
return args_len + gopt( opts, key );
-
+
*args_ptr++= opts-> arg;
}
if( args_stop != args_ptr )
diff --git a/third_party/gopt/gopt.h b/third_party/gopt/gopt.h
index 441e8b1..c2a7f7b 100644
--- a/third_party/gopt/gopt.h
+++ b/third_party/gopt/gopt.h
@@ -31,34 +31,40 @@ read http://www.purposeful.co.uk/tfl/
#define gopt_longs( ... ) (const char**)(const char*[]){ __VA_ARGS__,
NULL }
+/** Returns a pointer for use in the following calls. Prints to
+ * stderr and call exit() on error.
+ */
void *gopt_sort( int *argc, const char **argv, const void *opt_specs );
-/* returns a pointer for use in the following calls
- * prints to stderr and call exit() on error
+
+/** Returns the number of times the option was specified which
+ * will be 0 or 1 unless GOPT_REPEAT was used.
*/
size_t gopt( const void *opts, int key );
-/* returns the number of times the option was specified
- * which will be 0 or 1 unless GOPT_REPEAT was used
+
+/** Returns the number of times the option was specified writes
+ * a pointer to the option argument from the first (or only)
+ * occurrence to *arg.
*/
size_t gopt_arg( const void *opts, int key, const char **arg );
-/* returns the number of times the option was specified
- * writes a pointer to the option argument from the first (or only) occurance
to *arg
+
+/** Returns a pointer to the ith (starting at zero) occurrence of
+ * the option, or NULL if it was not specified that many times.
*/
const char *gopt_arg_i( const void *opts, int key, size_t i );
-/* returns a pointer to the ith (starting at zero) occurance
- * of the option, or NULL if it was not specified that many times
+
+/** Returns the number of times the option was specified writes
+ * pointers to the option arguments in the order of occurrence to
+ * args[]. Writes at most args_len pointers if the return value is
+ * less than args_len, also writes a null pointer.
*/
size_t gopt_args( const void *opts, int key, const char **args, size_t
args_len );
-/* returns the number of times the option was specified
- * writes pointers to the option arguments in the order of occurance to args[].
- * writes at most args_len pointers
- * if the return value is less than args_len, also writes a null pointer
+
+/** Releases memory allocated in the corresponding call to
+ * gopt_sort(); opts can no longer be used.
*/
void gopt_free( void *opts );
-/* releases memory allocated in the corresponding call to gopt_sort()
- * opts can no longer be used
- */
+/** Prints descriptions for all options. */
void gopt_help(const void *opt_def);
-/* prints options description */
#endif /* GOPT_H_INCLUDED */
--
Tarantool -- an efficient key/value data store
_______________________________________________
Mailing list: https://launchpad.net/~tarantool-developers
Post to : [email protected]
Unsubscribe : https://launchpad.net/~tarantool-developers
More help : https://help.launchpad.net/ListHelp