… | |
… | |
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) |
… | |
… | |
741 | /* only calculate the continuation's width once */ |
740 | /* only calculate the continuation's width once */ |
742 | if (continuation_width == -1) |
741 | if (continuation_width == -1) |
743 | { |
742 | { |
744 | continuation_length = strlen(continuation); |
743 | continuation_length = strlen(continuation); |
745 | continuation_width = XmbTextEscapement (fontset, continuation, continuation_length); |
744 | continuation_width = XmbTextEscapement (fontset, continuation, continuation_length); |
746 | printf("continuation width is %d and length is %d\n", continuation_width, continuation_length); |
|
|
747 | } |
745 | } |
748 | |
746 | |
749 | do |
747 | do |
750 | { |
748 | { |
751 | const char *beg = p; |
749 | const char *beg = p; |
… | |
… | |
762 | |
760 | |
763 | /* find the width in pixels of the next character */ |
761 | /* find the width in pixels of the next character */ |
764 | int cw = XmbTextEscapement (fontset, p, len); |
762 | int cw = XmbTextEscapement (fontset, p, len); |
765 | if (cw + w > width - effect_x_space) |
763 | if (cw + w > width - effect_x_space) |
766 | { |
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 | |
767 | wrapped = 1; |
772 | wrapped = 1; |
768 | break; |
773 | break; |
769 | } |
774 | } |
770 | |
775 | |
771 | if (opt_wordwrap && len == 1 && p[0] == ' ') |
776 | if (opt_wordwrap && len == 1 && p[0] == ' ') |
… | |
… | |
1140 | |
1145 | |
1141 | e->fname = xstrdup (fname); |
1146 | e->fname = xstrdup (fname); |
1142 | if (openlog (e) == NULL) |
1147 | if (openlog (e) == NULL) |
1143 | perror (fname), exit (1); |
1148 | perror (fname), exit (1); |
1144 | |
1149 | |
1145 | l = strlen (desc); |
1150 | e->desc = xstrdup (desc); |
1146 | /* HACK-6: width is in pixels now */ |
|
|
1147 | if (l > width - 2) /* must account for [ ] */ |
|
|
1148 | l = width - 2; |
|
|
1149 | e->desc = xmalloc (l + 1); |
|
|
1150 | memcpy (e->desc, desc, l); |
|
|
1151 | *(e->desc + l) = '\0'; |
|
|
1152 | } |
1151 | } |
1153 | |
1152 | |
1154 | e->color = GetColor (fcolor); |
1153 | e->color = GetColor (fcolor); |
1155 | e->partial = 0; |
1154 | e->partial = 0; |
1156 | e->next = NULL; |
1155 | e->next = NULL; |