Clarify fpurge's effect on the file position.
[gnulib.git] / tests / test-argp.c
index f33cb7c..2831dc1 100644 (file)
@@ -2,23 +2,20 @@
    Copyright (C) 2006-2007 Free Software Foundation, Inc.
    This file is part of the GNUlib Library.
 
-   This program is free software; you can redistribute it and/or modify
+   This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
-   You should have received a copy of the GNU General Public License along
-   with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
+#include <config.h>
 
 #include "argp.h"
 
@@ -30,6 +27,7 @@
 #if HAVE_STRINGS_H
 # include <strings.h>
 #endif
+#include "progname.h"
 
 struct test_args
 {
@@ -44,12 +42,12 @@ struct test_args
   int group_1_1_option;
 };
 
-static struct argp_option group1_option[] = 
+static struct argp_option group1_option[] =
 {
   { NULL, 0, NULL, 0, "Option Group 1", 0},
   { "verbose", 'v', NULL, 0, "Simple option without arguments", 1 },
   { "file", 'f', "FILE", 0, "Option with a mandatory argument", 1 },
-  { "input", 0, NULL, OPTION_ALIAS, NULL, 1 }, 
+  { "input", 0, NULL, OPTION_ALIAS, NULL, 1 },
   { "hidden", 'H', "FILE", OPTION_HIDDEN, "Hidden option", 1 },
   { NULL, 0, NULL, 0, NULL, 0 }
 };
@@ -64,15 +62,15 @@ group1_parser (int key, char *arg, struct argp_state *state)
     case 'v':
       args->verbose++;
       break;
-      
+
     case 'f':
       args->file = arg;
       break;
-      
+
     case 'H':
       args->hidden = arg;
       break;
-      
+
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -92,7 +90,7 @@ struct argp_child group1_child = {
 };
 
 \f
-static struct argp_option group1_1_option[] = 
+static struct argp_option group1_1_option[] =
 {
   { NULL, 0, NULL, 0, "Option Group 1.1", 0},
   { "cantiga", 'C', NULL, 0, "create a cantiga" },
@@ -129,7 +127,7 @@ struct argp_child group1_1_child = {
 };
 
 \f
-static struct argp_option group2_option[] = 
+static struct argp_option group2_option[] =
 {
   { NULL, 0, NULL, 0, "Option Group 2", 0},
   { "option", 'O', NULL, 0, "An option", 1 },
@@ -151,12 +149,12 @@ group2_parser (int key, char *arg, struct argp_state *state)
     case 'O':
       args->opt = 1;
       break;
-      
+
     case 'o':
       args->optional_set = 1;
       args->optional = arg;
       break;
-      
+
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -176,7 +174,7 @@ struct argp_child group2_child = {
 };
 
 \f
-static struct argp_option group2_1_option[] = 
+static struct argp_option group2_1_option[] =
 {
   { NULL, 0, NULL, 0, "Option Group 2.1", 0},
   { "poem", 'p', NULL, 0, "create a poem" },
@@ -211,12 +209,12 @@ struct argp_child group2_1_child = {
   "",
   2
 };
-         
+
 \f
 static struct argp_option main_options[] =
   {
     { NULL, 0, NULL, 0, "Main options", 0},
-    { "test", 't', NULL, 0, NULL, 1 }, 
+    { "test", 't', NULL, 0, NULL, 1 },
     { NULL, 0, NULL, 0, NULL, 0 }
   };
 
@@ -225,7 +223,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
 {
   struct test_args *args = state->input;
   int i;
-  
+
   switch (key)
     {
     case ARGP_KEY_INIT:
@@ -236,7 +234,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
     case 't':
       args->test = 1;
       break;
-      
+
     default:
       return ARGP_ERR_UNKNOWN;
     }
@@ -402,7 +400,7 @@ test10(struct argp *argp)
   INIT_TEST2 (10, "--optional", "ARG");
   test_optional(argp, argc, argv, &test_args, NULL, "ARG");
 }
-  
+
 void
 test11(struct argp *argp)
 {
@@ -415,7 +413,7 @@ test12(struct argp *argp)
 {
   INIT_TEST3 (12, "--option", "--optional=OPT", "FILE");
   test_optional(argp, argc, argv, &test_args, "OPT", "FILE");
-}  
+}
 
 void
 test13(struct argp *argp)
@@ -464,7 +462,7 @@ main (int argc, char **argv)
   group2_children[0] = group2_1_child;
   group2_children[1].argp = NULL;
   group2_argp.children = group2_children;
-  
+
   argp_children[0] = group1_child;
   argp_children[1] = group2_child;
   argp_children[2].argp = NULL;
@@ -472,11 +470,11 @@ main (int argc, char **argv)
 
   if (argc > 0)
     {
-      struct test_args test_args;    
-      init_args(test_args);          
+      struct test_args test_args;
+      init_args(test_args);
       return argp_parse (&test_argp, argc, argv, 0, NULL, &test_args);
     }
-  
+
   for (fun = test_fun; *fun; fun++)
     (*fun) (&test_argp);