gethost.c (145479) | gethost.c (167465) |
---|---|
1/* $Header: /src/pub/tcsh/gethost.c,v 1.10 2005/01/05 16:06:13 christos Exp $ */ | 1/* $Header: /p/tcsh/cvsroot/tcsh/gethost.c,v 1.12 2006/03/02 18:46:44 christos Exp $ */ |
2/* 3 * gethost.c: Create version file from prototype 4 */ 5/*- 6 * Copyright (c) 1980, 1991 The Regents of the University of California. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without --- 17 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33#include "sh.h" 34 | 2/* 3 * gethost.c: Create version file from prototype 4 */ 5/*- 6 * Copyright (c) 1980, 1991 The Regents of the University of California. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without --- 17 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33#include "sh.h" 34 |
35RCSID("$Id: gethost.c,v 1.10 2005/01/05 16:06:13 christos Exp $") | 35RCSID("$tcsh: gethost.c,v 1.12 2006/03/02 18:46:44 christos Exp $") |
36 37#ifdef SCO 38# define perror __perror 39# define rename __rename 40# define getopt __getopt 41# define system __system 42#endif 43#include <stdio.h> --- 40 unchanged lines hidden (view full) --- 84#define T_NONE 10 85}; 86 87#define S_DISCARD 0 88#define S_COMMENT 1 89#define S_CODE 2 90#define S_KEYWORD 3 91 | 36 37#ifdef SCO 38# define perror __perror 39# define rename __rename 40# define getopt __getopt 41# define system __system 42#endif 43#include <stdio.h> --- 40 unchanged lines hidden (view full) --- 84#define T_NONE 10 85}; 86 87#define S_DISCARD 0 88#define S_COMMENT 1 89#define S_CODE 2 90#define S_KEYWORD 3 91 |
92static int findtoken __P((char *)); 93static char *gettoken __P((char **, char *)); | 92static int findtoken (char *); 93static char *gettoken (char **, char *); |
94 | 94 |
95int main __P((int, char *[])); | 95int main (int, char *[]); |
96 97/* findtoken(): 98 * Return the token number of the given token 99 */ 100static int | 96 97/* findtoken(): 98 * Return the token number of the given token 99 */ 100static int |
101findtoken(ptr) 102 char *ptr; | 101findtoken(char *ptr) |
103{ 104 int i; 105 106 if (ptr == NULL || *ptr == '\0') 107 return T_NONE; 108 109 for (i = 0; keyword[i] != NULL; i++) 110 if (strcmp(keyword[i], ptr) == 0) 111 return i; 112 113 return T_NONE; 114} 115 116 117/* gettoken(): 118 * Get : delimited token and remove leading/trailing blanks/newlines 119 */ 120static char * | 102{ 103 int i; 104 105 if (ptr == NULL || *ptr == '\0') 106 return T_NONE; 107 108 for (i = 0; keyword[i] != NULL; i++) 109 if (strcmp(keyword[i], ptr) == 0) 110 return i; 111 112 return T_NONE; 113} 114 115 116/* gettoken(): 117 * Get : delimited token and remove leading/trailing blanks/newlines 118 */ 119static char * |
121gettoken(pptr, token) 122 char **pptr; 123 char *token; | 120gettoken(char **pptr, char *token) |
124{ 125 char *ptr = *pptr; 126 char *tok = token; 127 128 for (; *ptr && ISSPACE(*ptr); ptr++) 129 continue; 130 131 for (; *ptr && *ptr != ':'; *tok++ = *ptr++) --- 10 unchanged lines hidden (view full) --- 142 *++tok = '\0'; 143 144 *pptr = ptr; 145 return token; 146} 147 148 149int | 121{ 122 char *ptr = *pptr; 123 char *tok = token; 124 125 for (; *ptr && ISSPACE(*ptr); ptr++) 126 continue; 127 128 for (; *ptr && *ptr != ':'; *tok++ = *ptr++) --- 10 unchanged lines hidden (view full) --- 139 *++tok = '\0'; 140 141 *pptr = ptr; 142 return token; 143} 144 145 146int |
150main(argc, argv) 151 int argc; 152 char *argv[]; | 147main(int argc, char *argv[]) |
153{ 154 char line[INBUFSIZE]; 155 char *pname; 156 const char *fname = "stdin"; 157 char *ptr, *tok; 158 char defs[INBUFSIZE]; 159 char stmt[INBUFSIZE]; 160 FILE *fp = stdin; --- 174 unchanged lines hidden --- | 148{ 149 char line[INBUFSIZE]; 150 char *pname; 151 const char *fname = "stdin"; 152 char *ptr, *tok; 153 char defs[INBUFSIZE]; 154 char stmt[INBUFSIZE]; 155 FILE *fp = stdin; --- 174 unchanged lines hidden --- |