Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 23, 2026

Diff for cpdf/svga.c between version 1.5 and 1.6

version 1.5, 2002/12/23 02:40:05 version 1.6, 2003/02/11 20:10:30
Line 1 
Line 1 
 #include <stdio.h>  #include <stdio.h>
   #include <string.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
Line 11 
Line 12 
 #include "utils.h"  #include "utils.h"
 #include "filter.h"  #include "filter.h"
   
 void text(char *start, char *end)  char *strndup(const char *s, size_t n);
   
   void donothing(char *line)
   {
           return;
   }
   
   void text(char *line)
 {  {
         char *tj;          char *tj = NULL, delim[2];
         int x = 10, y = 10, len = end - start;          int x = 10, y = 10;
         tj = strnstr(start, "TJ", len) - 1;          if ((tj = strstr(line, "TJ")) != NULL) {
         while (*tj != '[')                  delim[0] = ']';
                 tj--;                  delim[1] = 'J';
         while (tj != end) {                  while (*tj != '[')
                 if (*tj == '(')                          tj--;
                         for (tj++; *tj != ')'; tj++) {          }
                                 gl_writen(x, y, sizeof(char), tj);          if (!tj)
                                 x += 10;                  if ((tj = strstr(line, "Tj")) != NULL) {
                                 if (x == screen.x - 10) {                          delim[0] = ')';
                                         x = 10;                          delim[1] = 'j';
                                         y += 10;                          while (*tj != '(')
                                 }                                  tj--;
                                 if (y == screen.y - 10)                  }
                                         y = 10;          if (!tj)
                         }                  return;
           tj++;
           while (*tj != delim[0] && *(tj + 1) != 'T'
                  && *(tj + 2) != delim[1]) {
   #ifndef DEBUG
                   gl_writen(x, y, sizeof(char), tj);
   #endif
                   x += 10;
                   if (x == screen.x - 10) {
                           x = 10;
                           y += 10;
                   }
                   if (y == screen.y - 10)
                           y = 10;
                 tj++;                  tj++;
         }          }
         return;          return;
Line 37  void text(char *start, char *end)
Line 58  void text(char *start, char *end)
   
 void render(void)  void render(void)
 {  {
         char *content, *txtstart, *txtend;          char *content, *p, *endline, *dup;
         unsigned long dstlen;          unsigned long dstlen;
         struct page *page;          struct page *page;
           void (*fun) (char *line) = donothing;
         page = (struct page *) get_object(page_tree[current_page], NULL);          page = (struct page *) get_object(page_tree[current_page], NULL);
         dstlen = 3 * page->contents->length;          if(!page)
         txtstart = content = (char *) xcalloc((int) dstlen, 1);                  return;
           dstlen = page->contents->length << 3;
           content = (char *) xcalloc((int) dstlen, sizeof(char));
 #ifndef DEBUG  #ifndef DEBUG
         gl_setfont(8, 8, gl_font8x8);          gl_setfont(8, 8, gl_font8x8);
         gl_setwritemode(FONT_COMPRESSED + WRITEMODE_OVERWRITE);          gl_setwritemode(FONT_COMPRESSED + WRITEMODE_OVERWRITE);
         gl_setfontcolors(0xFFFFFFFF, 0);          gl_setfontcolors(0xFFFFFFFF, 0);
 #endif  #endif
         filter(page->contents->filter, page->contents->stream,          if (page->contents->filter != -1) {
                page->contents->length, content, &dstlen);                  filter(page->contents->filter, page->contents->stream,
         content = (char *) realloc(content, dstlen);                         page->contents->length, content, &dstlen);
                   if (dstlen != page->contents->length << 3)
                           content = (char *) realloc(content, dstlen);
           }
         write(2, content, (int) dstlen);          write(2, content, (int) dstlen);
         while ((txtstart = strnstr(txtstart + 1, "BT", dstlen)) != NULL) {          p = content;
                 txtend = strnstr(txtstart, "ET", dstlen);          while ((endline = strchr(p, '\n')) != NULL) {
                 text(txtstart, txtend);                  dup = strndup(p, endline - p + 1);
                 txtstart = txtend;                  if (strstr(dup, "BT"))
                           fun = text;
                   if (strstr(dup, "ET"))
                           fun = donothing;
                   fun(dup);
                   free(dup);
                   p = endline + 1;
         }          }
 #ifndef DEBUG  #ifndef DEBUG
         gl_copyscreen(physicalscreen);          gl_copyscreen(physicalscreen);
 #endif  #endif
           free(content);
         getchar();          getchar();
         exit(0);          return;
 }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top