/*Copyright (C) 1992, 1996 by Thomas Glen Smith. All Rights Reserved.*/
/* Copyright (C) 1992 by Thomas Glen Smith. All Rights Reserved. */
/* savfsub APL2 V1.0.0 *************************************************
* Called from aplsavf with the first node in a binary tree, and called *
* recursively by itself with the first node in each branch. For each *
* terminal node (leaf) savfsub calls either savfsfn for a function *
* definition, or savfscb for an apl variable. *
***********************************************************************/
#define INCLUDES APLCB+APLFUNCI+IO+STDIO+STRING+TREE
#include "includes.h"
void savfsub(fp,node)
int fp; /* file handle */
Avlnode node; /* points to node of binary tree */
{
Savfsfn; Savfscb; Strwrite;
Aplcb cb;
static char ch = 'x'; /* name following indicator */
int i,j;
if (node == NULL) return;
savfsub(fp,node->left_child); /* write left branch, if any */
savfsub(fp,node->rite_child); /* write right branch, if any */
if (NULL == (cb = node->avlleaf)) return;
i = write(fp, &ch, 1); /* write name following indicator */
i = strwrite(fp, node->avlname); /* write name string */
if (cb->aplflags & APLFUNC)
savfsfn(fp,(Aplfunc)cb); /* save function definition */
else savfscb(fp,cb); /* save apl variable */
}