fgets() coz Axel wants it :p
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5661 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4cba418c34
commit
1a1ac7a563
@ -433,15 +433,13 @@ status_t Initialize(int fatbits, const char *device, const char *label, bool nop
|
||||
printf("Initializing will erase all existing data on the drive.\n");
|
||||
printf("Do you wish to proceed? ");
|
||||
char answer[1000];
|
||||
char *p = answer;
|
||||
char *p;
|
||||
memset(answer, 0, 1000);
|
||||
fflush(stdout);
|
||||
while ((p < answer + 1000) && (read(0, p, 1) == 1) && (*p != '\n') && (*p != '\r'))
|
||||
p++;
|
||||
*p = '\0';
|
||||
|
||||
//scanf("%s",answer); //XXX who wants to fix this buffer overflow?
|
||||
if ((strlen(answer) < 1) || (0 != strncasecmp(answer, "yes", strlen(answer)))) {
|
||||
p = fgets(answer, 1000, stdin);
|
||||
if (p && (p=strchr(p, '\n')))
|
||||
*p = '\0'; /* remove newline */
|
||||
if ((p == NULL) || (strlen(answer) < 1) || (0 != strncasecmp(answer, "yes", strlen(answer)))) {
|
||||
printf("drive NOT initialized\n");
|
||||
close(fd);
|
||||
return B_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user