97d4b58c28
PR: 48264 Submitted by: David A. Bader <dbader@eece.unm.edu>
43 lines
1.1 KiB
Text
43 lines
1.1 KiB
Text
--- util.c.orig Thu Feb 13 16:19:35 2003
|
|
+++ util.c Thu Feb 13 16:21:40 2003
|
|
@@ -171,10 +171,11 @@
|
|
return str;
|
|
}
|
|
|
|
-void getstr(char *instr,char *outstr)
|
|
+void getstr(char *instr,char *outstr, int len)
|
|
{
|
|
fprintf(stdout,"%s: ",instr);
|
|
- gets(outstr);
|
|
+ fgets(outstr, len, stdin);
|
|
+ outstr[strlen(outstr)-1] = '\0';
|
|
}
|
|
|
|
double getreal(char *instr,double minx,double maxx,double def)
|
|
@@ -185,7 +186,7 @@
|
|
|
|
while(TRUE) {
|
|
fprintf(stdout,"%s (%.1f-%.1f) [%.1f]: ",instr,minx,maxx,def);
|
|
- gets(line);
|
|
+ fgets(line, MAXLINE, stdin);
|
|
status=sscanf(line,"%f",&ret);
|
|
if(status == EOF) return def;
|
|
if(ret>maxx) {
|
|
@@ -210,7 +211,7 @@
|
|
while(TRUE) {
|
|
fprintf(stdout,"%s (%d..%d) [%d]: ",
|
|
instr,(pint)minx,(pint)maxx,(pint)def);
|
|
- gets(line);
|
|
+ fgets(line, MAXLINE, stdin);
|
|
status=sscanf(line,"%d",&ret);
|
|
if(status == EOF) return def;
|
|
if(ret>maxx) {
|
|
@@ -230,7 +231,7 @@
|
|
{
|
|
char line[MAXLINE];
|
|
|
|
- getstr("\n\nEnter system command",line);
|
|
+ getstr("\n\nEnter system command",line,MAXLINE);
|
|
if(*line != EOS)
|
|
system(line);
|
|
fprintf(stdout,"\n\n");
|