--- /dev/null
+/*
+ * FML interpreter. Europagate, 1995
+ *
+ * $Log: fmlstr.c,v $
+ * Revision 1.1 1995/02/10 18:15:53 adam
+ * FML function 'strcmp' implemented. This function can be used to
+ * test for existence of MARC fields.
+ *
+ */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "fmlp.h"
+
+static struct fml_node *fml_exec_strcmp (Fml fml, struct fml_node **lp,
+ struct token *tp)
+{
+ char *arg;
+ struct fml_node *fn = NULL, *fn1, *fn2;
+ int n;
+
+ fml_cmd_lex (lp, tp);
+
+ fn1 = fml_expr_term (fml, lp, tp);
+ fn2 = fml_expr_term (fml, lp, tp);
+ if (!fn1->is_atom && !fn2->is_atom)
+ fn = NULL;
+ n = fml_atom_cmp (fml, fn1->p[0], fn2->p[0]);
+ if (n == 0)
+ arg = "0";
+ else if (n > 0)
+ arg = "1";
+ else
+ arg = "-1";
+ fn = fml_node_alloc (fml);
+ fn->is_atom = 1;
+ fn->p[0] = fml_atom_alloc (fml, arg);
+ return fn;
+}
+
+void fml_str_init (Fml fml)
+{
+ struct fml_sym_info *sym_info;
+
+ sym_info = fml_sym_add (fml->sym_tab, "strcmp");
+ sym_info->kind = FML_CPREFIX;
+ sym_info->prefix = fml_exec_strcmp;
+}