less bug?

Tito farmatito at tiscali.it
Sun Sep 18 10:57:45 UTC 2005


On Sunday 18 September 2005 11:38, Tito wrote:
> Hi,
> are these supposed to work?
> 
> dmesg | ./busybox less   
> dmesg | ./less   
> 
> because I get only a blank screen with the
> word "stdin" in the left bottom corner.
> 
> Ciao,
> Tito
This changeto  data_readlines() fixes it for me.
This seems to work with files and with pipes,
but should be tested by the mantainer and the gurus.
Let me know if you need a diff.

Ciao,
Tito

static void data_readlines(void) {

	int i;
	char current_line[256];
	FILE *fp;

	fp = (inp_stdin) ? stdin : bb_xfopen(filename, "rt");

	flines = NULL;
	for (i = 0; (feof(fp)==0) && (i <= MAXLINES); i++) {
		fgets(current_line, 256, fp);
		if(fp != stdin)
			bb_xferror(fp, filename);
		flines = xrealloc(flines, (i+1) * sizeof(char *));
		flines[i] = (char *) bb_xstrndup(current_line, (strlen(current_line) + 1) * sizeof(char));
	}
	num_flines = i - 2;

/* Reset variables for a new file */

	line_pos = 0;
	past_eof = 0;

	fclose(fp);

	inp = (inp_stdin) ? fopen(CURRENT_TTY, "r") : stdin;
	
	if (ea_inp_stdin) {
		fclose(inp);
		inp = fopen(CURRENT_TTY, "r");
	}

	if (flags & FLAG_N)
		add_linenumbers();
}



More information about the busybox mailing list