mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
CLean up current_filename, make it a std::stack
This commit is contained in:
parent
6afc06b97e
commit
623eb42a6a
3 changed files with 18 additions and 12 deletions
|
@ -1012,6 +1012,10 @@ int parser_t::get_lineno() const
|
||||||
|
|
||||||
const wchar_t *parser_t::current_filename() const
|
const wchar_t *parser_t::current_filename() const
|
||||||
{
|
{
|
||||||
|
/* We query a global array for the current file name, so it only makes sense to ask this on the principal parser. */
|
||||||
|
ASSERT_IS_MAIN_THREAD();
|
||||||
|
assert(this == &principal_parser());
|
||||||
|
|
||||||
block_t *b = current_block;
|
block_t *b = current_block;
|
||||||
|
|
||||||
while( 1 )
|
while( 1 )
|
||||||
|
|
22
reader.cpp
22
reader.cpp
|
@ -44,6 +44,7 @@ commence.
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
#if HAVE_NCURSES_H
|
#if HAVE_NCURSES_H
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
|
@ -103,6 +104,7 @@ commence.
|
||||||
#include "halloc.h"
|
#include "halloc.h"
|
||||||
#include "halloc_util.h"
|
#include "halloc_util.h"
|
||||||
#include "iothread.h"
|
#include "iothread.h"
|
||||||
|
#include "intern.h"
|
||||||
|
|
||||||
#include "parse_util.h"
|
#include "parse_util.h"
|
||||||
|
|
||||||
|
@ -325,9 +327,9 @@ static int is_interactive_read;
|
||||||
static int end_loop = 0;
|
static int end_loop = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The list containing names of files that are being parsed
|
The stack containing names of files that are being parsed
|
||||||
*/
|
*/
|
||||||
static array_list_t current_filename;
|
static std::stack<const wchar_t *> current_filename;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -498,21 +500,24 @@ void reader_handle_int( int sig )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *reader_current_filename()
|
const wchar_t *reader_current_filename()
|
||||||
{
|
{
|
||||||
return al_get_count( ¤t_filename )?(wchar_t *)al_peek( ¤t_filename ):0;
|
ASSERT_IS_MAIN_THREAD();
|
||||||
|
return current_filename.empty() ? NULL : current_filename.top();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void reader_push_current_filename( const wchar_t *fn )
|
void reader_push_current_filename( const wchar_t *fn )
|
||||||
{
|
{
|
||||||
al_push( ¤t_filename, fn );
|
ASSERT_IS_MAIN_THREAD();
|
||||||
|
current_filename.push(intern(fn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wchar_t *reader_pop_current_filename()
|
void reader_pop_current_filename()
|
||||||
{
|
{
|
||||||
return (wchar_t *)al_pop( ¤t_filename );
|
ASSERT_IS_MAIN_THREAD();
|
||||||
|
current_filename.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -730,14 +735,11 @@ void reader_init()
|
||||||
shell_modes.c_lflag &= ~ECHO; /* turn off echo mode */
|
shell_modes.c_lflag &= ~ECHO; /* turn off echo mode */
|
||||||
shell_modes.c_cc[VMIN]=1;
|
shell_modes.c_cc[VMIN]=1;
|
||||||
shell_modes.c_cc[VTIME]=0;
|
shell_modes.c_cc[VTIME]=0;
|
||||||
|
|
||||||
al_init( ¤t_filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void reader_destroy()
|
void reader_destroy()
|
||||||
{
|
{
|
||||||
al_destroy( ¤t_filename);
|
|
||||||
tcsetattr(0, TCSANOW, &saved_modes);
|
tcsetattr(0, TCSANOW, &saved_modes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
reader.h
4
reader.h
|
@ -46,7 +46,7 @@ void reader_destroy();
|
||||||
/**
|
/**
|
||||||
Returns the filename of the file currently read
|
Returns the filename of the file currently read
|
||||||
*/
|
*/
|
||||||
wchar_t *reader_current_filename();
|
const wchar_t *reader_current_filename();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Push a new filename on the stack of read files
|
Push a new filename on the stack of read files
|
||||||
|
@ -57,7 +57,7 @@ void reader_push_current_filename( const wchar_t *fn );
|
||||||
/**
|
/**
|
||||||
Pop the current filename from the stack of read files
|
Pop the current filename from the stack of read files
|
||||||
*/
|
*/
|
||||||
wchar_t *reader_pop_current_filename();
|
void reader_pop_current_filename();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Write the title to the titlebar. This function is called just
|
Write the title to the titlebar. This function is called just
|
||||||
|
|
Loading…
Reference in a new issue