The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: jnc@mercury.lcs.mit.edu (Noel Chiappa)
Subject: [TUHS] Oddness in V6 'mv'
Date: Wed, 14 Feb 2018 12:47:29 -0500 (EST)	[thread overview]
Message-ID: <20180214174729.5147518C09E@mercury.lcs.mit.edu> (raw)

So, in:

  http://minnie.tuhs.org/cgi-bin/utree.pl?file=V6/usr/source/s2/mv.c

what's the point of this piece of code:

	p = place;
	p1 = p;
	while(*p++ = *argp3++);
	p2 = p;
	while(*p++ = *argp4++);
	execl("/bin/cp","cp", p1, p2, 0);

I mean, I get that it's copying the two strings pointed to by 'argp3' and
'argp4' into a temporary buffer at 'place', and leaving 'p1' and 'p2' as
pointers to the copies of said strings, but... why is it doing that?

I at first thought that maybe the execl() call was smashing the stack (and
thus the copies pointed to by 'argp3' and 'argp4'), or something, but I don't
think it does that. So why couldn't the code have just been:

	execl("/bin/cp","cp", argp3, argp4, 0);

Is this code maybe just a left-over from some previous variant?

	Noel


                 reply	other threads:[~2018-02-14 17:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180214174729.5147518C09E@mercury.lcs.mit.edu \
    --to=jnc@mercury.lcs.mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).