First of all, please show some respect and don't mess up coding
style of existing source files.
Second, when all parsing functions in xtypes.h use a common name
for the input string, just use it, too.
return "";
}
-int xtype_unit_parser(const char *units_str, struct unit_definition *units_def)
+int xtype_unit_parser(const char *str, struct unit_definition *units)
{
- int i = 0;
- while(units_def[i].unit != NULL) {
- if(strcmp(units_str, units_def[i].unit) == 0) {
+ for (int i=0; units[i].unit; i++)
+ if (!strcmp(str, units[i].unit))
return i;
- }
- i++;
- }
-
return -1;
}
};
/**
- * Parses a unit definition in units_str and returns index into units_def array. -1 if the units
- * were not contained in the array.
+ * Parse a name of a unit and return its index in the @units array or -1
+ * if is not present there.
**/
-int xtype_unit_parser(const char *units_str, struct unit_definition *units_def);
+int xtype_unit_parser(const char *str, struct unit_definition *units);
/**
* This structure describes an xtype. Among other things, it points to callback