示例#1
0
void MatchACommand( int (*advance)(char *), int (*retreat)(char *) )
/******************************************************************/
{
    int advanced;

    SaveLine();
    advanced = 0;
    for( ;; ) {
        ++advanced;
        MaxCursor = advance( Line );
        if( MaxCursor == 0 ) {
            while( --advanced >= 0 ) {
                MaxCursor = retreat( Line );
            }
            RestoreLine();
            return;
        }
        if( MaxCursor < OldCursor ) continue;
        if( Equal( OldLine, Line, OldCursor ) ) break;
    }
    Draw = TRUE;
    Base = 0;
    Edited = FALSE;
    FirstNextOrPrev = FALSE;
}
示例#2
0
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;
}
示例#3
0
void Trace::Log(const char *func_name, const char *format, ...) {
  char str[kBufferSize] = {0};
  sprintf(str, "%s: %s", func_name, format);
  va_list args;
  va_start(args, format);
  SaveLine(kDepth, kDepth * 2, str, args);
  va_end(args);
}
示例#4
0
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;
}