netbsdsrc/usr.bin/split/split.c
/*
 * newfile --
 *	Open a new output file.
 */
newfile
Open a new output file.
newfile Open a new output file .
void
newfile()
{
	static long fnum;
	static int defname;
	static char *fpnt;
	if (ofd == -1) {
		if (fname[0] == '\0') {
			fname[0] = 'x';
			fpnt = fname + 1;
			defname = 1;
		} else {
			fpnt = fname + strlen(fname);
			defname = 0;
		}
		ofd = fileno(stdout);
	}
#define MAXFILES	676
	if (fnum == MAXFILES) {
		if (!defname || fname[0] == 'z')
			errx(1, "too many files.");
		++fname[0];
		fnum = 0;
	}
	fpnt[0] = fnum / 26 + 'a';
	fpnt[1] = fnum % 26 + 'a';
	++fnum;
	if (!freopen(fname, "w", stdout))
		err(1, "%s", fname);
}
void newfile ( ) { static long fnum ; static int defname ; static char * fpnt ; if ( ofd == -1 ) { if ( fname [ 0 ] == ' \0 ' ) { fname [ 0 ] = ' ' ; fpnt = fname + 1 ; defname = 1 ; } else { fpnt = fname + strlen ( fname ) ; defname = 0 ; } ofd = fileno ( stdout ) ; } #define MAXFILES 	676 if ( fnum == MAXFILES ) { if ( ! defname || fname [ 0 ] == ' ' ) errx ( 1 , " " ) ; ++ fname [ 0 ] ; fnum = 0 ; } fpnt [ 0 ] = fnum / 26 + ' ' ; fpnt [ 1 ] = fnum % 26 + ' ' ; ++ fnum ; if ( ! freopen ( fname , " " , stdout ) ) err ( 1 , " " , fname ) ; }
newfile
      Open a new output file.
newfile Open a new output file .
/*
	 * Hack to increase max files; original code wandered through
	 * magic characters.  Maximum files is 3 * 26 * 26 == 2028
	 */