mirror of
https://github.com/zoriya/ash.git
synced 2026-06-02 02:35:12 +00:00
inhibitor are now removed correctly
This commit is contained in:
+3
-1
@@ -20,4 +20,6 @@ char **parse_input(char *cmd);
|
||||
int parse_quotes(char *ptr, char **data);
|
||||
|
||||
char *strcat_realloc(char *dest, char *src);
|
||||
char *add_to_buffer(char *buffer, char *ptr, int nb);
|
||||
char *add_to_buffer(char *buffer, char *ptr, int nb, bool inhibitors);
|
||||
|
||||
void remove_inhibitors_symbols_n_limit(char *str, int nb);
|
||||
+3
-3
@@ -59,8 +59,8 @@ int manage_specials_parsers(char *cmd, int index, char **buffer, int *inc, char
|
||||
if (new_index == -1)
|
||||
return (-1);
|
||||
if (new_index > 0) {
|
||||
*buffer = add_to_buffer(*buffer, *ptr, (*inc) - 1);
|
||||
*buffer = add_to_buffer(*buffer, data, strlen(data));
|
||||
*buffer = add_to_buffer(*buffer, *ptr, (*inc) - 1, true);
|
||||
*buffer = add_to_buffer(*buffer, data, strlen(data), false);
|
||||
free(data);
|
||||
*inc = -1;
|
||||
*ptr = cmd + index + 1;
|
||||
@@ -94,7 +94,7 @@ char **parse_input(char *cmd)
|
||||
inc = 0;
|
||||
continue;
|
||||
}
|
||||
buffer = add_to_buffer(buffer, ptr, inc - 1);
|
||||
buffer = add_to_buffer(buffer, ptr, inc - 1, true);
|
||||
if (!buffer)
|
||||
return (NULL);
|
||||
ret[ret_inc++] = buffer;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <malloc.h>
|
||||
#include "parser.h"
|
||||
|
||||
|
||||
|
||||
char *strcat_realloc(char *dest, char *src)
|
||||
{
|
||||
if (dest) {
|
||||
@@ -24,7 +26,7 @@ char *strcat_realloc(char *dest, char *src)
|
||||
return (dest);
|
||||
}
|
||||
|
||||
char *add_to_buffer(char *buffer, char *ptr, int nb)
|
||||
char *add_to_buffer(char *buffer, char *ptr, int nb, bool inhibitors)
|
||||
{
|
||||
char *new;
|
||||
|
||||
@@ -34,7 +36,21 @@ char *add_to_buffer(char *buffer, char *ptr, int nb)
|
||||
if (!new)
|
||||
return (NULL);
|
||||
new[nb] = '\0';
|
||||
if (inhibitors)
|
||||
remove_inhibitors_symbols_n_limit(new, nb);
|
||||
buffer = strcat_realloc(buffer, new);
|
||||
free(new);
|
||||
return (buffer);
|
||||
}
|
||||
|
||||
void remove_inhibitors_symbols_n_limit(char *str, int nb)
|
||||
{
|
||||
for (int i = 0; str[i] && i < nb; i++) {
|
||||
if (str[i] == '\\') {
|
||||
for (int j = i; str[j]; j++) {
|
||||
str[j] = str[j + 1];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user