?? word.c
字號:
/****************************************/
/* Copyright (c) 2004, 63研究所 苗龍 */
/* All rights reserved. */
/* 作 者:苗龍 */
/****************************************/
#include "word.h"
bit InterpretCommand(unsigned char *ComBuf,stWORDTABLE *WordTable)
{
int i=0; /*ComBuf String pointer*/
int j=0; /*Length of Word */
int k=-1; /*The number of WordTable*/
int StrFlag=0; /*There is "0-9/a-z/A-Z" before " ,()"*/
int SentenceEndFlag=0; /*Sentence end*/
char ch;
WordTable->Num=0;
WordTable->LeftCurveNum=0;//左括號
WordTable->RightCurveNum=0;//右括號
ch=ComBuf[0];
while(!SentenceEndFlag&&i<MaxLenComBuf)
{
if((ch>='0'&&ch<='9')||(ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z')||(ch=='.'))
{
if(StrFlag==0)
{
StrFlag=1;k=k+1;j=0;
if(k>=MaxLenWordTable) return 0;
WordTable->wt[k].Str[j]=ch;
WordTable->Num=k+1;
}
else
{
j=j+1;
if(j>=MaxLenWord) return 0;
WordTable->wt[k].Str[j]=ch;
}
}
else if(ch==' '||ch==','||ch=='('||ch==')'||ch=='\0')
{
if(ch=='(')
WordTable->LeftCurveNum++;
if(ch==')')
WordTable->RightCurveNum++;
if(StrFlag==1)
{
StrFlag=0;j=j+1;
WordTable->wt[k].Str[j]='\0';
WordTable->wt[k].Length=j;
}
if(ch=='\0')
SentenceEndFlag=1;
}
else
{
return 0;
}
i=i+1;
ch=ComBuf[i];
}
if(i<MaxLenComBuf||ComBuf[MaxLenComBuf]=='\0'){
if(WordTable->LeftCurveNum==WordTable->RightCurveNum) return 1;
else return 0;
}
else{
return 0;
}
}
void strlwr(unsigned char *str)//將字符串全部轉換成小寫格式
{
int i;
unsigned char ch;
for(i=0;1;i++){
ch=*(str+i);
if(ch=='\0') break;
else if(ch>='A'&&ch<='Z') *(str+i)=ch-'A'+'a';
}
}
char strcmp(unsigned char *stra,unsigned char *strb)//比較a和b兩個字符串的大小,a>b 1 a=b 0 a<b -1
{
int i;
unsigned char cha,chb;
for(i=0;1;i++){
cha=*(stra+i);
chb=*(strb+i);
if(cha=='\0'&&chb=='\0')
return 0;
else if(cha>chb)
return 1;
else if(cha<chb)
return -1;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -