mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 08:51:14 -03:00
Minor comment edits, reindentation and other code formating changes
darcs-hash:20060615103706-ac50b-ad9f7060e40f5a786877e95f027688c90f43b6ec.gz
This commit is contained in:
125
common.c
125
common.c
@@ -720,62 +720,68 @@ wchar_t *escape( const wchar_t *in,
|
|||||||
*(pos++) = L'n';
|
*(pos++) = L'n';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L'\b':
|
case L'\b':
|
||||||
*(pos++) = L'\\';
|
*(pos++) = L'\\';
|
||||||
*(pos++) = L'b';
|
*(pos++) = L'b';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L'\r':
|
case L'\r':
|
||||||
*(pos++) = L'\\';
|
*(pos++) = L'\\';
|
||||||
*(pos++) = L'r';
|
*(pos++) = L'r';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L'\e':
|
case L'\e':
|
||||||
*(pos++) = L'\\';
|
*(pos++) = L'\\';
|
||||||
*(pos++) = L'e';
|
*(pos++) = L'e';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case L'\\':
|
case L'\\':
|
||||||
case L'&':
|
case L'&':
|
||||||
case L'$':
|
case L'$':
|
||||||
case L' ':
|
case L' ':
|
||||||
case L'#':
|
case L'#':
|
||||||
case L'^':
|
case L'^':
|
||||||
case L'<':
|
case L'<':
|
||||||
case L'>':
|
case L'>':
|
||||||
case L'(':
|
case L'(':
|
||||||
case L')':
|
case L')':
|
||||||
case L'[':
|
case L'[':
|
||||||
case L']':
|
case L']':
|
||||||
case L'{':
|
case L'{':
|
||||||
case L'}':
|
case L'}':
|
||||||
case L'?':
|
case L'?':
|
||||||
case L'*':
|
case L'*':
|
||||||
case L'|':
|
case L'|':
|
||||||
case L';':
|
case L';':
|
||||||
case L':':
|
case L':':
|
||||||
case L'\'':
|
case L'\'':
|
||||||
case L'"':
|
case L'"':
|
||||||
case L'%':
|
case L'%':
|
||||||
case L'~':
|
case L'~':
|
||||||
if( escape_all )
|
|
||||||
*pos++ = L'\\';
|
|
||||||
*pos++ = *in;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if( *in < 32 )
|
|
||||||
{
|
{
|
||||||
int tmp = (*in)%16;
|
if( escape_all )
|
||||||
*pos++ = L'\\';
|
*pos++ = L'\\';
|
||||||
*pos++ = L'x';
|
|
||||||
*pos++ = ((*in>15)? L'1' : L'0');
|
|
||||||
*pos++ = tmp > 9? L'a'+(tmp-10):L'0'+tmp;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*pos++ = *in;
|
*pos++ = *in;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
if( *in < 32 )
|
||||||
|
{
|
||||||
|
int tmp = (*in)%16;
|
||||||
|
*pos++ = L'\\';
|
||||||
|
*pos++ = L'x';
|
||||||
|
*pos++ = ((*in>15)? L'1' : L'0');
|
||||||
|
*pos++ = tmp > 9? L'a'+(tmp-10):L'0'+tmp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*pos++ = *in;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
in++;
|
in++;
|
||||||
@@ -798,13 +804,12 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
|||||||
if( !orig )
|
if( !orig )
|
||||||
{
|
{
|
||||||
debug( 0, L"%s called with null input", __func__ );
|
debug( 0, L"%s called with null input", __func__ );
|
||||||
exit(1);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = wcslen( orig );
|
len = wcslen( orig );
|
||||||
in = wcsdup( orig );
|
in = wcsdup( orig );
|
||||||
|
|
||||||
|
|
||||||
if( !in )
|
if( !in )
|
||||||
die_mem();
|
die_mem();
|
||||||
|
|
||||||
@@ -1314,13 +1319,13 @@ static char *gen_unique_nfs_filename( const char *filename )
|
|||||||
pidlen = sprint_pid_t( getpid(), newname + orglen + 1 + hnlen + 1 );
|
pidlen = sprint_pid_t( getpid(), newname + orglen + 1 + hnlen + 1 );
|
||||||
newname[orglen + 1 + hnlen + 1 + pidlen] = '\0';
|
newname[orglen + 1 + hnlen + 1 + pidlen] = '\0';
|
||||||
/* debug( 1, L"gen_unique_nfs_filename returning with: newname = \"%s\"; "
|
/* debug( 1, L"gen_unique_nfs_filename returning with: newname = \"%s\"; "
|
||||||
L"HOST_NAME_MAX = %d; hnlen = %d; orglen = %d; "
|
L"HOST_NAME_MAX = %d; hnlen = %d; orglen = %d; "
|
||||||
L"sizeof(pid_t) = %d; maxpiddigits = %d; malloc'd size: %d",
|
L"sizeof(pid_t) = %d; maxpiddigits = %d; malloc'd size: %d",
|
||||||
newname, (int)HOST_NAME_MAX, hnlen, orglen,
|
newname, (int)HOST_NAME_MAX, hnlen, orglen,
|
||||||
(int)sizeof(pid_t),
|
(int)sizeof(pid_t),
|
||||||
(int)(0.31 * sizeof(pid_t) * CHAR_BIT + 1),
|
(int)(0.31 * sizeof(pid_t) * CHAR_BIT + 1),
|
||||||
(int)(orglen + 1 + hnlen + 1 +
|
(int)(orglen + 1 + hnlen + 1 +
|
||||||
(int)(0.31 * sizeof(pid_t) * CHAR_BIT + 1) + 1) ); */
|
(int)(0.31 * sizeof(pid_t) * CHAR_BIT + 1) + 1) ); */
|
||||||
return newname;
|
return newname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
common.h
4
common.h
@@ -95,8 +95,8 @@ wchar_t **list_to_char_arr( array_list_t *l );
|
|||||||
int fgetws2( wchar_t **buff, int *len, FILE *f );
|
int fgetws2( wchar_t **buff, int *len, FILE *f );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sorts a list of wide strings according to the wcsfilecmp-function
|
Sorts an array_list of wide strings according to the
|
||||||
from the util library
|
wcsfilecmp-function from the util library
|
||||||
*/
|
*/
|
||||||
void sort_list( array_list_t *comp );
|
void sort_list( array_list_t *comp );
|
||||||
|
|
||||||
|
|||||||
23
expand.h
23
expand.h
@@ -137,19 +137,24 @@ enum
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Perform various forms of expansion on in, such as tilde expansion
|
Perform various forms of expansion on in, such as tilde expansion
|
||||||
(~USER becomes the users home directory), variable expansion
|
(\~USER becomes the users home directory), variable expansion
|
||||||
($VAR_NAME becomes the value of the environment variable VAR_NAME),
|
(\$VAR_NAME becomes the value of the environment variable VAR_NAME),
|
||||||
subshell expansion and wildcard expansion. The results are inserted
|
subshell expansion and wildcard expansion. The results are inserted
|
||||||
into the list out.
|
into the list out.
|
||||||
|
|
||||||
If the parameter does not need expansion, it is copied into the list
|
If the parameter does not need expansion, it is copied into the list
|
||||||
out. If expansion is performed, the original parameter is freed and
|
out. If expansion is performed, the original parameter is freed and
|
||||||
newly allocated strings are inserted into the list out.
|
newly allocated strings are inserted into the list out.
|
||||||
|
|
||||||
|
If \c context is non-null, all the strings contained in the
|
||||||
|
array_list_t \c out will be registered to be free'd when context is
|
||||||
|
free'd.
|
||||||
|
|
||||||
|
\param context the halloc context to use for automatic deallocation
|
||||||
\param in The parameter to expand
|
\param in The parameter to expand
|
||||||
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
||||||
\param out The list to which the result will be appended.
|
\param out The list to which the result will be appended.
|
||||||
\return One of EXPAND_OK, EXPAND_ERROR, EXPAND_WILDCARD_MATCH and EXPAND_WILDCARD_NO_MATCH
|
\return One of EXPAND_OK, EXPAND_ERROR, EXPAND_WILDCARD_MATCH and EXPAND_WILDCARD_NO_MATCH. EXPAND_WILDCARD_NO_MATCH and EXPAND_WILDCARD_MATCH are normal exit conditions used only on strings containing wildcards to tell if the wildcard produced any matches.
|
||||||
*/
|
*/
|
||||||
int expand_string( void *context, wchar_t *in, array_list_t *out, int flag );
|
int expand_string( void *context, wchar_t *in, array_list_t *out, int flag );
|
||||||
|
|
||||||
@@ -158,6 +163,10 @@ int expand_string( void *context, wchar_t *in, array_list_t *out, int flag );
|
|||||||
expands to more than one string. This is used for expanding command
|
expands to more than one string. This is used for expanding command
|
||||||
names.
|
names.
|
||||||
|
|
||||||
|
If \c context is non-null, the returning string ill be registered
|
||||||
|
to be free'd when context is free'd.
|
||||||
|
|
||||||
|
\param context the halloc context to use for automatic deallocation
|
||||||
\param in The parameter to expand
|
\param in The parameter to expand
|
||||||
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
\param flag Specifies if any expansion pass should be skipped. Legal values are any combination of EXPAND_SKIP_SUBSHELL EXPAND_SKIP_VARIABLES and EXPAND_SKIP_WILDCARDS
|
||||||
\return The expanded parameter, or 0 on failiure
|
\return The expanded parameter, or 0 on failiure
|
||||||
@@ -166,6 +175,8 @@ wchar_t *expand_one( void *context, wchar_t *in, int flag );
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Convert the variable value to a human readable form, i.e. escape things, handle arrays, etc. Suitable for pretty-printing.
|
Convert the variable value to a human readable form, i.e. escape things, handle arrays, etc. Suitable for pretty-printing.
|
||||||
|
|
||||||
|
\param in the value to escape
|
||||||
*/
|
*/
|
||||||
wchar_t *expand_escape_variable( const wchar_t *in );
|
wchar_t *expand_escape_variable( const wchar_t *in );
|
||||||
|
|
||||||
@@ -174,6 +185,8 @@ wchar_t *expand_escape_variable( const wchar_t *in );
|
|||||||
|
|
||||||
If tilde expansion is needed, the original string is freed and a
|
If tilde expansion is needed, the original string is freed and a
|
||||||
new string, allocated using malloc, is returned.
|
new string, allocated using malloc, is returned.
|
||||||
|
|
||||||
|
\param in the string to tilde expand
|
||||||
*/
|
*/
|
||||||
wchar_t *expand_tilde(wchar_t *in);
|
wchar_t *expand_tilde(wchar_t *in);
|
||||||
|
|
||||||
@@ -186,6 +199,8 @@ wchar_t *expand_tilde(wchar_t *in);
|
|||||||
skipping expansion on them actually does save a small amount of
|
skipping expansion on them actually does save a small amount of
|
||||||
time, since it avoids multiple memory allocations during the
|
time, since it avoids multiple memory allocations during the
|
||||||
expansion process.
|
expansion process.
|
||||||
|
|
||||||
|
\param in the string to test
|
||||||
*/
|
*/
|
||||||
int expand_is_clean( const wchar_t *in );
|
int expand_is_clean( const wchar_t *in );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user