Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site wu1.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!cmcl2!rna!rocky2!cubsvax!wu1!rf From: rf@wu1.UUCP Newsgroups: net.lang.c Subject: Can anyone find a system on which this doesn't work? Message-ID: <324@wu1.UUCP> Date: Mon, 19-Nov-84 21:18:44 EST Article-I.D.: wu1.324 Posted: Mon Nov 19 21:18:44 1984 Date-Received: Thu, 22-Nov-84 06:04:00 EST Organization: Western Union Telegraph, Mahwah, NJ Lines: 193 Does anyone know of any system on which the acat() routine in the program test.c (attached) does not work? Acat is part of a string management package -- an allocating concatenate routine. It takes up to 10 strings, allocates storage for their concatenation and concatenates them. The output of test.c is given. Test.c will end with the error message "test: More than 10 strings in acat()". Randolph Fritz UUCPnet: {ihnp4,decvax}!philabs!wu1!rf "Rust and moth are the only true Critics; . . ." -- "The True Critics", Paul Edwin Zimmer ----------------- output of test.c 1 122 122333 1223334444 122333444455555 122333444455555666666 1223334444555556666667777777 122333444455555666666777777788888888 122333444455555666666777777788888888999999999 ----------------- test.c #include typedef int VOID; typedef unsigned int COUNT; typedef char TEXT; typedef int BOOL; #define EOS '\0' /* End-of-string */ #define NO ((BOOL) 0) /* Logic false */ #define YES ((BOOL) 1) /* Logic true */ TEXT *acat(), *stralloc(); main () { fprintf (stdout, "%s\n", acat("", NULL)); fflush (stdout); fprintf (stdout, "%s\n", acat("","1", NULL)); fflush (stdout); fprintf (stdout, "%s\n", acat("","1","22", NULL)); fflush (stdout); fprintf (stdout, "%s\n", acat("","1","22","333", NULL)); fflush (stdout); fprintf (stdout, "%s\n", acat("","1","22","333","4444", NULL)); fflush (stdout); fprintf (stdout, "%s\n", acat("","1","22","333","4444","55555", NULL)); fflush (stdout); fprintf (stdout, "%s\n", acat("","1","22","333","4444","55555","666666", NULL)); fflush (stdout); fprintf (stdout, "%s\n", acat("","1","22","333","4444","55555","666666", "7777777", NULL)); fflush (stdout); fprintf (stdout, "%s\n", acat("","1","22","333","4444","55555","666666", "7777777","88888888", NULL)); fflush (stdout); fprintf (stdout, "%s\n", acat("","1","22","333","4444","55555","666666", "7777777","88888888","999999999", NULL)); fflush (stdout); fprintf (stdout, "%s\n", acat("","1","22","333","4444","55555","666666", "7777777","88888888","999999999","10101010101010101010", NULL)); fflush (stdout); } /* acat - allocating string concatenate (for up to 10 strings) This (believed to be) portable routine will concatenate up to 10 strings. Acat() is invoked by: newstring = acat (string1, string2 , . . . stringn, NULL); Acat is by no means elegant -- it even contains (horrors!) a goto -- but it provides an amazingly useful function. */ TEXT * acat (s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10) TEXT *s0, *s1, *s2, *s3, *s4, *s5, *s6, *s7, *s8, *s9, *s10; { TEXT *instr[11]; COUNT newlen, nstr, i; TEXT *news, *np, *op; nstr = 0; if (s0!=NULL) instr[nstr++] = s0; else goto got_em; if (s1!=NULL) instr[nstr++] = s1; else goto got_em; if (s2!=NULL) instr[nstr++] = s2; else goto got_em; if (s3!=NULL) instr[nstr++] = s3; else goto got_em; if (s4!=NULL) instr[nstr++] = s4; else goto got_em; if (s5!=NULL) instr[nstr++] = s5; else goto got_em; if (s6!=NULL) instr[nstr++] = s6; else goto got_em; if (s7!=NULL) instr[nstr++] = s7; else goto got_em; if (s8!=NULL) instr[nstr++] = s8; else goto got_em; if (s9!=NULL) instr[nstr++] = s9; else goto got_em; if (s10!=NULL) bugout ("More than 10 strings in acat()\n"); got_em: instr[nstr] = NULL; newlen = 0; for (i=0; i