void ListAliases( void ) /**********************/ { int i; char far *alias; char prompt[ 80 ]; SaveLine(); SavePrompt( prompt ); PutNL(); i = 0; alias = AliasList; while( *alias != '\0' ) { if( *alias == '\n' ) { if( ++i == 23 ) { PutChar( '\n' ); if( !PutMore() ) break; ++alias; i = 0; continue; } } PutChar( *alias ); ++alias; } RestorePrompt( prompt ); RestoreLine(); Draw = TRUE; }
local void OutputString( char *p, char *record ) { char *r; unsigned col; unsigned space; char numstr[30]; for( ; *p != '\0';++p ) { if( *p == '%' ) { ++p; switch( *p ) { case 's': col = 0; for( r = record; *r != '\0' && !( *r == '\r' && *( r + 1 ) == '\0' );++r ) { if( *r != '\t' || TabStop == 0 ) { OutputChar( *r ); ++col; } else { space = ( col + TabStop ) - ( ( col + TabStop ) % TabStop ); while( col < space ) { OutputChar( ' ' ); ++col; } } } break; case 'n': PutNL(); break; case '#': sprintf( numstr, "%u", OutNum ); for( col = 0; col < strlen( numstr ); ++col ) { OutputChar( numstr[col] ); } break; case '+': ++OutNum; break; case '-': --OutNum; break; default: OutputChar( *p ); break; } } else { OutputChar( *p ); } } }
local void ProcessRecord( // PROCESS A RECORD OF INPUT int kw, // - key-word for record char *record )// - record { SEGMENT *seg; // - current segment switch( kw ) { case KW_SEGMENT: PushSegStack(); switch( ProcessMode ) { case MODE_DELETE: ProcessMode = MODE_SKIPPING; break; case MODE_OUTPUT: SegmentCheck(); break; } break; case KW_ELSESEGMENT: switch( ProcessMode ) { case MODE_DELETE: EatWhite(); if( *Rptr == '\0' ) { ProcessMode = MODE_OUTPUT; } else { SegmentCheck(); } break; case MODE_OUTPUT: ProcessMode = MODE_SKIPPING; break; } break; case KW_ENDSEGMENT: PopSegStack(); break; case KW_KEEP: switch( ProcessMode ) { case MODE_OUTPUT: seg = ScanSegment(); if( seg != NULL ) seg->seg_type = SEG_KEEP; break; } break; case KW_REMOVE: switch( ProcessMode ) { case MODE_OUTPUT: seg = ScanSegment(); if( seg != NULL ) seg->seg_type = SEG_REMOVE; break; } break; case KW_INCLUDE: switch( ProcessMode ) { case MODE_OUTPUT: if( ScanString() ) { OpenFileNormal( Token, "r" ); } else { Error( "Missing or invalid inclusion file" ); } break; } break; case KW_TEXT: switch( ProcessMode ) { case MODE_OUTPUT: OutputString( OutFmt, record ); PutNL(); break; } break; } }
void NextFile( void ) /*******************/ { #ifdef DOS int dot; #endif USHORT hdl; int i; int path; int fattr; USHORT cnt; int searchpath; static int lastrc; static char buff[ MAX_FNAME+2 ]; char c0,c1,c2,c3; char *word; char *alias; static DIRINFO dir; char prompt[SCREEN_WIDTH]; int is_directory; char in_quote; char has_blank; fattr = 0; if( ExpandDirCommand() ) { fattr = _D_SDIR; } if( Cursor != 0 ) { if( !HaveDirent ) { if( NextFileCalls == 0 ) SaveLine(); recurse: path = 0; i = Cursor - 1; #ifdef DOS dot = FALSE; #endif in_quote = FALSE; for( ;; ) { if( Line[ i ] == '/' || Line[ i ] == '\\' ) path = 1; #ifdef DOS if( path == 0 && Line[ i ] == '.' ) dot = TRUE; #endif if( Line[i] == '"' ) in_quote = !in_quote; if( !in_quote && NonFileChar( Line[ i ] ) ) { ++i; break; } if( i == 0 ) break; --i; } searchpath = FALSE; if( i == 0 ) { if( PathCurr != 0 ) { searchpath = TRUE; } else if( Line[0] != '.' && Line[0] != '\\' && Line[0] != '/' && ( MaxCursor == 0 || Line[1] != ':' ) ) { searchpath = TRUE; } } if( searchpath && !FileUnique ) { if( NextFileCalls == 0 && PathCurr == 0 ) { PathCurr = GetEnv( PATH, sizeof( PATH ) - 1 ); } else if( PathCurr == 0 ) { lastrc = ~0; goto done; } else if( *PathCurr == '\0' ) { ++NextFileCalls; PathCurr = 0; lastrc = ~0; RestoreLine(); goto done; } else { RestoreLine(); #ifdef DOS dot = FALSE; #endif word = PathBuff; for( ;; ) { if( *PathCurr == '\0' ) break; if( *PathCurr == ';' ) { ++PathCurr; break; } *word = *PathCurr; ++word; ++PathCurr; } *word = 0; ReplaceAlias( PathBuff, Line, Line ); ReplaceAlias( "\\", Line+(word-PathBuff), Line+(word-PathBuff) ); } } c0 = Line[Cursor+0]; c1 = Line[Cursor+1]; c2 = Line[Cursor+2]; c3 = Line[Cursor+3]; Line[ Cursor ] = '*'; #ifdef DOS if( !dot ) { Line[ Cursor + 1 ] = '.'; Line[ Cursor + 2 ] = '*'; Line[ Cursor + 3 ] = '\0'; } else { Line[ Cursor + 1 ] = '\0'; } #else Line[ Cursor + 1 ] = '\0'; #endif hdl = 1; cnt = 1; lastrc = DosFindFirst( Line + i, &hdl, _D_SDIR, &dir, sizeof( DIRINFO ), &cnt, 0 ); Line[Cursor+0] = c0; Line[Cursor+1] = c1; Line[Cursor+2] = c2; Line[Cursor+3] = c3; if( lastrc == 0 ) { if( FileIgnore( &dir, fattr ) ) lastrc = FindNext( &dir, fattr ); HaveDirent = TRUE; } } done: ++NextFileCalls; if( lastrc == 0 ) { is_directory = dir.attrFile & _D_SDIR; word = dir.achName; alias = buff; has_blank = strchr( dir.achName, ' ' ) != NULL; if( has_blank ) *alias++ = '"'; while( *alias = *word ) { ++alias; ++word; } if( has_blank ) *alias++ = '"'; *alias = '\r'; if( FileUnique ) { if( PrintAllFiles ) { SaveLine(); NextFileCalls = 0; SavePrompt( prompt ); PutNL(); i = 1; } for( ;; ) { if( PrintAllFiles ) { if( --i == 0 ) { PutNL(); i = 6; } PutPad( dir.achName, 13 ); } lastrc = FindNext( &dir, fattr ); if( lastrc != 0 ) break; alias = buff; word = dir.achName; while( tolower( *alias ) == tolower( *word ) && *alias != '\r' ) { ++alias; ++word; } *alias = '\r'; } if( PrintAllFiles ) { PutNL(); PutNL(); RestorePrompt( prompt ); RestoreLine(); } HaveDirent = FALSE; } else { lastrc = FindNext( &dir, fattr ); } i = Cursor - 1; if( AppendSlash && NextFileCalls > 1 ) { --i; } in_quote = FALSE; for( ;; ) { if( Line[ i ] == '"' ) in_quote = !in_quote; if( Line[ i ] == '\\' ) break; if( Line[ i ] == '/' ) break; if( Line[ i ] == ':' ) break; if( !in_quote && NonFileChar( Line[ i ] ) ) break; --i; if( i == -1 ) break; } ++i; if( FileLower ) ZapLower( &buff ); if( AppendSlash ) { alias = buff; while( *alias != '\0' && *alias != '\r' ) ++alias; *alias++ = is_directory ? '\\' : ' '; *alias = 0; } ReplaceAlias( &buff, Line+i, Line+Cursor ); } else if( PathCurr != 0 ) { RestoreLine(); HaveDirent = FALSE; --NextFileCalls; goto recurse; } else { --NextFileCalls; } } else if( LineSaved ) { RestoreLine(); } Draw = TRUE; PrintAllFiles = FALSE; }