示例#1
0
void t_isgraph_0xb4()
{
    Assert(isgraph(180)  == 0 ,"isgraph should be 0 for 0xb4");
}
示例#2
0
void loadconfig(char *cfgfile)  /* load aget rc file */
{
	FILE *fd;
	char buf[BUFSIZE];
	char keyword[KEYSIZE];
	char value[VALSIZE];
	char *cp1, *cp2;
	char *variables[] = { "Invalid",
		"ftpanonymoususer",
		"ftpanonymouspass",
		"http_proxyhost",
		"http_proxyuser",
		"http_proxypass",
		"preferredthread"
	};

	int i, key, line, keyword_nums = sizeof(variables)/sizeof(char *);
	int slen = 0;
	int j = 0;

	if ((fd = fopen(cfgfile, "r")) == NULL) {
		fprintf(stderr, "loadconfig: cannot open aget rc file %s, exiting...\n", cfgfile);
		exit(-1);
	}
	line = 0;
	i = 0;
	while ((fgets(buf, BUFSIZE, fd)) != NULL) {
		line++;
		if (buf[0] == '#') 
			continue;
		if ((slen = strlen(buf)) <= 1)
			continue;
		cp1 = buf;
		cp2 = keyword;
		while (isspace((int)*cp1) && (cp1 - buf < slen)) 
			cp1++;
		j = 0;
		while (isgraph((int)*cp1) && (*cp1 != '=') && (j++ < KEYSIZE -2) && (cp1 - buf < slen)) 
			*cp2++ = *cp1++;
		j = 0;
		*cp2 = '\0';
		cp2 = value;
		while ((*cp1 != '\0') && (*cp1 !='\n') && (*cp1 !='=') && (cp1 - buf < slen))
			cp1++;
		cp1++; 
		while (isspace((int)*cp1) && (cp1 - buf < slen))
			cp1++; 
		if (*cp1 == '"') 
			cp1++;
		while ((*cp1 != '\0') && (*cp1 !='\n') && (*cp1 !='"') && (j++ < VALSIZE -2) && (cp1 - buf < slen))
			*cp2++ = *cp1++;
		*cp2-- = '\0';
		if (keyword[0] =='\0' || value[0] =='\0')
			continue;
		key = 0;
		for (i = 0; i < keyword_nums; i++) {
			if ((strcmp(keyword, variables[i])) == 0) {
				key = i;
				break;
			}
		}


		switch(key) {
		case 0:
			fprintf(stderr, "Illegal Keyword in RC file %s: %s\n", cfgfile, keyword);
			break;
		case 1:
			strncpy(ftpanonymoususer, value, VALSIZE);
			break;
		case 2:
			strncpy(ftpanonymouspass, value, VALSIZE);
			break;
		case 3:
			strncpy(http_proxyhost, value, VALSIZE);
			break;
		case 4:
			strncpy(http_proxyuser, value, VALSIZE);
			break;
		case 5:
			strncpy(http_proxypass, value, VALSIZE);
			break;
		case 6:
			preferredthread = atoi(value);
			break;
		}
	}
	fclose(fd);
}
示例#3
0
BBStr *bbTrim( BBStr *s ){
	int n=0,p=s->size();
	while( n<s->size() && !isgraph( (*s)[n] ) ) ++n;
	while( p>n && !isgraph( (*s)[p-1] ) ) --p;
	*s=s->substr( n,p-n );return s;
}
示例#4
0
void t_isgraph_0xc7()
{
    Assert(isgraph(199)  == 0 ,"isgraph should be 0 for 0xc7");
}
示例#5
0
int Gen_ClisfileI(int argc, char **argv)
{
    int line,n,pb,com;
    char bufS[DEF_BS],inS[NSIZE],outS[NSIZE],extS[NSIZE];
    FILE *inPF, *outPF;

    sprintf(inS,"%s",INFILE_S);
    sprintf(extS,"%s",DEF_EXT_S);
    if(!ParseArgsI(argc,argv,
        "-i S -ext S",
        inS,extS,
        (int *)NULL))
    {
        Gen_ClisUse();
        return(FALSE);
    }
    if(!(inPF = OpenUFilePF(inS,"r",NULL)))
    {
        return(FALSE);
    }
    outPF = NULL;
    pb = TRUE;
    com = FALSE;
    line = n = 0;
    while(fgets(bufS,LINEGRAB,inPF) != NULL)
    {
        line++;
        if( (!com) && strstr(bufS,"/*") )
            com = TRUE;
        if( (com) && strstr(bufS,"*/") )
            com = FALSE;
        if(com)
            continue;
        if((pb) && (bufS[0] == '#'))
        {
            INIT_S(outS);
            sscanf(bufS,"# %s",outS);
            if(NO_S(outS))
            {
                printf("Error on line %d\n",line);
                printf("Need name to follow '#'\n");
                printf("ABORTING\n");
                break;
            }
            strcat(outS,".");
            strcat(outS,extS);
            if(!(outPF = OpenUFilePF(outS,"w",NULL)))
            {
                printf("ABORTING\n");
                break;
            }
            GetFilePartsI(outS,NULL,bufS,NULL);
            fprintf(outPF,"# Source listing for %s\n",bufS);
            fprintf(outPF,"# Generated by gen_clis\n");
            FillDateString(bufS);
            fprintf(outPF,"# %s\n",bufS);
            pb = FALSE;
            n++;
            continue;
        }
        if(!outPF)
        {
            continue;   
        }
        if((!isgraph(INT(bufS[0]))) || (strstr(bufS,"break")))
        {
            pb = TRUE;
            if(outPF)
            {
                FILECLOSE(outPF);
                printf("NEW FILE: %s\n",outS);
            }
            continue;
        }
        pb = FALSE;
        fputs(bufS,outPF);
    }
    if(outPF)
    {
        FILECLOSE(outPF);
        printf("NEW FILE: %s\n",outS);
    }
    FILECLOSE(inPF);
    return(TRUE);
}
示例#6
0
void t_isgraph_0xc3()
{
    Assert(isgraph(195)  == 0 ,"isgraph should be 0 for 0xc3");
}
示例#7
0
void t_isgraph_0xc5()
{
    Assert(isgraph(197)  == 0 ,"isgraph should be 0 for 0xc5");
}
示例#8
0
void t_isgraph_0xb9()
{
    Assert(isgraph(185)  == 0 ,"isgraph should be 0 for 0xb9");
}
示例#9
0
void t_isgraph_0xba()
{
    Assert(isgraph(186)  == 0 ,"isgraph should be 0 for 0xba");
}
示例#10
0
void t_isgraph_0x12()
{
    Assert(isgraph(18)  == 0 ,"isgraph should be 0 for 0x12");
}
示例#11
0
void t_isgraph_0xb8()
{
    Assert(isgraph(184)  == 0 ,"isgraph should be 0 for 0xb8");
}
示例#12
0
void t_isgraph_0xb7()
{
    Assert(isgraph(183)  == 0 ,"isgraph should be 0 for 0xb7");
}
示例#13
0
void t_isgraph_0xb6()
{
    Assert(isgraph(182)  == 0 ,"isgraph should be 0 for 0xb6");
}
示例#14
0
void t_isgraph_0xb5()
{
    Assert(isgraph(181)  == 0 ,"isgraph should be 0 for 0xb5");
}
示例#15
0
void t_isgraph_0x13()
{
    Assert(isgraph(19)  == 0 ,"isgraph should be 0 for 0x13");
}
示例#16
0
void t_isgraph_0xbb()
{
    Assert(isgraph(187)  == 0 ,"isgraph should be 0 for 0xbb");
}
示例#17
0
void t_isgraph_0xc2()
{
    Assert(isgraph(194)  == 0 ,"isgraph should be 0 for 0xc2");
}
示例#18
0
void t_isgraph_0xbc()
{
    Assert(isgraph(188)  == 0 ,"isgraph should be 0 for 0xbc");
}
示例#19
0
void t_isgraph_0xc4()
{
    Assert(isgraph(196)  == 0 ,"isgraph should be 0 for 0xc4");
}
示例#20
0
void t_isgraph_0xbd()
{
    Assert(isgraph(189)  == 0 ,"isgraph should be 0 for 0xbd");
}
示例#21
0
void t_isgraph_0xc6()
{
    Assert(isgraph(198)  == 0 ,"isgraph should be 0 for 0xc6");
}
示例#22
0
void t_isgraph_0xbe()
{
    Assert(isgraph(190)  == 0 ,"isgraph should be 0 for 0xbe");
}
示例#23
0
const unsigned char *
pcre_maketables(void)
{
unsigned char *yield, *p;
int i;

#ifndef DFTABLES
yield = (unsigned char*)(pcre_malloc)(tables_length);
#else
yield = (unsigned char*)malloc(tables_length);
#endif

if (yield == NULL) return NULL;
p = yield;

/* First comes the lower casing table */

for (i = 0; i < 256; i++) *p++ = tolower(i);

/* Next the case-flipping table */

for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);

