Staging
v0.5.1
https://github.com/python/cpython
Revision a9d157a8dd7a5b2b53b60680729c320f9fd9f96c authored by Victor Stinner on 04 March 2010, 12:16:27 UTC, committed by Victor Stinner on 04 March 2010, 12:16:27 UTC
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r78647 | victor.stinner | 2010-03-04 13:14:57 +0100 (jeu., 04 mars 2010) | 12 lines

  Merged revisions 78646 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r78646 | victor.stinner | 2010-03-04 13:09:33 +0100 (jeu., 04 mars 2010) | 5 lines

    Issue #1054943: Fix unicodedata.normalize('NFC', text) for the Public Review
    Issue #29.

    PR #29 was released in february 2004!
  ........
................
1 parent da13545
Raw File
Tip revision: a9d157a8dd7a5b2b53b60680729c320f9fd9f96c authored by Victor Stinner on 04 March 2010, 12:16:27 UTC
Merged revisions 78647 via svnmerge from
Tip revision: a9d157a
dup2.c
/*
 * Public domain dup2() lookalike
 * by Curtis Jackson @ AT&T Technologies, Burlington, NC
 * electronic address:  burl!rcj
 *
 * dup2 performs the following functions:
 *
 * Check to make sure that fd1 is a valid open file descriptor.
 * Check to see if fd2 is already open; if so, close it.
 * Duplicate fd1 onto fd2; checking to make sure fd2 is a valid fd.
 * Return fd2 if all went well; return BADEXIT otherwise.
 */

#include <fcntl.h>

#define BADEXIT -1

int
dup2(int fd1, int fd2)
{
	if (fd1 != fd2) {
		if (fcntl(fd1, F_GETFL) < 0)
			return BADEXIT;
		if (fcntl(fd2, F_GETFL) >= 0)
			close(fd2);
		if (fcntl(fd1, F_DUPFD, fd2) < 0)
			return BADEXIT;
	}
	return fd2;
}
back to top