tilde.c
来自「spice中支持多层次元件模型仿真的可单独运行的插件源码」· C语言 代码 · 共 62 行
C
62 行
/**********Copyright 1991 Regents of the University of California. All rights reserved.**********/#include "spice.h"#include "misc.h"#include <stdio.h>#ifdef HAS_GETPW#include <pwd.h>#endif#include "suffix.h"char *tilde_expand(string) char *string;{#ifdef HAS_GETPW struct passwd *pw; /*extern struct passwd *getpwuid( );*/ char *tail; char buf[BSIZE_SP]; char *k, c; if (!string) return NULL; while (*string && isspace(*string)) string++; if (*string != '~') return copy(string); string += 1; if (!*string || *string == '/') { pw = getpwuid(getuid()); *buf = 0; } else { k = buf; while ((c = *string) && c != '/') *k++ = c, string++; *k = 0; pw = getpwnam(buf); } if (pw) { strcpy(buf, pw->pw_dir); if (*string) strcat(buf, string); } else return NULL; return copy(buf);#else return copy(string);#endif}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?