diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-16 22:34:11 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-08-16 22:34:11 +0800 |
commit | 1598828725cc3a14f4e9a1a18b4212ad808a3516 (patch) | |
tree | 2cb820bce71131ecf10acb43babf9a601cfb22a8 /util | |
parent | 472675788b286d9ce07d478c03b1f526048f682f (diff) | |
download | pttbbs-1598828725cc3a14f4e9a1a18b4212ad808a3516.tar pttbbs-1598828725cc3a14f4e9a1a18b4212ad808a3516.tar.gz pttbbs-1598828725cc3a14f4e9a1a18b4212ad808a3516.tar.bz2 pttbbs-1598828725cc3a14f4e9a1a18b4212ad808a3516.tar.lz pttbbs-1598828725cc3a14f4e9a1a18b4212ad808a3516.tar.xz pttbbs-1598828725cc3a14f4e9a1a18b4212ad808a3516.tar.zst pttbbs-1598828725cc3a14f4e9a1a18b4212ad808a3516.zip |
it's stupid to call c program in perl for string manipulation.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3050 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r-- | util/Makefile | 2 | ||||
-rw-r--r-- | util/stock.perl | 19 | ||||
-rw-r--r-- | util/weather.perl | 1 | ||||
-rw-r--r-- | util/webgrep.c | 46 |
4 files changed, 11 insertions, 57 deletions
diff --git a/util/Makefile b/util/Makefile index e423d171..cc94fdd5 100644 --- a/util/Makefile +++ b/util/Makefile @@ -31,7 +31,7 @@ CPROG_WITH_UTIL= \ # 下面這些程式, 會直接被 compile CPROG_WITHOUT_UTIL= \ uhash_loader showboard \ - countalldice webgrep bbsrf initbbs \ + countalldice bbsrf initbbs \ userlist merge_passwd \ merge_board bbsmail gamble_fix diff --git a/util/stock.perl b/util/stock.perl index 568c2d86..1c4120ed 100644 --- a/util/stock.perl +++ b/util/stock.perl @@ -6,18 +6,19 @@ # 中央氣象局的 WWW 及 URL 是否正確。 # 理論上適用所有 Eagle BBS 系列。 # -- Beagle Apr 13 1997 -open(BBSPOST, "| bin/webgrep >etc/stock.tmp"); -# 日期 -open(DATE, "date +'%a %b %d %T %Y' |"); -$date = <DATE>; -chop $date; -close DATE; +open(BBSPOST, " >etc/stock.tmp"); # Header # 內容 -#open(WEATHER, "/usr/local/bin/lynx -dump http://www.dashin.com.tw/bulletin_board/today_stock_price.htm |"); while (<WEATHER>) { -open(WEATHER, "/usr/bin/lynx -dump http://quotecenter.jpc.com.tw/today_stock_price.htm |"); while(<WEATHER>) { - print BBSPOST if ($_ ne "\n"); +my $url = 'http://quotecenter.jpc.com.tw/today_stock_price.htm'; +open(WEATHER, "/usr/bin/lynx -dump $url |"); +while(<WEATHER>) { + next if $_ eq "\n"; + last if m/^References/; + + s/\[[0-9\]]*//g; + + print BBSPOST $_; } close WEATHER; diff --git a/util/weather.perl b/util/weather.perl index 0c3ce208..36d773d7 100644 --- a/util/weather.perl +++ b/util/weather.perl @@ -20,7 +20,6 @@ sub weather_report # Header # 內容 -#open(WEATHER, "$LYNX -assume_charset=big5 -assume_local_charset=big5 -dump http://www.cwb.gov.tw/V3.0/weather/text/W03.htm |"); open(WEATHER, "$LYNX -assume_charset=big5 -assume_local_charset=big5 -dump -nolist $link|"); while (<WEATHER>) { diff --git a/util/webgrep.c b/util/webgrep.c deleted file mode 100644 index d101e035..00000000 --- a/util/webgrep.c +++ /dev/null @@ -1,46 +0,0 @@ -/* $Id$ */ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> - -int main() -{ - char genbuf[256], *str, *buf; - while (fgets(genbuf, 255, stdin)) - { - register int ansi; - if (!strncmp(genbuf, "References", 10)) - break; - str = genbuf; - buf = genbuf; - if (!strncmp(genbuf, "lynx: Can't access", 18)) - { - printf("氣象報導小姐休假中,請到Record板翻過去資料."); - break; - } - for (ansi = 0; *str; str++) - { - if (*str == '[' && strchr("0123456789", *(str + 1))) - { - ansi = 1; - } - else if (ansi) - { - if (!strchr("0123456789]", *str)) - { - ansi = 0; - if (str) - *buf++ = *str; - } - } - else - { - if (str) - *buf++ = *str; - } - } - *buf = 0; - printf(genbuf); - } - return 0; -} |