Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Sobota, 24. október 2026

Rozdiely pre cpdf/parse.c medzi verziami 1.4 a 1.5

verzia 1.4, 2002/09/14 12:42:40 verzia 1.5, 2002/09/26 17:45:15
Riadok 1 
Riadok 1 
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 /* function compute number of locations of char c from buffer to character e  #include "parse.h"
   void *xmalloc(size_t size);
   /* function compute number of locations of char c from buffer to character c
  */   */
 int strlenc(char *buffer, char c, char to)  int strlenc(char *buffer, char c, char to)
 {  {
         register int i = 0;          int i = 0;
         register char *p = buffer;          while (*buffer && *buffer != to) {
         while (*p && *p != to) {                  if (*buffer == c)
                 if (*p == c)  
                         i++;                          i++;
                 p++;                  buffer++;
         }          }
         return i;          return i;
 }  }
 /* function compute lenght of string to char e */  
 int strlento(register char *buffer, char e)  /* function compute lenght of string to char to
    */
   int strlento(char *buffer, char to)
 {  {
         register int i = 0;          int i = 0;
         register char *p = buffer;          while (*buffer && *buffer != to) {
         register char to = e;  
         while (*p && *p != to)  
                 i++;                  i++;
                   buffer++;
           }
         return i;          return i;
 }  }
   
 /* convert hex to bin  */  /* convert hex to bin
    */
 char *hex(char *buffer)  char *hex(char *buffer)
 {  {
         char *hex_array;          char *hex_array, *end;
         char num[2];          char num[5] = { '0', 'x', '\0', '\0', '\0' };
         int i;          int i;
         if (*buffer != '<')          if (*buffer != '<')
                 return NULL;                  return NULL;
         i = strlento(buffer + 1, '>') / 2 * sizeof(char);          if ((i = strlento(buffer + 1, '>') >> 1) == 0)
         hex_array = (char *) malloc(i);                  return NULL;
         while (*buffer != '>') {          end = hex_array = (char *) xmalloc(i);
                 num[0] = *buffer;          for (buffer++; *buffer != '>'; hex_array++) {
                 if (*(buffer + 1) == '>')                  num[2] = *buffer;
                         num[1] = '0';                  if (*(buffer + 1) == '>') {
                 else {                          num[3] = '0';
                         num[1] = *(buffer + 1);                          buffer++;
                   } else {
                           num[3] = *(buffer + 1);
                         buffer += 2;                          buffer += 2;
                 }                  }
                 *hex_array = (char) strtoul((char *) &num, NULL, 16);                  *hex_array = (char) strtoul((char *) &num, NULL, 16);
                 hex_array++;  
         }          }
         return hex_array;          return end;
 }  }
   
 /* interpreter for special characters in name string */  /* interpreter for special characters in name string */
 char *name(char *buffer)  char *name(char *buffer)
 {  {
         register char *ret;          char *ret, *end;
         char num[4] = "0x";          char num[5] = { '0', 'x', '\0', '\0', '\0' };
         if (*buffer != '/')          if (*buffer != '/')
                 return NULL;                  return NULL;
         ret = (char *) malloc(strlento(buffer, ' ') * sizeof(char));          if (memchr(buffer, '#', MAXNAMELEN) == NULL)
         while (*buffer != ' ') {                  return buffer;
           end = ret = (char *) xmalloc(MAXNAMELEN);
           while (*buffer && *buffer != ' ') {
                 if (*buffer == '#') {                  if (*buffer == '#') {
                         num[2] = *(buffer + 1);                          num[2] = *(buffer + 1);
                         num[3] = *(buffer + 2);                          num[3] = *(buffer + 2);
Riadok 69  char *name(char *buffer)
Riadok 76  char *name(char *buffer)
                 ret++;                  ret++;
                 buffer++;                  buffer++;
         }          }
         return ret;          return end;
 }  }
   
 /* parse arrays */  /* parse arrays */
 char **array(char *buffer)  char **array(char *buffer)
 {  {
         register char **ret;          char **ret = NULL;
         register int end, a, index;          int end = 1, len, index = 0;
         if (*buffer != '[')          if (*buffer != '[')
                 return NULL;                  return NULL;
         ret = (char **) malloc(strlenc(buffer, ' ', ']') * sizeof(char));          ret[index] = (char *) xmalloc(1);
         end = a = index = 0;          *ret[index] = '[';
         while (end > 0) {          index++;
                 switch (*buffer) {          buffer += 2;
                 case '[':          do {
                         end++;                  if (*buffer == ']')
                         if (*(buffer + 1) == ' ') {  
                                 buffer += 2;  
                                 continue;  
                         }  
                         break;  
                 case ']':  
                         end--;                          end--;
                         break;                  if (*buffer == '[')
                 case ' ':                          end++;
                         if (*(buffer + 1) == ']')                  len = strlento(buffer, ' ');
                                 break;                  ret[index] = (char *) xmalloc(len);
                         ret[index] = buffer - a;                  strncpy(ret[index], buffer, len);
                         *buffer = '\0';                  buffer += len + 1;
                         a = 0;                  index++;
                         index++;          } while (end > 0);
                         break;  
                 default:  
                         a++;  
                 }  
                 buffer++;  
         }  
         return ret;          return ret;
 }  }

Legend:
Odstranené z verzie1.4  
zmenené riadky
  Pridané vo verzii1.5

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok