From 1598828725cc3a14f4e9a1a18b4212ad808a3516 Mon Sep 17 00:00:00 2001 From: kcwu Date: Tue, 16 Aug 2005 14:34:11 +0000 Subject: 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 --- util/Makefile | 2 +- util/stock.perl | 19 ++++++++++--------- util/weather.perl | 1 - util/webgrep.c | 46 ---------------------------------------------- 4 files changed, 11 insertions(+), 57 deletions(-) delete mode 100644 util/webgrep.c (limited to 'util') 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 = ; -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 () { -open(WEATHER, "/usr/bin/lynx -dump http://quotecenter.jpc.com.tw/today_stock_price.htm |"); while() { - print BBSPOST if ($_ ne "\n"); +my $url = 'http://quotecenter.jpc.com.tw/today_stock_price.htm'; +open(WEATHER, "/usr/bin/lynx -dump $url |"); +while() { + 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 () { 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 -#include -#include - -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; -} -- cgit v1.2.3