Roland Mainz <[EMAIL PROTECTED]> wrote:
> [The following falls under the category "micro-optimisation" but may IMO
> still be worth an investigation]
> After working on various parts of OpenSolaris I found that is common to
> use the following sequence to concatenate strings:
> -- snip --
> ...
> char *s;
> ...
> strcat(s, "foo");
> strcat(s, "/");
> strcat(s, "bar");
> -- snip --
UNOS (a UNIX clode) did introduce strcatl() in 1982.
I have a re-implementation in my libschily
/* @(#)strcatl.c 1.12 03/10/29 Copyright 1985, 1989, 1995-2003 J.
Schilling */
/*
* list version of strcat()
*
* concatenates all past first parameter until a NULL pointer is reached
*
* WARNING: a NULL constant is not a NULL pointer, so a caller must
* cast a NULL constant to a pointer: (char *)NULL
*
* returns pointer past last character (to '\0' byte)
*
* Copyright (c) 1985, 1989, 1995-2003 J. Schilling
*/
/*@@C@@*/
#include <mconfig.h>
#include <vadefs.h>
#include <standard.h>
#include <schily.h>
/* VARARGS3 */
#ifdef PROTOTYPES
EXPORT char *
strcatl(char *to, ...)
#else
EXPORT char *
strcatl(to, va_alist)
char *to;
va_dcl
#endif
{
va_list args;
register char *p;
register char *tor = to;
#ifdef PROTOTYPES
va_start(args, to);
#else
va_start(args);
#endif
while ((p = va_arg(args, char *)) != NULL) {
while ((*tor = *p++) != '\0') {
tor++;
}
}
*tor = '\0';
va_end(args);
return (tor);
}
Jörg
--
EMail:[EMAIL PROTECTED] (home) Jörg Schilling D-13353 Berlin
[EMAIL PROTECTED] (uni)
[EMAIL PROTECTED] (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/old/private/ ftp://ftp.berlios.de/pub/schily
_______________________________________________
opensolaris-discuss mailing list
[email protected]