/* Then the character class tables. Don't try to be clever and save effort
on exclusive ones - in some locales things may be different. */

memset(p, 0, cbit_length);
for (i = 0; i < 256; i++)
  {
  if (isdigit(i))
    {
    p[cbit_digit  + i/8] |= 1 << (i&7);
    p[cbit_word   + i/8] |= 1 << (i&7);
    }
  if (isupper(i))
    {
    p[cbit_upper  + i/8] |= 1 << (i&7);
    p[cbit_word   + i/8] |= 1 << (i&7);
    }
  if (islower(i))
    {
    p[cbit_lower  + i/8] |= 1 << (i&7);
    p[cbit_word   + i/8] |= 1 << (i&7);
    }
  if (i == '_')   p[cbit_word   + i/8] |= 1 << (i&7);
  if (isspace(i)) p[cbit_space  + i/8] |= 1 << (i&7);
  if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);
  if (isgraph(i)) p[cbit_graph  + i/8] |= 1 << (i&7);
  if (isprint(i)) p[cbit_print  + i/8] |= 1 << (i&7);
  if (ispunct(i)) p[cbit_punct  + i/8] |= 1 << (i&7);
  if (iscntrl(i)) p[cbit_cntrl  + i/8] |= 1 << (i&7);
  }
p += cbit_length;

