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

📄 util.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
字号:
#include "sam.h"voidcvttorunes(char *p, int n, Rune *r, int *nb, int *nr, int *nulls){	uchar *q;	Rune *s;	int j, w;	/*	 * Always guaranteed that n bytes may be interpreted	 * without worrying about partial runes.  This may mean	 * reading up to UTFmax-1 more bytes than n; the caller	 * knows this.  If n is a firm limit, the caller should	 * set p[n] = 0.	 */	q = (uchar*)p;	s = r;	for(j=0; j<n; j+=w){		if(*q < Runeself){			w = 1;			*s = *q++;		}else{			w = chartorune(s, (char*)q);			q += w;		}		if(*s)			s++;		else if(nulls)			*nulls = TRUE;	}	*nb = (char*)q-p;	*nr = s-r;}void*fbufalloc(void){	return emalloc(BUFSIZE);}voidfbuffree(void *f){	free(f);}uintmin(uint a, uint b){	if(a < b)		return a;	return b;}

⌨️ 快捷键说明

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