From 619f88e87fedfaa091382bc05db28f33019d2267 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Sun, 30 Jan 2000 15:44:40 -0800
Subject: [PATCH] better output for non-terminals

Rev: bin/test_pike.pike:1.32
---
 bin/test_pike.pike | 58 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 54 insertions(+), 4 deletions(-)

diff --git a/bin/test_pike.pike b/bin/test_pike.pike
index 08b129f916..11ef8444e4 100755
--- a/bin/test_pike.pike
+++ b/bin/test_pike.pike
@@ -1,6 +1,6 @@
 #!/usr/local/bin/pike
 
-/* $Id: test_pike.pike,v 1.31 1999/12/10 00:51:43 grubba Exp $ */
+/* $Id: test_pike.pike,v 1.32 2000/01/30 23:44:40 hubbe Exp $ */
 
 import Stdio;
 
@@ -18,6 +18,21 @@ int foo(string opt)
   return (int)opt;
 }
 
+int istty_cache;
+int istty()
+{
+#ifdef __NT__
+  return 1;
+#else
+  if(!istty_cache)
+  {
+    istty_cache=!!Stdio.stdin->tcgetattr();
+    if(!istty_cache) istty_cache=-1;
+  }
+  return istty_cache>0;
+#endif
+}
+
 mapping(string:int) cond_cache=([]);
 
 #if constant(thread_create)
@@ -96,6 +111,7 @@ int main(int argc, string *argv)
     ({"check",Getopt.MAY_HAVE_ARG,({"-c","--check"})}),
     ({"mem",Getopt.MAY_HAVE_ARG,({"-m","--mem","--memory"})}),
     ({"auto",Getopt.MAY_HAVE_ARG,({"-a","--auto"})}),
+    ({"notty",Getopt.NO_ARG,({"-t","--notty"})}),
 #ifdef HAVE_DEBUG
     ({"debug",Getopt.MAY_HAVE_ARG,({"-d","--debug"})}),
 #endif
@@ -103,6 +119,10 @@ int main(int argc, string *argv)
     {
       switch(opt[0])
       {
+	case "notty":
+	  istty_cache=-1;
+	  break;
+
 	case "help":
 	  werror("Usage: "+argv[e]+" [-v | --verbose] [-h | --help] [-t <testno>] <testfile>\n");
 	  return 0;
@@ -175,8 +195,32 @@ int main(int argc, string *argv)
       
 	for(e=start;e<sizeof(tests);e++)
 	{
-	  werror("%6d\r",e+1);
-
+	  if(istty())
+	  {
+	    werror("%6d\r",e+1);
+	  }else{
+	    switch( (e-start) % 50)
+	    {
+	      case 0:
+		werror("%5d: ",e);
+		break;
+		
+	      case 9:
+	      case 19:
+	      case 29:
+	      case 39:
+		werror(". ");
+		break;
+		
+	      default:
+		werror(".");
+		break;
+		
+	      case 49:
+		werror(".\n");
+	    }
+	  }
+	    
 	  string test,condition;
 	  string|int type;
 	  object o;
@@ -409,7 +453,13 @@ int main(int argc, string *argv)
 	
 	  a=b=0;
       }
-	werror("             \r");
+
+	if(istty())
+	{
+	  werror("             \r");
+	}else{
+	  werror("\n");
+	}
     }
     if(mem)
     {
-- 
GitLab