Category : C Source Code
Archive   : CSRC2.ZIP
Filename : CSJOIN.C

 
Output of file : CSJOIN.C contained in archive : CSRC2.ZIP
/*
* c s j o i n . c
*/

/*)LIBRARY
*/

#ifdef DOCUMENTATION

title csjoin Compute Join (Union) of Two Csets
index Compute join (union) of two csets

synopsis

#ifdef vms
#include "c:cset.h"
#else
#include
#endif

CSET *
csjoin(cs1,cs2);
CSET *cs1;
CSET *cs2;

description

The cset returned by csjoin() has as members all elements of either
cs1 or cs2. Whenever possible, csjoin() shares existing data by
returning a cset that shares the memory used by cs1 and cs2. This
is most likely to occur if very few calls to cset() (or other cset
functions that allocate new csets) occured between the calls that
created cs1 and cs2.

If csunique is true, a new cset is always formed.

csjoin() returns NULL if it couldn't allocate a cset to return.

bugs

author

Jerry Leichter

#endif

/*
)EDITLEVEL=03
* Edit history
* 0.0 16-Jul-82 JSL Invention
*/

#ifdef vms
#include "c:cset.h"
#else
#include
#endif
#define NULL 0

CSET *
csjoin(cs1,cs2)
CSET *cs1;
CSET *cs2;
{ register CSET *newcs;
register int i;

if ( (((int)cs1 & 1) == 0) /* cs1 not complemented */
&& (((int)cs2 & 1) == 0) /* cs2 not complemented */
&& (cs1->table == cs2->table) /* Shared table */
&& !csunique ) /* No forced copy */
{ if ((newcs = (CSET *)malloc(sizeof(CSET))) != NULL)
copy((char *)newcs,(char *)cs1,sizeof(CSET));
/* Duplicate cs1 desc. */
newcs->mask |= cs2->mask;
/* Or the masks */
}
else /* All new... */
if ((newcs = cset("")) != NULL)
{ for (i = 0; i < cssize; i++)
if (csmember(cs1,i) || csmember(cs2,i))
newcs->table[i] |= newcs->mask;
}

return(newcs);
}


  3 Responses to “Category : C Source Code
Archive   : CSRC2.ZIP
Filename : CSJOIN.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/