/[mailutils]/mailutils/lib/argcv.c
ViewVC logotype

Diff of /mailutils/lib/argcv.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by gray, Fri Feb 22 13:16:22 2002 UTC revision 1.11 by gray, Sat Feb 23 10:01:35 2002 UTC
# Line 19  Line 19 
19    
20  #include "argcv.h"  #include "argcv.h"
21    
 char srtime[] = __TIME__;  
   
22  /*  /*
23   * takes a string and splits it into several strings, breaking at ' '   * takes a string and splits it into several strings, breaking at ' '
24   * command is the string to split   * command is the string to split
# Line 43  argcv_scan (int len, const char *command Line 41  argcv_scan (int len, const char *command
41        i = *save;        i = *save;
42    
43        if (i >= len)        if (i >= len)
44          return i;          return i + 1;
45    
46        /* Skip initial whitespace */        /* Skip initial whitespace */
47        while (i < len && isws (command[i]))        while (i < len && isws (command[i]))
# Line 102  argcv_get (const char *command, const ch Line 100  argcv_get (const char *command, const ch
100    *argv = NULL;    *argv = NULL;
101    
102    /* Count number of arguments */    /* Count number of arguments */
103    *argc = 1;    *argc = 0;
104    save = 0;    save = 0;
105    
106    while (argcv_scan (len, command, delim, cmnt, &start, &end, &save) < len)    while (argcv_scan (len, command, delim, cmnt, &start, &end, &save) <= len)
107        (*argc)++;        (*argc)++;
108    
109    *argv = calloc ((*argc + 1), sizeof (char *));    *argv = calloc ((*argc + 1), sizeof (char *));
# Line 198  argcv_string (int argc, char **argv, cha Line 196  argcv_string (int argc, char **argv, cha
196  }  }
197    
198  #if 0  #if 0
199  char *command = "set prompt=\"& \"";  char *command = "set prompt=\"& \" ";
200    
201  main()  main(int xargc, char **xargv)
202  {  {
203    int i, argc;    int i, argc;
204    char **argv;    char **argv;
205    
206    argcv_get (command, "=", NULL, &argc, &argv);    argcv_get (xargv[1] ? xargv[1]:command, "=", "#", &argc, &argv);
207    printf ("%d args:\n", argc);    printf ("%d args:\n", argc);
208    for (i = 0; i < argc; i++)    for (i = 0; i < argc; i++)
209      printf ("%s\n", argv[i]);      printf ("%s\n", argv[i]);

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26