help-gengetopt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [help-gengetopt] make cmd_line_list and cmd_line_list_tmp static?


From: Lorenzo Bettini
Subject: Re: [help-gengetopt] make cmd_line_list and cmd_line_list_tmp static?
Date: Sun, 09 Apr 2006 21:47:45 +0200
User-agent: Mail/News 1.5 (X11/20060228)

Lorenzo Bettini wrote:
I think the right behavior is to go back to optind = 1

Of course I'll document this fact (and also add an example of using more parsers following the example you sent me).

by the way, I'd use this alternative split function (that detects multiple spaces):

unsigned my_split_args(char *args, char ***argv_ptr)
{
        char *p = args;
        char **argv;
        size_t n = 0, i, j;

        while ((i = strcspn(p, " \t")) && (p += i)) {
                p += strspn(p, " \t");
                n++;
        }
        *argv_ptr = malloc((n + 1) * sizeof(char *));
        argv = *argv_ptr;
        i = 0;
        p = args;
        while (p) {
                argv[i] = p;
                j = strcspn(p, " \t");
                if (j) {
                  p += strcspn(p, " \t");
                  *p = '\0';
                  p++;
                  p += strspn(p, " \t");
                  i++;
                } else {
                  break;
                }
        }
        argv[n] = NULL;
        return n;
}


--
+-----------------------------------------------------+
|  Lorenzo Bettini          ICQ# lbetto, 16080134     |
|  PhD in Computer Science                            |
|  Dip. Sistemi e Informatica, Univ. di Firenze       |
|  Florence - Italy        (GNU/Linux User # 158233)  |
|  Home Page        : http://www.lorenzobettini.it    |
|  http://music.dsi.unifi.it         XKlaim language  |
|  http://www.purplesucker.com Deep Purple Cover Band |
|  http://www.gnu.org/software/src-highlite           |
|  http://www.gnu.org/software/gengetopt              |
|  http://www.lorenzobettini.it/software/gengen       |
|  http://www.lorenzobettini.it/software/doublecpp    |
+-----------------------------------------------------+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]