lib.c (201951) | lib.c (221381) |
---|---|
1/**************************************************************** 2Copyright (C) Lucent Technologies 1997 3All Rights Reserved 4 5Permission to use, copy, modify, and distribute this software and 6its documentation for any purpose and without fee is hereby 7granted, provided that the above copyright notice appear in all 8copies and that both that the copyright notice and this --- 242 unchanged lines hidden (view full) --- 251 dprintf( ("command line set %s to |%s|\n", s, p) ); 252} 253 254 255void fldbld(void) /* create fields from current record */ 256{ 257 /* this relies on having fields[] the same length as $0 */ 258 /* the fields are all stored in this one array with \0's */ | 1/**************************************************************** 2Copyright (C) Lucent Technologies 1997 3All Rights Reserved 4 5Permission to use, copy, modify, and distribute this software and 6its documentation for any purpose and without fee is hereby 7granted, provided that the above copyright notice appear in all 8copies and that both that the copyright notice and this --- 242 unchanged lines hidden (view full) --- 251 dprintf( ("command line set %s to |%s|\n", s, p) ); 252} 253 254 255void fldbld(void) /* create fields from current record */ 256{ 257 /* this relies on having fields[] the same length as $0 */ 258 /* the fields are all stored in this one array with \0's */ |
259 /* possibly with a final trailing \0 not associated with any field */ |
|
259 char *r, *fr, sep; 260 Cell *p; 261 int i, j, n; 262 263 if (donefld) 264 return; 265 if (!isstr(fldtab[0])) 266 getsval(fldtab[0]); 267 r = fldtab[0]->sval; 268 n = strlen(r); 269 if (n > fieldssize) { 270 xfree(fields); | 260 char *r, *fr, sep; 261 Cell *p; 262 int i, j, n; 263 264 if (donefld) 265 return; 266 if (!isstr(fldtab[0])) 267 getsval(fldtab[0]); 268 r = fldtab[0]->sval; 269 n = strlen(r); 270 if (n > fieldssize) { 271 xfree(fields); |
271 if ((fields = (char *) malloc(n+1)) == NULL) | 272 if ((fields = (char *) malloc(n+2)) == NULL) /* possibly 2 final \0s */ |
272 FATAL("out of space for fields in fldbld %d", n); 273 fieldssize = n; 274 } 275 fr = fields; 276 i = 0; /* number of fields accumulated here */ 277 strcpy(inputFS, *FS); 278 if (strlen(inputFS) > 1) { /* it's a regular expression */ 279 i = refldbld(r, inputFS); --- 418 unchanged lines hidden --- | 273 FATAL("out of space for fields in fldbld %d", n); 274 fieldssize = n; 275 } 276 fr = fields; 277 i = 0; /* number of fields accumulated here */ 278 strcpy(inputFS, *FS); 279 if (strlen(inputFS) > 1) { /* it's a regular expression */ 280 i = refldbld(r, inputFS); --- 418 unchanged lines hidden --- |