delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/08/01/00:37:06

From: "Richard E. Stone" <restone AT skypoint DOT com>
To: <djgpp-workers AT delorie DOT com>
Subject: FW: stpncpy
Date: Mon, 31 Jul 2000 23:33:34 -0500
Message-ID: <LPBBINFBCBNBLIBJHPBGGEKKCAAA.restone@skypoint.com>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0)
Importance: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Reply-To: djgpp-workers AT delorie DOT com

This is a multi-part message in MIME format.

------=_NextPart_000_0000_01BFFB47.BEAFB820
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hmm, this seemed to bounce...

-----Original Message-----
From: Richard E. Stone [mailto:restone AT skypoint DOT com]
Sent: Monday, July 31, 2000 10:44 PM
To: Eli Zaretskii; Laurynas Biveinis
Cc: djgpp-workers AT delorie DOT com
Subject: RE: stpncpy


Hi,

Attached are two files, stpncpy.c and makefile.
Both are intended to be put in the directory
tests\libc\compat\string, with stpncpy.c being
an addition and makefile being a replacement.
The makefile adds a line to include stpncpy.c
in the tests, while stpncpy.c is a test file
for the stpncpy function.  (I basically copied
it out of tester.c found in the GNU sources.)

Thanks.

--- Richard Stone

> -----Original Message-----
> From: Eli Zaretskii [mailto:eliz AT is DOT elta DOT co DOT il]
> Sent: Monday, July 24, 2000 11:28 AM
> To: Laurynas Biveinis
> Cc: djgpp-workers AT delorie DOT com; Richard E. Stone
> Subject: Re: stpncpy
>
>
>
> On Mon, 24 Jul 2000, Laurynas Biveinis wrote:
>
> > Martin Stromberg wrote:
> > >
> > > Here's a reference to a patch that's gone missing (I never saw any
> > > discussion):
> > >
> <http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp-wor
kers/2000/06/16/00:21:31>.
> > Perhaps Laurunas feels like applying it if nobody have something to say?
>
> Silence is a sign of agreement, isn't it ;)
> Below is what I've applied. Note that I've added new wc204.txi entry.

Thanks.

A test program would be nice, though...

------=_NextPart_000_0000_01BFFB47.BEAFB820
Content-Type: application/octet-stream;
	name="makefile"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="makefile"

TOP=3D../..=0A=
=0A=
SRC +=3D ffs.c=0A=
SRC +=3D stpcpy.c=0A=
SRC +=3D stpncpy.c=0A=
=0A=
include $(TOP)/../makefile.inc=0A=

------=_NextPart_000_0000_01BFFB47.BEAFB820
Content-Type: application/octet-stream;
	name="stpncpy.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="stpncpy.c"

#include <stdio.h>
#include <string.h>

int
check(int thing, int number)
{
  if (!thing)
  {
    printf("stpncpy flunked test %d\n", number);
    return 1;
  }
  return 0;
}

int
main(void)
{
  int errors = 0;
  char d[] = "xxxxxxxxxxxxxxxxxxxx";
  errors += check(stpncpy(d, "abc", 2) == d + 2, 1);
  errors += check(stpncpy(d, "abc", 3) == d + 3, 2);
  errors += check(stpncpy(d, "abc", 4) == d + 3, 3);
  errors += check(d[3] == '\0' && d[4] == 'x', 4);
  errors += check(stpncpy(d, "abcd", 5) == d + 4, 5);
  errors += check(d[4] == '\0' && d[5] == 'x', 6);
  errors += check(stpncpy(d, "abcd", 6) == d + 4, 7);
  errors += check(d[4] == '\0' && d[5] == '\0' && d[6] == 'x', 8);
  if (errors)
    printf("%d errors.\n", errors);
  else
    printf("No errors.\n");
  return 0;
}

------=_NextPart_000_0000_01BFFB47.BEAFB820--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019