Skip to content

Commit 0078939

Browse files
committed
flush buffer if more than 32 char
1 parent fa01941 commit 0078939

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

dse.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,21 @@ int crypt(char *keyfile, int encrypt, char *src, char *dst)
180180
return status;
181181
}
182182

183-
184183
/*=====================================================================*/
185184

186-
187185
int passgets(char *s, int n)
188186
{
189187
int c;
190188
char *t;
191-
192189
t = s;
193190
while(--n >= 0)
194191
{
195192
c = getchar();
196-
if(c < 32 || c > 126) break;
193+
if(c == '\n') break;
197194
*s++ = c;
198195
}
199196
*s = 0;
197+
if(n<0) while (getchar() != '\n') { }; // n char or more, flush the rest of the buffer containing the linefeed
200198
return s != t;
201199
}
202200

@@ -216,7 +214,7 @@ int password(char *pass)
216214
return 1;
217215
}
218216
}
219-
printf("\nError\n");
217+
printf("Error\n");
220218
return 0;
221219
}
222220

0 commit comments

Comments
 (0)