utils.c

来自「DM64+系列 interpreter 程序」· C语言 代码 · 共 50 行

C
50
字号
/*
 *  Copyright 2002 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */

#include "utils.h"

/* Check if all the characters in the string test are positive integers */
int isnum(char * test){
	int i = 0;
	if (test == NULL){
		return 0;
	}
	
	for (i = 0; i < strlen(test); i++){
		if ((test[i] < '0') || (test[i] > '9')){ /* Not a number */
			return 0;
		}
	}
	
	return 1;
}

/* Check if all the characters in the string test are blank spaces */
int is_space(char * test){
	int i = 0;
	if (test == NULL){
		return 1;
	}
	if (strlen(test) == 0){
		return 1;
	}
	for (i = 0; i < strlen(test); i++){
		if ((test[i] == ' ') || (test[i] == '\t'))
			continue;
		else
			return 0;
	}
	return 1;
}

/* Get the array index for a register */
int get_index(char * reg){
	return ((int)reg[0] - 65);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?