81 char * pFileNameOther;
90 pFile = fopen( pFileNameOther,
"r" );
91 if ( pFile == NULL && pS2 )
94 pFile = fopen( pFileNameOther,
"r" );
95 if ( pFile == NULL && pS3 )
98 pFile = fopen( pFileNameOther,
"r" );
99 if ( pFile == NULL && pS4 )
102 pFile = fopen( pFileNameOther,
"r" );
103 if ( pFile == NULL && pS5 )
106 pFile = fopen( pFileNameOther,
"r" );
115 return pFileNameOther;
271 char * pBeg, * pEnd, * pStore, * pCur;
273 for ( pEnd = pFileName; *pEnd; pEnd++ )
277 for ( pBeg = pEnd - 1; pBeg >= pFileName; pBeg-- )
278 if ( !((*pBeg >=
'a' && *pBeg <=
'z') || (*pBeg >=
'A' && *pBeg <=
'Z') || (*pBeg >=
'0' && *pBeg <=
'9') || *pBeg ==
'_') )
282 pStore =
ABC_ALLOC(
char, pEnd - pBeg + 1 );
283 for ( pCur = pStore; pBeg < pEnd; pBeg++, pCur++ )
362 nFileSize = ftell( pFile );
366 pBuffer =
ABC_ALLOC(
char, nFileSize + 3 );
367 RetValue = fread( pBuffer, nFileSize, 1, pFile );
369 pBuffer[ nFileSize + 0] =
'\n';
370 pBuffer[ nFileSize + 1] =
'\0';
380 nSize = ftell( pFile );
384 nSize2 = ftell( pFile2 );
387 pBuffer =
ABC_ALLOC(
char, nSize + nSize2 + 3 );
388 RetValue = fread( pBuffer, nSize, 1, pFile );
389 RetValue = fread( pBuffer + nSize, nSize2, 1, pFile2 );
391 pBuffer[ nSize + nSize2 + 0] =
'\n';
392 pBuffer[ nSize + nSize2 + 1] =
'\0';
418 FILE * pFile, * pFile2;
420 pFile = fopen( pFileName,
"rb" );
421 pFile2 = fopen( pFileName2,
"rb" );
423 if ( pFile ) fclose( pFile );
424 if ( pFile2 ) fclose( pFile2 );
441 int lenS, lenF =
strlen(pFileName);
442 lenS = pS1 ?
strlen(pS1) : 0;
443 if ( lenS && lenF > lenS && !
strncmp( pFileName+lenF-lenS, pS1, lenS ) )
445 lenS = pS2 ?
strlen(pS2) : 0;
446 if ( lenS && lenF > lenS && !
strncmp( pFileName+lenF-lenS, pS2, lenS ) )
448 lenS = pS3 ?
strlen(pS3) : 0;
449 if ( lenS && lenF > lenS && !
strncmp( pFileName+lenF-lenS, pS3, lenS ) )
613 int nDigits, Digit, k;
614 if ( nVars == 0 && !(Sign[0] & 1) ) {
sprintf(pString,
"0");
return; }
615 if ( nVars == 0 && (Sign[0] & 1) ) {
sprintf(pString,
"1");
return; }
616 if ( nVars == 1 && (Sign[0] & 1) ) {
sprintf(pString,
"1");
return; }
617 if ( nVars == 1 && !(Sign[0] & 1) ) {
sprintf(pString,
"2");
return; }
619 nDigits = (1 << nVars) / 4;
620 for ( k = nDigits - 1; k >= 0; k-- )
622 Digit = ((Sign[k/8] >> ((k%8) * 4)) & 15);
624 *pString++ =
'0' + Digit;
626 *pString++ =
'a' + Digit-10;
645 int nMints, nDigits, Digit, k;
648 fprintf( pFile,
"0x" );
649 nMints = (1 << nVars);
650 nDigits = nMints / 4 + ((nMints % 4) > 0);
651 for ( k = nDigits - 1; k >= 0; k-- )
653 Digit = ((pTruth[k/8] >> (k * 4)) & 15);
655 fprintf( pFile,
"%d", Digit );
657 fprintf( pFile,
"%c",
'A' + Digit-10 );
663 int nMints, nDigits, Digit, k;
667 nMints = (1 << nVars);
668 nDigits = nMints / 4 + ((nMints % 4) > 0);
669 for ( k = nDigits - 1; k >= 0; k-- )
671 Digit = ((pTruth[k/8] >> (k * 4)) & 15);
673 fprintf( pFile,
"%d", Digit );
675 fprintf( pFile,
"%c",
'A' + Digit-10 );
681 int nMints, nDigits, Digit, k;
684 fprintf( pFile,
"0x" );
685 nMints = (1 << nVars);
686 nDigits = nMints / 4 + ((nMints % 4) > 0);
687 for ( k = 0; k < nDigits; k++ )
689 Digit = ((pTruth[k/8] >> (k * 4)) & 15);
691 fprintf( pFile,
"%d", Digit );
693 fprintf( pFile,
"%c",
'A' + Digit-10 );
803 int i, nLines, Begin;
804 pFile = fopen( pFileName,
"rb" );
807 printf(
"Extra_FileSort(): Cannot open file \"%s\".\n", pFileName );
812 if ( pContents == NULL )
814 printf(
"Extra_FileSort(): Cannot read contents of file \"%s\".\n", pFileName );
818 for ( nLines = 0, i = 0; pContents[i]; i++ )
819 nLines += (pContents[i] ==
'\n');
821 pLines = (
char **)
malloc(
sizeof(
char *) * nLines );
823 for ( nLines = 0, i = 0; pContents[i]; i++ )
824 if ( pContents[i] ==
'\n' )
827 pLines[nLines++] = pContents + Begin;
831 qsort( pLines, (
size_t)nLines,
sizeof(
char *), (
int(*)(
const void *,
const void *))
Extra_StringCompare );
833 pFile = fopen( pFileNameOut,
"wb" );
834 for ( i = 0; i < nLines; i++ )
836 fprintf( pFile,
"%s\n", pLines[i] );
842 printf(
"The file after sorting is \"%s\".\n", pFileNameOut );
863 pFile = fopen( pFileName,
"rb" );
866 printf(
"Extra_FileLineNumAdd(): Cannot open file \"%s\".\n", pFileName );
869 pFile2 = fopen( pFileNameOut,
"wb" );
870 if ( pFile2 == NULL )
873 printf(
"Extra_FileLineNumAdd(): Cannot open file \"%s\".\n", pFileNameOut );
876 for ( iLine = 0; fgets( Buffer, 1000, pFile ); iLine++ )
878 sprintf( Buffer +
strlen(Buffer) - 2,
"%03d\n%c", iLine, 0 );
879 fputs( Buffer, pFile2 );
884 printf(
"The resulting file is \"%s\".\n", pFileNameOut );