OSDN Git Service

Update reflace_many
authora <a@b.c>
Tue, 1 Nov 2016 20:28:31 +0000 (21:28 +0100)
committera <a@b.c>
Tue, 1 Nov 2016 20:28:31 +0000 (21:28 +0100)
README.md
doc/pinkybar.1
doc/pinkybar.texi
set.pl [moved from portable_sed.pl with 55% similarity]

index a4ef07a..770f125 100644 (file)
--- a/README.md
+++ b/README.md
@@ -206,7 +206,7 @@ Don't just rush to register yourself, read carefully what the "Free" account lim
 ## Installation for dwm
 
 ```bash
-perl portable_sed.pl "distro"
+perl set.pl "distro"
 autoreconf --install --force
 
 ./configure --prefix=$HOME/.cache --with-x11
@@ -223,7 +223,7 @@ Copy the code from extra/scripts/dwm.sh or `exec` it from **xinitrc** or the scr
 mkdir -p --mode=700 $HOME/.xmonad/icons
 cp -r extra/xbm_icons/*.xbm $HOME/.xmonad/icons
 
-perl portable_sed.pl "distro"
+perl set.pl "distro"
 autoreconf --install --force
 
 # disable X11, point the location to the icons
@@ -262,7 +262,7 @@ Copy only 'dev.MODULE.NUMBER' (if there is any number at all) and paste it into
 Do the same for your cpu temperature, copy and paste the variable as is. **dev.cpu.0.temperature** below is provied as example.
 
 ```bash
-perl portable_sed.pl "distro"
+perl set.pl "distro"
 autoreconf --install --force
 
 ./configure --prefix=$HOME/.cache --with-x11 --without-alsa --with-oss mobo_sensor='dev.aibs.0' cpu_sensor='dev.cpu.0.temperature'
@@ -295,7 +295,7 @@ pkg_add gcc
 ## pinky curses installation
 
 ```bash
-perl portable_sed.pl "distro"
+perl set.pl "distro"
 autoreconf --install --force
 
 # disable X11, enable the colours and ncurses opts.
@@ -326,7 +326,7 @@ pinky-bar is no longer tied to Window Managers only. With the addition of "witho
 The installation steps:
 
 ```bash
-perl portable_sed.pl "distro"
+perl set.pl "distro"
 autoreconf --install --force
 
 ./configure --prefix=$HOME/.cache --without-x11 --without-colours
index b77b016..d62e91e 100644 (file)
@@ -797,7 +797,7 @@ I'm not responsible if you exceeded the limits, you've been warned.
 .IP
 .nf
 \f[C]
-perl\ portable_sed.pl\ "distro"
+perl\ set.pl\ "distro"
 autoreconf\ \-\-install\ \-\-force
 
 \&./configure\ \-\-prefix=$HOME/.cache\ \-\-with\-x11
