RESULT result = { 0, 0, 0, NULL };
printf("\neval> ");
- for (fgets(line, 1024, stdin); !feof(stdin); fgets(line, 1024, stdin)) {
+ for (fgets(line, sizeof(line), stdin); !feof(stdin); fgets(line, sizeof(line), stdin)) {
if (line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0';
if (strlen(line) > 0) {
static void my_readline(RESULT * result, RESULT * arg1, RESULT * arg2)
{
char value[80], val2[80];
- char *pos;
FILE *fp;
int reqline, i, size;
i = 0;
while (!feof(fp) && i++ < reqline) {
fgets(val2, sizeof(val2), fp);
- size = strcspn(val2, "\n");
+ size = strcspn(val2, "\r\n");
strncpy(value, val2, size);
value[size] = '\0';
- pos = strchr(val2, '\n');
/* more than 80 chars, chew up rest of line */
- while (!pos) {
+ while (!feof(fp) && strchr(val2, '\n') == NULL) {
fgets(val2, sizeof(val2), fp);
- pos = strchr(val2, '\n');
}
}
fclose(fp);
if (!fp)
return;
- while (fgets(line, 128, fp)) {
+ while (fgets(line, sizeof(line), fp)) {
if (*line == '#')
continue;
if (!strncmp(line, number, strlen(number))) {