]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/subs/m_replace.c
Create new mh-format function %(ordinal)
[nmh] / docs / historical / mh-jun-1982 / subs / m_replace.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #include "../mh.h"
9 char *malloc();
10
11 m_replace(key,value)
12 char *key, *value;
13
14 {
15 register struct node *np;
16
17 m_getdefs();
18 for(np = m_defs; ; np = np->n_next) {
19 if(uleq(np->n_name, key)) {
20 if(strcmp(value, np->n_field) != 0) {
21 cndfree(np->n_field);
22 np->n_field = value;
23 def_flags |= DEFMOD;
24 }
25 return;
26 }
27 if(!np->n_next)
28 break;
29 }
30 np->n_next = (struct node *) malloc(sizeof *np);
31 np = np->n_next;
32 np->n_name = getcpy(key);
33 np->n_next = 0;
34 np->n_field = value;
35 def_flags |= DEFMOD;
36 }