mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-12 19:03:10 +03:00
Just identation of some source files
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
786174fac8
commit
75fe3bf3a8
@ -55,28 +55,28 @@ mc_search__glob_translate_to_regex (gchar * str, gsize * len)
|
||||
while (loop < orig_len) {
|
||||
switch (str[loop]) {
|
||||
case '*':
|
||||
if (!strutils_is_char_escaped (str, &(str[loop]) )) {
|
||||
if (!strutils_is_char_escaped (str, &(str[loop]))) {
|
||||
g_string_append (buff, (inside_group) ? ".*" : "(.*)");
|
||||
loop++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
if (!strutils_is_char_escaped (str, &(str[loop]) )) {
|
||||
if (!strutils_is_char_escaped (str, &(str[loop]))) {
|
||||
g_string_append (buff, (inside_group) ? "." : "(.)");
|
||||
loop++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case ',':
|
||||
if (!strutils_is_char_escaped (str, &(str[loop]) )) {
|
||||
if (!strutils_is_char_escaped (str, &(str[loop]))) {
|
||||
g_string_append (buff, "|");
|
||||
loop++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case '{':
|
||||
if (!strutils_is_char_escaped (str, &(str[loop]) )) {
|
||||
if (!strutils_is_char_escaped (str, &(str[loop]))) {
|
||||
g_string_append (buff, "(");
|
||||
inside_group = TRUE;
|
||||
loop++;
|
||||
@ -84,7 +84,7 @@ mc_search__glob_translate_to_regex (gchar * str, gsize * len)
|
||||
}
|
||||
break;
|
||||
case '}':
|
||||
if (!strutils_is_char_escaped (str, &(str[loop]) )) {
|
||||
if (!strutils_is_char_escaped (str, &(str[loop]))) {
|
||||
g_string_append (buff, ")");
|
||||
inside_group = FALSE;
|
||||
loop++;
|
||||
|
@ -75,7 +75,7 @@ mc_search__hex_translate_to_regex (gchar * str, gsize * len)
|
||||
gsize loop2 = 0;
|
||||
while (loop + loop2 < *len) {
|
||||
if (*(tmp_str + loop + loop2) == '"' &&
|
||||
!strutils_is_char_escaped (tmp_str, tmp_str + loop + loop2 ))
|
||||
!strutils_is_char_escaped (tmp_str, tmp_str + loop + loop2))
|
||||
break;
|
||||
loop2++;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ mc_search__cond_struct_new_regex_ci_str (const char *charset, const char *str, g
|
||||
|
||||
while (loop < str_len && !(tmp->str[loop] == ']'
|
||||
&& !strutils_is_char_escaped (tmp->str,
|
||||
&(tmp->str[loop])))) {
|
||||
&(tmp->str[loop])))) {
|
||||
g_string_append_c (ret_str, tmp->str[loop]);
|
||||
loop++;
|
||||
|
||||
@ -374,7 +374,7 @@ mc_search_regex__process_replace_str (const GString * replace_str, const gsize c
|
||||
*skip_len = 0;
|
||||
|
||||
if (*curr_str == '$' && *(curr_str + 1) == '{' && (*(curr_str + 2) & (char) 0xf0) == 0x30) {
|
||||
if (strutils_is_char_escaped (replace_str->str, curr_str ))
|
||||
if (strutils_is_char_escaped (replace_str->str, curr_str))
|
||||
return -1;
|
||||
|
||||
for (*skip_len = 0;
|
||||
@ -396,7 +396,7 @@ mc_search_regex__process_replace_str (const GString * replace_str, const gsize c
|
||||
}
|
||||
|
||||
if (*curr_str == '\\') {
|
||||
if (strutils_is_char_escaped (replace_str->str, curr_str ))
|
||||
if (strutils_is_char_escaped (replace_str->str, curr_str))
|
||||
return -1;
|
||||
|
||||
if ((*(curr_str + 1) & (char) 0xf0) == 0x30) {
|
||||
|
196
src/strescape.c
196
src/strescape.c
@ -61,44 +61,43 @@
|
||||
return escaped string (which needs to be freed later)
|
||||
or NULL when NULL string is passed.
|
||||
*/
|
||||
char*
|
||||
shell_escape(const char* src)
|
||||
char *
|
||||
shell_escape (const char *src)
|
||||
{
|
||||
GString *str;
|
||||
char *result = NULL;
|
||||
GString *str;
|
||||
char *result = NULL;
|
||||
|
||||
/* do NOT break allocation semantics */
|
||||
if (!src)
|
||||
return NULL;
|
||||
/* do NOT break allocation semantics */
|
||||
if (!src)
|
||||
return NULL;
|
||||
|
||||
if (*src == '\0')
|
||||
return strdup("");
|
||||
if (*src == '\0')
|
||||
return strdup ("");
|
||||
|
||||
str = g_string_new("");
|
||||
|
||||
/* look for the first char to escape */
|
||||
while (1)
|
||||
{
|
||||
char c;
|
||||
/* copy over all chars not to escape */
|
||||
while ((c=(*src)) && shell_escape_nottoesc(c))
|
||||
{
|
||||
g_string_append_c(str,c);
|
||||
src++;
|
||||
}
|
||||
str = g_string_new ("");
|
||||
|
||||
/* at this point we either have an \0 or an char to escape */
|
||||
if (!c) {
|
||||
result = str->str;
|
||||
g_string_free(str,FALSE);
|
||||
return result;
|
||||
}
|
||||
/* look for the first char to escape */
|
||||
while (1) {
|
||||
char c;
|
||||
/* copy over all chars not to escape */
|
||||
while ((c = (*src)) && shell_escape_nottoesc (c)) {
|
||||
g_string_append_c (str, c);
|
||||
src++;
|
||||
}
|
||||
|
||||
g_string_append_c(str,'\\');
|
||||
g_string_append_c(str,c);
|
||||
src++;
|
||||
}
|
||||
/* at this point we either have an \0 or an char to escape */
|
||||
if (!c) {
|
||||
result = str->str;
|
||||
g_string_free (str, FALSE);
|
||||
return result;
|
||||
}
|
||||
|
||||
g_string_append_c (str, '\\');
|
||||
g_string_append_c (str, c);
|
||||
src++;
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/** Unescape paths or other strings for e.g the internal cd
|
||||
@ -110,78 +109,83 @@ shell_escape(const char* src)
|
||||
\returns
|
||||
return unescaped string (which needs to be freed)
|
||||
*/
|
||||
char*
|
||||
shell_unescape(const char* text)
|
||||
char *
|
||||
shell_unescape (const char *text)
|
||||
{
|
||||
GString *str;
|
||||
char *result = NULL;
|
||||
const char* readptr;
|
||||
char c;
|
||||
|
||||
if (!text)
|
||||
return NULL;
|
||||
GString *str;
|
||||
char *result = NULL;
|
||||
const char *readptr;
|
||||
char c;
|
||||
|
||||
if (!text)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* look for the first \ - that's quick skipover if there's nothing to escape */
|
||||
readptr = text;
|
||||
while ((*readptr) && ((*readptr)!='\\')) readptr++;
|
||||
if (!(*readptr)) {
|
||||
result = g_strdup(text);
|
||||
return result;
|
||||
}
|
||||
str = g_string_new_len(text, readptr - text);
|
||||
/* look for the first \ - that's quick skipover if there's nothing to escape */
|
||||
readptr = text;
|
||||
while ((*readptr) && ((*readptr) != '\\'))
|
||||
readptr++;
|
||||
if (!(*readptr)) {
|
||||
result = g_strdup (text);
|
||||
return result;
|
||||
}
|
||||
str = g_string_new_len (text, readptr - text);
|
||||
|
||||
/* if we're here, we're standing on the first '\' */
|
||||
while ((c = *readptr))
|
||||
{
|
||||
if (c=='\\')
|
||||
{
|
||||
readptr++;
|
||||
switch ((c = *readptr))
|
||||
{
|
||||
case '\0': /* end of string! malformed escape string */
|
||||
goto out;
|
||||
/* if we're here, we're standing on the first '\' */
|
||||
while ((c = *readptr)) {
|
||||
if (c == '\\') {
|
||||
readptr++;
|
||||
switch ((c = *readptr)) {
|
||||
case '\0': /* end of string! malformed escape string */
|
||||
goto out;
|
||||
|
||||
case 'n': g_string_append_c(str,'\n'); break;
|
||||
case 'r': g_string_append_c(str,'\r'); break;
|
||||
case 't': g_string_append_c(str,'\t'); break;
|
||||
case 'n':
|
||||
g_string_append_c (str, '\n');
|
||||
break;
|
||||
case 'r':
|
||||
g_string_append_c (str, '\r');
|
||||
break;
|
||||
case 't':
|
||||
g_string_append_c (str, '\t');
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
case '\\':
|
||||
case '#':
|
||||
case '$':
|
||||
case '%':
|
||||
case '(':
|
||||
case ')':
|
||||
case '[':
|
||||
case ']':
|
||||
case '{':
|
||||
case '}':
|
||||
case '<':
|
||||
case '>':
|
||||
case '!':
|
||||
case '*':
|
||||
case '?':
|
||||
case '~':
|
||||
case '`':
|
||||
case '"':
|
||||
case ';':
|
||||
default:
|
||||
g_string_append_c(str,c); break;
|
||||
}
|
||||
}
|
||||
else /* got a normal character */
|
||||
{
|
||||
g_string_append_c(str,c);
|
||||
}
|
||||
readptr++;
|
||||
}
|
||||
out:
|
||||
case ' ':
|
||||
case '\\':
|
||||
case '#':
|
||||
case '$':
|
||||
case '%':
|
||||
case '(':
|
||||
case ')':
|
||||
case '[':
|
||||
case ']':
|
||||
case '{':
|
||||
case '}':
|
||||
case '<':
|
||||
case '>':
|
||||
case '!':
|
||||
case '*':
|
||||
case '?':
|
||||
case '~':
|
||||
case '`':
|
||||
case '"':
|
||||
case ';':
|
||||
default:
|
||||
g_string_append_c (str, c);
|
||||
break;
|
||||
}
|
||||
} else { /* got a normal character */
|
||||
|
||||
result = str->str;
|
||||
g_string_free(str,FALSE);
|
||||
g_string_append_c (str, c);
|
||||
}
|
||||
readptr++;
|
||||
}
|
||||
out:
|
||||
|
||||
result = str->str;
|
||||
g_string_free (str, FALSE);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/** Check if char in pointer contain escape'd chars
|
||||
@ -194,7 +198,7 @@ out:
|
||||
otherwise return FALSE
|
||||
*/
|
||||
gboolean
|
||||
strutils_is_char_escaped ( const char *start, const char *current )
|
||||
strutils_is_char_escaped (const char *start, const char *current)
|
||||
{
|
||||
int num_esc = 0;
|
||||
|
||||
@ -202,7 +206,7 @@ strutils_is_char_escaped ( const char *start, const char *current )
|
||||
return FALSE;
|
||||
|
||||
current--;
|
||||
while (current >= start && *current == '\\' ) {
|
||||
while (current >= start && *current == '\\') {
|
||||
num_esc++;
|
||||
current--;
|
||||
}
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
gboolean shell_is_char_escaped ( const char * );
|
||||
char *shell_unescape( const char * );
|
||||
char *shell_escape( const char * );
|
||||
gboolean shell_is_char_escaped (const char *);
|
||||
char *shell_unescape (const char *);
|
||||
char *shell_escape (const char *);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user