@@ -816,7 +816,7 @@ Copy the code from extra/scripts/dwm.sh or \f[C]exec\f[] it from
 mkdir\ \-p\ \-\-mode=700\ $HOME/.xmonad/icons
 cp\ \-r\ extra/xbm_icons/*.xbm\ $HOME/.xmonad/icons
 
-perl\ portable_sed.pl\ "distro"
+perl\ set.pl\ "distro"
 autoreconf\ \-\-install\ \-\-force
 
 #\ disable\ X11,\ point\ the\ location\ to\ the\ icons
@@ -867,7 +867,7 @@ Do the same for your cpu temperature, copy and paste the variable as is.
 .IP
 .nf
 \f[C]
-perl\ portable_sed.pl\ "distro"
+perl\ set.pl\ "distro"
 autoreconf\ \-\-install\ \-\-force
 
 \&./configure\ \-\-prefix=$HOME/.cache\ \-\-with\-x11\ \-\-without\-alsa\ \-\-with\-oss\ mobo_sensor=\[aq]dev.aibs.0\[aq]\ cpu_sensor=\[aq]dev.cpu.0.temperature\[aq]
@@ -904,7 +904,7 @@ pkg_add\ gcc
 .IP
 .nf
 \f[C]
-perl\ portable_sed.pl\ "distro"
+perl\ set.pl\ "distro"
 autoreconf\ \-\-install\ \-\-force
 
 #\ disable\ X11,\ enable\ the\ colours\ and\ ncurses\ opts.
@@ -947,7 +947,7 @@ The installation steps:
 .IP
 .nf
 \f[C]
-perl\ portable_sed.pl\ "distro"
+perl\ set.pl\ "distro"
 autoreconf\ \-\-install\ \-\-force
 
 \&./configure\ \-\-prefix=$HOME/.cache\ \-\-without\-x11\ \-\-without\-colours
index 4dfe56e..bac7a28 100644 (file)
@@ -572,7 +572,7 @@ you've been warned.
 @anchor{#installation-for-dwm}
 
 @verbatim
-perl portable_sed.pl "distro"
+perl set.pl "distro"
 autoreconf --install --force
 
 ./configure --prefix=$HOME/.cache --with-x11
@@ -592,7 +592,7 @@ Copy the code from extra/scripts/dwm.sh or @code{exec} it from
 mkdir -p --mode=700 $HOME/.xmonad/icons
 cp -r extra/xbm_icons/*.xbm $HOME/.xmonad/icons
 
-perl portable_sed.pl "distro"
+perl set.pl "distro"
 autoreconf --install --force
 
 # disable X11, point the location to the icons
@@ -639,7 +639,7 @@ Do the same for your cpu temperature, copy and paste the variable as is.
 @strong{dev.cpu.0.temperature} below is provied as example.
 
 @verbatim
-perl portable_sed.pl "distro"
+perl set.pl "distro"
 autoreconf --install --force
 
 ./configure --prefix=$HOME/.cache --with-x11 --without-alsa --with-oss mobo_sensor='dev.aibs.0' cpu_sensor='dev.cpu.0.temperature'
@@ -677,7 +677,7 @@ pkg_add gcc
 @anchor{#pinky-curses-installation}
 
 @verbatim
-perl portable_sed.pl "distro"
+perl set.pl "distro"
 autoreconf --install --force
 
 # disable X11, enable the colours and ncurses opts.
@@ -718,7 +718,7 @@ information will be shown. The tmux status bar in action:
 The installation steps:
 
 @verbatim
-perl portable_sed.pl "distro"
+perl set.pl "distro"
 autoreconf --install --force
 
 ./configure --prefix=$HOME/.cache --without-x11 --without-colours
similarity index 55%
rename from portable_sed.pl
rename to set.pl
index c623aae..b663ad1 100644 (file)
+++ b/set.pl
@@ -51,8 +51,8 @@ sub reflace_configure {
   my ($new) = @_;
   my $filename = "configure.ac";
 
-  my $derefs = re_read(\$filename);
-  my @arr = split("\n", $$derefs);
+  my $refs = re_read(\$filename);
+  my @arr = split("\n", $$refs);
   $arr[9] = $$new;
   my $concatArr = join("\n", @arr);
 
@@ -61,15 +61,15 @@ sub reflace_configure {
 }
 
 sub reflace_many {
-  my ($ag1,$ag2,$ag3,$ag4,$ag5,$ag6,$filename) = @_;
+  my ($arr,$filename) = @_;
   my $derefFilename = $$filename;
   my $concatArr = re_read(\$derefFilename);
-  my $derefs = $$concatArr;
-
-  $derefs =~ s/$ag1/$$ag2/g;
-  $derefs =~ s/$ag3/$$ag4/g;
-  $derefs =~ s/$ag5/$$ag6/g;
+  my @arr2 = @$arr;
+  my ($x,$arrLen,$derefs) = (0,$#arr2,$$concatArr);
 
+  for (; $x <= $arrLen; $x++) {
+    $derefs =~ s/${$arr2[$x][0]}/${$arr2[$x][1]}/g;
+  }
   re_write(\$derefFilename,\$derefs);
   return;
 }
@@ -85,39 +85,44 @@ sub reflace_single {
   return;
 }
 
-my ($amCF, $srcToAppend, $bsdLibs) = ("", "", "");
-my $osEntered = $ARGV[0] ? uc $ARGV[0] : die "No OS/Distro supplied.";
 
-my $srcMake = "src/Makefile.am";
-my $defTits = "m4_define([cuRos],[$osEntered])";
-my $bsdCF = "-D_DEFAULT_SOURCE -L/usr/local/lib";
-my $posixCF = "-D_POSIX_C_SOURCE=200112L";
-
-if ($osEntered eq "FREEBSD") {
-  $bsdLibs = "-largp -ldevstat";
-  $amCF = \$bsdCF;
-  $defTits = "$defTits m4_define([FREEBZD], [tits])";
-  $srcToAppend = "freebsd_functions.c include/freebzd.h";
-}
-elsif ($osEntered eq "OPENBSD") {
-  $bsdLibs = "-largp -lossaudio";
-  $amCF = \$bsdCF;
-  $defTits = "$defTits m4_define([OPENBZD], [forSure])";
-  $srcToAppend = "openbsd_functions.c include/openbzd.h";
+{
+  my ($amCF, $srcToAppend, $bsdLibs) = ("", "", "");
+  my $osEntered = $ARGV[0] ? uc $ARGV[0] : die "No OS/Distro supplied.";
+
+  my $srcMake = "src/Makefile.am";
+  my $defTits = "m4_define([cuRos],[$osEntered])";
+  my $bsdCF = "-D_DEFAULT_SOURCE -L/usr/local/lib";
+  my $posixCF = "-D_POSIX_C_SOURCE=200112L";
+  my ($amStr, $srcStr, $bsdStr) = ("{amCF}","{srcFiles}","{bzdlibs}");
+
+  if ($osEntered eq "FREEBSD") {
+    $bsdLibs = "-largp -ldevstat";
+    $amCF = \$bsdCF;
+    $defTits = "$defTits m4_define([FREEBZD], [tits])";
+    $srcToAppend = "freebsd_functions.c include/freebzd.h";
+  }
+  elsif ($osEntered eq "OPENBSD") {
+    $bsdLibs = "-largp -lossaudio";
+    $amCF = \$bsdCF;
+    $defTits = "$defTits m4_define([OPENBZD], [forSure])";
+    $srcToAppend = "openbsd_functions.c include/openbzd.h";
+  }
+  else {
+    $amCF = \$posixCF;
+    $defTits = "$defTits m4_define([LINUKS], [cryMeAriver])";
+    $srcToAppend = "linux_functions.c";
+  }
+
+  copy("src/Makefail.skel",$srcMake)
+    or die "Could not copy src/Makefail.skel $!";
+
+  reflace_configure(\$defTits);
+
+  my @hugeArr = (
+    [\$amStr, \$$amCF],
+    [\$srcStr, \$srcToAppend],
+    [\$bsdStr, \$bsdLibs]
+  );
+  reflace_many(\@hugeArr,\$srcMake);
 }
-else {
-  $amCF = \$posixCF;
-  $defTits = "$defTits m4_define([LINUKS], [cryMeAriver])";
-  $srcToAppend = "linux_functions.c";
-}
-
-copy("src/Makefail.skel",$srcMake)
-  or die "Could not copy src/Makefail.skel $!";
-
-reflace_configure(\$defTits);
-reflace_many(
-  "{amCF}", \$$amCF,
-  "{srcFiles}", \$srcToAppend,
-  "{bzdlibs}", \$bsdLibs,
-  \$srcMake
-);