ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/root-tail/root-tail.c
(Generate patch)

Comparing root-tail/root-tail.c (file contents):
Revision 1.38 by pcg, Wed Mar 31 01:50:24 2004 UTC vs.
Revision 1.39 by pcg, Wed Mar 31 01:59:19 2004 UTC

415 { 415 {
416 /* update the record of what has been displayed; 416 /* update the record of what has been displayed;
417 * first make sure the buffer is big enough */ 417 * first make sure the buffer is big enough */
418 if (display_line->buffer_size <= line->len) 418 if (display_line->buffer_size <= line->len)
419 { 419 {
420 display_line->buffer_size = line->len + 1; 420 display_line->buffer_size = line->len;
421 display_line->line = xrealloc (display_line->line, display_line->buffer_size); 421 display_line->line = xrealloc (display_line->line, display_line->buffer_size);
422 } 422 }
423 423
424 display_line->len = line->len; 424 display_line->len = line->len;
425 memcpy (display_line->line, line->line, line->len); 425 memcpy (display_line->line, line->line, line->len);
432 if (opt_outline) 432 if (opt_outline)
433 { 433 {
434 int x, y; 434 int x, y;
435 XSetForeground (disp, WinGC, black_color); 435 XSetForeground (disp, WinGC, black_color);
436 436
437 for (x = -1; x < 2; x += 2) 437 for (x = -1; x <= 1; x += 2)
438 for (y = -1; y < 2; y += 2) 438 for (y = -1; y <= 1; y += 2)
439 XmbDrawString (disp, root, fontset, WinGC, 439 XmbDrawString (disp, root, fontset, WinGC,
440 win_x + effect_x_offset + x, 440 win_x + effect_x_offset + x,
441 win_y + y + offset, 441 win_y + y + offset,
442 line->line, line->len); 442 line->line, line->len);
443 } 443 }
488 if (i == 0) 488 if (i == 0)
489 { /* matched */ 489 { /* matched */
490 int match_start = matched[0].rm_so; 490 int match_start = matched[0].rm_so;
491 int match_end = matched[0].rm_eo; 491 int match_end = matched[0].rm_eo;
492 int old_len = match_end - match_start; 492 int old_len = match_end - match_start;
493 int new_len = strlen(transform_to); 493 int new_len = strlen (transform_to);
494 int old_whole_len = strlen(s); 494 int old_whole_len = strlen (s);
495
495 printf("regexp was matched by '%s' - replace with '%s'\n", s, transform_to); 496 printf ("regexp was matched by '%s' - replace with '%s'\n", s, transform_to);
496 printf("match is from %d to %d\n", 497 printf ("match is from %d to %d\n", match_start, match_end);
497 match_start, match_end);
498 if (new_len > old_len) { 498 if (new_len > old_len)
499 s = xrealloc(s, old_whole_len + new_len - old_len); 499 s = xrealloc(s, old_whole_len + new_len - old_len);
500 } 500
501 if (new_len != old_len) { 501 if (new_len != old_len)
502 {
502 memcpy(s + match_end + new_len - old_len, 503 memcpy(s + match_end + new_len - old_len,
503 s + match_end, 504 s + match_end,
504 old_whole_len - match_end); 505 old_whole_len - match_end);
505 s[old_whole_len + new_len - old_len] = '\0'; 506 s[old_whole_len + new_len - old_len] = '\0';
506 } 507 }
508
507 memcpy(s + match_start, 509 memcpy (s + match_start,
508 transform_to, 510 transform_to,
509 new_len); 511 new_len);
510 printf("transformed to '%s'\n", s); 512 printf ("transformed to '%s'\n", s);
511 } 513 }
512 else 514 else
513 { 515 {
514 printf("regexp was not matched by '%s'\n", s); 516 printf ("regexp was not matched by '%s'\n", s);
515 } 517 }
516 } 518 }
517} 519}
518#endif 520#endif
519 521
670 { /* file renamed? */ 672 { /* file renamed? */
671 if (e->fp) 673 if (e->fp)
672 fclose (e->fp); 674 fclose (e->fp);
673 if (openlog (e) == NULL) 675 if (openlog (e) == NULL)
674 continue; 676 continue;
677 if (fstat (fileno (e->fp), &stats) < 0)
678 continue;
675 } 679 }
676 680
677 if (stats.st_size < e->last_size) 681 if (stats.st_size < e->last_size)
678 { /* file truncated? */ 682 { /* file truncated? */
679 fseek (e->fp, 0, SEEK_SET); 683 fseek (e->fp, 0, SEEK_SET);
738 static int continuation_length; 742 static int continuation_length;
739 743
740 /* only calculate the continuation's width once */ 744 /* only calculate the continuation's width once */
741 if (continuation_width == -1) 745 if (continuation_width == -1)
742 { 746 {
743 continuation_length = strlen(continuation); 747 continuation_length = strlen (continuation);
744 continuation_width = XmbTextEscapement (fontset, continuation, continuation_length); 748 continuation_width = XmbTextEscapement (fontset, continuation, continuation_length);
745 } 749 }
746 750
747 do 751 do
748 { 752 {
762 int cw = XmbTextEscapement (fontset, p, len); 766 int cw = XmbTextEscapement (fontset, p, len);
763 if (cw + w > width - effect_x_space) 767 if (cw + w > width - effect_x_space)
764 { 768 {
765 if (p == beg) 769 if (p == beg)
766 { 770 {
767 fprintf(stderr, "we can't even fit a single character onto the line\n"); 771 fprintf (stderr, "we can't even fit a single character onto the line\n");
768 if (len == 1) fprintf(stderr, "(the character we couldn't fit was '%c')\n", *p); 772 if (len == 1) fprintf (stderr, "(the character we couldn't fit was '%c')\n", *p);
769 exit(1); 773 exit (1);
770 } 774 }
771 775
772 wrapped = 1; 776 wrapped = 1;
773 break; 777 break;
774 } 778 }
799 { 803 {
800 memcpy (s, continuation, continuation_length); 804 memcpy (s, continuation, continuation_length);
801 memcpy (s + continuation_length, beg, p - beg); 805 memcpy (s + continuation_length, beg, p - beg);
802 } 806 }
803 else 807 else
804 memcpy (s, beg, len); 808 memcpy (s, beg, len);
805 809
806 s[len] = 0; 810 s[len] = 0;
807 insert_line (idx); 811 insert_line (idx);
808 lines[idx].line = s; 812 lines[idx].line = s;
809 lines[idx].len = len; 813 lines[idx].len = len;
860 { 864 {
861 lines[lin].line = xstrdup ("~"); 865 lines[lin].line = xstrdup ("~");
862 lines[lin].len = 1; 866 lines[lin].len = 1;
863 display[lin].line = xstrdup(""); 867 display[lin].line = xstrdup("");
864 display[lin].len = 0; 868 display[lin].len = 0;
865 display[lin].buffer_size = 1; 869 display[lin].buffer_size = 0;
866 lines[lin].color = GetColor (def_color); 870 lines[lin].color = GetColor (def_color);
867 } 871 }
868 872
869 for (;;) 873 for (;;)
870 { 874 {
1133 { 1137 {
1134 if ((e->fp = fdopen (0, "r")) == NULL) 1138 if ((e->fp = fdopen (0, "r")) == NULL)
1135 perror ("fdopen"), exit (1); 1139 perror ("fdopen"), exit (1);
1136 if (fcntl (0, F_SETFL, O_NONBLOCK) < 0) 1140 if (fcntl (0, F_SETFL, O_NONBLOCK) < 0)
1137 perror ("fcntl"), exit (1); 1141 perror ("fcntl"), exit (1);
1142
1138 e->fname = NULL; 1143 e->fname = NULL;
1139 e->inode = 0; 1144 e->inode = 0;
1140 e->desc = xstrdup ("stdin"); 1145 e->desc = xstrdup ("stdin");
1141 } 1146 }
1142 else 1147 else
1143 { 1148 {
1144 int l;
1145
1146 e->fname = xstrdup (fname); 1149 e->fname = xstrdup (fname);
1150
1147 if (openlog (e) == NULL) 1151 if (openlog (e) == NULL)
1148 perror (fname), exit (1); 1152 perror (fname), exit (1);
1149 1153
1150 e->desc = xstrdup (desc); 1154 e->desc = xstrdup (desc);
1151 } 1155 }
1156 1160
1157 if (!loglist) 1161 if (!loglist)
1158 loglist = e; 1162 loglist = e;
1159 if (loglist_tail) 1163 if (loglist_tail)
1160 loglist_tail->next = e; 1164 loglist_tail->next = e;
1165
1161 loglist_tail = e; 1166 loglist_tail = e;
1162 } 1167 }
1163 } 1168 }
1164 1169
1165 if (!loglist) 1170 if (!loglist)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines