Category : C Source Code
Archive   : ECSTR.ZIP
Filename : STRPACK.C

Output of file : STRPACK.C contained in archive : ECSTR.ZIP
/* File : strpack.c
Author : Richard A. O'Keefe.
Updated: 20 April 1984
Defines: strpack()

strpack(dst, src, set, c)
copies characters from src to dst, stopping when it finds a NUL. If
c is NUL, characters in set are not copied to dst. If c is not NUL,
sequences of characters from set are copied as a single c.
strpack(d, s, " \t", ' ') can be used to compress white space,
strpack(d, s, " \t", NUL) to eliminate it. To translate characters
in set to c without compressing runs, see strtrans(). The result is
the address of the NUL byte now terminating dst. Note that dst may
safely be the same as src.

#include "strings.h"
#include "_str2set.h"

char *strpack(dst, src, set, c)
register _char_ *dst, *src;
char *set;
register int c;
register int chr;

while (chr = *src++) {
if (_set_vec[chr] == _set_ctr) {
while ((chr = *src++) && _set_vec[chr] == _set_ctr) ;
if (c) *dst++ = c; /* 1. If you don't want trailing */
if (!chr) break; /* 2. things turned into "c", swap */
} /* lines 1 and 2. */
*dst++ = chr;
*dst = 0;
return dst;

  3 Responses to “Category : C Source Code
Archive   : ECSTR.ZIP
Filename : STRPACK.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: