Formatting

This commit is contained in:
ridiculousfish 2013-01-12 12:55:23 -08:00
parent b32fcc7a8e
commit 373cca0bf6
6 changed files with 18 additions and 14 deletions

View File

@ -106,7 +106,7 @@ static char *wcs2str_internal(const wchar_t *in, char *out);
void show_stackframe() void show_stackframe()
{ {
ASSERT_IS_NOT_FORKED_CHILD(); ASSERT_IS_NOT_FORKED_CHILD();
/* Hack to avoid showing backtraces in the tester */ /* Hack to avoid showing backtraces in the tester */
if (program_name && ! wcscmp(program_name, L"(ignore)")) if (program_name && ! wcscmp(program_name, L"(ignore)"))
return; return;

View File

@ -1644,7 +1644,7 @@ int expand_string(const wcstring &input, std::vector<completion_t> &output, expa
{ {
wcstring next = in->at(i).completion; wcstring next = in->at(i).completion;
if (! (EXPAND_SKIP_HOME_DIRECTORIES & flags)) if (!(EXPAND_SKIP_HOME_DIRECTORIES & flags))
expand_home_directory(next); expand_home_directory(next);

View File

@ -54,7 +54,7 @@ enum
/** Don't expand jobs (but you can still expand processes). This is because job expansion is not thread safe. */ /** Don't expand jobs (but you can still expand processes). This is because job expansion is not thread safe. */
EXPAND_SKIP_JOBS = 1 << 8, EXPAND_SKIP_JOBS = 1 << 8,
/** Don't expand home directories */ /** Don't expand home directories */
EXPAND_SKIP_HOME_DIRECTORIES = 1 << 9 EXPAND_SKIP_HOME_DIRECTORIES = 1 << 9
}; };

View File

@ -382,7 +382,8 @@ static int test_fork_helper(void *unused)
for (i=0; i < 1000; i++) for (i=0; i < 1000; i++)
{ {
//delete [](new char[4 * 1024 * 1024]); //delete [](new char[4 * 1024 * 1024]);
for (int j=0; j < 1024; j++) { for (int j=0; j < 1024; j++)
{
strerror(j); strerror(j);
} }
} }
@ -421,8 +422,10 @@ static void test_fork(void)
{ {
/* Child */ /* Child */
//new char[4 * 1024 * 1024]; //new char[4 * 1024 * 1024];
for (size_t i=0; i < 1024 * 16; i++) { for (size_t i=0; i < 1024 * 16; i++)
for (int j=0; j < 256; j++) { {
for (int j=0; j < 256; j++)
{
strerror(j); strerror(j);
} }
} }

View File

@ -3061,7 +3061,7 @@ int parser_t::test(const wchar_t * buff,
arg_count=0; arg_count=0;
command = tok_last(&tok); command = tok_last(&tok);
// Pass SKIP_HOME_DIRECTORIES for https://github.com/fish-shell/fish-shell/issues/512 // Pass SKIP_HOME_DIRECTORIES for https://github.com/fish-shell/fish-shell/issues/512
has_command = expand_one(command, EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES | EXPAND_SKIP_HOME_DIRECTORIES); has_command = expand_one(command, EXPAND_SKIP_CMDSUBST | EXPAND_SKIP_VARIABLES | EXPAND_SKIP_HOME_DIRECTORIES);
if (! has_command) if (! has_command)

View File

@ -306,17 +306,17 @@ const char *safe_strerror(int err)
else else
{ {
int saved_err = errno; int saved_err = errno;
/* Use a shared buffer for this case */ /* Use a shared buffer for this case */
static char buff[384]; static char buff[384];
char errnum_buff[64]; char errnum_buff[64];
format_long_safe(errnum_buff, err); format_long_safe(errnum_buff, err);
buff[0] = '\0'; buff[0] = '\0';
safe_append(buff, "unknown error (errno was ", sizeof buff); safe_append(buff, "unknown error (errno was ", sizeof buff);
safe_append(buff, errnum_buff, sizeof buff); safe_append(buff, errnum_buff, sizeof buff);
safe_append(buff, ")", sizeof buff); safe_append(buff, ")", sizeof buff);
errno = saved_err; errno = saved_err;
return buff; return buff;
} }
@ -326,17 +326,18 @@ void safe_perror(const char *message)
{ {
// Note we cannot use strerror, because on Linux it uses gettext, which is not safe // Note we cannot use strerror, because on Linux it uses gettext, which is not safe
int err = errno; int err = errno;
char buff[384]; char buff[384];
buff[0] = '\0'; buff[0] = '\0';
if (message) { if (message)
{
safe_append(buff, message, sizeof buff); safe_append(buff, message, sizeof buff);
safe_append(buff, ": ", sizeof buff); safe_append(buff, ": ", sizeof buff);
} }
safe_append(buff, safe_strerror(err), sizeof buff); safe_append(buff, safe_strerror(err), sizeof buff);
safe_append(buff, "\n", sizeof buff); safe_append(buff, "\n", sizeof buff);
write(STDERR_FILENO, buff, strlen(buff)); write(STDERR_FILENO, buff, strlen(buff));
errno = err; errno = err;
} }