Mail Archives: djgpp-workers/2011/07/02/14:44:18
Am Samstag, 2. Juli 2011 schrieb Ozkan Sezer:
[snip]
> Quick scanning reveals:
>
> src/utils/djtar/djtar.c: line #208: Missed this because I never use
> it, not needed in cross-tools
>
> src/libc/dos/dir/fnsplit.c::main() line #119 (but that's only TEST code,
> not compiled into lib.)
Yes, I found the same. The proposed changes seem ok to me. If no one oposses
I will commit the patch below.
Regards,
Juan M. Guerrero
* src/stub/stubedit.c: Use fgets instead of gets.
From Ozkan Sezer <sezeroz AT gmail DOT com>
* src/utils/djtar/djtar.c: Use fgets instead of gets.
From Ozkan Sezer <sezeroz AT gmail DOT com>
diff -aprNU3 djgpp.orig/src/stub/stubedit.c djgpp/src/stub/stubedit.c
--- djgpp.orig/src/stub/stubedit.c 2003-01-05 17:59:26 +0000
+++ djgpp/src/stub/stubedit.c 2011-07-02 20:20:40 +0000
@@ -87,9 +87,20 @@ void store_info(char *filename)
char *pose_question(char *question, char *default_answer)
{
static char response[200];
+ char *ptr;
printf("%s ? [%s] ", question, default_answer);
fflush(stdout);
- gets(response);
+ ptr = fgets(response, sizeof(response), stdin);
+ if (!ptr)
+ return 0;
+ for (; *ptr; ++ptr)
+ {
+ if (*ptr == '\n')
+ {
+ *ptr = '\0';
+ break;
+ }
+ }
if (response[0] == '\0')
return 0;
return response;
diff -aprNU3 djgpp.orig/src/utils/djtar/djtar.c djgpp/src/utils/djtar/djtar.c
--- djgpp.orig/src/utils/djtar/djtar.c 2011-02-26 19:52:06 +0000
+++ djgpp/src/utils/djtar/djtar.c 2011-07-02 20:27:00 +0000
@@ -205,12 +205,21 @@ change(char *fname, const char *problem,
fprintf(log_out, " %s %s\n new name : ", problem, fname);
fflush(log_out);
new[0] = '\0';
- if (!gets(new))
+ pos = fgets(new, sizeof(new), stdin);
+ if (!pos)
Fatal("EOF while reading stdin");
+ for (; *pos; ++pos)
+ {
+ if (*pos == '\n')
+ {
+ *pos = '\0';
+ break;
+ }
+ }
- if ((strcmp(new, "") == 0) && (isadir == 2))
+ if ((new[0] == '\0') && (isadir == 2))
return 0;
- if (isadir) isadir=1;
+ if (isadir) isadir = 1;
ch = (CHANGE *)xmalloc(sizeof(CHANGE));
ch->next = change_root;
change_root = ch;
- Raw text -