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.32 by chris_moore, Tue Mar 30 23:33:59 2004 UTC vs.
Revision 1.38 by pcg, Wed Mar 31 01:50:24 2004 UTC

660 sleep (1); 660 sleep (1);
661 if (e->fp) 661 if (e->fp)
662 fclose (e->fp); 662 fclose (e->fp);
663 if (openlog (e) == NULL) 663 if (openlog (e) == NULL)
664 continue; 664 continue;
665 if (fstat (fileno (e->fp), &stats) < 0)
666 continue;
665 } 667 }
666 668
667 /* HACK-3: stats can be uninitialised here (if the file didn't
668 * exist when stat() was called, but was recreated during the
669 * sleep(1)) */
670 if (stats.st_ino != e->inode) 669 if (stats.st_ino != e->inode)
671 { /* file renamed? */ 670 { /* file renamed? */
672 if (e->fp) 671 if (e->fp)
673 fclose (e->fp); 672 fclose (e->fp);
674 if (openlog (e) == NULL) 673 if (openlog (e) == NULL)
731 */ 730 */
732static void 731static void
733split_line (int idx, const char *str, unsigned long color) 732split_line (int idx, const char *str, unsigned long color)
734{ 733{
735 int l = strlen (str); 734 int l = strlen (str);
735 int last_wrapped = 0;
736 const char *p = str; 736 const char *p = str;
737 static int continuation_width = -1;
738 static int continuation_length;
739
740 /* only calculate the continuation's width once */
741 if (continuation_width == -1)
742 {
743 continuation_length = strlen(continuation);
744 continuation_width = XmbTextEscapement (fontset, continuation, continuation_length);
745 }
737 746
738 do 747 do
739 { 748 {
740 const char *beg = p; 749 const char *beg = p;
750 int w = last_wrapped ? continuation_width : 0;
741 int w = 0, wrapped = 0; 751 int wrapped = 0;
742 const char *break_p = NULL; 752 const char *break_p = NULL;
743 753
744 while (*p) 754 while (*p)
745 { 755 {
746 /* find the length in bytes of the next multibyte character */ 756 /* find the length in bytes of the next multibyte character */
750 760
751 /* find the width in pixels of the next character */ 761 /* find the width in pixels of the next character */
752 int cw = XmbTextEscapement (fontset, p, len); 762 int cw = XmbTextEscapement (fontset, p, len);
753 if (cw + w > width - effect_x_space) 763 if (cw + w > width - effect_x_space)
754 { 764 {
765 if (p == beg)
766 {
767 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);
769 exit(1);
770 }
771
755 wrapped = 1; 772 wrapped = 1;
756 break; 773 break;
757 } 774 }
758 775
759 if (opt_wordwrap && len == 1 && p[0] == ' ') 776 if (opt_wordwrap && len == 1 && p[0] == ' ')
774 } 791 }
775 792
776 { 793 {
777 /* HACK-4 - consider inserting the 'continuation string' 794 /* HACK-4 - consider inserting the 'continuation string'
778 * before the rest of the wrapped line */ 795 * before the rest of the wrapped line */
796 int len = p - beg + (last_wrapped ? continuation_length : 0);
779 char *s = xmalloc (p - beg + 1); 797 char *s = xmalloc (len + 1);
798 if (last_wrapped)
799 {
800 memcpy (s, continuation, continuation_length);
801 memcpy (s + continuation_length, beg, p - beg);
802 }
803 else
780 memcpy (s, beg, p - beg); 804 memcpy (s, beg, len);
805
781 s[p - beg] = 0; 806 s[len] = 0;
782 insert_line (idx); 807 insert_line (idx);
783 lines[idx].line = s; 808 lines[idx].line = s;
784 lines[idx].len = p - beg; 809 lines[idx].len = len;
785 lines[idx].color = color; 810 lines[idx].color = color;
786 } 811 }
787 812
788 /* if we wrapped at a space, don't display the space */ 813 /* if we wrapped at a space, don't display the space */
789 if (opt_wordwrap && wrapped && break_p && break_p != beg) 814 if (opt_wordwrap && wrapped && break_p && break_p != beg)
790 { 815 {
791 l--; 816 l--;
792 p++; 817 p++;
793 } 818 }
819
820 last_wrapped = wrapped;
794 } 821 }
795 while (l); 822 while (l);
796} 823}
797 824
798/* 825/*
1118 1145
1119 e->fname = xstrdup (fname); 1146 e->fname = xstrdup (fname);
1120 if (openlog (e) == NULL) 1147 if (openlog (e) == NULL)
1121 perror (fname), exit (1); 1148 perror (fname), exit (1);
1122 1149
1123 l = strlen (desc); 1150 e->desc = xstrdup (desc);
1124 /* HACK-6: width is in pixels now */
1125 if (l > width - 2) /* must account for [ ] */
1126 l = width - 2;
1127 e->desc = xmalloc (l + 1);
1128 memcpy (e->desc, desc, l);
1129 *(e->desc + l) = '\0';
1130 } 1151 }
1131 1152
1132 e->color = GetColor (fcolor); 1153 e->color = GetColor (fcolor);
1133 e->partial = 0; 1154 e->partial = 0;
1134 e->next = NULL; 1155 e->next = NULL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines