aboutsummaryrefslogtreecommitdiff
path: root/miscutils/less.c
diff options
context:
space:
mode:
author"Vladimir N. Oleynik" <dzo@simtreas.ru>2005-09-22 14:19:34 +0000
committer"Vladimir N. Oleynik" <dzo@simtreas.ru>2005-09-22 14:19:34 +0000
commitb8fa7e88f22c2392684d9f5e3cb590bde3fb741e (patch)
tree255b5d647eac3d73c6e25ce3633b8852dd53cd84 /miscutils/less.c
parent1f0ac23c20a2a65c45bb75f5e0431c9b68b800ea (diff)
downloadbusybox-w32-b8fa7e88f22c2392684d9f5e3cb590bde3fb741e.tar.gz
busybox-w32-b8fa7e88f22c2392684d9f5e3cb590bde3fb741e.tar.bz2
busybox-w32-b8fa7e88f22c2392684d9f5e3cb590bde3fb741e.zip
quick patch - have removed stranges for me
Diffstat (limited to 'miscutils/less.c')
-rw-r--r--miscutils/less.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index 5bf59a130..7b1b96c6d 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -332,7 +332,7 @@ static void status_print(void) {
332 printf("%s%s%s%s", HIGHLIGHT, "- Next: ", files[current_file], NORMAL); 332 printf("%s%s%s%s", HIGHLIGHT, "- Next: ", files[current_file], NORMAL);
333 } 333 }
334 else { 334 else {
335 printf("%c", ':'); 335 putchar(':');
336 } 336 }
337#ifdef CONFIG_FEATURE_LESS_FLAGS 337#ifdef CONFIG_FEATURE_LESS_FLAGS
338 } 338 }
@@ -375,7 +375,7 @@ static void buffer_init(void) {
375 /* Fill the buffer until the end of the file or the 375 /* Fill the buffer until the end of the file or the
376 end of the buffer is reached */ 376 end of the buffer is reached */
377 for (i = 0; (i < (height - 1)) && (i <= num_flines); i++) { 377 for (i = 0; (i < (height - 1)) && (i <= num_flines); i++) {
378 buffer[i] = (char *) bb_xstrdup(flines[i]); 378 buffer[i] = bb_xstrdup(flines[i]);
379 } 379 }
380 380
381 /* If the buffer still isn't full, fill it with blank lines */ 381 /* If the buffer still isn't full, fill it with blank lines */
@@ -394,7 +394,7 @@ static void buffer_down(int nlines) {
394 line_pos += nlines; 394 line_pos += nlines;
395 for (i = 0; i < (height - 1); i++) { 395 for (i = 0; i < (height - 1); i++) {
396 free(buffer[i]); 396 free(buffer[i]);
397 buffer[i] = (char *) bb_xstrdup(flines[line_pos + i]); 397 buffer[i] = bb_xstrdup(flines[line_pos + i]);
398 } 398 }
399 } 399 }
400 else { 400 else {
@@ -404,7 +404,7 @@ static void buffer_down(int nlines) {
404 line_pos += 1; 404 line_pos += 1;
405 for (i = 0; i < (height - 1); i++) { 405 for (i = 0; i < (height - 1); i++) {
406 free(buffer[i]); 406 free(buffer[i]);
407 buffer[i] = (char *) bb_xstrdup(flines[line_pos + i]); 407 buffer[i] = bb_xstrdup(flines[line_pos + i]);
408 } 408 }
409 } 409 }
410 } 410 }
@@ -425,7 +425,7 @@ static void buffer_up(int nlines) {
425 line_pos -= nlines; 425 line_pos -= nlines;
426 for (i = 0; i < (height - 1); i++) { 426 for (i = 0; i < (height - 1); i++) {
427 free(buffer[i]); 427 free(buffer[i]);
428 buffer[i] = (char *) bb_xstrdup(flines[line_pos + i]); 428 buffer[i] = bb_xstrdup(flines[line_pos + i]);
429 } 429 }
430 } 430 }
431 else { 431 else {
@@ -435,7 +435,7 @@ static void buffer_up(int nlines) {
435 line_pos -= 1; 435 line_pos -= 1;
436 for (i = 0; i < (height - 1); i++) { 436 for (i = 0; i < (height - 1); i++) {
437 free(buffer[i]); 437 free(buffer[i]);
438 buffer[i] = (char *) bb_xstrdup(flines[line_pos + i]); 438 buffer[i] = bb_xstrdup(flines[line_pos + i]);
439 } 439 }
440 } 440 }
441 } 441 }
@@ -457,7 +457,7 @@ static void buffer_up(int nlines) {
457 for (i = 0; i < (height - 1); i++) { 457 for (i = 0; i < (height - 1); i++) {
458 free(buffer[i]); 458 free(buffer[i]);
459 if (i < tilde_line - nlines + 1) 459 if (i < tilde_line - nlines + 1)
460 buffer[i] = (char *) bb_xstrdup(flines[line_pos + i]); 460 buffer[i] = bb_xstrdup(flines[line_pos + i]);
461 else { 461 else {
462 if (line_pos >= num_flines - height + 2) 462 if (line_pos >= num_flines - height + 2)
463 buffer[i] = bb_xstrdup("~\n"); 463 buffer[i] = bb_xstrdup("~\n");
@@ -480,7 +480,7 @@ static void buffer_line(int linenum) {
480 else if (linenum < (num_flines - height - 2)) { 480 else if (linenum < (num_flines - height - 2)) {
481 for (i = 0; i < (height - 1); i++) { 481 for (i = 0; i < (height - 1); i++) {
482 free(buffer[i]); 482 free(buffer[i]);
483 buffer[i] = (char *) bb_xstrdup(flines[linenum + i]); 483 buffer[i] = bb_xstrdup(flines[linenum + i]);
484 } 484 }
485 line_pos = linenum; 485 line_pos = linenum;
486 } 486 }
@@ -488,9 +488,9 @@ static void buffer_line(int linenum) {
488 for (i = 0; i < (height - 1); i++) { 488 for (i = 0; i < (height - 1); i++) {
489 free(buffer[i]); 489 free(buffer[i]);
490 if (linenum + i < num_flines + 2) 490 if (linenum + i < num_flines + 2)
491 buffer[i] = (char *) bb_xstrdup(flines[linenum + i]); 491 buffer[i] = bb_xstrdup(flines[linenum + i]);
492 else 492 else
493 buffer[i] = (char *) bb_xstrdup((flags & FLAG_TILDE) ? "\n" : "~\n"); 493 buffer[i] = bb_xstrdup((flags & FLAG_TILDE) ? "\n" : "~\n");
494 } 494 }
495 line_pos = linenum; 495 line_pos = linenum;
496 /* Set past_eof so buffer_down and buffer_up act differently */ 496 /* Set past_eof so buffer_down and buffer_up act differently */
@@ -525,7 +525,7 @@ static void examine_file(void) {
525 newline_offset = strlen(filename) - 1; 525 newline_offset = strlen(filename) - 1;
526 filename[newline_offset] = '\0'; 526 filename[newline_offset] = '\0';
527 527
528 files[num_files] = bb_xstrndup(filename, (strlen(filename) + 1) * sizeof(char)); 528 files[num_files] = bb_xstrdup(filename);
529 current_file = num_files + 1; 529 current_file = num_files + 1;
530 num_files++; 530 num_files++;
531 531
@@ -681,7 +681,15 @@ static void regex_process(void) {
681 /* Get the uncompiled regular expression from the user */ 681 /* Get the uncompiled regular expression from the user */
682 clear_line(); 682 clear_line();
683 putchar((match_backwards) ? '?' : '/'); 683 putchar((match_backwards) ? '?' : '/');
684 scanf("%s", uncomp_regex); 684 uncomp_regex[0] = 0;
685 fgets(uncomp_regex, sizeof(uncomp_regex), stdin);
686 i = strlen(uncomp_regex);
687 if(i > 0) {
688 if(uncomp_regex[i-1] == '\n')
689 uncomp_regex[i-1] = '\0';
690 else
691 while((i = getchar()) != '\n' && i != EOF);
692 }
685 693
686 /* Compile the regex and check for errors */ 694 /* Compile the regex and check for errors */
687 xregcomp(pattern, uncomp_regex, 0); 695 xregcomp(pattern, uncomp_regex, 0);
@@ -689,7 +697,7 @@ static void regex_process(void) {
689 /* Run the regex on each line of the current file here */ 697 /* Run the regex on each line of the current file here */
690 for (i = 0; i <= num_flines; i++) { 698 for (i = 0; i <= num_flines; i++) {
691 strcpy(current_line, process_regex_on_line(flines[i], pattern)); 699 strcpy(current_line, process_regex_on_line(flines[i], pattern));
692 flines[i] = (char *) bb_xstrndup(current_line, sizeof(char) * (strlen(current_line)+1)); 700 flines[i] = bb_xstrdup(current_line);
693 if (match_found) { 701 if (match_found) {
694 match_lines[j] = i; 702 match_lines[j] = i;
695 j++; 703 j++;
@@ -697,7 +705,6 @@ static void regex_process(void) {
697 } 705 }
698 706
699 num_matches = j; 707 num_matches = j;
700
701 if ((match_lines[0] != -1) && (num_flines > height - 2)) 708 if ((match_lines[0] != -1) && (num_flines > height - 2))
702 buffer_line(match_lines[0]); 709 buffer_line(match_lines[0]);
703 else 710 else
@@ -752,7 +759,7 @@ static void number_process(int first_digit) {
752 759
753 /* Receive input until a letter is given (max 80 chars)*/ 760 /* Receive input until a letter is given (max 80 chars)*/
754 while((i < 80) && (num_input[i] = tless_getch()) && isdigit(num_input[i])) { 761 while((i < 80) && (num_input[i] = tless_getch()) && isdigit(num_input[i])) {
755 printf("%c", num_input[i]); 762 putchar(num_input[i]);
756 i++; 763 i++;
757 } 764 }
758 765
@@ -809,16 +816,16 @@ static void flag_change(void) {
809 816
810 switch (keypress) { 817 switch (keypress) {
811 case 'M': 818 case 'M':
812 flags &= ~FLAG_M; 819 flags ^= FLAG_M;
813 break; 820 break;
814 case 'm': 821 case 'm':
815 flags &= ~FLAG_m; 822 flags ^= FLAG_m;
816 break; 823 break;
817 case 'E': 824 case 'E':
818 flags &= ~FLAG_E; 825 flags ^= FLAG_E;
819 break; 826 break;
820 case '~': 827 case '~':
821 flags &= ~FLAG_TILDE; 828 flags ^= FLAG_TILDE;
822 break; 829 break;
823 default: 830 default:
824 break; 831 break;