-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #296 from evalEmpire/rewrite_cmd_wrapper
Rewrite cmd wrapper
- Loading branch information
Showing
8 changed files
with
77 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ nytprof* | |
MYMETA.* | ||
*.o | ||
bin/perl5i | ||
bin/perl5i.c | ||
bin/perl5i.h | ||
bin/perl5i.bat | ||
.prove | ||
*.swp | ||
*.dSYM/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Meant to mimic the shell command | ||
* exec perl -Mperl5i::latest "$@" | ||
* | ||
* This is a C program so it works in a #! line with minimal overhead. | ||
*/ | ||
|
||
#define DEBUG 0 | ||
|
||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <errno.h> | ||
#include <stdlib.h> | ||
#include "perl5i.h" | ||
|
||
char *safe_cat(char *a, char*b) { | ||
char *new = malloc(sizeof(char) * (strlen(a) + strlen(b) + 1)); | ||
|
||
strcpy(new, a); | ||
strcat(new, b); | ||
|
||
return new; | ||
} | ||
|
||
int main (int argc, char* argv[]) { | ||
int i; | ||
|
||
char **exec_args = malloc(sizeof(char*) * (argc + 2)); | ||
int num_exec_args = argc + 1; | ||
|
||
/* Insert -Mperl5i::cmd=... into a copy of argv */ | ||
exec_args[0] = argv[0]; | ||
exec_args[1] = safe_cat("-Mperl5i::cmd=", argv[0]); | ||
for( i = 1; i < argc; i++ ) { | ||
exec_args[i+1] = argv[i]; | ||
} | ||
|
||
exec_args[num_exec_args] = NULL; | ||
|
||
execv(Perl_Path, exec_args ); | ||
|
||
fprintf(stderr, "Executing %s failed: %s\n", Perl_Path, strerror(errno)); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Write out a header config file for the perl5i C wrapper. | ||
|
||
use strict; | ||
use warnings; | ||
use File::Spec; | ||
|
||
my $file = shift; | ||
|
||
# Its going inside double quotes. | ||
my $perl_path = $^X; | ||
$perl_path =~ s{ ([\\"]) }{\\$1}gx; | ||
|
||
my $tempdir = File::Spec->tmpdir || "/tmp"; | ||
|
||
open my $fh, ">", $file or die $!; | ||
printf $fh <<"END"; | ||
/* THIS FILE IS GENERATED BY $0 | ||
* Any changes here will be wiped out. Edit it there instead. | ||
*/ | ||
const char Perl_Path[] = "$perl_path"; | ||
const char Temp_Template[] = "$tempdir/perl5i.XXXXXXXX"; | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters