diff options
| author | 諏訪子 <suwako@076.moe> | 2024-06-18 16:42:23 +0900 | 
|---|---|---|
| committer | 諏訪子 <suwako@076.moe> | 2024-06-18 16:42:23 +0900 | 
| commit | 656923fefbcef9e4071a477194e5706171ee5c18 (patch) | |
| tree | 0bdcdcf56762fb9b85432a409ca18d97d87e8c75 | |
| parent | 564e48b6fb6b53c7420849cf79c7c73f7788ed6c (diff) | |
NetBSD: 起動時間の修正
| -rw-r--r-- | main.c | 2 | ||||
| -rw-r--r-- | src/uptime.c | 7 | ||||
| -rw-r--r-- | src/uptime.h | 2 | 
3 files changed, 11 insertions, 0 deletions
@@ -72,8 +72,10 @@ int main() {    printf("%s ", LOGO[4]);    printf(COLOR"%s%s"RESET, "Uptime", ": "); +#ifndef __NetBSD__    display_days();    printf(", "); +#endif    display_time();    printf("\n"); diff --git a/src/uptime.c b/src/uptime.c index c9f1c8e..49161c9 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -21,11 +21,18 @@ void run_uptime_command(const char *command) {    pclose(p);  } +#ifndef __NetBSD__  void display_days() {    run_uptime_command("uptime | awk '{print $3}' && echo \" days\"");  } +#endif  void display_time() { +#if defined(__NetBSD__) +  run_uptime_command("uptime | awk '{print $3}' | sed 's/,//' | " +                     "sed 's/:/ hours, /' && echo \" mins\""); +#else    run_uptime_command("uptime | awk '{print $5}' | sed 's/,//' | "                       "sed 's/:/ hours, /' && echo \" mins\""); +#endif  } diff --git a/src/uptime.h b/src/uptime.h index 12ee668..74e0afe 100644 --- a/src/uptime.h +++ b/src/uptime.h @@ -1,7 +1,9 @@  #ifndef UPTIME_H  #define UPTIME_H +#ifndef __NetBSD__  void display_days(); +#endif  void display_time();  #endif  | 