/* Finally, the character type table */

for (i = 0; i < 256; i++)
  {
  int x = 0;
  if (isspace(i)) x += ctype_space;
  if (isalpha(i)) x += ctype_letter;
  if (isdigit(i)) x += ctype_digit;
  if (isxdigit(i)) x += ctype_xdigit;
  if (isalnum(i) || i == '_') x += ctype_word;
  if (strchr("*+?{^.$|()[", i) != 0) x += ctype_meta;
  *p++ = x;
  }

return yield;
}
示例#24
0
void t_isgraph_0xbf()
{
    Assert(isgraph(191)  == 0 ,"isgraph should be 0 for 0xbf");
}
示例#25
0
int
network_process_io(int timeout)
{
    network_handle nh;
    static server_handle sh;
    static Stream *s = 0;
    char buffer[1024];
    int count;
    char *ptr, *end;
    int got_some = 0;

    if (s == 0) {
	int flags;

	s = new_stream(1000);

	if ((flags = fcntl(0, F_GETFL)) < 0
	    || fcntl(0, F_SETFL, flags | NONBLOCK_FLAG) < 0) {
	    log_perror("Setting standard input non-blocking");
	    return 0;
	}
    }
    switch (state) {
    case STATE_CLOSED:
	if (listening) {
	    sh = server_new_connection(slistener, nh, 0);
	    state = STATE_OPEN;
	    got_some = 1;
	} else if (timeout != 0)
	    sleep(timeout);
	break;

    case STATE_OPEN:
	for (;;) {
	    while (!input_suspended
		   && (count = read(0, buffer, sizeof(buffer))) > 0) {
		got_some = 1;
		if (binary) {
		    stream_add_string(s, raw_bytes_to_binary(buffer, count));
		    server_receive_line(sh, reset_stream(s));
		} else
		    for (ptr = buffer, end = buffer + count;
			 ptr < end;
			 ptr++) {
			unsigned char c = *ptr;

			if (isgraph(c) || c == ' ' || c == '\t')
			    stream_add_char(s, c);
			else if (c == '\n')
			    server_receive_line(sh, reset_stream(s));
		    }
	    }

	    if (got_some || timeout == 0)
		goto done;

	    sleep(1);
	    timeout--;
	}
    }

  done:
    return got_some;
}
示例#26
0
void t_isgraph_0xc0()
{
    Assert(isgraph(192)  == 0 ,"isgraph should be 0 for 0xc0");
}
示例#27
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   R e a d H D R I m a g e                                                   %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  ReadHDRImage() reads the Radiance RGBE image format and returns it.  It
%  allocates the memory necessary for the new Image structure and returns a
%  pointer to the new image.
%
%  The format of the ReadHDRImage method is:
%
%      Image *ReadHDRImage(const ImageInfo *image_info,ExceptionInfo *exception)
%
%  A description of each parameter follows:
%
%    o image_info: the image info.
%
%    o exception: return any errors or warnings in this structure.
%
*/
static Image *ReadHDRImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
  char
    format[MaxTextExtent],
    keyword[MaxTextExtent],
    tag[MaxTextExtent],
    value[MaxTextExtent];

  double
    gamma;

  Image
    *image;

  int
    c;

  MagickBooleanType
    status,
    value_expected;

  register Quantum
    *q;

  register ssize_t
    i,
    x;

  register unsigned char
    *p;

  ssize_t
    count,
    y;

  unsigned char
    *end,
    pixel[4],
    *pixels;

  /*
    Open image file.
  */
  assert(image_info != (const ImageInfo *) NULL);
  assert(image_info->signature == MagickSignature);
  if (image_info->debug != MagickFalse)
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
      image_info->filename);
  assert(exception != (ExceptionInfo *) NULL);
  assert(exception->signature == MagickSignature);
  image=AcquireImage(image_info,exception);
  status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
  if (status == MagickFalse)
    {
      image=DestroyImageList(image);
      return((Image *) NULL);
    }
  /*
    Decode image header.
  */
  image->columns=0;
  image->rows=0;
  *format='\0';
  c=ReadBlobByte(image);
  if (c == EOF)
    {
      image=DestroyImage(image);
      return((Image *) NULL);
    }
  while (isgraph(c) && (image->columns == 0) && (image->rows == 0))
  {
    if (c == (int) '#')
      {
        char
          *comment;

        register char
          *p;

        size_t
          length;

        /*
          Read comment-- any text between # and end-of-line.
        */
        length=MaxTextExtent;
        comment=AcquireString((char *) NULL);
        for (p=comment; comment != (char *) NULL; p++)
        {
          c=ReadBlobByte(image);
          if ((c == EOF) || (c == (int) '\n'))
            break;
          if ((size_t) (p-comment+1) >= length)
            {
              *p='\0';
              length<<=1;
              comment=(char *) ResizeQuantumMemory(comment,length+
                MaxTextExtent,sizeof(*comment));
              if (comment == (char *) NULL)
                break;
              p=comment+strlen(comment);
            }
          *p=(char) c;
        }
        if (comment == (char *) NULL)
          ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
        *p='\0';
        (void) SetImageProperty(image,"comment",comment,exception);
        comment=DestroyString(comment);
        c=ReadBlobByte(image);
      }
    else
      if (isalnum(c) == MagickFalse)
        c=ReadBlobByte(image);
      else
        {
          register char
            *p;

          /*
            Determine a keyword and its value.
          */
          p=keyword;
          do
          {
            if ((size_t) (p-keyword) < (MaxTextExtent-1))
              *p++=c;
            c=ReadBlobByte(image);
          } while (isalnum(c) || (c == '_'));
          *p='\0';
          value_expected=MagickFalse;
          while ((isspace((int) ((unsigned char) c)) != 0) || (c == '='))
          {
            if (c == '=')
              value_expected=MagickTrue;
            c=ReadBlobByte(image);
          }
          if (LocaleCompare(keyword,"Y") == 0)
            value_expected=MagickTrue;
          if (value_expected == MagickFalse)
            continue;
          p=value;
          while ((c != '\n') && (c != '\0'))
          {
            if ((size_t) (p-value) < (MaxTextExtent-1))
              *p++=c;
            c=ReadBlobByte(image);
          }
          *p='\0';
          /*
            Assign a value to the specified keyword.
          */
          switch (*keyword)
          {
            case 'F':
            case 'f':
            {
              if (LocaleCompare(keyword,"format") == 0)
                {
                  (void) CopyMagickString(format,value,MaxTextExtent);
                  break;
                }
              (void) FormatLocaleString(tag,MaxTextExtent,"hdr:%s",keyword);
              (void) SetImageProperty(image,tag,value,exception);
              break;
            }
            case 'G':
            case 'g':
            {
              if (LocaleCompare(keyword,"gamma") == 0)
                {
                  image->gamma=StringToDouble(value,(char **) NULL);
                  break;
                }
              (void) FormatLocaleString(tag,MaxTextExtent,"hdr:%s",keyword);
              (void) SetImageProperty(image,tag,value,exception);
              break;
            }
            case 'P':
            case 'p':
            {
              if (LocaleCompare(keyword,"primaries") == 0)
                {
                  float
                    chromaticity[6],
                    white_point[2];

                  (void) sscanf(value,"%g %g %g %g %g %g %g %g",
                    &chromaticity[0],&chromaticity[1],&chromaticity[2],
                    &chromaticity[3],&chromaticity[4],&chromaticity[5],
                    &white_point[0],&white_point[1]);
                  image->chromaticity.red_primary.x=chromaticity[0];
                  image->chromaticity.red_primary.y=chromaticity[1];
                  image->chromaticity.green_primary.x=chromaticity[2];
                  image->chromaticity.green_primary.y=chromaticity[3];
                  image->chromaticity.blue_primary.x=chromaticity[4];
                  image->chromaticity.blue_primary.y=chromaticity[5];
                  image->chromaticity.white_point.x=white_point[0],
                  image->chromaticity.white_point.y=white_point[1];
                  break;
                }
              (void) FormatLocaleString(tag,MaxTextExtent,"hdr:%s",keyword);
              (void) SetImageProperty(image,tag,value,exception);
              break;
            }
            case 'Y':
            case 'y':
            {
              if (strcmp(keyword,"Y") == 0)
                {
                  int
                    height,
                    width;

                  (void) sscanf(value,"%d +X %d",&height,&width);
                  image->columns=(size_t) width;
                  image->rows=(size_t) height;
                  break;
                }
              (void) FormatLocaleString(tag,MaxTextExtent,"hdr:%s",keyword);
              (void) SetImageProperty(image,tag,value,exception);
              break;
            }
            default:
            {
              (void) FormatLocaleString(tag,MaxTextExtent,"hdr:%s",keyword);
              (void) SetImageProperty(image,tag,value,exception);
              break;
            }
          }
        }
    if ((image->columns == 0) && (image->rows == 0))
      while (isspace((int) ((unsigned char) c)) != 0)
        c=ReadBlobByte(image);
  }
  if ((LocaleCompare(format,"32-bit_rle_rgbe") != 0) &&
      (LocaleCompare(format,"32-bit_rle_xyze") != 0))
    ThrowReaderException(CorruptImageError,"ImproperImageHeader");
  if ((image->columns == 0) || (image->rows == 0))
    ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize");
  if (LocaleCompare(format,"32-bit_rle_xyze") == 0)
    image->colorspace=XYZColorspace;
  image->compression=(image->columns < 8) || (image->columns > 0x7ffff) ?
    NoCompression : RLECompression;
  if (image_info->ping != MagickFalse)
    {
      (void) CloseBlob(image);
      return(GetFirstImageInList(image));
    }
  /*
    Read RGBE (red+green+blue+exponent) pixels.
  */
  pixels=(unsigned char *) AcquireQuantumMemory(image->columns,4*
    sizeof(*pixels));
  if (pixels == (unsigned char *) NULL)
    ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
  for (y=0; y < (ssize_t) image->rows; y++)
  {
    if (image->compression != RLECompression)
      {
        count=ReadBlob(image,4*image->columns*sizeof(*pixels),pixels);
        if (count != (ssize_t) (4*image->columns*sizeof(*pixels)))
          break;
      }
    else
      {
        count=ReadBlob(image,4*sizeof(*pixel),pixel);
        if (count != 4)
          break;
        if ((size_t) ((((size_t) pixel[2]) << 8) | pixel[3]) != image->columns)
          {
            (void) memcpy(pixels,pixel,4*sizeof(*pixel));
            count=ReadBlob(image,4*(image->columns-1)*sizeof(*pixels),pixels+4);
            image->compression=NoCompression;
          }
        else
          {
            p=pixels;
            for (i=0; i < 4; i++)
            {
              end=&pixels[(i+1)*image->columns];
              while (p < end)
              {
                count=ReadBlob(image,2*sizeof(*pixel),pixel);
                if (count < 1)
                  break;
                if (pixel[0] > 128)
                  {
                    count=(ssize_t) pixel[0]-128;
                    if ((count == 0) || (count > (ssize_t) (end-p)))
                      break;
                    while (count-- > 0)
                      *p++=pixel[1];
                  }
                else
                  {
                    count=(ssize_t) pixel[0];
                    if ((count == 0) || (count > (ssize_t) (end-p)))
                      break;
                    *p++=pixel[1];
                    if (--count > 0)
                      {
                        count=ReadBlob(image,(size_t) count*sizeof(*p),p);
                        if (count < 1)
                          break;
                        p+=count;
                      }
                  }
              }
            }
          }
      }
    q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
    if (q == (Quantum *) NULL)
      break;
    i=0;
    for (x=0; x < (ssize_t) image->columns; x++)
    {
      if (image->compression == RLECompression)
        {
          pixel[0]=pixels[x];
          pixel[1]=pixels[x+image->columns];
          pixel[2]=pixels[x+2*image->columns];
          pixel[3]=pixels[x+3*image->columns];
        }
      else
        {
          pixel[0]=pixels[i++];
          pixel[1]=pixels[i++];
          pixel[2]=pixels[i++];
          pixel[3]=pixels[i++];
        }
      SetPixelRed(image,0,q);
      SetPixelGreen(image,0,q);
      SetPixelBlue(image,0,q);
      if (pixel[3] != 0)
        {
          gamma=pow(2.0,pixel[3]-(128.0+8.0));
          SetPixelRed(image,ClampToQuantum(QuantumRange*gamma*pixel[0]),q);
          SetPixelGreen(image,ClampToQuantum(QuantumRange*gamma*pixel[1]),q);
          SetPixelBlue(image,ClampToQuantum(QuantumRange*gamma*pixel[2]),q);
        }
      q+=GetPixelChannels(image);
    }
    if (SyncAuthenticPixels(image,exception) == MagickFalse)
      break;
    status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
      image->rows);
    if (status == MagickFalse)
      break;
  }
  pixels=(unsigned char *) RelinquishMagickMemory(pixels);
  if (EOFBlob(image) != MagickFalse)
    ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
      image->filename);
  (void) CloseBlob(image);
  return(GetFirstImageInList(image));
}
示例#28
0
void t_isgraph_0xc1()
{
    Assert(isgraph(193)  == 0 ,"isgraph should be 0 for 0xc1");
}
示例#29
0
char *str_token( TOKEN *tok )
{  
  /* skip leading blanks and tabs */

  while( *(tok->next_token) == ' ' || *(tok->next_token) == '\t' ) (tok->next_token)++;  
  tok->actual_token = tok->next_token;

  /* search for open c-comment */

  while( *++(tok->next_token) )
    if( *(tok->next_token) == '/' )
    {
      if( *(tok->next_token-1) == '*' )
      {
        tok->tok_type = TOK_C_COMMENT;
        tok->next_token = char_insert( tok->next_token + 1, '\0' );
        tok->tok_length = (int)(tok->next_token - tok->actual_token - 1);
        return( tok->actual_token );
      }
      if( *(tok->next_token+1) == '*' )
        break;
    }    

  tok->next_token = tok->actual_token;    
  
  /* *next_token is printable character, except space */

  if( '\x20' < *(tok->next_token) && '\x7F' > *(tok->next_token) )
    switch( *(tok->next_token) )
    {
      case '#' :                        /* token is user comment */
        tok->tok_type = TOK_USR_COMMENT;
        while( *++(tok->next_token) );
        tok->tok_length = (int)(tok->next_token - tok->actual_token);
        return( tok->actual_token );
      case '"' :                        /* token is string, delimiter '"' */
        tok->tok_type = TOK_STRING;
        while( *++(tok->next_token) )
          if( *(tok->next_token) == '"' )
          {
            *(tok->next_token)++ = '\0';
            break;
          }
        (tok->actual_token)++;
        tok->tok_length = (int)(tok->next_token - tok->actual_token);
        if( *(tok->next_token) ) (tok->tok_length)--;
        return( tok->actual_token );       
      case '\'' :                       /* token is string, delimiter '\'' */
        tok->tok_type = TOK_STRING;
        while( *++(tok->next_token) )
          if( *(tok->next_token) == '\'' )
          {
            *(tok->next_token)++ = '\0';
            break;
          }
        (tok->actual_token)++;
        tok->tok_length = (int)(tok->next_token - tok->actual_token);
        if( *(tok->next_token) ) (tok->tok_length)--;
        return( tok->actual_token );       
      case '/' :
        if( *++(tok->next_token) == '*' )      /* token is c comment */
        {
          tok->tok_type = TOK_C_COMMENT;
          while( *++(tok->next_token) )
            if( *(tok->next_token) == '*' && *(tok->next_token+1) == '/' )
            {
              tok->next_token = char_insert( tok->next_token + 2, '\0' );
              break;
            }  
          tok->tok_length = (int)(tok->next_token - tok->actual_token);
          if( *(tok->next_token) ) (tok->tok_length)--;
          return( tok->actual_token );
        }
        (tok->next_token)--;
      default :                         /* token is alphanumerical */    
        tok->tok_type = TOK_ALNUM;
        while( isgraph( *++(tok->next_token) ) );
        tok->next_token = char_insert( tok->next_token, '\0' );
        tok->tok_length = (int)(tok->next_token - tok->actual_token - 1);
        return( tok->actual_token );
      }
  else                                    /* token is not printable */
    switch( *(tok->next_token) )
    {
      case '\0' :
        tok->tok_type = TOK_EOS;          /* End Of String reached */
        return( NULL );
      default   :
        if( *(tok->next_token) <= '\x20' )
          tok->tok_type = TOK_CONTROL;   /* Control character */
        else
          tok->tok_type = TOK_INVALID;   /* Invalid token */
        (tok->next_token)++;
        tok->tok_length = 1;
        return( NULL );   
     }
}
示例#30
0
void t_isgraph_0xb3()
{
    Assert(isgraph(179)  == 0 ,"isgraph should be 0 for 0xb3");
}