extern int scols_table_enable_export(struct libscols_table *tb, int enable);
extern int scols_table_enable_maxout(struct libscols_table *tb, int enable);
-extern int scols_table_set_column_separator(struct libscols_table *tb, char *sep);
-extern int scols_table_set_line_separator(struct libscols_table *tb, char *sep);
+extern int scols_table_set_column_separator(struct libscols_table *tb, const char *sep);
+extern int scols_table_set_line_separator(struct libscols_table *tb, const char *sep);
extern struct libscols_table *scols_new_table(void);
extern void scols_ref_table(struct libscols_table *tb);
*
* Returns: 0, a negative value in case of an error.
*/
-int scols_table_set_column_separator(struct libscols_table *tb, char *sep)
+int scols_table_set_column_separator(struct libscols_table *tb, const char *sep)
{
+ char *p = NULL;
+
assert (tb);
if (!tb)
return -EINVAL;
- sep = strdup(sep);
- if (!sep)
- return -ENOMEM;
+ if (sep) {
+ p = strdup(sep);
+ if (!p)
+ return -ENOMEM;
+ }
free(tb->colsep);
- tb->colsep = sep;
-
+ tb->colsep = p;
return 0;
}
*
* Returns: 0, a negative value in case of an error.
*/
-int scols_table_set_line_separator(struct libscols_table *tb, char *sep)
+int scols_table_set_line_separator(struct libscols_table *tb, const char *sep)
{
+ char *p = NULL;
+
assert (tb);
if (!tb)
return -EINVAL;
- sep = strdup(sep);
- if (!sep)
- return -ENOMEM;
+ if (sep) {
+ p = strdup(sep);
+ if (!p)
+ return -ENOMEM;
+ }
free(tb->linesep);
- tb->linesep = sep;
-
+ tb->linesep = p;
return 0;
}
notree = 1;
break;
case 'c':
- scols_table_set_line_separator(tb, ",");
- /* a column separator should always take up one cell */
- scols_table_set_column_separator(tb, ":");
+ scols_table_set_column_separator(tb, ",");
scols_table_enable_raw(tb, 1);
+ notree = 1;
break;
case 'C':
clonetb = 1;