Changeset d275eb2 for variable.c
- Timestamp:
- Jan 2, 2011, 3:31:58 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- 2bc6ad35
- Parents:
- f640876
- git-author:
- David Benjamin <davidben@mit.edu> (12/15/10 13:18:34)
- git-committer:
- David Benjamin <davidben@mit.edu> (01/02/11 15:31:58)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
variable.c
rbc14adc rd275eb2 952 952 int nenums, val; 953 953 if (newval == NULL) return(0); 954 enums = atokenize(v->validsettings, ",", &nenums);955 if (enums == NULL) return(0);956 atokenize_delete(enums, nenums);954 enums = g_strsplit_set(v->validsettings, ",", 0); 955 nenums = g_strv_length(enums); 956 g_strfreev(enums); 957 957 val = *(const int*)newval; 958 958 if (val < 0 || val >= nenums) { … … 964 964 int owl_variable_enum_set_fromstring(owl_variable *v, const char *newval) { 965 965 char **enums; 966 int nenums,i, val=-1;966 int i, val=-1; 967 967 if (newval == NULL) return(-1); 968 enums = atokenize(v->validsettings, ",", &nenums); 969 if (enums == NULL) return(-1); 970 for (i=0; i<nenums; i++) { 968 enums = g_strsplit_set(v->validsettings, ",", 0); 969 for (i = 0; enums[i] != NULL; i++) { 971 970 if (0==strcmp(newval, enums[i])) { 972 971 val = i; 973 972 } 974 973 } 975 atokenize_delete(enums, nenums);974 g_strfreev(enums); 976 975 if (val == -1) return(-1); 977 976 return (v->set_fn(v, &val)); … … 986 985 return -1; 987 986 } 988 enums = atokenize(v->validsettings, ",", &nenums); 987 enums = g_strsplit_set(v->validsettings, ",", 0); 988 nenums = g_strv_length(enums); 989 989 i = *(const int*)val; 990 990 if (i<0 || i>=nenums) { 991 991 snprintf(buf, bufsize, "<invalid:%d>",i); 992 atokenize_delete(enums, nenums);992 g_strfreev(enums); 993 993 return(-1); 994 994 } 995 995 snprintf(buf, bufsize, "%s", enums[i]); 996 atokenize_delete(enums, nenums);996 g_strfreev(enums); 997 997 return 0; 998 998 }
Note: See TracChangeset
for help on using the changeset viewer.