资源简介
bash4.4源代码,学习了解bash原理,及系统级别开发的绝佳参考
代码片段和文件信息
/* alias.c -- Not a full alias but just the kind that we use in the
shell. Csh style alias is somewhere else (‘over there in a box‘). */
/* Copyright (C) 1987-2015 Free Software Foundation Inc.
This file is part of GNU Bash the Bourne Again SHell.
Bash 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 3 of the License or
(at your option) any later version.
Bash 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 Bash. If not see .
*/
#include “config.h“
#if defined (ALIAS)
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include
# endif
# include
#endif
#include
#include “chartypes.h“
#include “bashansi.h“
#include “command.h“
#include “general.h“
#include “externs.h“
#include “alias.h“
#if defined (PROGRAMMABLE_COMPLETION)
# include “pcomplete.h“
#endif
#if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR)
# include /* mbschr */
#endif
#define ALIAS_HASH_BUCKETS 64 /* must be power of two */
typedef int sh_alias_map_func_t __P((alias_t *));
static void free_alias_data __P((PTR_T));
static alias_t **map_over_aliases __P((sh_alias_map_func_t *));
static void sort_aliases __P((alias_t **));
static int qsort_alias_compare __P((alias_t ** alias_t **));
#if defined (READLINE)
static int skipquotes __P((char * int));
static int skipws __P((char * int));
static int rd_token __P((char * int));
#endif
/* Non-zero means expand all words on the line. Otherwise expand
after first expansion if the expansion ends in a space. */
int alias_expand_all = 0;
/* The list of aliases that we have. */
HASH_TABLE *aliases = (HASH_TABLE *)NULL;
void
initialize_aliases ()
{
if (aliases == 0)
aliases = hash_create (ALIAS_HASH_BUCKETS);
}
/* Scan the list of aliases looking for one with NAME. Return NULL
if the alias doesn‘t exist else a pointer to the alias_t. */
alias_t *
find_alias (name)
char *name;
{
BUCKET_CONTENTS *al;
if (aliases == 0)
return ((alias_t *)NULL);
al = hash_search (name aliases 0);
return (al ? (alias_t *)al->data : (alias_t *)NULL);
}
/* Return the value of the alias for NAME or NULL if there is none. */
char *
get_alias_value (name)
char *name;
{
alias_t *alias;
if (aliases == 0)
return ((char *)NULL);
alias = find_alias (name);
return (alias ? alias->value : (char *)NULL);
}
/* Make a new alias from NAME and VALUE. If NAME can be found
then replace its value. */
void
add_alias (name value)
char *name *value;
{
BUCKET_CONTENTS *elt;
alias_t *temp;
int n;
if (aliases == 0
相关资源
- 我的世界源码(易语言版)
- labview编程软件滤波器以及编写程序设
- 我的界面(visual foxpro)源码
- 易语言:一键cf基址源码
- The Secret Path 3D 3D魔方迷宫[源码][scra
- scratch垃圾分类源码(最终版本).sb
- 安卓QQ6.71协议源码易语言,qq协议源码
- 编译原理实验工具及参考源码(lex&
- E盾偷后台工具源码
- UNIX/LINUX编程实践教程的源码
- 十以内加减法练习 powerbuilder源码
- 农场开发项目
- OCR源码
- PLC上位机编程软件
- 用foobar2000听google音乐[更新一下]
- 学生信息管理系统源码
- 用VC 编写的仿QQ聊天室程序源代码
- 毕业论文之温度传感器DS18B20(源码
- 可自定义导航网站源码
- 栅栏填充算法源码(VC)
- msp430F149操作红外接收模块源码
- [免费]图像识别c 源码
- 周易排盘源码
- RSA算法源码
- 一个人脸识别程序源码
- 编译原理课程设计:词法语法编译器
- 透明加密源码及说明
- 电视直播源码
- 远程桌面(带C 源码)
- mtrace 源码
评论
共有 条评论