⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 word.c

📁 简单Shell命令调试系统开发的程序
💻 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 + -