mirror of
https://github.com/sheumann/hush.git
synced 2025-01-13 21:31:51 +00:00
Patch from Rob Landley;
Moving on to building diffutils, busybox sed needs this patch to get past the first problem. (Passing it a multi-line command line argument with -e works, but if you don't use -e it doesn't break up the multiple lines...)
This commit is contained in:
parent
fd7bc13557
commit
42c25735e6
@ -344,6 +344,8 @@ static int parse_subst_cmd(sed_cmd_t * const sed_cmd, const char *substr)
|
|||||||
sed_cmd->which_match=(unsigned short)strtol(substr+idx,&pos,10);
|
sed_cmd->which_match=(unsigned short)strtol(substr+idx,&pos,10);
|
||||||
idx=pos-substr;
|
idx=pos-substr;
|
||||||
}
|
}
|
||||||
|
/* Skip spaces */
|
||||||
|
if(isspace(substr[idx])) continue;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch (substr[idx]) {
|
switch (substr[idx]) {
|
||||||
@ -366,10 +368,6 @@ static int parse_subst_cmd(sed_cmd_t * const sed_cmd, const char *substr)
|
|||||||
case 'I':
|
case 'I':
|
||||||
cflags |= REG_ICASE;
|
cflags |= REG_ICASE;
|
||||||
break;
|
break;
|
||||||
/* Skip spaces */
|
|
||||||
case ' ':
|
|
||||||
case '\t':
|
|
||||||
break;
|
|
||||||
case ';':
|
case ';':
|
||||||
case '}':
|
case '}':
|
||||||
goto out;
|
goto out;
|
||||||
@ -1043,6 +1041,24 @@ discard_line:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* It is possible to have a command line argument with embedded
|
||||||
|
newlines. This counts as multiple command lines. */
|
||||||
|
|
||||||
|
static void add_cmd_block(char *cmdstr)
|
||||||
|
{
|
||||||
|
int go=1;
|
||||||
|
char *temp=bb_xstrdup(cmdstr),*temp2=temp;
|
||||||
|
|
||||||
|
while(go) {
|
||||||
|
int len=strcspn(temp2,"\n");
|
||||||
|
if(!temp2[len]) go=0;
|
||||||
|
else temp2[len]=0;
|
||||||
|
add_cmd(temp2);
|
||||||
|
temp2+=len+1;
|
||||||
|
}
|
||||||
|
free(temp);
|
||||||
|
}
|
||||||
|
|
||||||
extern int sed_main(int argc, char **argv)
|
extern int sed_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int opt, status = EXIT_SUCCESS;
|
int opt, status = EXIT_SUCCESS;
|
||||||
@ -1060,23 +1076,8 @@ extern int sed_main(int argc, char **argv)
|
|||||||
be_quiet++;
|
be_quiet++;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
{
|
add_cmd_block(optarg);
|
||||||
int go=1;
|
|
||||||
char *temp=bb_xstrdup(optarg),*temp2=temp;
|
|
||||||
|
|
||||||
/* It is possible to have a command line argument with embedded
|
|
||||||
newlines. This counts as a multi-line argument. */
|
|
||||||
|
|
||||||
while(go) {
|
|
||||||
int len=strcspn(temp2,"\n");
|
|
||||||
if(!temp2[len]) go=0;
|
|
||||||
else temp2[len]=0;
|
|
||||||
add_cmd(temp2);
|
|
||||||
temp2+=len+1;
|
|
||||||
}
|
|
||||||
free(temp);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case 'f':
|
case 'f':
|
||||||
{
|
{
|
||||||
FILE *cmdfile;
|
FILE *cmdfile;
|
||||||
@ -1097,8 +1098,6 @@ extern int sed_main(int argc, char **argv)
|
|||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Flush any unfinished commands. */
|
|
||||||
add_cmd("");
|
|
||||||
|
|
||||||
/* if we didn't get a pattern from a -e and no command file was specified,
|
/* if we didn't get a pattern from a -e and no command file was specified,
|
||||||
* argv[optind] should be the pattern. no pattern, no worky */
|
* argv[optind] should be the pattern. no pattern, no worky */
|
||||||
@ -1106,8 +1105,10 @@ extern int sed_main(int argc, char **argv)
|
|||||||
if (argv[optind] == NULL)
|
if (argv[optind] == NULL)
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
else
|
else
|
||||||
add_cmd(argv[optind++]);
|
add_cmd_block(argv[optind++]);
|
||||||
}
|
}
|
||||||
|
/* Flush any unfinished commands. */
|
||||||
|
add_cmd("");
|
||||||
|
|
||||||
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
||||||
* files were specified or '-' was specified, take input from stdin.
|
* files were specified or '-' was specified, take input from stdin.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user