optparse icon indicating copy to clipboard operation
optparse copied to clipboard

add argc to struct optparse

Open ComerLater opened this issue 1 year ago • 0 comments

struct optparse结构体原始定义里面没有argc,optparse()函数根据option==0来判断argv[]是否解析结束了,这样是判断会存在隐患

int optparse(struct optparse *options, const char *optstring)
{
    int type;
    char *next;
    char *option = options->argv[options->optind];
    options->errmsg[0] = '\0';
    options->optopt = 0;
    options->optarg = 0;
    if (option == 0)

本次提交在struct optparse中增加了argc,并修改optparse_init()和optparse(),增加了根据argc来判断是否解析结束。

ComerLater avatar Jul 23 '23 07:07 ComerLater