caml_raise_with_args (*exn, 4, args);
}
+static const char *
+Optstring_val (value strv)
+{
+ if (strv == Val_int (0)) /* None */
+ return NULL;
+ else /* Some string */
+ return String_val (Field (strv, 0));
+}
+
/* Map OCaml flags to C flags. */
static const int flag_map[] = {
/* AugSaveBackup */ AUG_SAVE_BACKUP,
{
CAMLparam1 (rootv);
const char *root = String_val (rootv);
- const char *loadpath;
+ const char *loadpath = Optstring_val (loadpathv);
int flags = 0, i;
augeas_t t;
- /* Optional loadpath. */
- loadpath =
- loadpathv == Val_int (0)
- ? NULL
- : String_val (Field (loadpathv, 0));
-
/* Convert list of flags to C. */
for (; flagsv != Val_int (0); flagsv = Field (flagsv, 1)) {
i = Int_val (Field (flagsv, 0));
CAMLparam3 (tv, pathv, valuev);
augeas_t t = Augeas_t_val (tv);
const char *path = String_val (pathv);
- const char *val;
-
- val =
- valuev == Val_int (0)
- ? NULL
- : String_val (Field (valuev, 0));
+ const char *val = Optstring_val (valuev);
if (aug_set (t, path, val) == -1)
raise_error (t, "Augeas.set");