mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-24 03:33:06 +01:00
Add options conditional on whether code is being pasted
This commit is contained in:
parent
9dfe67c7b3
commit
d473c1650b
@ -17,6 +17,8 @@ sub initialize {
|
||||
$self->{sourcefile} = 'prog.c';
|
||||
$self->{execfile} = 'prog';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c11 -lm -Wfatal-errors';
|
||||
$self->{options_paste} = '-fdiagnostics-show-caret';
|
||||
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
||||
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
|
@ -91,14 +91,22 @@ sub show_output {
|
||||
$cmdline =~ s/\$sourcefile/$self->{sourcefile}/g;
|
||||
$cmdline =~ s/\$execfile/$self->{execfile}/g;
|
||||
|
||||
my $options;
|
||||
if (length $self->{cmdline_options}) {
|
||||
$cmdline =~ s/\$options/$self->{cmdline_options}/g;
|
||||
$options = $self->{cmdline_options};
|
||||
} else {
|
||||
if (length $self->{default_options}) {
|
||||
$cmdline =~ s/\$options/$self->{default_options}/g;
|
||||
} else {
|
||||
$cmdline =~ s/\$options\s+//g;
|
||||
}
|
||||
$options = $self->{default_options};
|
||||
}
|
||||
|
||||
if (exists $self->{options_paste}) {
|
||||
$options .= ' ' if length $options;
|
||||
$options .= $self->{options_paste};
|
||||
}
|
||||
|
||||
if (length $options) {
|
||||
$cmdline =~ s/\$options/$options/;
|
||||
} else {
|
||||
$cmdline =~ s/\$options\s+//;
|
||||
}
|
||||
|
||||
my $pretty_code = $self->pretty_format($self->{code});
|
||||
@ -218,10 +226,29 @@ sub execute {
|
||||
$cmdline =~ s/\$sourcefile/$self->{sourcefile}/g;
|
||||
$cmdline =~ s/\$execfile/$self->{execfile}/g;
|
||||
|
||||
my $options;
|
||||
if (length $self->{cmdline_options}) {
|
||||
$cmdline =~ s/\$options/$self->{cmdline_options}/g;
|
||||
$options = $self->{cmdline_options};
|
||||
} else {
|
||||
$cmdline =~ s/\$options/$self->{default_options}/g;
|
||||
$options = $self->{default_options};
|
||||
}
|
||||
|
||||
if ((not exists $self->{options}->{'-paste'}) and (not defined $self->{got_run} or $self->{got_run} ne 'paste')) {
|
||||
if (exists $self->{options_nopaste}) {
|
||||
$options .= ' ' if length $options;
|
||||
$options .= $self->{options_nopaste};
|
||||
}
|
||||
} else {
|
||||
if (exists $self->{options_paste}) {
|
||||
$options .= ' ' if length $options;
|
||||
$options .= $self->{options_paste};
|
||||
}
|
||||
}
|
||||
|
||||
if (length $options) {
|
||||
$cmdline =~ s/\$options/$options/;
|
||||
} else {
|
||||
$cmdline =~ s/\$options\s+//;
|
||||
}
|
||||
|
||||
open FILE, ">> log.txt";
|
||||
|
@ -11,7 +11,9 @@ sub initialize {
|
||||
|
||||
$self->{sourcefile} = 'prog.c';
|
||||
$self->{execfile} = 'prog';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c11 -lm -Wfatal-errors -fsanitize=bounds -fsanitize=alignment -fno-diagnostics-show-caret';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c11 -lm -Wfatal-errors -fsanitize=bounds -fsanitize=alignment';
|
||||
$self->{options_paste} = '-fdiagnostics-show-caret';
|
||||
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
||||
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
|
@ -12,6 +12,8 @@ sub initialize {
|
||||
$self->{sourcefile} = 'prog.c';
|
||||
$self->{execfile} = 'prog';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c89 -lm -Wfatal-errors -fsanitize=bounds -fsanitize=alignment';
|
||||
$self->{options_paste} = '-fdiagnostics-show-caret';
|
||||
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
||||
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
@ -21,6 +23,7 @@ sub initialize {
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
@ -31,6 +34,9 @@ sub initialize {
|
||||
#include <locale.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <prelude.h>
|
||||
|
||||
END
|
||||
|
@ -12,6 +12,8 @@ sub initialize {
|
||||
$self->{sourcefile} = 'prog.c';
|
||||
$self->{execfile} = 'prog';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c99 -lm -Wfatal-errors -fsanitize=bounds -fsanitize=alignment';
|
||||
$self->{options_paste} = '-fdiagnostics-show-caret';
|
||||
$self->{options_nopaste} = '-fno-diagnostics-show-caret';
|
||||
$self->{cmdline} = 'gcc -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
|
@ -11,7 +11,9 @@ sub initialize {
|
||||
|
||||
$self->{sourcefile} = 'prog.c';
|
||||
$self->{execfile} = 'prog';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c11 -lm -Wfatal-errors -fsanitize=integer -fsanitize=bounds -fsanitize=undefined -fno-caret-diagnostics';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c11 -lm -Wfatal-errors -fsanitize=integer -fsanitize=bounds -fsanitize=undefined';
|
||||
$self->{options_paste} = '-fcaret-diagnostics';
|
||||
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
||||
$self->{cmdline} = 'clang -g $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
|
@ -11,7 +11,9 @@ sub initialize {
|
||||
|
||||
$self->{sourcefile} = 'prog.c';
|
||||
$self->{execfile} = 'prog';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c89 -lm -Wfatal-errors -fsanitize=integer -fsanitize=bounds -fsanitize=undefined -fno-caret-diagnostics';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c89 -lm -Wfatal-errors -fsanitize=integer -fsanitize=bounds -fsanitize=undefined';
|
||||
$self->{options_paste} = '-fcaret-diagnostics';
|
||||
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
||||
$self->{cmdline} = 'clang -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
@ -30,6 +32,9 @@ sub initialize {
|
||||
#include <locale.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <prelude.h>
|
||||
|
||||
END
|
||||
|
@ -11,7 +11,9 @@ sub initialize {
|
||||
|
||||
$self->{sourcefile} = 'prog.c';
|
||||
$self->{execfile} = 'prog';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c99 -lm -Wfatal-errors -fsanitize=integer -fsanitize=bounds -fsanitize=undefined -fno-caret-diagnostics';
|
||||
$self->{default_options} = '-Wextra -Wall -Wno-unused -pedantic -Wfloat-equal -Wshadow -std=c99 -lm -Wfatal-errors -fsanitize=integer -fsanitize=bounds -fsanitize=undefined';
|
||||
$self->{options_paste} = '-fcaret-diagnostics';
|
||||
$self->{options_nopaste} = '-fno-caret-diagnostics';
|
||||
$self->{cmdline} = 'clang -ggdb -g3 $sourcefile $options -o $execfile';
|
||||
|
||||
$self->{prelude} = <<'END';
|
||||
|
Loading…
Reference in New Issue
Block a user