patacongo commented on a change in pull request #2326:
URL: https://github.com/apache/incubator-nuttx/pull/2326#discussion_r527858513



##########
File path: libs/libc/unistd/lib_getopt.c
##########
@@ -39,257 +39,565 @@
 
 #include <nuttx/config.h>
 
-#include <stdbool.h>
-#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
+#include <getopt.h>
 
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
 
+#define PERMUTE                 0
+#define RETURN_IN_ORDER         1
+#define REQUIRE_ORDER           2
+
 /****************************************************************************
- * Public Data
+ * Private Type Definitions
  ****************************************************************************/
 
-FAR char *optarg; /* Optional argument following option */
-int optind = 1;   /* Index into argv */
-int optopt = '?'; /* unrecognized option character */
+typedef struct getopt_data_s
+{
+  FAR char *optarg;
+  int optind;
+  int opterr;
+  int optopt;
+  int optwhere;
+  int permute_from;
+  int num_nonopts;
+} getopt_data_t;
 
 /****************************************************************************
  * Private Data
  ****************************************************************************/
 
-static FAR char         *g_optptr       = NULL;
-static FAR char * const *g_argv         = NULL;
-static int               g_argc         = 0;
-static bool              g_binitialized = false;
+static int optwhere = 1;
+static int permute_from = 0;
+static int num_nonopts = 0;
+
+static int prev_argc;
+static FAR char *const *prev_argv;

Review comment:
       I suppose that these could be similarly int16_t.
   
   Also, there is a violation in the naming convertion:  The coding standard 
requires that all global varialbes (i.e., variables with scope beyond a 
function) must begin with the prefix g_  This is important.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to