bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: xstring.h


From: Karl Berry
Subject: Re: xstring.h
Date: Fri, 9 May 2008 19:44:48 -0500

    |   char * xsubstring (const char *str, size_t len);

FWIW, looking at my code again, I see that it was convenient to be able
to pass in two pointers, const char *start and const char *end, and the
function extracts what is between them.

char *
substring (const char *start, const char *end)
{
  char *result = xmalloc (end - start + 1);
  char *scan_result = result;
  const char *scan = start;

  while (scan < end)
    *scan_result++ = *scan++;

  *scan_result = 0;
  return result;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]