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

📄 tab.c

📁 代码检索工具GLOBAL源码。可用来浏览分析LINUX源码。
💻 C
字号:
/* * Copyright (c) 1996, 1997, 1998, 1999, 2000 *	Tama Communications Corporation * * This file is part of GNU GLOBAL. * * GNU GLOBAL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * GNU GLOBAL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA. */#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <stdio.h>#include "tab.h"static int tabs = 8;#define TABPOS(i)	((i)%tabs == 0)/* * settabs: set default tab stop * *	i)	n	tab stop */voidsettabs(n)	int n;{	if (n < 1 || n > 32)		return;	tabs = n;}/* * detab: convert tabs into spaces and print * *	i)	op	FILE * *	i)	buf	string including tabs */voiddetab(op, buf)	FILE *op;	const char *buf;{	int src, dst;	char c;	src = dst = 0;	while ((c = buf[src++]) != 0) {		if (c == '\t') {			do {				(void)putc(' ', op);				dst++;			} while (!TABPOS(dst));		} else {			(void)putc(c, op);			dst++;		}	}	(void)putc('\n', op);}/* * entab: convert spaces into tabs * *	io)	buf	string buffer */voidentab(buf)	char *buf;{	int blanks = 0;	int pos, src, dst;	char c;	pos = src = dst = 0;	while ((c = buf[src++]) != 0) {		if (c == ' ') {			if (!TABPOS(++pos)) {				blanks++;		/* count blanks */				continue;			}			/* don't convert single blank into tab */			buf[dst++] = (blanks == 0) ? ' ' : '\t';		} else if (c == '\t') {			while (!TABPOS(++pos))				;			buf[dst++] = '\t';		} else {			++pos;			while (blanks--)				buf[dst++] = ' ';			buf[dst++] = c;		}		blanks = 0;	}	if (blanks > 0)		while (blanks--)			buf[dst++] = ' ';	buf[dst] = 0;}

⌨️ 快捷键说明

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