Changeset 41340 for trunk/Ohana/src/opihi/cmd.data/create.c
- Timestamp:
- Apr 16, 2020, 1:54:47 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/cmd.data/create.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.data/create.c
r41269 r41340 7 7 Vector *vec; 8 8 9 // create a vector of empty strings10 if ((N = get_argument (argc, argv, "-str"))) {11 remove_argument (N, &argc, argv);12 13 char *stringValue = NULL;14 if ((N = get_argument (argc, argv, "-value"))) {15 remove_argument (N, &argc, argv);16 stringValue = strcreate (argv[N]);17 remove_argument (N, &argc, argv);18 }19 20 if (argc != 3) {21 gprint (GP_ERR, "USAGE: create vector Nelements -value word\n");22 return (FALSE);23 }24 25 if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) return (FALSE);26 int Nelements = atoi (argv[2]);27 28 // a newly reset vector has NULL-valued pointers29 ResetVector (vec, OPIHI_STR, Nelements);30 for (int i = 0; i < Nelements; i++) {31 vec[0].elements.Str[i] = stringValue ? strcreate (stringValue) : strcreate ("");32 }33 return TRUE;34 }35 36 9 INT = FALSE; 37 10 if ((N = get_argument (argc, argv, "-int"))) { … … 43 16 gprint (GP_ERR, "USAGE: create vector start end [delta] [-int]\n"); 44 17 gprint (GP_ERR, " -int : resulting vector is integer type (delta must be integer)\n"); 45 gprint (GP_ERR, " -str : resulting vector is string type (only give number of elements)\n");46 18 return (FALSE); 47 19 }
Note:
See TracChangeset
for help on using the changeset viewer.
