Rework code to get rid of $[ assigment.
Use directly uc instead of customer toupper.
This commit is contained in:
41
lib/lib.pl
41
lib/lib.pl
@@ -1,21 +1,8 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
$[ = 1; # set array base to 1
|
|
||||||
$, = ' '; # set output field separator
|
$, = ' '; # set output field separator
|
||||||
$\ = "\n"; # set output record separator
|
$\ = "\n"; # set output record separator
|
||||||
|
|
||||||
sub toupper {
|
|
||||||
local($_) = @_;
|
|
||||||
tr/a-z/A-Z/;
|
|
||||||
return $_;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub tolower {
|
|
||||||
local($_) = @_;
|
|
||||||
tr/A-Z/a-z/;
|
|
||||||
return $_;
|
|
||||||
}
|
|
||||||
|
|
||||||
print '/* lib.c */';
|
print '/* lib.c */';
|
||||||
print "/* This is a generated file. Please modify `lib.pl' */";
|
print "/* This is a generated file. Please modify `lib.pl' */";
|
||||||
print '';
|
print '';
|
||||||
@@ -86,9 +73,9 @@ while (<>) {
|
|||||||
sub output {
|
sub output {
|
||||||
local($line) = @_;
|
local($line) = @_;
|
||||||
@line_fields = split(/\|/, $line, 9999);
|
@line_fields = split(/\|/, $line, 9999);
|
||||||
$retval = $line_fields[1];
|
$retval = $line_fields[0];
|
||||||
$feature = $line_fields[2];
|
$feature = $line_fields[1];
|
||||||
$param_def = $line_fields[3];
|
$param_def = $line_fields[2];
|
||||||
|
|
||||||
$orig = $feature;
|
$orig = $feature;
|
||||||
$feature =~ s/^@//;
|
$feature =~ s/^@//;
|
||||||
@@ -106,16 +93,16 @@ sub output {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($param_def eq 'string') {
|
if ($param_def eq 'string') {
|
||||||
$call_param = ', ' . $line_fields[4];
|
$call_param = ', ' . $line_fields[3];
|
||||||
$param_buf = '';
|
$param_buf = '';
|
||||||
$buf_set = '';
|
$buf_set = '';
|
||||||
$param_decl = ",\n " . $space . ' const char *' .
|
$param_decl = ",\n " . $space . ' const char *' .
|
||||||
|
|
||||||
$line_fields[4];
|
$line_fields[3];
|
||||||
$send_ptr = "\n\tconst void *send_ptr = " . $line_fields[4] . ';';
|
$send_ptr = "\n\tconst void *send_ptr = " . $line_fields[3] . ';';
|
||||||
$send_size = "\n\tconst size_t send_size =\n\t\tstrlen (" .
|
$send_size = "\n\tconst size_t send_size =\n\t\tstrlen (" .
|
||||||
|
|
||||||
$line_fields[4] . ') + 1;';
|
$line_fields[3] . ') + 1;';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$call_param = '';
|
$call_param = '';
|
||||||
@@ -128,7 +115,7 @@ sub output {
|
|||||||
if ($nr_params) {
|
if ($nr_params) {
|
||||||
$param_buf = "\t\tstruct {\n";
|
$param_buf = "\t\tstruct {\n";
|
||||||
}
|
}
|
||||||
for ($param = 1; $param <= $nr_params; $param++) {
|
for ($param = 0; $param < $nr_params; $param++) {
|
||||||
$list = $params[$param];
|
$list = $params[$param];
|
||||||
$type = $params[$param];
|
$type = $params[$param];
|
||||||
$type =~ s/\(.*//;
|
$type =~ s/\(.*//;
|
||||||
@@ -137,13 +124,13 @@ sub output {
|
|||||||
$count = (@fields = split(/,/, $list, 9999));
|
$count = (@fields = split(/,/, $list, 9999));
|
||||||
|
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
for ($field = 1; $field <= $count; $field++) {
|
for ($field = 0; $field < $count; $field++) {
|
||||||
$param_buf .= "\t\t\t$convert{$type} buf_$fields[$field];\n";
|
$param_buf .= "\t\t\t$convert{$type} buf_$fields[$field];\n";
|
||||||
$buf_set .= "\t\tparam_buf.buf_$fields[$field] = $fields[$field];\n";
|
$buf_set .= "\t\tparam_buf.buf_$fields[$field] = $fields[$field];\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($field = 1; $field <= $count; $field++) {
|
for ($field = 0; $field < $count; $field++) {
|
||||||
if ($param_decl eq '') {
|
if ($param_decl eq '') {
|
||||||
$param_decl = ",\n " . $space . ' ';
|
$param_decl = ",\n " . $space . ' ';
|
||||||
}
|
}
|
||||||
@@ -183,7 +170,7 @@ sub output {
|
|||||||
|
|
||||||
print "\tglibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_" .
|
print "\tglibtop_init_r (&server, (1 << GLIBTOP_SYSDEPS_" .
|
||||||
|
|
||||||
&toupper($feature) . '), 0);';
|
uc($feature) . '), 0);';
|
||||||
|
|
||||||
print '';
|
print '';
|
||||||
print "\t/* If neccessary, we ask the server for the requested";
|
print "\t/* If neccessary, we ask the server for the requested";
|
||||||
@@ -193,7 +180,7 @@ sub output {
|
|||||||
print "\tif ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&";
|
print "\tif ((server->flags & _GLIBTOP_INIT_STATE_SERVER) &&";
|
||||||
print "\t (server->features & (1 << GLIBTOP_SYSDEPS_" .
|
print "\t (server->features & (1 << GLIBTOP_SYSDEPS_" .
|
||||||
|
|
||||||
&toupper($feature) . ')))';
|
uc($feature) . ')))';
|
||||||
print "\t{";
|
print "\t{";
|
||||||
|
|
||||||
if ($param_buf) {
|
if ($param_buf) {
|
||||||
@@ -207,7 +194,7 @@ sub output {
|
|||||||
|
|
||||||
print "\t\t" . $prefix . 'glibtop_call_l (server, GLIBTOP_CMND_' .
|
print "\t\t" . $prefix . 'glibtop_call_l (server, GLIBTOP_CMND_' .
|
||||||
|
|
||||||
&toupper($feature) . ',';
|
uc($feature) . ',';
|
||||||
print "\t\t\t\t" . $prefix_space . 'send_size, send_ptr,';
|
print "\t\t\t\t" . $prefix_space . 'send_size, send_ptr,';
|
||||||
print "\t\t\t\t" . $prefix_space . 'sizeof (glibtop_' . $feature .
|
print "\t\t\t\t" . $prefix_space . 'sizeof (glibtop_' . $feature .
|
||||||
|
|
||||||
@@ -216,7 +203,7 @@ sub output {
|
|||||||
print "\t} else {";
|
print "\t} else {";
|
||||||
|
|
||||||
if ($orig !~ /^@/) {
|
if ($orig !~ /^@/) {
|
||||||
print '#if (!GLIBTOP_SUID_' . &toupper($feature) . ')';
|
print '#if (!GLIBTOP_SUID_' . uc($feature) . ')';
|
||||||
}
|
}
|
||||||
print "\t\t" . $prefix . 'glibtop_get_' . $feature . '_s (server, buf' .
|
print "\t\t" . $prefix . 'glibtop_get_' . $feature . '_s (server, buf' .
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user