Mercurial > cpython-lru_cache-weakref
comparison Python/pythonmain.c @ 728:76d92ebb4d82 legacy-trunk
Add -v option (verbose) and get rid of finaloutput() function (unused)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 27 Mar 1992 17:21:30 +0000 |
| parents | 891f98357c04 |
| children | 0cd197947d81 |
comparison
equal
deleted
inserted
replaced
| 727:9a754486ef0b | 728:76d92ebb4d82 |
|---|---|
| 40 extern char *getpythonpath(); | 40 extern char *getpythonpath(); |
| 41 | 41 |
| 42 extern grammar gram; /* From graminit.c */ | 42 extern grammar gram; /* From graminit.c */ |
| 43 | 43 |
| 44 int debugging; /* Needed by parser.c */ | 44 int debugging; /* Needed by parser.c */ |
| 45 int verbose; /* Needed by import.c */ | |
| 45 | 46 |
| 46 /* Interface to getopt(): */ | 47 /* Interface to getopt(): */ |
| 47 extern int optind; | 48 extern int optind; |
| 48 extern char *optarg; | 49 extern char *optarg; |
| 49 extern int getopt PROTO((int, char **, char *)); | 50 extern int getopt PROTO((int, char **, char *)); |
| 58 char *filename = NULL; | 59 char *filename = NULL; |
| 59 FILE *fp = stdin; | 60 FILE *fp = stdin; |
| 60 | 61 |
| 61 initargs(&argc, &argv); /* Defined in config*.c */ | 62 initargs(&argc, &argv); /* Defined in config*.c */ |
| 62 | 63 |
| 63 while ((c = getopt(argc, argv, "c:d")) != EOF) { | 64 while ((c = getopt(argc, argv, "c:dv")) != EOF) { |
| 64 if (c == 'c') { | 65 if (c == 'c') { |
| 65 /* -c is the last option; following arguments | 66 /* -c is the last option; following arguments |
| 66 that look like options are left for the | 67 that look like options are left for the |
| 67 the command to interpret. */ | 68 the command to interpret. */ |
| 68 command = malloc(strlen(optarg) + 2); | 69 command = malloc(strlen(optarg) + 2); |
| 76 | 77 |
| 77 case 'd': | 78 case 'd': |
| 78 debugging++; | 79 debugging++; |
| 79 break; | 80 break; |
| 80 | 81 |
| 82 case 'v': | |
| 83 verbose++; | |
| 84 break; | |
| 85 | |
| 81 /* This space reserved for other options */ | 86 /* This space reserved for other options */ |
| 82 | 87 |
| 83 default: | 88 default: |
| 84 fprintf(stderr, | 89 fprintf(stderr, |
| 85 "usage: %s [-c cmd | file | -] [arg] ...\n", | 90 "usage: %s [-c cmd | file | -] [arg] ...\n", |
| 155 FILE *fp; | 160 FILE *fp; |
| 156 char *filename; | 161 char *filename; |
| 157 { | 162 { |
| 158 if (filename == NULL) | 163 if (filename == NULL) |
| 159 filename = "???"; | 164 filename = "???"; |
| 160 if (isatty(fileno(fp))) | 165 if (isatty((int)fileno(fp))) |
| 161 return run_tty_loop(fp, filename); | 166 return run_tty_loop(fp, filename); |
| 162 else | 167 else |
| 163 return run_script(fp, filename); | 168 return run_script(fp, filename); |
| 164 } | 169 } |
| 165 | 170 |
| 455 | 460 |
| 456 exit(sts); | 461 exit(sts); |
| 457 /*NOTREACHED*/ | 462 /*NOTREACHED*/ |
| 458 } | 463 } |
| 459 | 464 |
| 460 static | |
| 461 finaloutput() | |
| 462 { | |
| 463 #ifdef TRACE_REFS | 465 #ifdef TRACE_REFS |
| 464 if (!askyesno("Print left references?")) | |
| 465 return; | |
| 466 printrefs(stderr); | |
| 467 #endif /* TRACE_REFS */ | |
| 468 } | |
| 469 | |
| 470 /* Ask a yes/no question */ | 466 /* Ask a yes/no question */ |
| 471 | 467 |
| 472 static int | 468 static int |
| 473 askyesno(prompt) | 469 askyesno(prompt) |
| 474 char *prompt; | 470 char *prompt; |
| 478 printf("%s [ny] ", prompt); | 474 printf("%s [ny] ", prompt); |
| 479 if (fgets(buf, sizeof buf, stdin) == NULL) | 475 if (fgets(buf, sizeof buf, stdin) == NULL) |
| 480 return 0; | 476 return 0; |
| 481 return buf[0] == 'y' || buf[0] == 'Y'; | 477 return buf[0] == 'y' || buf[0] == 'Y'; |
| 482 } | 478 } |
| 479 #endif | |
| 483 | 480 |
| 484 #ifdef applec /* MPW (also usable for Think C 3.0) */ | 481 #ifdef applec /* MPW (also usable for Think C 3.0) */ |
| 485 | 482 |
| 486 /* Check for file descriptor connected to interactive device. | 483 /* Check for file descriptor connected to interactive device. |
| 487 Pretend that stdin is always interactive, other files never. */ | 484 Pretend that stdin is always interactive, other files never. */ |
