test for existence of MARC fields.
# FML interpreter. Europagate, 1995
#
-# $Id: Makefile,v 1.5 1995/02/10 17:21:44 adam Exp $
+# $Id: Makefile,v 1.6 1995/02/10 18:15:51 adam Exp $
SHELL=/bin/sh
INCLUDE=-I../include -I.
DEFS=$(INCLUDE)
LIB=fml.a
PO = fmltoken.o fmlmem.o fml.o fmlsym.o fmlrel.o fmlarit.o fmllist.o \
-fmlcall.o fmlcalls.o fmlmarc.o
+fmlcall.o fmlcalls.o fmlmarc.o fmlstr.o
CPP=cc -E
CC=gcc
* FML interpreter. Europagate, 1995
*
* $Log: fml.c,v $
- * Revision 1.7 1995/02/10 15:50:54 adam
+ * Revision 1.8 1995/02/10 18:15:52 adam
+ * FML function 'strcmp' implemented. This function can be used to
+ * test for existence of MARC fields.
+ *
+ * Revision 1.7 1995/02/10 15:50:54 adam
* MARC interface implemented. Minor bugs fixed. fmltest can
* be used to format single MARC records. New function '\list'
* implemented.
fml_list_init (fml);
fml_arit_init (fml);
fml_rel_init (fml);
+ fml_str_init (fml);
sym_info = fml_sym_add (fml->sym_tab, "s");
sym_info->kind = FML_CPREFIX;
* FML interpreter. Europagate, 1995
*
* $Log: fmlmem.c,v $
- * Revision 1.5 1995/02/09 14:37:18 adam
+ * Revision 1.6 1995/02/10 18:15:52 adam
+ * FML function 'strcmp' implemented. This function can be used to
+ * test for existence of MARC fields.
+ *
+ * Revision 1.5 1995/02/09 14:37:18 adam
* Removed .depend from cvs. Removed function fml_mk_list.
*
* Revision 1.4 1995/02/09 14:33:37 adam
return a0;
}
+int fml_atom_cmp (Fml fml, struct fml_atom *a1, struct fml_atom *a2)
+{
+ while (a1 && a2)
+ {
+ int n;
+ n = strncmp (a1->buf, a2->buf, FML_ATOM_BUF);
+ if (n)
+ return n;
+ a1 = a1->next;
+ a2 = a2->next;
+ }
+ if (!a1 && !a2)
+ return 0;
+ if (a1)
+ return 1;
+ return -1;
+}
+
int fml_atom_str (struct fml_atom *a, char *str)
{
int len = 0;
* FML interpreter. Europagate, 1995
*
* $Log: fmlp.h,v $
- * Revision 1.7 1995/02/10 15:50:56 adam
+ * Revision 1.8 1995/02/10 18:15:52 adam
+ * FML function 'strcmp' implemented. This function can be used to
+ * test for existence of MARC fields.
+ *
+ * Revision 1.7 1995/02/10 15:50:56 adam
* MARC interface implemented. Minor bugs fixed. fmltest can
* be used to format single MARC records. New function '\list'
* implemented.
void fml_node_delete (Fml fml, struct fml_node *fn);
struct fml_node *fml_node_copy (Fml fml, struct fml_node *fn);
struct fml_node *fml_mk_node_val (Fml fml, int val);
+int fml_atom_cmp (Fml fml, struct fml_atom *a1, struct fml_atom *a2);
struct token {
int kind;
void fml_rel_init (Fml fml);
void fml_arit_init (Fml fml);
void fml_list_init (Fml fml);
+void fml_str_init (Fml fml);
void fml_lr_values (Fml fml, struct fml_node *l, int *left_val,
struct fml_node *r, int *right_val);
void fml_cmd_lex (struct fml_node **np, struct token *tp);
--- /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;
+}
* FML interpreter. Europagate, 1995
*
* $Log: fmltoken.c,v $
- * Revision 1.3 1995/02/10 15:50:57 adam
+ * Revision 1.4 1995/02/10 18:15:53 adam
+ * FML function 'strcmp' implemented. This function can be used to
+ * test for existence of MARC fields.
+ *
+ * Revision 1.3 1995/02/10 15:50:57 adam
* MARC interface implemented. Minor bugs fixed. fmltest can
* be used to format single MARC records. New function '\list'
* implemented.
fml_pr_list (p);
printf ("\n");
}
+ if (look_char != fml->eof_mark)
+ {
+ fprintf (stderr, "Ill formed parantheses");
+ exit (1);
+ }
return p;
}
while (look_char != fml->eof_mark && look_char != '\'')
{
lex_buf[off++] = look_char;
+ if (look_char == '\\')
+ {
+ look_char = (*fml->read_func)();
+ switch (look_char)
+ {
+ case 'n':
+ lex_buf[off-1] = '\n';
+ break;
+ case 't':
+ lex_buf[off-1] = '\n';
+ break;
+ case '\'':
+ lex_buf[off-1] = '\'';
+ break;
+ default:
+ lex_buf[off-1] = look_char;
+ }
+ }
look_char = (*fml->read_func)();
}
lex_buf[off] = '\0';
# Fml scripts to display MARC records
-# $Id: marc.fml,v 1.2 1995/02/10 16:52:08 adam Exp $
+# $Id: marc.fml,v 1.3 1995/02/10 18:15:53 adam Exp $
\func f0 rec {
\foreach line {\rec} {
\line \index 1 \
\n
}
}
+\func mline prefix suffix lin tag subfield {
+ \if {{\strcmp {\line \index 1} \tag}\eq 0} {
+ \foreach field {\lin \index 3} {
+ \if {{\strcmp {\field \index 1} \subfield}\eq 0} {
+ \prefix
+ \field \index 2
+ \suffix
+ }
+ }
+ }
+}
+
+\func f1 rec {
+ \foreach line {\rec} {
+ \mline 'Title: ' '\n' \line 245 a
+ \mline 'Author: ' {} \line 100 a
+ \mline ', ' '\n' \line 100 h
+ }
+}